diff options
author | David S. Miller <davem@davemloft.net> | 2011-11-17 21:17:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-17 21:17:59 -0500 |
commit | 3e37fd3153ac95088a74f5e7c569f7567e9f993a (patch) | |
tree | 60a7f2334034a0294929f645373062620a67145d | |
parent | e88d2468718b0789b4c33da2f7e1cef2a1eee279 (diff) |
sparc: Kill custom io_remap_pfn_range().
To handle the large physical addresses, just make a simple wrapper
around remap_pfn_range() like MIPS does.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/sparc/include/asm/pgtable_32.h | 20 | ||||
-rw-r--r-- | arch/sparc/include/asm/pgtable_64.h | 20 | ||||
-rw-r--r-- | arch/sparc/mm/Makefile | 1 | ||||
-rw-r--r-- | arch/sparc/mm/generic_32.c | 99 | ||||
-rw-r--r-- | arch/sparc/mm/generic_64.c | 165 |
5 files changed, 32 insertions, 273 deletions
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index 5b31a8e89823..a790cc657476 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h | |||
@@ -431,10 +431,6 @@ extern unsigned long *sparc_valid_addr_bitmap; | |||
431 | #define kern_addr_valid(addr) \ | 431 | #define kern_addr_valid(addr) \ |
432 | (test_bit(__pa((unsigned long)(addr))>>20, sparc_valid_addr_bitmap)) | 432 | (test_bit(__pa((unsigned long)(addr))>>20, sparc_valid_addr_bitmap)) |
433 | 433 | ||
434 | extern int io_remap_pfn_range(struct vm_area_struct *vma, | ||
435 | unsigned long from, unsigned long pfn, | ||
436 | unsigned long size, pgprot_t prot); | ||
437 | |||
438 | /* | 434 | /* |
439 | * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in | 435 | * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in |
440 | * its high 4 bits. These macros/functions put it there or get it from there. | 436 | * its high 4 bits. These macros/functions put it there or get it from there. |
@@ -443,6 +439,22 @@ extern int io_remap_pfn_range(struct vm_area_struct *vma, | |||
443 | #define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) | 439 | #define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) |
444 | #define GET_PFN(pfn) (pfn & 0x0fffffffUL) | 440 | #define GET_PFN(pfn) (pfn & 0x0fffffffUL) |
445 | 441 | ||
442 | extern int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long, | ||
443 | unsigned long, pgprot_t); | ||
444 | |||
445 | static inline int io_remap_pfn_range(struct vm_area_struct *vma, | ||
446 | unsigned long from, unsigned long pfn, | ||
447 | unsigned long size, pgprot_t prot) | ||
448 | { | ||
449 | unsigned long long offset, space, phys_base; | ||
450 | |||
451 | offset = ((unsigned long long) GET_PFN(pfn)) << PAGE_SHIFT; | ||
452 | space = GET_IOSPACE(pfn); | ||
453 | phys_base = offset | (space << 32ULL); | ||
454 | |||
455 | return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot); | ||
456 | } | ||
457 | |||
446 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS | 458 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS |
447 | #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \ | 459 | #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \ |
448 | ({ \ | 460 | ({ \ |
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index adf89329af59..38ebb2c60137 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h | |||
@@ -757,10 +757,6 @@ static inline bool kern_addr_valid(unsigned long addr) | |||
757 | 757 | ||
758 | extern int page_in_phys_avail(unsigned long paddr); | 758 | extern int page_in_phys_avail(unsigned long paddr); |
759 | 759 | ||
760 | extern int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from, | ||
761 | unsigned long pfn, | ||
762 | unsigned long size, pgprot_t prot); | ||
763 | |||
764 | /* | 760 | /* |
765 | * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in | 761 | * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in |
766 | * its high 4 bits. These macros/functions put it there or get it from there. | 762 | * its high 4 bits. These macros/functions put it there or get it from there. |
@@ -769,6 +765,22 @@ extern int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from, | |||
769 | #define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) | 765 | #define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) |
770 | #define GET_PFN(pfn) (pfn & 0x0fffffffffffffffUL) | 766 | #define GET_PFN(pfn) (pfn & 0x0fffffffffffffffUL) |
771 | 767 | ||
768 | extern int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long, | ||
769 | unsigned long, pgprot_t); | ||
770 | |||
771 | static inline int io_remap_pfn_range(struct vm_area_struct *vma, | ||
772 | unsigned long from, unsigned long pfn, | ||
773 | unsigned long size, pgprot_t prot) | ||
774 | { | ||
775 | unsigned long offset = GET_PFN(pfn) << PAGE_SHIFT; | ||
776 | int space = GET_IOSPACE(pfn); | ||
777 | unsigned long phys_base; | ||
778 | |||
779 | phys_base = offset | (((unsigned long) space) << 32UL); | ||
780 | |||
781 | return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot); | ||
782 | } | ||
783 | |||
772 | #include <asm-generic/pgtable.h> | 784 | #include <asm-generic/pgtable.h> |
773 | 785 | ||
774 | /* We provide our own get_unmapped_area to cope with VA holes and | 786 | /* We provide our own get_unmapped_area to cope with VA holes and |
diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile index e3cda21b5ee9..301421c11291 100644 --- a/arch/sparc/mm/Makefile +++ b/arch/sparc/mm/Makefile | |||
@@ -8,7 +8,6 @@ obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o | |||
8 | obj-y += fault_$(BITS).o | 8 | obj-y += fault_$(BITS).o |
9 | obj-y += init_$(BITS).o | 9 | obj-y += init_$(BITS).o |
10 | obj-$(CONFIG_SPARC32) += loadmmu.o | 10 | obj-$(CONFIG_SPARC32) += loadmmu.o |
11 | obj-y += generic_$(BITS).o | ||
12 | obj-$(CONFIG_SPARC32) += extable.o btfixup.o srmmu.o iommu.o io-unit.o | 11 | obj-$(CONFIG_SPARC32) += extable.o btfixup.o srmmu.o iommu.o io-unit.o |
13 | obj-$(CONFIG_SPARC32) += hypersparc.o viking.o tsunami.o swift.o | 12 | obj-$(CONFIG_SPARC32) += hypersparc.o viking.o tsunami.o swift.o |
14 | obj-$(CONFIG_SPARC_LEON)+= leon_mm.o | 13 | obj-$(CONFIG_SPARC_LEON)+= leon_mm.o |
diff --git a/arch/sparc/mm/generic_32.c b/arch/sparc/mm/generic_32.c deleted file mode 100644 index 6ca39a60a196..000000000000 --- a/arch/sparc/mm/generic_32.c +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | /* | ||
2 | * generic.c: Generic Sparc mm routines that are not dependent upon | ||
3 | * MMU type but are Sparc specific. | ||
4 | * | ||
5 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | ||
6 | */ | ||
7 | |||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/mm.h> | ||
10 | #include <linux/swap.h> | ||
11 | #include <linux/pagemap.h> | ||
12 | #include <linux/export.h> | ||
13 | |||
14 | #include <asm/pgalloc.h> | ||
15 | #include <asm/pgtable.h> | ||
16 | #include <asm/page.h> | ||
17 | #include <asm/cacheflush.h> | ||
18 | #include <asm/tlbflush.h> | ||
19 | |||
20 | /* Remap IO memory, the same way as remap_pfn_range(), but use | ||
21 | * the obio memory space. | ||
22 | * | ||
23 | * They use a pgprot that sets PAGE_IO and does not check the | ||
24 | * mem_map table as this is independent of normal memory. | ||
25 | */ | ||
26 | static inline void io_remap_pte_range(struct mm_struct *mm, pte_t * pte, unsigned long address, unsigned long size, | ||
27 | unsigned long offset, pgprot_t prot, int space) | ||
28 | { | ||
29 | unsigned long end; | ||
30 | |||
31 | address &= ~PMD_MASK; | ||
32 | end = address + size; | ||
33 | if (end > PMD_SIZE) | ||
34 | end = PMD_SIZE; | ||
35 | do { | ||
36 | set_pte_at(mm, address, pte, mk_pte_io(offset, prot, space)); | ||
37 | address += PAGE_SIZE; | ||
38 | offset += PAGE_SIZE; | ||
39 | pte++; | ||
40 | } while (address < end); | ||
41 | } | ||
42 | |||
43 | static inline int io_remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size, | ||
44 | unsigned long offset, pgprot_t prot, int space) | ||
45 | { | ||
46 | unsigned long end; | ||
47 | |||
48 | address &= ~PGDIR_MASK; | ||
49 | end = address + size; | ||
50 | if (end > PGDIR_SIZE) | ||
51 | end = PGDIR_SIZE; | ||
52 | offset -= address; | ||
53 | do { | ||
54 | pte_t *pte = pte_alloc_map(mm, NULL, pmd, address); | ||
55 | if (!pte) | ||
56 | return -ENOMEM; | ||
57 | io_remap_pte_range(mm, pte, address, end - address, address + offset, prot, space); | ||
58 | address = (address + PMD_SIZE) & PMD_MASK; | ||
59 | pmd++; | ||
60 | } while (address < end); | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from, | ||
65 | unsigned long pfn, unsigned long size, pgprot_t prot) | ||
66 | { | ||
67 | int error = 0; | ||
68 | pgd_t * dir; | ||
69 | unsigned long beg = from; | ||
70 | unsigned long end = from + size; | ||
71 | struct mm_struct *mm = vma->vm_mm; | ||
72 | int space = GET_IOSPACE(pfn); | ||
73 | unsigned long offset = GET_PFN(pfn) << PAGE_SHIFT; | ||
74 | |||
75 | /* See comment in mm/memory.c remap_pfn_range */ | ||
76 | vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP; | ||
77 | vma->vm_pgoff = (offset >> PAGE_SHIFT) | | ||
78 | ((unsigned long)space << 28UL); | ||
79 | |||
80 | offset -= from; | ||
81 | dir = pgd_offset(mm, from); | ||
82 | flush_cache_range(vma, beg, end); | ||
83 | |||
84 | while (from < end) { | ||
85 | pmd_t *pmd = pmd_alloc(mm, dir, from); | ||
86 | error = -ENOMEM; | ||
87 | if (!pmd) | ||
88 | break; | ||
89 | error = io_remap_pmd_range(mm, pmd, from, end - from, offset + from, prot, space); | ||
90 | if (error) | ||
91 | break; | ||
92 | from = (from + PGDIR_SIZE) & PGDIR_MASK; | ||
93 | dir++; | ||
94 | } | ||
95 | |||
96 | flush_tlb_range(vma, beg, end); | ||
97 | return error; | ||
98 | } | ||
99 | EXPORT_SYMBOL(io_remap_pfn_range); | ||
diff --git a/arch/sparc/mm/generic_64.c b/arch/sparc/mm/generic_64.c deleted file mode 100644 index 9b357ddae39d..000000000000 --- a/arch/sparc/mm/generic_64.c +++ /dev/null | |||
@@ -1,165 +0,0 @@ | |||
1 | /* | ||
2 | * generic.c: Generic Sparc mm routines that are not dependent upon | ||
3 | * MMU type but are Sparc specific. | ||
4 | * | ||
5 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | ||
6 | */ | ||
7 | |||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/mm.h> | ||
10 | #include <linux/swap.h> | ||
11 | #include <linux/export.h> | ||
12 | #include <linux/pagemap.h> | ||
13 | |||
14 | #include <asm/pgalloc.h> | ||
15 | #include <asm/pgtable.h> | ||
16 | #include <asm/page.h> | ||
17 | #include <asm/tlbflush.h> | ||
18 | |||
19 | /* Remap IO memory, the same way as remap_pfn_range(), but use | ||
20 | * the obio memory space. | ||
21 | * | ||
22 | * They use a pgprot that sets PAGE_IO and does not check the | ||
23 | * mem_map table as this is independent of normal memory. | ||
24 | */ | ||
25 | static inline void io_remap_pte_range(struct mm_struct *mm, pte_t * pte, | ||
26 | unsigned long address, | ||
27 | unsigned long size, | ||
28 | unsigned long offset, pgprot_t prot, | ||
29 | int space) | ||
30 | { | ||
31 | unsigned long end; | ||
32 | |||
33 | /* clear hack bit that was used as a write_combine side-effect flag */ | ||
34 | offset &= ~0x1UL; | ||
35 | address &= ~PMD_MASK; | ||
36 | end = address + size; | ||
37 | if (end > PMD_SIZE) | ||
38 | end = PMD_SIZE; | ||
39 | do { | ||
40 | pte_t entry; | ||
41 | unsigned long curend = address + PAGE_SIZE; | ||
42 | |||
43 | entry = mk_pte_io(offset, prot, space, PAGE_SIZE); | ||
44 | if (!(address & 0xffff)) { | ||
45 | if (PAGE_SIZE < (4 * 1024 * 1024) && | ||
46 | !(address & 0x3fffff) && | ||
47 | !(offset & 0x3ffffe) && | ||
48 | end >= address + 0x400000) { | ||
49 | entry = mk_pte_io(offset, prot, space, | ||
50 | 4 * 1024 * 1024); | ||
51 | curend = address + 0x400000; | ||
52 | offset += 0x400000; | ||
53 | } else if (PAGE_SIZE < (512 * 1024) && | ||
54 | !(address & 0x7ffff) && | ||
55 | !(offset & 0x7fffe) && | ||
56 | end >= address + 0x80000) { | ||
57 | entry = mk_pte_io(offset, prot, space, | ||
58 | 512 * 1024 * 1024); | ||
59 | curend = address + 0x80000; | ||
60 | offset += 0x80000; | ||
61 | } else if (PAGE_SIZE < (64 * 1024) && | ||
62 | !(offset & 0xfffe) && | ||
63 | end >= address + 0x10000) { | ||
64 | entry = mk_pte_io(offset, prot, space, | ||
65 | 64 * 1024); | ||
66 | curend = address + 0x10000; | ||
67 | offset += 0x10000; | ||
68 | } else | ||
69 | offset += PAGE_SIZE; | ||
70 | } else | ||
71 | offset += PAGE_SIZE; | ||
72 | |||
73 | if (pte_write(entry)) | ||
74 | entry = pte_mkdirty(entry); | ||
75 | do { | ||
76 | BUG_ON(!pte_none(*pte)); | ||
77 | set_pte_at(mm, address, pte, entry); | ||
78 | address += PAGE_SIZE; | ||
79 | pte_val(entry) += PAGE_SIZE; | ||
80 | pte++; | ||
81 | } while (address < curend); | ||
82 | } while (address < end); | ||
83 | } | ||
84 | |||
85 | static inline int io_remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size, | ||
86 | unsigned long offset, pgprot_t prot, int space) | ||
87 | { | ||
88 | unsigned long end; | ||
89 | |||
90 | address &= ~PGDIR_MASK; | ||
91 | end = address + size; | ||
92 | if (end > PGDIR_SIZE) | ||
93 | end = PGDIR_SIZE; | ||
94 | offset -= address; | ||
95 | do { | ||
96 | pte_t *pte = pte_alloc_map(mm, NULL, pmd, address); | ||
97 | if (!pte) | ||
98 | return -ENOMEM; | ||
99 | io_remap_pte_range(mm, pte, address, end - address, address + offset, prot, space); | ||
100 | pte_unmap(pte); | ||
101 | address = (address + PMD_SIZE) & PMD_MASK; | ||
102 | pmd++; | ||
103 | } while (address < end); | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | static inline int io_remap_pud_range(struct mm_struct *mm, pud_t * pud, unsigned long address, unsigned long size, | ||
108 | unsigned long offset, pgprot_t prot, int space) | ||
109 | { | ||
110 | unsigned long end; | ||
111 | |||
112 | address &= ~PUD_MASK; | ||
113 | end = address + size; | ||
114 | if (end > PUD_SIZE) | ||
115 | end = PUD_SIZE; | ||
116 | offset -= address; | ||
117 | do { | ||
118 | pmd_t *pmd = pmd_alloc(mm, pud, address); | ||
119 | if (!pud) | ||
120 | return -ENOMEM; | ||
121 | io_remap_pmd_range(mm, pmd, address, end - address, address + offset, prot, space); | ||
122 | address = (address + PUD_SIZE) & PUD_MASK; | ||
123 | pud++; | ||
124 | } while (address < end); | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from, | ||
129 | unsigned long pfn, unsigned long size, pgprot_t prot) | ||
130 | { | ||
131 | int error = 0; | ||
132 | pgd_t * dir; | ||
133 | unsigned long beg = from; | ||
134 | unsigned long end = from + size; | ||
135 | struct mm_struct *mm = vma->vm_mm; | ||
136 | int space = GET_IOSPACE(pfn); | ||
137 | unsigned long offset = GET_PFN(pfn) << PAGE_SHIFT; | ||
138 | unsigned long phys_base; | ||
139 | |||
140 | phys_base = offset | (((unsigned long) space) << 32UL); | ||
141 | |||
142 | /* See comment in mm/memory.c remap_pfn_range */ | ||
143 | vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP; | ||
144 | vma->vm_pgoff = phys_base >> PAGE_SHIFT; | ||
145 | |||
146 | offset -= from; | ||
147 | dir = pgd_offset(mm, from); | ||
148 | flush_cache_range(vma, beg, end); | ||
149 | |||
150 | while (from < end) { | ||
151 | pud_t *pud = pud_alloc(mm, dir, from); | ||
152 | error = -ENOMEM; | ||
153 | if (!pud) | ||
154 | break; | ||
155 | error = io_remap_pud_range(mm, pud, from, end - from, offset + from, prot, space); | ||
156 | if (error) | ||
157 | break; | ||
158 | from = (from + PGDIR_SIZE) & PGDIR_MASK; | ||
159 | dir++; | ||
160 | } | ||
161 | |||
162 | flush_tlb_range(vma, beg, end); | ||
163 | return error; | ||
164 | } | ||
165 | EXPORT_SYMBOL(io_remap_pfn_range); | ||