From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by ozlabs.org (Postfix) with ESMTP id C7F26B70A8 for ; Tue, 27 Jul 2010 05:42:07 +1000 (EST) From: David Howells In-Reply-To: References: To: Ravi Gupta Subject: Re: Memory Mapping a char array in User Space Date: Mon, 26 Jul 2010 20:42:01 +0100 Message-ID: <918.1280173321@redhat.com> Sender: dhowells@redhat.com Cc: linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Ravi Gupta 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. David [*] unless your kernel is CONFIG_MMU=n