diff options
author | Hiroshi Doyu <hdoyu@nvidia.com> | 2012-07-25 16:46:28 +0300 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2013-09-14 12:33:35 -0700 |
commit | afa28ce7ec39852a7095ed950dcf22410cf94dfa (patch) | |
tree | 2d539c4479a90e7f80c73cc1ff33206232d074ae | |
parent | 3d22f64bd2671308aa5c6664efd9fff698f7c706 (diff) |
ARM: dma-mapping: Introduce dma_map_linear_attrs() for IOVA linear map
Introduce a helper function, dma_map_linear(_attrs)() to create IOVA
linear map, where IOVA and kernel virtual addresses are mapped at the
same address linearly. This is useful to support legacy device drivers
which expects no IOMMU.
Change-Id: Iedd7cd291b1c2a814ac0270344ceb4f439d47a00
Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com>
Rebase-Id: Rc9d13e9149f5e3644684743125ab4517bae3947c
-rw-r--r-- | arch/arm/include/asm/dma-mapping.h | 13 | ||||
-rw-r--r-- | include/asm-generic/dma-mapping-common.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 63b6ca226cda..4654bbec73fc 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -215,6 +215,19 @@ static inline size_t dma_iova_get_free_max(struct device *dev) return ops->iova_get_free_max(dev); } +static inline dma_addr_t dma_map_linear_attrs(struct device *dev, void *va, + size_t size, enum dma_data_direction dir, + struct dma_attrs *attrs) +{ + dma_addr_t da; + + da = dma_iova_alloc_at(dev, (dma_addr_t)va, size); + if (da == DMA_ERROR_CODE) + return DMA_ERROR_CODE; + + return dma_map_single_at_attrs(dev, va, da, size, dir, attrs); +} + /** * arm_dma_mmap - map a coherent DMA allocation into user space * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h index eada2d88cc06..4564bf07a96d 100644 --- a/include/asm-generic/dma-mapping-common.h +++ b/include/asm-generic/dma-mapping-common.h @@ -191,6 +191,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL) #define dma_map_single_at(d, a, h, s, r) \ dma_map_single_at_attrs(d, a, h, s, r, NULL) +#define dma_map_linear(d, a, s, r) dma_map_linear_attrs(d, a, s, r, NULL) #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL) #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL) |