diff options
-rw-r--r-- | arch/x86/include/asm/iomap.h | 5 | ||||
-rw-r--r-- | arch/x86/mm/iomap_32.c | 44 | ||||
-rw-r--r-- | include/linux/io-mapping.h | 6 |
3 files changed, 5 insertions, 50 deletions
diff --git a/arch/x86/include/asm/iomap.h b/arch/x86/include/asm/iomap.h index bd46495ff7de..86af26091d6c 100644 --- a/arch/x86/include/asm/iomap.h +++ b/arch/x86/include/asm/iomap.h | |||
@@ -24,10 +24,7 @@ | |||
24 | #include <asm/tlbflush.h> | 24 | #include <asm/tlbflush.h> |
25 | 25 | ||
26 | int | 26 | int |
27 | reserve_io_memtype_wc(u64 base, unsigned long size, pgprot_t *prot); | 27 | is_io_mapping_possible(resource_size_t base, unsigned long size); |
28 | |||
29 | void | ||
30 | free_io_memtype(u64 base, unsigned long size); | ||
31 | 28 | ||
32 | void * | 29 | void * |
33 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); | 30 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); |
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c index d5e28424622c..6c2b1af16926 100644 --- a/arch/x86/mm/iomap_32.c +++ b/arch/x86/mm/iomap_32.c | |||
@@ -21,13 +21,13 @@ | |||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | 22 | ||
23 | #ifdef CONFIG_X86_PAE | 23 | #ifdef CONFIG_X86_PAE |
24 | static int | 24 | int |
25 | is_io_mapping_possible(resource_size_t base, unsigned long size) | 25 | is_io_mapping_possible(resource_size_t base, unsigned long size) |
26 | { | 26 | { |
27 | return 1; | 27 | return 1; |
28 | } | 28 | } |
29 | #else | 29 | #else |
30 | static int | 30 | int |
31 | is_io_mapping_possible(resource_size_t base, unsigned long size) | 31 | is_io_mapping_possible(resource_size_t base, unsigned long size) |
32 | { | 32 | { |
33 | /* There is no way to map greater than 1 << 32 address without PAE */ | 33 | /* There is no way to map greater than 1 << 32 address without PAE */ |
@@ -38,46 +38,6 @@ is_io_mapping_possible(resource_size_t base, unsigned long size) | |||
38 | } | 38 | } |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | int | ||
42 | reserve_io_memtype_wc(u64 base, unsigned long size, pgprot_t *prot) | ||
43 | { | ||
44 | unsigned long ret_flag; | ||
45 | |||
46 | if (!is_io_mapping_possible(base, size)) | ||
47 | goto out_err; | ||
48 | |||
49 | if (!pat_enabled) { | ||
50 | *prot = pgprot_noncached(PAGE_KERNEL); | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | if (reserve_memtype(base, base + size, _PAGE_CACHE_WC, &ret_flag)) | ||
55 | goto out_err; | ||
56 | |||
57 | if (ret_flag == _PAGE_CACHE_WB) | ||
58 | goto out_free; | ||
59 | |||
60 | if (kernel_map_sync_memtype(base, size, ret_flag)) | ||
61 | goto out_free; | ||
62 | |||
63 | *prot = __pgprot(__PAGE_KERNEL | ret_flag); | ||
64 | return 0; | ||
65 | |||
66 | out_free: | ||
67 | free_memtype(base, base + size); | ||
68 | out_err: | ||
69 | return -EINVAL; | ||
70 | } | ||
71 | EXPORT_SYMBOL_GPL(reserve_io_memtype_wc); | ||
72 | |||
73 | void | ||
74 | free_io_memtype(u64 base, unsigned long size) | ||
75 | { | ||
76 | if (pat_enabled) | ||
77 | free_memtype(base, base + size); | ||
78 | } | ||
79 | EXPORT_SYMBOL_GPL(free_io_memtype); | ||
80 | |||
81 | /* Map 'pfn' using fixed map 'type' and protections 'prot' | 41 | /* Map 'pfn' using fixed map 'type' and protections 'prot' |
82 | */ | 42 | */ |
83 | void * | 43 | void * |
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h index f1ed66c43787..cbc2f0cd631b 100644 --- a/include/linux/io-mapping.h +++ b/include/linux/io-mapping.h | |||
@@ -49,9 +49,8 @@ static inline struct io_mapping * | |||
49 | io_mapping_create_wc(resource_size_t base, unsigned long size) | 49 | io_mapping_create_wc(resource_size_t base, unsigned long size) |
50 | { | 50 | { |
51 | struct io_mapping *iomap; | 51 | struct io_mapping *iomap; |
52 | pgprot_t prot; | ||
53 | 52 | ||
54 | if (!reserve_io_memtype_wc(base, size, &prot)) | 53 | if (!is_io_mapping_possible(base, size)) |
55 | return NULL; | 54 | return NULL; |
56 | 55 | ||
57 | iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); | 56 | iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); |
@@ -60,14 +59,13 @@ io_mapping_create_wc(resource_size_t base, unsigned long size) | |||
60 | 59 | ||
61 | iomap->base = base; | 60 | iomap->base = base; |
62 | iomap->size = size; | 61 | iomap->size = size; |
63 | iomap->prot = prot; | 62 | iomap->prot = pgprot_writecombine(__pgprot(__PAGE_KERNEL)); |
64 | return iomap; | 63 | return iomap; |
65 | } | 64 | } |
66 | 65 | ||
67 | static inline void | 66 | static inline void |
68 | io_mapping_free(struct io_mapping *mapping) | 67 | io_mapping_free(struct io_mapping *mapping) |
69 | { | 68 | { |
70 | free_io_memtype(mapping->base, mapping->size); | ||
71 | kfree(mapping); | 69 | kfree(mapping); |
72 | } | 70 | } |
73 | 71 | ||