Memory Mapping a char array in User Space

David Howells dhowells at
Tue Jul 27 05:42:01 EST 2010

Ravi Gupta <dceravigupta at> wrote:

> My device gets memory map successfully but when I tried to read from it
> I get garbage value. Is there something that I am missing?

For starters, you really should allocate a page for your buffer rather than
using kernel static data.  mmap() allows access to page-aligned data through
multiple-of-page-sized holes only[*].  Not only that, your kernel static map
buffer may not necessarily have a struct page covering it, in which case
virt_to_page() may not give you anything useful.

Furthermore, I don't think *you* should be calling remap_pfn_range().
I think you should be leaving the mapping to the core VM routines.


[*] unless your kernel is CONFIG_MMU=n

More information about the Linuxppc-dev mailing list