diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2009-03-11 10:33:18 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-11 10:47:46 -0400 |
commit | bb6d59ca927d855ffac567b35c0a790c67016103 (patch) | |
tree | cbfa2c1b8fd85c1ed93d077625a2e15b5b8a8ea9 /arch | |
parent | 78b020d035074fc3aa4d017353bb2c32e2aff56f (diff) |
x86: unify kmap_atomic_pfn() and iomap_atomic_prot_pfn()
kmap_atomic_pfn() and iomap_atomic_prot_pfn() are almost same
except pgprot. This patch removes the code duplication for these
two functions.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
LKML-Reference: <20090311143317.GA22244@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/highmem.h | 1 | ||||
-rw-r--r-- | arch/x86/mm/highmem_32.c | 17 | ||||
-rw-r--r-- | arch/x86/mm/iomap_32.c | 13 |
3 files changed, 14 insertions, 17 deletions
diff --git a/arch/x86/include/asm/highmem.h b/arch/x86/include/asm/highmem.h index bf9276bea660..014c2b85ae45 100644 --- a/arch/x86/include/asm/highmem.h +++ b/arch/x86/include/asm/highmem.h | |||
@@ -63,6 +63,7 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot); | |||
63 | void *kmap_atomic(struct page *page, enum km_type type); | 63 | void *kmap_atomic(struct page *page, enum km_type type); |
64 | void kunmap_atomic(void *kvaddr, enum km_type type); | 64 | void kunmap_atomic(void *kvaddr, enum km_type type); |
65 | void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); | 65 | void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); |
66 | void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); | ||
66 | struct page *kmap_atomic_to_page(void *ptr); | 67 | struct page *kmap_atomic_to_page(void *ptr); |
67 | 68 | ||
68 | #ifndef CONFIG_PARAVIRT | 69 | #ifndef CONFIG_PARAVIRT |
diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c index d11745334a67..ae4c8dae2669 100644 --- a/arch/x86/mm/highmem_32.c +++ b/arch/x86/mm/highmem_32.c | |||
@@ -121,23 +121,28 @@ void kunmap_atomic(void *kvaddr, enum km_type type) | |||
121 | pagefault_enable(); | 121 | pagefault_enable(); |
122 | } | 122 | } |
123 | 123 | ||
124 | /* This is the same as kmap_atomic() but can map memory that doesn't | 124 | void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) |
125 | * have a struct page associated with it. | ||
126 | */ | ||
127 | void *kmap_atomic_pfn(unsigned long pfn, enum km_type type) | ||
128 | { | 125 | { |
129 | enum fixed_addresses idx; | 126 | enum fixed_addresses idx; |
130 | unsigned long vaddr; | 127 | unsigned long vaddr; |
131 | 128 | ||
132 | pagefault_disable(); | 129 | pagefault_disable(); |
133 | 130 | ||
134 | idx = type + KM_TYPE_NR*smp_processor_id(); | 131 | idx = type + KM_TYPE_NR * smp_processor_id(); |
135 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); | 132 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); |
136 | set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot)); | 133 | set_pte(kmap_pte - idx, pfn_pte(pfn, prot)); |
137 | arch_flush_lazy_mmu_mode(); | 134 | arch_flush_lazy_mmu_mode(); |
138 | 135 | ||
139 | return (void*) vaddr; | 136 | return (void*) vaddr; |
140 | } | 137 | } |
138 | |||
139 | /* This is the same as kmap_atomic() but can map memory that doesn't | ||
140 | * have a struct page associated with it. | ||
141 | */ | ||
142 | void *kmap_atomic_pfn(unsigned long pfn, enum km_type type) | ||
143 | { | ||
144 | return kmap_atomic_prot_pfn(pfn, type, kmap_prot); | ||
145 | } | ||
141 | EXPORT_SYMBOL_GPL(kmap_atomic_pfn); /* temporarily in use by i915 GEM until vmap */ | 146 | EXPORT_SYMBOL_GPL(kmap_atomic_pfn); /* temporarily in use by i915 GEM until vmap */ |
142 | 147 | ||
143 | struct page *kmap_atomic_to_page(void *ptr) | 148 | struct page *kmap_atomic_to_page(void *ptr) |
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c index 04102d42ff42..592984e5496b 100644 --- a/arch/x86/mm/iomap_32.c +++ b/arch/x86/mm/iomap_32.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <asm/iomap.h> | 19 | #include <asm/iomap.h> |
20 | #include <asm/pat.h> | 20 | #include <asm/pat.h> |
21 | #include <asm/highmem.h> | ||
21 | #include <linux/module.h> | 22 | #include <linux/module.h> |
22 | 23 | ||
23 | int is_io_mapping_possible(resource_size_t base, unsigned long size) | 24 | int is_io_mapping_possible(resource_size_t base, unsigned long size) |
@@ -36,11 +37,6 @@ EXPORT_SYMBOL_GPL(is_io_mapping_possible); | |||
36 | void * | 37 | void * |
37 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) | 38 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) |
38 | { | 39 | { |
39 | enum fixed_addresses idx; | ||
40 | unsigned long vaddr; | ||
41 | |||
42 | pagefault_disable(); | ||
43 | |||
44 | /* | 40 | /* |
45 | * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS. | 41 | * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS. |
46 | * PAGE_KERNEL_WC maps to PWT, which translates to uncached if the | 42 | * PAGE_KERNEL_WC maps to PWT, which translates to uncached if the |
@@ -50,12 +46,7 @@ iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) | |||
50 | if (!pat_enabled && pgprot_val(prot) == pgprot_val(PAGE_KERNEL_WC)) | 46 | if (!pat_enabled && pgprot_val(prot) == pgprot_val(PAGE_KERNEL_WC)) |
51 | prot = PAGE_KERNEL_UC_MINUS; | 47 | prot = PAGE_KERNEL_UC_MINUS; |
52 | 48 | ||
53 | idx = type + KM_TYPE_NR*smp_processor_id(); | 49 | return kmap_atomic_prot_pfn(pfn, type, prot); |
54 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); | ||
55 | set_pte(kmap_pte-idx, pfn_pte(pfn, prot)); | ||
56 | arch_flush_lazy_mmu_mode(); | ||
57 | |||
58 | return (void*) vaddr; | ||
59 | } | 50 | } |
60 | EXPORT_SYMBOL_GPL(iomap_atomic_prot_pfn); | 51 | EXPORT_SYMBOL_GPL(iomap_atomic_prot_pfn); |
61 | 52 | ||