All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: "Xenomai@xenomai.org" <Xenomai@xenomai.org>
Subject: [Xenomai] rtdm_iomap_to_user: fix caching and page fault issues
Date: Tue, 15 Jan 2013 16:22:02 +0100	[thread overview]
Message-ID: <50F5741A.9060404@grandegger.com> (raw)

From: Wolfgang Grandegger <wg@denx.de>

Pages mapped by rtdm_iomap_to_user() might be cached and may
page fault on the first write. At least that's the behaviour
we observed on an ARM mx6q system. This patch fixes these
issues.

Signed-off-by: Wolfgang Grandegger <wg@denx.de>
---
 include/asm-generic/wrappers.h | 2 +-
 ksrc/skins/rtdm/drvlib.c       | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h
index de1f0d7..e71bcc3 100644
--- a/include/asm-generic/wrappers.h
+++ b/include/asm-generic/wrappers.h
@@ -394,7 +394,7 @@ static inline void *kzalloc(size_t size, int flags)
 #define wrap_remap_io_page_range(vma,from,to,size,prot)  ({		\
     (vma)->vm_page_prot = pgprot_noncached((vma)->vm_page_prot);	\
     /* Sets VM_RESERVED | VM_IO | VM_PFNMAP on the vma. */		\
-    remap_pfn_range(vma,from,(to) >> PAGE_SHIFT,size,prot);		\
+    remap_pfn_range(vma,from,(to) >> PAGE_SHIFT,size,pgprot_noncached(prot));		\
     })
 #define wrap_remap_kmem_page_range(vma,from,to,size,prot)  ({		\
     /* Sets VM_RESERVED | VM_IO | VM_PFNMAP on the vma. */		\
diff --git a/ksrc/skins/rtdm/drvlib.c b/ksrc/skins/rtdm/drvlib.c
index e5c470c..391d45f 100644
--- a/ksrc/skins/rtdm/drvlib.c
+++ b/ksrc/skins/rtdm/drvlib.c
@@ -1858,10 +1858,12 @@ static int rtdm_mmap_buffer(struct file *filp, struct vm_area_struct *vma)
 #else
 	vma->vm_pgoff = paddr >> PAGE_SHIFT;
 #endif /* CONFIG_MMU */
-	if (mmap_data->src_paddr)
-	  	ret = xnarch_remap_io_page_range(filp, vma, maddr, paddr,
+	if (mmap_data->src_paddr) {
+		ret = xnarch_remap_io_page_range(filp, vma, maddr, paddr,
 						 size, PAGE_SHARED);
-	else {
+		if (!ret)
+			xnarch_fault_range(vma);
+	} else {
 		ret = xnarch_remap_kmem_page_range(vma, maddr, paddr,
 						   size, PAGE_SHARED);
 		if (!ret)
-- 
1.7.11.7



             reply	other threads:[~2013-01-15 15:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15 15:22 Wolfgang Grandegger [this message]
2013-01-15 19:46 ` [Xenomai] rtdm_iomap_to_user: fix caching and page fault issues Gilles Chanteperdrix
2013-01-16  7:37   ` Wolfgang Grandegger
2013-01-16  8:22     ` Gilles Chanteperdrix
2013-09-27  9:25       ` Henri Roosen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50F5741A.9060404@grandegger.com \
    --to=wg@grandegger.com \
    --cc=Xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.