1 Subject: Unable to Use Small BSR register on Power LPAR
2 From: Sonny Rao <sonnyrao@us.ibm.com>
3 References: 443673 - LTC49749
5 Fix the BSR driver to allow small BSR devices on a 64k page kernel.
6 Previously the driver would reject the mmap since the size was smaller
7 than PAGESIZE. This patch adds a check for this case and uses remap_4k_pfn().
9 Also, take out code to set vm_flags, as the remap_pfn functions will
12 Signed-off-by: Sonny Rao <sonnyrao@us.ibm.com>
13 Signed-off-by: Olaf Hering <olh@suse.de>
16 drivers/char/bsr.c | 20 ++++++++++++++------
17 1 file changed, 14 insertions(+), 6 deletions(-)
19 --- a/drivers/char/bsr.c
20 +++ b/drivers/char/bsr.c
22 #include <linux/cdev.h>
23 #include <linux/list.h>
25 +#include <asm/pgtable.h>
29 @@ -115,15 +116,22 @@ static int bsr_mmap(struct file *filp, s
31 unsigned long size = vma->vm_end - vma->vm_start;
32 struct bsr_dev *dev = filp->private_data;
35 - if (size > dev->bsr_len || (size & (PAGE_SIZE-1)))
38 - vma->vm_flags |= (VM_IO | VM_DONTEXPAND);
39 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
41 - if (io_remap_pfn_range(vma, vma->vm_start, dev->bsr_addr >> PAGE_SHIFT,
42 - size, vma->vm_page_prot))
43 + /* check for the case of a small BSR device and map one 4k page for it*/
44 + if (dev->bsr_len < PAGE_SIZE && size == PAGE_SIZE)
45 + ret = remap_4k_pfn(vma, vma->vm_start, dev->bsr_addr >> 12,
47 + else if (size <= dev->bsr_len)
48 + ret = io_remap_pfn_range(vma, vma->vm_start,
49 + dev->bsr_addr >> PAGE_SHIFT,
50 + size, vma->vm_page_prot);