linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix BSR to allow mmap of small BSR on 64k kernel
@ 2008-11-07  0:38 Sonny Rao
  2008-11-07  5:28 ` Paul Mackerras
  0 siblings, 1 reply; 9+ messages in thread
From: Sonny Rao @ 2008-11-07  0:38 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: paulus

Fix the BSR driver to allow small BSR devices, which are limited to a
single 4k space, on a 64k page kernel.  Previously the driver would
reject the mmap since the size was smaller than PAGESIZE (or because
the size was greater than the size of the device).  Now, we check for
this case use remap_4k_pfn(). Also, take out code to set vm_flags,
as the remap_pfn functions will do this for us.


Signed-off-by: Sonny Rao <sonnyrao@us.ibm.com>

Index: common/drivers/char/bsr.c
===================================================================
--- common.orig/drivers/char/bsr.c	2008-11-06 16:43:58.000000000 -0600
+++ common/drivers/char/bsr.c	2008-11-06 18:30:41.000000000 -0600
@@ -27,6 +27,7 @@
 #include <linux/cdev.h>
 #include <linux/list.h>
 #include <linux/mm.h>
+#include <asm/pgtable.h>
 #include <asm/io.h>
 
 /*
@@ -115,15 +116,23 @@
 {
 	unsigned long size   = vma->vm_end - vma->vm_start;
 	struct bsr_dev *dev = filp->private_data;
+	int ret;
 
-	if (size > dev->bsr_len || (size & (PAGE_SIZE-1)))
-		return -EINVAL;
+	/* This is legal where we have a BSR on a 4k page but a 64k kernel */
+	if (size > dev->bsr_len)
+		size = dev->bsr_len;
 
-	vma->vm_flags |= (VM_IO | VM_DONTEXPAND);
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
-	if (io_remap_pfn_range(vma, vma->vm_start, dev->bsr_addr >> PAGE_SHIFT,
-			       size, vma->vm_page_prot))
+	if (dev->bsr_len < PAGE_SIZE)
+		ret = remap_4k_pfn(vma, vma->vm_start, dev->bsr_addr >> 12,
+				   vma->vm_page_prot);
+	else
+		ret = io_remap_pfn_range(vma, vma->vm_start,
+					 dev->bsr_addr >> PAGE_SHIFT,
+					 size, vma->vm_page_prot);
+
+	if (ret)
 		return -EAGAIN;
 
 	return 0;

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-06-19  1:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-07  0:38 [PATCH] Fix BSR to allow mmap of small BSR on 64k kernel Sonny Rao
2008-11-07  5:28 ` Paul Mackerras
2008-11-07 23:25   ` Sonny Rao
2008-11-17  7:26   ` Sonny Rao
2008-11-19  4:07     ` Paul Mackerras
2008-11-19 17:04       ` Sonny Rao
2008-11-19 22:54         ` Paul Mackerras
2008-11-20 19:20           ` Sonny Rao
2009-06-19  1:13     ` Sonny Rao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).