LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 06-02-2009, 08:30 AM   #1
marc_ba
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:

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

Code:
pBar[0] = 2;
bla = pBar[1];
etc.
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,

Marc
 
Old 06-20-2011, 12:08 PM   #2
shark-bmt
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.
 
  


Reply

Tags
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:12 AM.

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