diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-02-27 19:43:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-02-27 19:43:05 -0500 |
commit | 535d8e8f19376518e52e64f511440e502acda150 (patch) | |
tree | 06c1ab74b5e7b319a2474cae73cb1a6e77d281e0 /include | |
parent | 6febf65b2965858507e4d55afad20b24b2ad9a91 (diff) | |
parent | f6be37fdc62d0c0214bc49815d1180ebfbd716e2 (diff) |
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86: enable DMAR by default
xen: disable interrupts early, as start_kernel expects
gpu/drm, x86, PAT: io_mapping_create_wc and resource_size_t
gpu/drm, x86, PAT: Handle io_mapping_create_wc() errors in a clean way
x86, Voyager: fix compile by lifting the degeneracy of phys_cpu_present_map
x86, doc: fix references to Documentation/x86/i386/boot.txt
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/io-mapping.h | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h index 82df31726a54..cbc2f0cd631b 100644 --- a/include/linux/io-mapping.h +++ b/include/linux/io-mapping.h | |||
@@ -30,11 +30,14 @@ | |||
30 | * See Documentation/io_mapping.txt | 30 | * See Documentation/io_mapping.txt |
31 | */ | 31 | */ |
32 | 32 | ||
33 | /* this struct isn't actually defined anywhere */ | ||
34 | struct io_mapping; | ||
35 | |||
36 | #ifdef CONFIG_HAVE_ATOMIC_IOMAP | 33 | #ifdef CONFIG_HAVE_ATOMIC_IOMAP |
37 | 34 | ||
35 | struct io_mapping { | ||
36 | resource_size_t base; | ||
37 | unsigned long size; | ||
38 | pgprot_t prot; | ||
39 | }; | ||
40 | |||
38 | /* | 41 | /* |
39 | * For small address space machines, mapping large objects | 42 | * For small address space machines, mapping large objects |
40 | * into the kernel virtual space isn't practical. Where | 43 | * into the kernel virtual space isn't practical. Where |
@@ -43,23 +46,40 @@ struct io_mapping; | |||
43 | */ | 46 | */ |
44 | 47 | ||
45 | static inline struct io_mapping * | 48 | static inline struct io_mapping * |
46 | io_mapping_create_wc(unsigned long base, unsigned long size) | 49 | io_mapping_create_wc(resource_size_t base, unsigned long size) |
47 | { | 50 | { |
48 | return (struct io_mapping *) base; | 51 | struct io_mapping *iomap; |
52 | |||
53 | if (!is_io_mapping_possible(base, size)) | ||
54 | return NULL; | ||
55 | |||
56 | iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); | ||
57 | if (!iomap) | ||
58 | return NULL; | ||
59 | |||
60 | iomap->base = base; | ||
61 | iomap->size = size; | ||
62 | iomap->prot = pgprot_writecombine(__pgprot(__PAGE_KERNEL)); | ||
63 | return iomap; | ||
49 | } | 64 | } |
50 | 65 | ||
51 | static inline void | 66 | static inline void |
52 | io_mapping_free(struct io_mapping *mapping) | 67 | io_mapping_free(struct io_mapping *mapping) |
53 | { | 68 | { |
69 | kfree(mapping); | ||
54 | } | 70 | } |
55 | 71 | ||
56 | /* Atomic map/unmap */ | 72 | /* Atomic map/unmap */ |
57 | static inline void * | 73 | static inline void * |
58 | io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) | 74 | io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) |
59 | { | 75 | { |
60 | offset += (unsigned long) mapping; | 76 | resource_size_t phys_addr; |
61 | return iomap_atomic_prot_pfn(offset >> PAGE_SHIFT, KM_USER0, | 77 | unsigned long pfn; |
62 | __pgprot(__PAGE_KERNEL_WC)); | 78 | |
79 | BUG_ON(offset >= mapping->size); | ||
80 | phys_addr = mapping->base + offset; | ||
81 | pfn = (unsigned long) (phys_addr >> PAGE_SHIFT); | ||
82 | return iomap_atomic_prot_pfn(pfn, KM_USER0, mapping->prot); | ||
63 | } | 83 | } |
64 | 84 | ||
65 | static inline void | 85 | static inline void |
@@ -71,8 +91,9 @@ io_mapping_unmap_atomic(void *vaddr) | |||
71 | static inline void * | 91 | static inline void * |
72 | io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset) | 92 | io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset) |
73 | { | 93 | { |
74 | offset += (unsigned long) mapping; | 94 | BUG_ON(offset >= mapping->size); |
75 | return ioremap_wc(offset, PAGE_SIZE); | 95 | resource_size_t phys_addr = mapping->base + offset; |
96 | return ioremap_wc(phys_addr, PAGE_SIZE); | ||
76 | } | 97 | } |
77 | 98 | ||
78 | static inline void | 99 | static inline void |
@@ -83,9 +104,12 @@ io_mapping_unmap(void *vaddr) | |||
83 | 104 | ||
84 | #else | 105 | #else |
85 | 106 | ||
107 | /* this struct isn't actually defined anywhere */ | ||
108 | struct io_mapping; | ||
109 | |||
86 | /* Create the io_mapping object*/ | 110 | /* Create the io_mapping object*/ |
87 | static inline struct io_mapping * | 111 | static inline struct io_mapping * |
88 | io_mapping_create_wc(unsigned long base, unsigned long size) | 112 | io_mapping_create_wc(resource_size_t base, unsigned long size) |
89 | { | 113 | { |
90 | return (struct io_mapping *) ioremap_wc(base, size); | 114 | return (struct io_mapping *) ioremap_wc(base, size); |
91 | } | 115 | } |