All of lore.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-mm@kvack.org
Cc: Magnus Damm <magnus.damm@gmail.com>,
	lethal@linux-sh.org, jayakumar.lkml@gmail.com,
	akpm@linux-foundation.org
Subject: [PATCH][RFC] mm: uncached vma support with writenotify
Date: Sun, 14 Jun 2009 22:28:45 +0900	[thread overview]
Message-ID: <20090614132845.17543.11882.sendpatchset@rx1.opensource.se> (raw)

From: Magnus Damm <damm@igel.co.jp>

This patch modifies the generic mmap() code to keep the cache
attribute in vma->vm_page_prot regardless if writenotify is 
enabled or not. Without this patch the cache configuration
selected by f_op->mmap() is overwritten if writenotify is
enabled, making it impossible to keep the vma uncached.

Needed by drivers such as drivers/video/sh_mobile_lcdcfb.c
which uses deferred io together with uncached memory.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 Everyone: Maybe there is a cleaner way to do this?

 Jaya: Will post a patch for deferred io to use fb_pgprotect()
 in the non-vmalloc mmap() case. That patch together with this
 allow architectures to use uncached memory with deferred io.

 mm/mmap.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

--- 0001/mm/mmap.c
+++ work/mm/mmap.c	2009-06-11 21:43:16.000000000 +0900
@@ -1209,8 +1209,20 @@ munmap_back:
 	pgoff = vma->vm_pgoff;
 	vm_flags = vma->vm_flags;
 
-	if (vma_wants_writenotify(vma))
+	if (vma_wants_writenotify(vma)) {
+		pgprot_t pprot = vma->vm_page_prot;
+
+		/* Can vma->vm_page_prot have changed??
+		 *
+		 * Answer: Yes, drivers may have changed it in their
+		 *         f_op->mmap method.
+		 *
+		 * Ensures that vmas marked as uncached stay that way.
+		 */
 		vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
+		if (pgprot_val(pprot) == pgprot_val(pgprot_noncached(pprot)))
+			vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	}
 
 	vma_link(mm, vma, prev, rb_link, rb_parent);
 	file = vma->vm_file;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2009-06-14 13:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-14 13:28 Magnus Damm [this message]
2009-06-15  3:32 ` [PATCH][RFC] mm: uncached vma support with writenotify Paul Mundt
2009-06-22 22:15   ` Andrew Morton
2009-06-23 12:40     ` Arnd Bergmann
2009-06-23 12:41     ` [PATCH] asm-generic: add dummy pgprot_noncached() Arnd Bergmann
2009-06-23 12:55       ` Paul Mundt
2009-06-23 13:00       ` xtensa: add pgprot_noncached Arnd Bergmann
2009-06-23 13:07       ` m32r: define pgprot_noncached Arnd Bergmann
2009-06-23 12:55     ` [PATCH] cris: add pgprot_noncached Arnd Bergmann
2009-06-23 19:20       ` Jesper Nilsson
2009-06-23 20:07         ` Arnd Bergmann
2009-06-23 20:23           ` Jesper Nilsson

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=20090614132845.17543.11882.sendpatchset@rx1.opensource.se \
    --to=magnus.damm@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jayakumar.lkml@gmail.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-mm@kvack.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.