dma: dma_{un}map_{single|sg}_attrs() interface
Subsystems (2)
Here's a new interface for passing attributes to the dma mapping and unmapping routines. (I have patches that make use of the interface as well, but let's discuss this piece first.)
For ia64, new machvec entries replace the dma map/unmap interface, and the old interface is implemented in terms of the new. (All implementations other than ia64/sn2 ignore the new attributes.)
For architectures other than ia64, the new interface is implemented in terms of the old (attributes are always ignored).
Tested on hpzx1 and ia64/sn2 (IA64_GENERIC kernels) and on x86_64.
Signature · 12 lines
arch/ia64/hp/common/hwsw_iommu.c | 60 +++++++++++++------------- arch/ia64/hp/common/sba_iommu.c | 62 +++++++++++++++------------ arch/ia64/sn/pci/pci_dma.c | 71 +++++++++++++++++++------------ include/asm-ia64/dma-mapping.h | 28 ++++++++++-- include/asm-ia64/machvec.h | 52 +++++++++++++--------- include/asm-ia64/machvec_hpzx1.h | 16 +++--- include/asm-ia64/machvec_hpzx1_swiotlb.h | 16 +++--- include/asm-ia64/machvec_sn2.h | 16 +++--- include/linux/dma-attrs.h | 33 ++++++++++++++ include/linux/dma-mapping.h | 33 ++++++++++++++ lib/swiotlb.c | 50 ++++++++++++++++++--- 11 files changed, 301 insertions(+), 136 deletions(-)
arch/ia64/hp/common/hwsw_iommu.c +32 -28
@@ -20,10 +20,10 @@extern int swiotlb_late_init_with_default_size (size_t size);extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent;extern ia64_mv_dma_free_coherent swiotlb_free_coherent; -extern ia64_mv_dma_map_single swiotlb_map_single; -extern ia64_mv_dma_unmap_single swiotlb_unmap_single; -extern ia64_mv_dma_map_sg swiotlb_map_sg; -extern ia64_mv_dma_unmap_sg swiotlb_unmap_sg; +extern ia64_mv_dma_map_single_attrs swiotlb_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs swiotlb_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs swiotlb_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs swiotlb_unmap_sg_attrs;extern ia64_mv_dma_supported swiotlb_dma_supported;extern ia64_mv_dma_mapping_error swiotlb_dma_mapping_error;
@@ -31,19 +31,19 @@ extern ia64_mv_dma_mapping_error swiotlb_dma_mapping_error;extern ia64_mv_dma_alloc_coherent sba_alloc_coherent;extern ia64_mv_dma_free_coherent sba_free_coherent; -extern ia64_mv_dma_map_single sba_map_single; -extern ia64_mv_dma_unmap_single sba_unmap_single; -extern ia64_mv_dma_map_sg sba_map_sg; -extern ia64_mv_dma_unmap_sg sba_unmap_sg; +extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs sba_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs sba_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs sba_unmap_sg_attrs;extern ia64_mv_dma_supported sba_dma_supported;extern ia64_mv_dma_mapping_error sba_dma_mapping_error;#define hwiommu_alloc_coherent sba_alloc_coherent#define hwiommu_free_coherent sba_free_coherent -#define hwiommu_map_single sba_map_single -#define hwiommu_unmap_single sba_unmap_single -#define hwiommu_map_sg sba_map_sg -#define hwiommu_unmap_sg sba_unmap_sg +#define hwiommu_map_single_attrs sba_map_single_attrs +#define hwiommu_unmap_single_attrs sba_unmap_single_attrs +#define hwiommu_map_sg_attrs sba_map_sg_attrs +#define hwiommu_unmap_sg_attrs sba_unmap_sg_attrs#define hwiommu_dma_supported sba_dma_supported#define hwiommu_dma_mapping_error sba_dma_mapping_error#define hwiommu_sync_single_for_cpu machvec_dma_sync_single
@@ -98,40 +98,44 @@ hwsw_free_coherent (struct device *dev, size_t size, void *vaddr, dma_addr_t dma }dma_addr_t -hwsw_map_single (struct device *dev,void *addr,size_t size,int dir) +hwsw_map_single_attrs (struct device *dev,void *addr,size_t size,int dir, +struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_map_single (dev, addr, size, dir); +return swiotlb_map_single_attrs (dev, addr, size, dir, attrs);else -return hwiommu_map_single (dev, addr, size, dir); +return hwiommu_map_single_attrs (dev, addr, size, dir, attrs); }void -hwsw_unmap_single (struct device *dev,dma_addr_t iova,size_t size,int dir) +hwsw_unmap_single_attrs (struct device *dev,dma_addr_t iova,size_t size, +int dir,struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_unmap_single (dev, iova, size, dir); +return swiotlb_unmap_single_attrs (dev, iova, size, dir, attrs);else -return hwiommu_unmap_single (dev, iova, size, dir); +return hwiommu_unmap_single_attrs (dev, iova, size, dir, attrs); }int -hwsw_map_sg (struct device *dev,struct scatterlist *sglist,int nents,int dir) +hwsw_map_sg_attrs (struct device *dev,struct scatterlist *sglist,int nents, +int dir,struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_map_sg (dev, sglist, nents, dir); +return swiotlb_map_sg_attrs (dev, sglist, nents, dir, attrs);else -return hwiommu_map_sg (dev, sglist, nents, dir); +return hwiommu_map_sg_attrs (dev, sglist, nents, dir, attrs); }void -hwsw_unmap_sg (struct device *dev,struct scatterlist *sglist,int nents,int dir) +hwsw_unmap_sg_attrs (struct device *dev,struct scatterlist *sglist,int nents, +int dir,struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_unmap_sg (dev, sglist, nents, dir); +return swiotlb_unmap_sg_attrs (dev, sglist, nents, dir, attrs);else -return hwiommu_unmap_sg (dev, sglist, nents, dir); +return hwiommu_unmap_sg_attrs (dev, sglist, nents, dir, attrs); }void
@@ -185,10 +189,10 @@ hwsw_dma_mapping_error (dma_addr_t dma_addr) }EXPORT_SYMBOL (hwsw_dma_mapping_error); -EXPORT_SYMBOL (hwsw_map_single); -EXPORT_SYMBOL (hwsw_unmap_single); -EXPORT_SYMBOL (hwsw_map_sg); -EXPORT_SYMBOL (hwsw_unmap_sg); +EXPORT_SYMBOL (hwsw_map_single_attrs); +EXPORT_SYMBOL (hwsw_unmap_single_attrs); +EXPORT_SYMBOL (hwsw_map_sg_attrs); +EXPORT_SYMBOL (hwsw_unmap_sg_attrs);EXPORT_SYMBOL (hwsw_dma_supported);EXPORT_SYMBOL (hwsw_alloc_coherent);EXPORT_SYMBOL (hwsw_free_coherent);
arch/ia64/hp/common/sba_iommu.c +36 -26
197 lines not on this page · raw message
arch/ia64/sn/pci/pci_dma.c +45 -26
171 lines not on this page · raw message
include/asm-ia64/dma-mapping.h +24 -4
@@ -23,10 +23,30 @@ dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr, {dma_free_coherent (dev, size, cpu_addr, dma_handle); } -#define dma_map_single platform_dma_map_single -#define dma_map_sg platform_dma_map_sg -#define dma_unmap_single platform_dma_unmap_single -#define dma_unmap_sg platform_dma_unmap_sg +#define dma_map_single_attrs platform_dma_map_single_attrs +static inline dma_addr_t dma_map_single (struct device * dev,void * cpu_addr, +size_t size,int dir) +{ +return dma_map_single_attrs (dev, cpu_addr, size, dir,NULL ); +} +#define dma_map_sg_attrs platform_dma_map_sg_attrs +static inline int dma_map_sg (struct device *dev,struct scatterlist *sgl, +int nents,int dir) +{ +return dma_map_sg_attrs (dev, sgl, nents, dir,NULL ); +} +#define dma_unmap_single_attrs platform_dma_unmap_single_attrs +static inline void dma_unmap_single (struct device * dev,dma_addr_t cpu_addr, +size_t size,int dir) +{ +return dma_unmap_single_attrs (dev, cpu_addr, size, dir,NULL ); +} +#define dma_unmap_sg_attrs platform_dma_unmap_sg_attrs +static inline void dma_unmap_sg (struct device *dev,struct scatterlist *sgl, +int nents,int dir) +{ +return dma_unmap_sg_attrs (dev, sgl, nents, dir,NULL ); +}#define dma_sync_single_for_cpu platform_dma_sync_single_for_cpu#define dma_sync_sg_for_cpu platform_dma_sync_sg_for_cpu#define dma_sync_single_for_device platform_dma_sync_single_for_device
include/asm-ia64/machvec.h +32 -20
100 lines not on this page · raw message
include/asm-ia64/machvec_hpzx1.h +8 -8
@@ -4,10 +4,10 @@extern ia64_mv_setup_t dig_setup;extern ia64_mv_dma_alloc_coherent sba_alloc_coherent;extern ia64_mv_dma_free_coherent sba_free_coherent; -extern ia64_mv_dma_map_single sba_map_single; -extern ia64_mv_dma_unmap_single sba_unmap_single; -extern ia64_mv_dma_map_sg sba_map_sg; -extern ia64_mv_dma_unmap_sg sba_unmap_sg; +extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs sba_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs sba_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs sba_unmap_sg_attrs;extern ia64_mv_dma_supported sba_dma_supported;extern ia64_mv_dma_mapping_error sba_dma_mapping_error;
@@ -23,10 +23,10 @@ extern ia64_mv_dma_mapping_error sba_dma_mapping_error;#define platform_dma_init machvec_noop#define platform_dma_alloc_coherent sba_alloc_coherent#define platform_dma_free_coherent sba_free_coherent -#define platform_dma_map_single sba_map_single -#define platform_dma_unmap_single sba_unmap_single -#define platform_dma_map_sg sba_map_sg -#define platform_dma_unmap_sg sba_unmap_sg +#define platform_dma_map_single_attrs sba_map_single_attrs +#define platform_dma_unmap_single_attrs sba_unmap_single_attrs +#define platform_dma_map_sg_attrs sba_map_sg_attrs +#define platform_dma_unmap_sg_attrs sba_unmap_sg_attrs#define platform_dma_sync_single_for_cpu machvec_dma_sync_single#define platform_dma_sync_sg_for_cpu machvec_dma_sync_sg#define platform_dma_sync_single_for_device machvec_dma_sync_single
include/asm-ia64/machvec_hpzx1_swiotlb.h +8 -8
@@ -4,10 +4,10 @@extern ia64_mv_setup_t dig_setup;extern ia64_mv_dma_alloc_coherent hwsw_alloc_coherent;extern ia64_mv_dma_free_coherent hwsw_free_coherent; -extern ia64_mv_dma_map_single hwsw_map_single; -extern ia64_mv_dma_unmap_single hwsw_unmap_single; -extern ia64_mv_dma_map_sg hwsw_map_sg; -extern ia64_mv_dma_unmap_sg hwsw_unmap_sg; +extern ia64_mv_dma_map_single_attrs hwsw_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs hwsw_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs hwsw_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs hwsw_unmap_sg_attrs;extern ia64_mv_dma_supported hwsw_dma_supported;extern ia64_mv_dma_mapping_error hwsw_dma_mapping_error;extern ia64_mv_dma_sync_single_for_cpu hwsw_sync_single_for_cpu;
@@ -28,10 +28,10 @@ extern ia64_mv_dma_sync_sg_for_device hwsw_sync_sg_for_device;#define platform_dma_init machvec_noop#define platform_dma_alloc_coherent hwsw_alloc_coherent#define platform_dma_free_coherent hwsw_free_coherent -#define platform_dma_map_single hwsw_map_single -#define platform_dma_unmap_single hwsw_unmap_single -#define platform_dma_map_sg hwsw_map_sg -#define platform_dma_unmap_sg hwsw_unmap_sg +#define platform_dma_map_single_attrs hwsw_map_single_attrs +#define platform_dma_unmap_single_attrs hwsw_unmap_single_attrs +#define platform_dma_map_sg_attrs hwsw_map_sg_attrs +#define platform_dma_unmap_sg_attrs hwsw_unmap_sg_attrs#define platform_dma_supported hwsw_dma_supported#define platform_dma_mapping_error hwsw_dma_mapping_error#define platform_dma_sync_single_for_cpu hwsw_sync_single_for_cpu
include/asm-ia64/machvec_sn2.h +8 -8
@@ -57,10 +57,10 @@ extern ia64_mv_readl_t __sn_readl_relaxed;extern ia64_mv_readq_t __sn_readq_relaxed;extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent;extern ia64_mv_dma_free_coherent sn_dma_free_coherent; -extern ia64_mv_dma_map_single sn_dma_map_single; -extern ia64_mv_dma_unmap_single sn_dma_unmap_single; -extern ia64_mv_dma_map_sg sn_dma_map_sg; -extern ia64_mv_dma_unmap_sg sn_dma_unmap_sg; +extern ia64_mv_dma_map_single_attrs sn_dma_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs sn_dma_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs sn_dma_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs;extern ia64_mv_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu;extern ia64_mv_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu;extern ia64_mv_dma_sync_single_for_device sn_dma_sync_single_for_device;
@@ -113,10 +113,10 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;#define platform_dma_init machvec_noop#define platform_dma_alloc_coherent sn_dma_alloc_coherent#define platform_dma_free_coherent sn_dma_free_coherent -#define platform_dma_map_single sn_dma_map_single -#define platform_dma_unmap_single sn_dma_unmap_single -#define platform_dma_map_sg sn_dma_map_sg -#define platform_dma_unmap_sg sn_dma_unmap_sg +#define platform_dma_map_single_attrs sn_dma_map_single_attrs +#define platform_dma_unmap_single_attrs sn_dma_unmap_single_attrs +#define platform_dma_map_sg_attrs sn_dma_map_sg_attrs +#define platform_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs#define platform_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu#define platform_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu#define platform_dma_sync_single_for_device sn_dma_sync_single_for_device
include/linux/dma-attrs.h +33 -0
@@ -0,0 +1,33 @@ +#ifndef _DMA_ATTR_H +#define _DMA_ATTR_H + +#include <linux/bug.h> + +enum { +DMA_ATTR_INVALID , +DMA_ATTR_BARRIER , +DMA_ATTR_FOO , +DMA_ATTR_GOO , +DMA_ATTR_MAX , +}; + +struct dma_attrs { +unsigned flags; +}; + +static inline int dma_set_attr (struct dma_attrs *attrs,unsigned attr) { +BUG_ON (attrs ==NULL ); +if (attr >DMA_ATTR_INVALID && attr <DMA_ATTR_MAX ) { + attrs->flags = (1 << attr); +return 0 ; + } +return 1 ; +} + +static inline int dma_get_attr (struct dma_attrs *attrs,unsigned attr) { +if (attrs) +return attrs->flags & (1 << attr); +return 0 ; +} + +#endif /* _DMA_ATTR_H */
include/linux/dma-mapping.h +33 -0
@@ -116,4 +116,37 @@ static inline void dmam_release_declared_memory(struct device *dev) }#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */ +#ifndef ARCH_USES_DMA_ATTRS +struct dma_attrs ; + +static inline dma_addr_t dma_map_single_attrs (struct device *dev, +void *cpu_addr,size_t size, +int dir,struct dma_attrs * attrs) +{ +return dma_map_single (dev, cpu_addr, size, dir); +} + +static inline void dma_unmap_single_attrs (struct device *dev, +dma_addr_t dma_addr, +size_t size,int dir, +struct dma_attrs * attrs) +{ +return dma_unmap_single (dev, dma_addr, size, dir); +} + +static inline int dma_map_sg_attrs (struct device *dev,struct scatterlist *sgl, +int nents,int dir,struct dma_attrs *attrs) +{ +return dma_map_sg (dev, sgl, nents, dir); +} + +static inline void dma_unmap_sg_attrs (struct device *dev, +struct scatterlist *sgl, +int nents,int dir, +struct dma_attrs *attrs) +{ +return dma_unmap_sg (dev, sgl, nents, dir); +} +#endif /* ARCH_USES_DMA_ATTRS */ +#endif
lib/swiotlb.c +42 -8
115 lines not on this page · raw message
Signature · 1 line
Arthur
Quoted 11 lines
include/linux/dma-attrs.h +8
-0@@ -0,0 +1,33 @@ +#ifndef _DMA_ATTR_H +#define _DMA_ATTR_H + +#include <linux/bug.h> + +enum { +DMA_ATTR_INVALID , + DMA_ATTR_BARRIER,
include/linux/dma-attrs.h line 18
Quoted 10 lines
include/linux/dma-attrs.h +10
-0+DMA_ATTR_FOO , +DMA_ATTR_GOO , + DMA_ATTR_MAX, +}; + +struct dma_attrs { +unsigned flags; +}; + +static inline int dma_set_attr (struct dma_attrs *attrs,unsigned attr) {
maybe this would be cleaner if you named the DMA_ATTR enum and used that instead of unsigned here (and below)?
include/linux/dma-attrs.h line 19
Quoted 1 line
include/linux/dma-attrs.h +1
-0+BUG_ON (attrs ==NULL );
does this BUG_ON() buy us much? It seems the only thing we would fail to oops on is if someone did dma_set_attr(NULL, INVALID) and I'm not sure it's worth it to BUG here.
include/linux/dma-attrs.h line 24
Quoted 5 lines
include/linux/dma-attrs.h +5
-0+if (attr >DMA_ATTR_INVALID && attr <DMA_ATTR_MAX ) { + attrs->flags = (1 << attr); +return 0 ; + } +return 1 ;
returning -EINVAL here instead of 1 would probably be more "kernelish".
include/linux/dma-attrs.h line 29
Quoted 5 lines
include/linux/dma-attrs.h +5
-0+} + +static inline int dma_get_attr (struct dma_attrs *attrs,unsigned attr) { +if (attrs) +return attrs->flags & (1 << attr);
so it's OK to pass attrs == NULL into dma_get_attr() but not into dma_set_attr()? seems kind of odd.
include/linux/dma-attrs.h line 31
Quoted 2 lines
include/linux/dma-attrs.h +2
-0+return 0 ; +}
It seems you're missing a way to initialize a struct dma_attrs. How do I clear the flags field to start with?
A macro like DEFINE_DMA_ATTRS() that initializes things for you (like LIST_HEAD or DEFINE_SPIN_LOCK) would probably be a good thing to have as well.
Also I guess you could test ARCH_USES_DMA_ATTRS in this file and stub everything out and define an empty structure if it's not defined. save a few bytes of stack etc.
Quoted 2 lines
include/linux/dma-attrs.h +2
-0+ +#endif /* _DMA_ATTR_H */
Thanks for the review.
An updated version of the patch follows.
Quoted 5 lines · Roland Dreier
Quoted 2 lines
...
+static inline intdma_set_attr(struct dma_attrs *attrs, unsigned attr){maybe this would be cleaner if you named the
DMA_ATTRenum and used that instead of unsigned here (and below)?
Changed that.
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ BUG_ON(attrs == NULL);does this
BUG_ON()buy us much? It seems the only thing we would fail to oops on is if someone diddma_set_attr(NULL, INVALID)and I'm not sure it's worth it to BUG here.
Removed it.
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +5
-0+ if (attr > DMA_ATTR_INVALID && attr < DMA_ATTR_MAX) { + attrs->flags = (1 << attr); + return 0; + } + return 1;returning
-EINVALhere instead of 1 would probably be more "kernelish".
Kernelized it.
Quoted 10 lines
Review
Quoted 6 lines
(quoted diff) +5
-0+} + +static inline int dma_get_attr(struct dma_attrs *attrs, unsigned attr) { + if (attrs) + return attrs->flags & (1 << attr);so it's OK to pass attrs == NULL into
dma_get_attr()but not intodma_set_attr()? seems kind of odd.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return 0; +}
Yeah, I fixed that. Passing a NULL struct dma_attrs * is now explicitly allowed.
Quoted 8 lines
It seems you're missing a way to initialize a struct
dma_attrs. How do I clear the flags field to start with?A macro like
DEFINE_DMA_ATTRS()that initializes things for you (likeLIST_HEADorDEFINE_SPIN_LOCK) would probably be a good thing to have as well.
Yep. (Mainly I was concerned with getting the "plumbing" right for introducing dma attributes, so I implemented as little as possible of the dma attributes interface itself. It's a bit more fleshed out now.)
Quoted 4 lines
Also I guess you could test
ARCH_USES_DMA_ATTRSin this file and stub everything out and define an empty structure if it's not defined. save a few bytes of stack etc.
Good idea. In fact, the forward declaration of struct dma_attrs is sufficient when ARCH_USES_DMA_ATTRS isn't defined, since the structure isn't used in that case anyway.
Updated patch below.
--
arch/ia64/hp/common/hwsw_iommu.c | 60 ++++++++++++------------ arch/ia64/hp/common/sba_iommu.c | 62 ++++++++++++++---------- arch/ia64/sn/pci/pci_dma.c | 77 ++++++++++++++++++++----------- include/asm-ia64/dma-mapping.h | 28 +++++++++-- include/asm-ia64/machvec.h | 52 ++++++++++++-------- include/asm-ia64/machvec_hpzx1.h | 16 +++--- include/asm-ia64/machvec_hpzx1_swiotlb.h | 16 +++--- include/asm-ia64/machvec_sn2.h | 16 +++--- include/linux/dma-attrs.h | 48 +++++++++++++++++++ include/linux/dma-mapping.h | 33 +++++++++++++ lib/swiotlb.c | 50 ++++++++++++++++---- 11 files changed, 322 insertions(+), 136 deletions(-)
arch/ia64/hp/common/hwsw_iommu.c +32 -28
@@ -20,10 +20,10 @@extern int swiotlb_late_init_with_default_size (size_t size);extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent;extern ia64_mv_dma_free_coherent swiotlb_free_coherent; -extern ia64_mv_dma_map_single swiotlb_map_single; -extern ia64_mv_dma_unmap_single swiotlb_unmap_single; -extern ia64_mv_dma_map_sg swiotlb_map_sg; -extern ia64_mv_dma_unmap_sg swiotlb_unmap_sg; +extern ia64_mv_dma_map_single_attrs swiotlb_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs swiotlb_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs swiotlb_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs swiotlb_unmap_sg_attrs;extern ia64_mv_dma_supported swiotlb_dma_supported;extern ia64_mv_dma_mapping_error swiotlb_dma_mapping_error;
@@ -31,19 +31,19 @@ extern ia64_mv_dma_mapping_error swiotlb_dma_mapping_error;extern ia64_mv_dma_alloc_coherent sba_alloc_coherent;extern ia64_mv_dma_free_coherent sba_free_coherent; -extern ia64_mv_dma_map_single sba_map_single; -extern ia64_mv_dma_unmap_single sba_unmap_single; -extern ia64_mv_dma_map_sg sba_map_sg; -extern ia64_mv_dma_unmap_sg sba_unmap_sg; +extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs sba_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs sba_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs sba_unmap_sg_attrs;extern ia64_mv_dma_supported sba_dma_supported;extern ia64_mv_dma_mapping_error sba_dma_mapping_error;#define hwiommu_alloc_coherent sba_alloc_coherent#define hwiommu_free_coherent sba_free_coherent -#define hwiommu_map_single sba_map_single -#define hwiommu_unmap_single sba_unmap_single -#define hwiommu_map_sg sba_map_sg -#define hwiommu_unmap_sg sba_unmap_sg +#define hwiommu_map_single_attrs sba_map_single_attrs +#define hwiommu_unmap_single_attrs sba_unmap_single_attrs +#define hwiommu_map_sg_attrs sba_map_sg_attrs +#define hwiommu_unmap_sg_attrs sba_unmap_sg_attrs#define hwiommu_dma_supported sba_dma_supported#define hwiommu_dma_mapping_error sba_dma_mapping_error#define hwiommu_sync_single_for_cpu machvec_dma_sync_single
@@ -98,40 +98,44 @@ hwsw_free_coherent (struct device *dev, size_t size, void *vaddr, dma_addr_t dma }dma_addr_t -hwsw_map_single (struct device *dev,void *addr,size_t size,int dir) +hwsw_map_single_attrs (struct device *dev,void *addr,size_t size,int dir, +struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_map_single (dev, addr, size, dir); +return swiotlb_map_single_attrs (dev, addr, size, dir, attrs);else -return hwiommu_map_single (dev, addr, size, dir); +return hwiommu_map_single_attrs (dev, addr, size, dir, attrs); }void -hwsw_unmap_single (struct device *dev,dma_addr_t iova,size_t size,int dir) +hwsw_unmap_single_attrs (struct device *dev,dma_addr_t iova,size_t size, +int dir,struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_unmap_single (dev, iova, size, dir); +return swiotlb_unmap_single_attrs (dev, iova, size, dir, attrs);else -return hwiommu_unmap_single (dev, iova, size, dir); +return hwiommu_unmap_single_attrs (dev, iova, size, dir, attrs); }int -hwsw_map_sg (struct device *dev,struct scatterlist *sglist,int nents,int dir) +hwsw_map_sg_attrs (struct device *dev,struct scatterlist *sglist,int nents, +int dir,struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_map_sg (dev, sglist, nents, dir); +return swiotlb_map_sg_attrs (dev, sglist, nents, dir, attrs);else -return hwiommu_map_sg (dev, sglist, nents, dir); +return hwiommu_map_sg_attrs (dev, sglist, nents, dir, attrs); }void -hwsw_unmap_sg (struct device *dev,struct scatterlist *sglist,int nents,int dir) +hwsw_unmap_sg_attrs (struct device *dev,struct scatterlist *sglist,int nents, +int dir,struct dma_attrs *attrs) {if (use_swiotlb (dev)) -return swiotlb_unmap_sg (dev, sglist, nents, dir); +return swiotlb_unmap_sg_attrs (dev, sglist, nents, dir, attrs);else -return hwiommu_unmap_sg (dev, sglist, nents, dir); +return hwiommu_unmap_sg_attrs (dev, sglist, nents, dir, attrs); }void
@@ -185,10 +189,10 @@ hwsw_dma_mapping_error (dma_addr_t dma_addr) }EXPORT_SYMBOL (hwsw_dma_mapping_error); -EXPORT_SYMBOL (hwsw_map_single); -EXPORT_SYMBOL (hwsw_unmap_single); -EXPORT_SYMBOL (hwsw_map_sg); -EXPORT_SYMBOL (hwsw_unmap_sg); +EXPORT_SYMBOL (hwsw_map_single_attrs); +EXPORT_SYMBOL (hwsw_unmap_single_attrs); +EXPORT_SYMBOL (hwsw_map_sg_attrs); +EXPORT_SYMBOL (hwsw_unmap_sg_attrs);EXPORT_SYMBOL (hwsw_dma_supported);EXPORT_SYMBOL (hwsw_alloc_coherent);EXPORT_SYMBOL (hwsw_free_coherent);
arch/ia64/hp/common/sba_iommu.c +36 -26
197 lines not on this page · raw message
arch/ia64/sn/pci/pci_dma.c +51 -26
177 lines not on this page · raw message
include/asm-ia64/dma-mapping.h +24 -4
@@ -23,10 +23,30 @@ dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr, {dma_free_coherent (dev, size, cpu_addr, dma_handle); } -#define dma_map_single platform_dma_map_single -#define dma_map_sg platform_dma_map_sg -#define dma_unmap_single platform_dma_unmap_single -#define dma_unmap_sg platform_dma_unmap_sg +#define dma_map_single_attrs platform_dma_map_single_attrs +static inline dma_addr_t dma_map_single (struct device * dev,void * cpu_addr, +size_t size,int dir) +{ +return dma_map_single_attrs (dev, cpu_addr, size, dir,NULL ); +} +#define dma_map_sg_attrs platform_dma_map_sg_attrs +static inline int dma_map_sg (struct device *dev,struct scatterlist *sgl, +int nents,int dir) +{ +return dma_map_sg_attrs (dev, sgl, nents, dir,NULL ); +} +#define dma_unmap_single_attrs platform_dma_unmap_single_attrs +static inline void dma_unmap_single (struct device * dev,dma_addr_t cpu_addr, +size_t size,int dir) +{ +return dma_unmap_single_attrs (dev, cpu_addr, size, dir,NULL ); +} +#define dma_unmap_sg_attrs platform_dma_unmap_sg_attrs +static inline void dma_unmap_sg (struct device *dev,struct scatterlist *sgl, +int nents,int dir) +{ +return dma_unmap_sg_attrs (dev, sgl, nents, dir,NULL ); +}#define dma_sync_single_for_cpu platform_dma_sync_single_for_cpu#define dma_sync_sg_for_cpu platform_dma_sync_sg_for_cpu#define dma_sync_single_for_device platform_dma_sync_single_for_device
include/asm-ia64/machvec.h +32 -20
100 lines not on this page · raw message
include/asm-ia64/machvec_hpzx1.h +8 -8
@@ -4,10 +4,10 @@extern ia64_mv_setup_t dig_setup;extern ia64_mv_dma_alloc_coherent sba_alloc_coherent;extern ia64_mv_dma_free_coherent sba_free_coherent; -extern ia64_mv_dma_map_single sba_map_single; -extern ia64_mv_dma_unmap_single sba_unmap_single; -extern ia64_mv_dma_map_sg sba_map_sg; -extern ia64_mv_dma_unmap_sg sba_unmap_sg; +extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs sba_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs sba_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs sba_unmap_sg_attrs;extern ia64_mv_dma_supported sba_dma_supported;extern ia64_mv_dma_mapping_error sba_dma_mapping_error;
@@ -23,10 +23,10 @@ extern ia64_mv_dma_mapping_error sba_dma_mapping_error;#define platform_dma_init machvec_noop#define platform_dma_alloc_coherent sba_alloc_coherent#define platform_dma_free_coherent sba_free_coherent -#define platform_dma_map_single sba_map_single -#define platform_dma_unmap_single sba_unmap_single -#define platform_dma_map_sg sba_map_sg -#define platform_dma_unmap_sg sba_unmap_sg +#define platform_dma_map_single_attrs sba_map_single_attrs +#define platform_dma_unmap_single_attrs sba_unmap_single_attrs +#define platform_dma_map_sg_attrs sba_map_sg_attrs +#define platform_dma_unmap_sg_attrs sba_unmap_sg_attrs#define platform_dma_sync_single_for_cpu machvec_dma_sync_single#define platform_dma_sync_sg_for_cpu machvec_dma_sync_sg#define platform_dma_sync_single_for_device machvec_dma_sync_single
include/asm-ia64/machvec_hpzx1_swiotlb.h +8 -8
@@ -4,10 +4,10 @@extern ia64_mv_setup_t dig_setup;extern ia64_mv_dma_alloc_coherent hwsw_alloc_coherent;extern ia64_mv_dma_free_coherent hwsw_free_coherent; -extern ia64_mv_dma_map_single hwsw_map_single; -extern ia64_mv_dma_unmap_single hwsw_unmap_single; -extern ia64_mv_dma_map_sg hwsw_map_sg; -extern ia64_mv_dma_unmap_sg hwsw_unmap_sg; +extern ia64_mv_dma_map_single_attrs hwsw_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs hwsw_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs hwsw_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs hwsw_unmap_sg_attrs;extern ia64_mv_dma_supported hwsw_dma_supported;extern ia64_mv_dma_mapping_error hwsw_dma_mapping_error;extern ia64_mv_dma_sync_single_for_cpu hwsw_sync_single_for_cpu;
@@ -28,10 +28,10 @@ extern ia64_mv_dma_sync_sg_for_device hwsw_sync_sg_for_device;#define platform_dma_init machvec_noop#define platform_dma_alloc_coherent hwsw_alloc_coherent#define platform_dma_free_coherent hwsw_free_coherent -#define platform_dma_map_single hwsw_map_single -#define platform_dma_unmap_single hwsw_unmap_single -#define platform_dma_map_sg hwsw_map_sg -#define platform_dma_unmap_sg hwsw_unmap_sg +#define platform_dma_map_single_attrs hwsw_map_single_attrs +#define platform_dma_unmap_single_attrs hwsw_unmap_single_attrs +#define platform_dma_map_sg_attrs hwsw_map_sg_attrs +#define platform_dma_unmap_sg_attrs hwsw_unmap_sg_attrs#define platform_dma_supported hwsw_dma_supported#define platform_dma_mapping_error hwsw_dma_mapping_error#define platform_dma_sync_single_for_cpu hwsw_sync_single_for_cpu
include/asm-ia64/machvec_sn2.h +8 -8
@@ -57,10 +57,10 @@ extern ia64_mv_readl_t __sn_readl_relaxed;extern ia64_mv_readq_t __sn_readq_relaxed;extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent;extern ia64_mv_dma_free_coherent sn_dma_free_coherent; -extern ia64_mv_dma_map_single sn_dma_map_single; -extern ia64_mv_dma_unmap_single sn_dma_unmap_single; -extern ia64_mv_dma_map_sg sn_dma_map_sg; -extern ia64_mv_dma_unmap_sg sn_dma_unmap_sg; +extern ia64_mv_dma_map_single_attrs sn_dma_map_single_attrs; +extern ia64_mv_dma_unmap_single_attrs sn_dma_unmap_single_attrs; +extern ia64_mv_dma_map_sg_attrs sn_dma_map_sg_attrs; +extern ia64_mv_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs;extern ia64_mv_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu;extern ia64_mv_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu;extern ia64_mv_dma_sync_single_for_device sn_dma_sync_single_for_device;
@@ -113,10 +113,10 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;#define platform_dma_init machvec_noop#define platform_dma_alloc_coherent sn_dma_alloc_coherent#define platform_dma_free_coherent sn_dma_free_coherent -#define platform_dma_map_single sn_dma_map_single -#define platform_dma_unmap_single sn_dma_unmap_single -#define platform_dma_map_sg sn_dma_map_sg -#define platform_dma_unmap_sg sn_dma_unmap_sg +#define platform_dma_map_single_attrs sn_dma_map_single_attrs +#define platform_dma_unmap_single_attrs sn_dma_unmap_single_attrs +#define platform_dma_map_sg_attrs sn_dma_map_sg_attrs +#define platform_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs#define platform_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu#define platform_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu#define platform_dma_sync_single_for_device sn_dma_sync_single_for_device
include/linux/dma-attrs.h +48 -0
48 lines not on this page · raw message
include/linux/dma-mapping.h +33 -0
@@ -116,4 +116,37 @@ static inline void dmam_release_declared_memory(struct device *dev) }#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */ +#ifndef ARCH_USES_DMA_ATTRS +struct dma_attrs ; + +static inline dma_addr_t dma_map_single_attrs (struct device *dev, +void *cpu_addr,size_t size, +int dir,struct dma_attrs * attrs) +{ +return dma_map_single (dev, cpu_addr, size, dir); +} + +static inline void dma_unmap_single_attrs (struct device *dev, +dma_addr_t dma_addr, +size_t size,int dir, +struct dma_attrs * attrs) +{ +return dma_unmap_single (dev, dma_addr, size, dir); +} + +static inline int dma_map_sg_attrs (struct device *dev,struct scatterlist *sgl, +int nents,int dir,struct dma_attrs *attrs) +{ +return dma_map_sg (dev, sgl, nents, dir); +} + +static inline void dma_unmap_sg_attrs (struct device *dev, +struct scatterlist *sgl, +int nents,int dir, +struct dma_attrs *attrs) +{ +return dma_unmap_sg (dev, sgl, nents, dir); +} +#endif /* ARCH_USES_DMA_ATTRS */ +#endif
lib/swiotlb.c +42 -8
115 lines not on this page · raw message