[lkml]   [2005]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectmmap(2)ping of pci_alloc_consistent() allocated buffers on 2.4 kernels question/help

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

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);

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.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-09-16 20:36    [W:0.073 / U:0.040 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site