diff options
author | Mark Nelson <markn@au1.ibm.com> | 2008-07-04 15:05:42 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-09 02:30:43 -0400 |
commit | 3affedc4e1ce837033b6c5e9289d2ce2f5a62d31 (patch) | |
tree | 83296af2c727e5b5f64b88b629dcf37f8e60e3f0 /include/asm-powerpc | |
parent | c8692362db3db3a6f644e05a477161d967430aac (diff) |
powerpc/dma: implement new dma_*map*_attrs() interfaces
Update powerpc to use the new dma_*map*_attrs() interfaces. In doing so
update struct dma_mapping_ops to accept a struct dma_attrs and propagate
these changes through to all users of the code (generic IOMMU and the
64bit DMA code, and the iseries and ps3 platform code).
The old dma_*map_*() interfaces are reimplemented as calls to the
corresponding new interfaces.
Signed-off-by: Mark Nelson <markn@au1.ibm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'include/asm-powerpc')
-rw-r--r-- | include/asm-powerpc/dma-mapping.h | 116 | ||||
-rw-r--r-- | include/asm-powerpc/iommu.h | 12 |
2 files changed, 94 insertions, 34 deletions
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h index bbefb69bfb67..de1395023cb1 100644 --- a/include/asm-powerpc/dma-mapping.h +++ b/include/asm-powerpc/dma-mapping.h | |||
@@ -13,6 +13,7 @@ | |||
13 | /* need struct page definitions */ | 13 | /* need struct page definitions */ |
14 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
15 | #include <linux/scatterlist.h> | 15 | #include <linux/scatterlist.h> |
16 | #include <linux/dma-attrs.h> | ||
16 | #include <asm/io.h> | 17 | #include <asm/io.h> |
17 | 18 | ||
18 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) | 19 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) |
@@ -53,13 +54,17 @@ struct dma_mapping_ops { | |||
53 | void (*free_coherent)(struct device *dev, size_t size, | 54 | void (*free_coherent)(struct device *dev, size_t size, |
54 | void *vaddr, dma_addr_t dma_handle); | 55 | void *vaddr, dma_addr_t dma_handle); |
55 | dma_addr_t (*map_single)(struct device *dev, void *ptr, | 56 | dma_addr_t (*map_single)(struct device *dev, void *ptr, |
56 | size_t size, enum dma_data_direction direction); | 57 | size_t size, enum dma_data_direction direction, |
58 | struct dma_attrs *attrs); | ||
57 | void (*unmap_single)(struct device *dev, dma_addr_t dma_addr, | 59 | void (*unmap_single)(struct device *dev, dma_addr_t dma_addr, |
58 | size_t size, enum dma_data_direction direction); | 60 | size_t size, enum dma_data_direction direction, |
61 | struct dma_attrs *attrs); | ||
59 | int (*map_sg)(struct device *dev, struct scatterlist *sg, | 62 | int (*map_sg)(struct device *dev, struct scatterlist *sg, |
60 | int nents, enum dma_data_direction direction); | 63 | int nents, enum dma_data_direction direction, |
64 | struct dma_attrs *attrs); | ||
61 | void (*unmap_sg)(struct device *dev, struct scatterlist *sg, | 65 | void (*unmap_sg)(struct device *dev, struct scatterlist *sg, |
62 | int nents, enum dma_data_direction direction); | 66 | int nents, enum dma_data_direction direction, |
67 | struct dma_attrs *attrs); | ||
63 | int (*dma_supported)(struct device *dev, u64 mask); | 68 | int (*dma_supported)(struct device *dev, u64 mask); |
64 | int (*set_dma_mask)(struct device *dev, u64 dma_mask); | 69 | int (*set_dma_mask)(struct device *dev, u64 dma_mask); |
65 | }; | 70 | }; |
@@ -109,6 +114,77 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask) | |||
109 | return 0; | 114 | return 0; |
110 | } | 115 | } |
111 | 116 | ||
117 | static inline dma_addr_t dma_map_single_attrs(struct device *dev, | ||
118 | void *cpu_addr, | ||
119 | size_t size, | ||
120 | enum dma_data_direction direction, | ||
121 | struct dma_attrs *attrs) | ||
122 | { | ||
123 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
124 | |||
125 | BUG_ON(!dma_ops); | ||
126 | return dma_ops->map_single(dev, cpu_addr, size, direction, attrs); | ||
127 | } | ||
128 | |||
129 | static inline void dma_unmap_single_attrs(struct device *dev, | ||
130 | dma_addr_t dma_addr, | ||
131 | size_t size, | ||
132 | enum dma_data_direction direction, | ||
133 | struct dma_attrs *attrs) | ||
134 | { | ||
135 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
136 | |||
137 | BUG_ON(!dma_ops); | ||
138 | dma_ops->unmap_single(dev, dma_addr, size, direction, attrs); | ||
139 | } | ||
140 | |||
141 | static inline dma_addr_t dma_map_page_attrs(struct device *dev, | ||
142 | struct page *page, | ||
143 | unsigned long offset, size_t size, | ||
144 | enum dma_data_direction direction, | ||
145 | struct dma_attrs *attrs) | ||
146 | { | ||
147 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
148 | |||
149 | BUG_ON(!dma_ops); | ||
150 | return dma_ops->map_single(dev, page_address(page) + offset, size, | ||
151 | direction, attrs); | ||
152 | } | ||
153 | |||
154 | static inline void dma_unmap_page_attrs(struct device *dev, | ||
155 | dma_addr_t dma_address, | ||
156 | size_t size, | ||
157 | enum dma_data_direction direction, | ||
158 | struct dma_attrs *attrs) | ||
159 | { | ||
160 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
161 | |||
162 | BUG_ON(!dma_ops); | ||
163 | dma_ops->unmap_single(dev, dma_address, size, direction, attrs); | ||
164 | } | ||
165 | |||
166 | static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, | ||
167 | int nents, enum dma_data_direction direction, | ||
168 | struct dma_attrs *attrs) | ||
169 | { | ||
170 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
171 | |||
172 | BUG_ON(!dma_ops); | ||
173 | return dma_ops->map_sg(dev, sg, nents, direction, attrs); | ||
174 | } | ||
175 | |||
176 | static inline void dma_unmap_sg_attrs(struct device *dev, | ||
177 | struct scatterlist *sg, | ||
178 | int nhwentries, | ||
179 | enum dma_data_direction direction, | ||
180 | struct dma_attrs *attrs) | ||
181 | { | ||
182 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | ||
183 | |||
184 | BUG_ON(!dma_ops); | ||
185 | dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs); | ||
186 | } | ||
187 | |||
112 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 188 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, |
113 | dma_addr_t *dma_handle, gfp_t flag) | 189 | dma_addr_t *dma_handle, gfp_t flag) |
114 | { | 190 | { |
@@ -131,63 +207,43 @@ static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, | |||
131 | size_t size, | 207 | size_t size, |
132 | enum dma_data_direction direction) | 208 | enum dma_data_direction direction) |
133 | { | 209 | { |
134 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 210 | return dma_map_single_attrs(dev, cpu_addr, size, direction, NULL); |
135 | |||
136 | BUG_ON(!dma_ops); | ||
137 | return dma_ops->map_single(dev, cpu_addr, size, direction); | ||
138 | } | 211 | } |
139 | 212 | ||
140 | static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, | 213 | static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, |
141 | size_t size, | 214 | size_t size, |
142 | enum dma_data_direction direction) | 215 | enum dma_data_direction direction) |
143 | { | 216 | { |
144 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 217 | dma_unmap_single_attrs(dev, dma_addr, size, direction, NULL); |
145 | |||
146 | BUG_ON(!dma_ops); | ||
147 | dma_ops->unmap_single(dev, dma_addr, size, direction); | ||
148 | } | 218 | } |
149 | 219 | ||
150 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | 220 | static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, |
151 | unsigned long offset, size_t size, | 221 | unsigned long offset, size_t size, |
152 | enum dma_data_direction direction) | 222 | enum dma_data_direction direction) |
153 | { | 223 | { |
154 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 224 | return dma_map_page_attrs(dev, page, offset, size, direction, NULL); |
155 | |||
156 | BUG_ON(!dma_ops); | ||
157 | return dma_ops->map_single(dev, page_address(page) + offset, size, | ||
158 | direction); | ||
159 | } | 225 | } |
160 | 226 | ||
161 | static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, | 227 | static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, |
162 | size_t size, | 228 | size_t size, |
163 | enum dma_data_direction direction) | 229 | enum dma_data_direction direction) |
164 | { | 230 | { |
165 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 231 | dma_unmap_page_attrs(dev, dma_address, size, direction, NULL); |
166 | |||
167 | BUG_ON(!dma_ops); | ||
168 | dma_ops->unmap_single(dev, dma_address, size, direction); | ||
169 | } | 232 | } |
170 | 233 | ||
171 | static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, | 234 | static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, |
172 | int nents, enum dma_data_direction direction) | 235 | int nents, enum dma_data_direction direction) |
173 | { | 236 | { |
174 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 237 | return dma_map_sg_attrs(dev, sg, nents, direction, NULL); |
175 | |||
176 | BUG_ON(!dma_ops); | ||
177 | return dma_ops->map_sg(dev, sg, nents, direction); | ||
178 | } | 238 | } |
179 | 239 | ||
180 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, | 240 | static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, |
181 | int nhwentries, | 241 | int nhwentries, |
182 | enum dma_data_direction direction) | 242 | enum dma_data_direction direction) |
183 | { | 243 | { |
184 | struct dma_mapping_ops *dma_ops = get_dma_ops(dev); | 244 | dma_unmap_sg_attrs(dev, sg, nhwentries, direction, NULL); |
185 | |||
186 | BUG_ON(!dma_ops); | ||
187 | dma_ops->unmap_sg(dev, sg, nhwentries, direction); | ||
188 | } | 245 | } |
189 | 246 | ||
190 | |||
191 | /* | 247 | /* |
192 | * Available generic sets of operations | 248 | * Available generic sets of operations |
193 | */ | 249 | */ |
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h index 65f6682bee87..51ecfef8d843 100644 --- a/include/asm-powerpc/iommu.h +++ b/include/asm-powerpc/iommu.h | |||
@@ -81,9 +81,11 @@ extern struct iommu_table *iommu_init_table(struct iommu_table * tbl, | |||
81 | 81 | ||
82 | extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, | 82 | extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, |
83 | struct scatterlist *sglist, int nelems, | 83 | struct scatterlist *sglist, int nelems, |
84 | unsigned long mask, enum dma_data_direction direction); | 84 | unsigned long mask, enum dma_data_direction direction, |
85 | struct dma_attrs *attrs); | ||
85 | extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist, | 86 | extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist, |
86 | int nelems, enum dma_data_direction direction); | 87 | int nelems, enum dma_data_direction direction, |
88 | struct dma_attrs *attrs); | ||
87 | 89 | ||
88 | extern void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl, | 90 | extern void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl, |
89 | size_t size, dma_addr_t *dma_handle, | 91 | size_t size, dma_addr_t *dma_handle, |
@@ -92,9 +94,11 @@ extern void iommu_free_coherent(struct iommu_table *tbl, size_t size, | |||
92 | void *vaddr, dma_addr_t dma_handle); | 94 | void *vaddr, dma_addr_t dma_handle); |
93 | extern dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl, | 95 | extern dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl, |
94 | void *vaddr, size_t size, unsigned long mask, | 96 | void *vaddr, size_t size, unsigned long mask, |
95 | enum dma_data_direction direction); | 97 | enum dma_data_direction direction, |
98 | struct dma_attrs *attrs); | ||
96 | extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, | 99 | extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, |
97 | size_t size, enum dma_data_direction direction); | 100 | size_t size, enum dma_data_direction direction, |
101 | struct dma_attrs *attrs); | ||
98 | 102 | ||
99 | extern void iommu_init_early_pSeries(void); | 103 | extern void iommu_init_early_pSeries(void); |
100 | extern void iommu_init_early_iSeries(void); | 104 | extern void iommu_init_early_iSeries(void); |