]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | Subject: Unable to Use Small BSR register on Power LPAR |
2 | From: Sonny Rao <sonnyrao@us.ibm.com> | |
3 | References: 443673 - LTC49749 | |
4 | ||
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(). | |
8 | ||
9 | Also, take out code to set vm_flags, as the remap_pfn functions will | |
10 | do this for us. | |
11 | ||
12 | Signed-off-by: Sonny Rao <sonnyrao@us.ibm.com> | |
13 | Signed-off-by: Olaf Hering <olh@suse.de> | |
14 | ||
15 | --- | |
16 | drivers/char/bsr.c | 20 ++++++++++++++------ | |
17 | 1 file changed, 14 insertions(+), 6 deletions(-) | |
18 | ||
19 | --- a/drivers/char/bsr.c | |
20 | +++ b/drivers/char/bsr.c | |
21 | @@ -27,6 +27,7 @@ | |
22 | #include <linux/cdev.h> | |
23 | #include <linux/list.h> | |
24 | #include <linux/mm.h> | |
25 | +#include <asm/pgtable.h> | |
26 | #include <asm/io.h> | |
27 | ||
28 | /* | |
29 | @@ -115,15 +116,22 @@ static int bsr_mmap(struct file *filp, s | |
30 | { | |
31 | unsigned long size = vma->vm_end - vma->vm_start; | |
32 | struct bsr_dev *dev = filp->private_data; | |
33 | + int ret; | |
34 | ||
35 | - if (size > dev->bsr_len || (size & (PAGE_SIZE-1))) | |
36 | - return -EINVAL; | |
37 | - | |
38 | - vma->vm_flags |= (VM_IO | VM_DONTEXPAND); | |
39 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | |
40 | ||
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, | |
46 | + vma->vm_page_prot); | |
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); | |
51 | + else | |
52 | + return -EINVAL; | |
53 | + | |
54 | + if (ret) | |
55 | return -EAGAIN; | |
56 | ||
57 | return 0; |