Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 06-02-2009, 08:30 AM   #1
LQ Newbie
Registered: Jan 2009
Posts: 4

Rep: Reputation: 0
pgprot_noncached when mapping io memory to user space

Dear experts,

I am writing a driver for a PCIe board. This board is configurable through IO memory regions (bars 0 & 1). These bars are exposed to the user space program thanks to the following driver code:

static int BLA_mmap(struct file *pFile, struct vm_area_struct *pVma)
   /* -- nResourceStart is the value returned by pci_resource_start -- */

   pVma->vm_page_prot = pgprot_noncached(pVma->vm_page_prot);
   pVma->vm_flags |= VM_RESERVED | VM_IO;

   return remap_pfn_range(pVma, pVma->vm_start, nResourceStart >> PAGE_SHIFT, pVma->vm_end - pVma->vm_start, pVma->vm_page_prot);
Thus, I can access these regions from user space with a simple pointer (after calling mmap):

pBar[0] = 2;
bla = pBar[1];
My question is about instructions caching. Although pgprot_noncached is used, I wonder if the operations performed through this pointer will be made exactly in the specified order or if any kind of reordering is likely to be performed by the CPU. If reoerdering is performed, is there a standard way to prevent this from happening?

I read Documentation/memory-barriers.txt but I did not find the answer ...

Any help appreciated !

Best regards,

Old 06-20-2011, 12:08 PM   #2
LQ Newbie
Registered: Jun 2011
Posts: 1

Rep: Reputation: Disabled
Hello! i had the same problem - even with nocache prot flag i noticed some latency in write/read - when user-space application writes to mmaped area, immediately after that driver did not see the new data - only after some delay data become coherent. Have you found out how to solve this problem? - i'm rather curious that application is seemed to work with "copy" of RAM-page, not directly with mapped area.


cache, io, remapping

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sharing memory between driver and user space ian b davidson Linux - Kernel 2 11-10-2008 10:20 AM
Sharing Memory between driver space and user space ian b davidson Programming 1 11-10-2008 06:35 AM
mapping contiguous kernel memory to user space nili Linux - Kernel 4 01-29-2008 01:43 PM
User wants to allocate more than 3Gb memory space in RHel5 batkinso Red Hat 3 07-24-2007 10:21 AM
memory mapping without being super user usagirl126 Linux - Security 7 02-20-2004 10:40 PM

All times are GMT -5. The time now is 03:18 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration