Hi,
can anyone explain me why it is not possible to mmap(2) a buffer
allocated in kernel by pci_alloc_consistent() to userspace on a 2.4
kernel?
In kernel PCI device initialization function I do something like:
...
kladdr = pci_alloc_consistent (dev, BUFSIZE, &baddr);
...
Then I send the physical address (i.e. the value of phaddr = __pa(kladdr))
to the userspace application, and then when in the userspace I do
something like
...
fd = fopen ("/dev/mem", O_RDWR);
buf = mmap (NULL, BUFSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, phaddr);
...
I get a mapping stated correctly in /proc/<pid>/maps as
40016000-4001e000 rw-s 11ac0000 00:06 4 /dev/mem
which is all correct. But when I read the contents of the mmap(2)ped
memory within the application I get all zeroes, while the value of the
buffer when read from kernel space or by simply doing
dd if=/dev/mem of=temp.dat bs=65536 skip=4524 count=1
I get the correct values (which are not all zeros). Something in the
process of mmap(2) system call seems to redirect the pages to /dev/zero it
seems. Is it intentional? Why?
Can I get around it somehow? The desired goal would be to mmap the buffer
directly from kernel upon an ioctl call to the driver of the PCI device.
(I do it by emmulating the mmap(2) call but initiated from the kernel by
calling the do_mmap_pgoff() with appropriate arguments, but (no surprise)
it does the same thing as the mmap(2) called from the userspace.
Can the mmapping be done correctly at least from the kernel somehow? Or is
it not possible at all.
Any hint would be much appreciated.
Thanks,
Martin.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
|
|