diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-09-25 15:59:12 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-09-25 18:39:24 -0400 |
commit | 56f55f8b58a02e95b401cb50df05086cabeaeeb5 (patch) | |
tree | 3be7e3383157c731178ca447008c0e7c236bfbfc | |
parent | afd1a321c49a250dab97cef6f2d3c3c9b9d0174a (diff) |
[ARM] dma: provide a better dma_map_page() implementation
We can translate a struct page directly to a DMA address using
page_to_dma(). No need to use page_address() followed by
virt_to_dma().
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/common/dmabounce.c | 13 | ||||
-rw-r--r-- | arch/arm/include/asm/dma-mapping.h | 11 |
2 files changed, 23 insertions, 1 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 35c72bcf3d0b..c7f23ced0a36 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
@@ -412,6 +412,19 @@ dma_map_single(struct device *dev, void *ptr, size_t size, | |||
412 | return dma_addr; | 412 | return dma_addr; |
413 | } | 413 | } |
414 | 414 | ||
415 | dma_addr_t dma_map_page(struct device *dev, struct page *page, | ||
416 | unsigned long offset, size_t size, | ||
417 | enum dma_data_direction dir) | ||
418 | { | ||
419 | dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n", | ||
420 | __func__, page, offset, size, dir); | ||
421 | |||
422 | BUG_ON(dir == DMA_NONE); | ||
423 | |||
424 | return map_single(dev, page_address(page) + offset, size, dir); | ||
425 | } | ||
426 | EXPORT_SYMBOL(dma_map_page); | ||
427 | |||
415 | /* | 428 | /* |
416 | * see if a mapped address was really a "safe" buffer and if so, copy | 429 | * see if a mapped address was really a "safe" buffer and if so, copy |
417 | * the data from the safe buffer back to the unsafe buffer and free up | 430 | * the data from the safe buffer back to the unsafe buffer and free up |
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index eff954852c2b..856ee1bdee57 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -227,13 +227,22 @@ extern dma_addr_t dma_map_single(struct device *,void *, size_t, enum dma_data_d | |||
227 | * can regain ownership by calling dma_unmap_page() or | 227 | * can regain ownership by calling dma_unmap_page() or |
228 | * dma_sync_single_for_cpu(). | 228 | * dma_sync_single_for_cpu(). |
229 | */ | 229 | */ |
230 | #ifndef CONFIG_DMABOUNCE | ||
230 | static inline dma_addr_t | 231 | static inline dma_addr_t |
231 | dma_map_page(struct device *dev, struct page *page, | 232 | dma_map_page(struct device *dev, struct page *page, |
232 | unsigned long offset, size_t size, | 233 | unsigned long offset, size_t size, |
233 | enum dma_data_direction dir) | 234 | enum dma_data_direction dir) |
234 | { | 235 | { |
235 | return dma_map_single(dev, page_address(page) + offset, size, dir); | 236 | if (!arch_is_coherent()) |
237 | dma_cache_maint(page_address(page) + offset, size, dir); | ||
238 | |||
239 | return page_to_dma(dev, page) + offset; | ||
236 | } | 240 | } |
241 | #else | ||
242 | extern dma_addr_t dma_map_page(struct device *dev, struct page *page, | ||
243 | unsigned long offset, size_t size, | ||
244 | enum dma_data_direction dir); | ||
245 | #endif | ||
237 | 246 | ||
238 | /** | 247 | /** |
239 | * dma_unmap_single - unmap a single buffer previously mapped | 248 | * dma_unmap_single - unmap a single buffer previously mapped |