add config symbols for arch_{setup,teardown}_dma_ops
Subsystems (5)
Hi all,
this series adds kconfig symbols to indicate that the architecture provides the arch_setup_dma_ops and arch_teardown_dma_ops hooks.
This avoids polluting dma-mapping.h which is included by just about every driver with implementation details, and also removes some clutter.
PATCH 1/2 dma-mapping: add a kconfig symbol for arch_setup_dma_ops availability
--- arch/arc/Kconfig | 1 + arch/arc/include/asm/Kbuild | 1 + arch/arc/include/asm/dma-mapping.h | 13 ------------- arch/arm/Kconfig | 1 + arch/arm/include/asm/dma-mapping.h | 4 ---- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/dma-mapping.h | 4 ---- arch/mips/Kconfig | 1 + arch/mips/include/asm/dma-mapping.h | 10 ---------- arch/mips/mm/dma-noncoherent.c | 8 ++++++++ include/linux/dma-mapping.h | 12 ++++++++---- kernel/dma/Kconfig | 3 +++ 12 files changed, 24 insertions(+), 35 deletions(-) delete mode 100644 arch/arc/include/asm/dma-mapping.h
arch/arc/Kconfig +1 -0
@@ -11,6 +11,7 @@ config ARC select ARC_TIMERS select ARCH_HAS_DMA_COHERENT_TO_PFN select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
arch/arc/include/asm/Kbuild +1 -0
@@ -3,6 +3,7 @@ generic-y += bugs.h generic-y += compat.h generic-y += device.h generic-y += div64.h +generic-y += dma-mapping.h generic-y += emergency-restart.h generic-y += extable.h generic-y += ftrace.h
arch/arc/include/asm/dma-mapping.h deleted +0 -13
@@ -1,13 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// (C) 2018 Synopsys, Inc. (www.synopsys.com) - -#ifndef ASM_ARC_DMA_MAPPING_H -#define ASM_ARC_DMA_MAPPING_H - -#include <asm-generic/dma-mapping.h> - -void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, -const struct iommu_ops *iommu,bool coherent); -#define arch_setup_dma_ops arch_setup_dma_ops - -#endif
arch/arm/Kconfig +1 -0
@@ -12,6 +12,7 @@ config ARM select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL if ARM_LPAE select ARCH_HAS_PHYS_TO_DMA + select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL select ARCH_HAS_STRICT_MODULE_RWX if MMU
arch/arm/include/asm/dma-mapping.h +0 -4
@@ -96,10 +96,6 @@ static inline unsigned long dma_max_pfn(struct device *dev) }#define dma_max_pfn (dev) dma_max_pfn(dev) -#define arch_setup_dma_ops arch_setup_dma_ops -extern void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, -const struct iommu_ops *iommu,bool coherent); -#ifdef CONFIG_MMU #define arch_teardown_dma_ops arch_teardown_dma_opsextern void arch_teardown_dma_ops (struct device *dev);
arch/arm64/Kconfig +1 -0
@@ -22,6 +22,7 @@ config ARM64 select ARCH_HAS_KCOV select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWX
arch/arm64/include/asm/dma-mapping.h +0 -4
@@ -29,10 +29,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)return NULL ; } -void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, -const struct iommu_ops *iommu,bool coherent); -#define arch_setup_dma_ops arch_setup_dma_ops -#ifdef CONFIG_IOMMU_DMA void arch_teardown_dma_ops (struct device *dev);#define arch_teardown_dma_ops arch_teardown_dma_ops
arch/mips/Kconfig +1 -0
@@ -1118,6 +1118,7 @@ config DMA_MAYBE_COHERENT config DMA_PERDEV_COHERENT bool + select ARCH_HAS_SETUP_DMA_OPS select DMA_NONCOHERENT config DMA_NONCOHERENT
arch/mips/include/asm/dma-mapping.h +0 -10
@@ -15,14 +15,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) #endif } -#define arch_setup_dma_ops arch_setup_dma_ops -static inline void arch_setup_dma_ops (struct device *dev,u64 dma_base, -u64 size,const struct iommu_ops *iommu, -bool coherent) -{ -#ifdef CONFIG_DMA_PERDEV_COHERENT - dev->dma_coherent = coherent; -#endif -} -#endif /* _ASM_DMA_MAPPING_H */
arch/mips/mm/dma-noncoherent.c +8 -0
@@ -159,3 +159,11 @@ void arch_dma_cache_sync(struct device *dev, void *vaddr, size_t size,dma_sync_virt (vaddr, size, direction); } + +#ifdef CONFIG_DMA_PERDEV_COHERENT +void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, +const struct iommu_ops *iommu,bool coherent) +{ + dev->dma_coherent = coherent; +} +#endif
include/linux/dma-mapping.h +8 -4
@@ -671,11 +671,15 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)return dma_set_mask_and_coherent (dev, mask); } -#ifndef arch_setup_dma_ops +#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS +void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, +const struct iommu_ops *iommu,bool coherent); +#else static inline void arch_setup_dma_ops (struct device *dev,u64 dma_base, -u64 size,const struct iommu_ops *iommu, -bool coherent) { } -#endif +u64 size,const struct iommu_ops *iommu,bool coherent) +{ +} +#endif /* CONFIG_ARCH_HAS_SETUP_DMA_OPS */ #ifndef arch_teardown_dma_opsstatic inline void arch_teardown_dma_ops (struct device *dev) { }
kernel/dma/Kconfig +3 -0
@@ -19,6 +19,9 @@ config ARCH_HAS_DMA_COHERENCE_H config HAVE_GENERIC_DMA_COHERENT bool +config ARCH_HAS_SETUP_DMA_OPS + bool + config ARCH_HAS_SYNC_DMA_FOR_DEVICE bool
Signature · 1 line
2.20.1
Re: [PATCH 1/2] dma-mapping: add a kconfig symbol for arch_setup_dma_ops availability
+CC Eugeniy
As resident ARC DMA expert can you please this a quick spin.
-Vineet
Quoted 199 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>--- arch/arc/Kconfig | 1 + arch/arc/include/asm/Kbuild | 1 + arch/arc/include/asm/dma-mapping.h | 13 ------------- arch/arm/Kconfig | 1 + arch/arm/include/asm/dma-mapping.h | 4 ---- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/dma-mapping.h | 4 ---- arch/mips/Kconfig | 1 + arch/mips/include/asm/dma-mapping.h | 10 ---------- arch/mips/mm/dma-noncoherent.c | 8 ++++++++ include/linux/dma-mapping.h | 12 ++++++++---- kernel/dma/Kconfig | 3 +++ 12 files changed, 24 insertions(+), 35 deletions(-) delete mode 100644 arch/arc/include/asm/dma-mapping.harch/arc/Kconfig +1
-0@@ -11,6 +11,7 @@ config ARC select ARC_TIMERS select ARCH_HAS_DMA_COHERENT_TO_PFN select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSCarch/arc/include/asm/Kbuild +1
-0@@ -3,6 +3,7 @@ generic-y += bugs.h generic-y += compat.h generic-y += device.h generic-y += div64.h +generic-y += dma-mapping.h generic-y += emergency-restart.h generic-y += extable.h generic-y += ftrace.harch/arc/include/asm/dma-mapping.h deleted +0
-13@@ -1,13 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// (C) 2018 Synopsys, Inc. (www.synopsys.com) - -#ifndef ASM_ARC_DMA_MAPPING_H -#define ASM_ARC_DMA_MAPPING_H - -#include <asm-generic/dma-mapping.h> - -void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, -const struct iommu_ops *iommu,bool coherent); -#define arch_setup_dma_ops arch_setup_dma_ops - -#endif arch/arm/Kconfig +1
-0@@ -12,6 +12,7 @@ config ARM select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL if ARM_LPAE select ARCH_HAS_PHYS_TO_DMA + select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL select ARCH_HAS_STRICT_MODULE_RWX if MMUarch/arm/include/asm/dma-mapping.h +0
-4@@ -96,10 +96,6 @@ static inline unsigned long dma_max_pfn(struct device *dev) }#define dma_max_pfn (dev) dma_max_pfn(dev) -#define arch_setup_dma_ops arch_setup_dma_ops -extern void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, -const struct iommu_ops *iommu,bool coherent); -#ifdef CONFIG_MMU #define arch_teardown_dma_ops arch_teardown_dma_opsextern void arch_teardown_dma_ops (struct device *dev);arch/arm64/Kconfig +1
-0@@ -22,6 +22,7 @@ config ARM64 select ARCH_HAS_KCOV select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL + select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWXarch/arm64/include/asm/dma-mapping.h +0
-4@@ -29,10 +29,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)return NULL ; } -void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, -const struct iommu_ops *iommu,bool coherent); -#define arch_setup_dma_ops arch_setup_dma_ops -#ifdef CONFIG_IOMMU_DMA void arch_teardown_dma_ops (struct device *dev);#define arch_teardown_dma_ops arch_teardown_dma_opsarch/mips/Kconfig +1
-0@@ -1118,6 +1118,7 @@ config DMA_MAYBE_COHERENT config DMA_PERDEV_COHERENT bool + select ARCH_HAS_SETUP_DMA_OPS select DMA_NONCOHERENT config DMA_NONCOHERENTarch/mips/include/asm/dma-mapping.h +0
-10@@ -15,14 +15,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) #endif } -#define arch_setup_dma_ops arch_setup_dma_ops -static inline void arch_setup_dma_ops (struct device *dev,u64 dma_base, -u64 size,const struct iommu_ops *iommu, -bool coherent) -{ -#ifdef CONFIG_DMA_PERDEV_COHERENT - dev->dma_coherent = coherent; -#endif -} -#endif /* _ASM_DMA_MAPPING_H */ arch/mips/mm/dma-noncoherent.c +8
-0@@ -159,3 +159,11 @@ void arch_dma_cache_sync(struct device *dev, void *vaddr, size_t size,dma_sync_virt (vaddr, size, direction); } + +#ifdef CONFIG_DMA_PERDEV_COHERENT +void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, +const struct iommu_ops *iommu,bool coherent) +{ + dev->dma_coherent = coherent; +} +#endif include/linux/dma-mapping.h +8
-4@@ -671,11 +671,15 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)return dma_set_mask_and_coherent (dev, mask); } -#ifndef arch_setup_dma_ops +#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS +void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size, +const struct iommu_ops *iommu,bool coherent); +#else static inline void arch_setup_dma_ops (struct device *dev,u64 dma_base, -u64 size,const struct iommu_ops *iommu, -bool coherent) { } -#endif +u64 size,const struct iommu_ops *iommu,bool coherent) +{ +} +#endif /* CONFIG_ARCH_HAS_SETUP_DMA_OPS */ #ifndef arch_teardown_dma_opsstatic inline void arch_teardown_dma_ops (struct device *dev) { }kernel/dma/Kconfig +3
-0@@ -19,6 +19,9 @@ config ARCH_HAS_DMA_COHERENCE_H config HAVE_GENERIC_DMA_COHERENT bool +config ARCH_HAS_SETUP_DMA_OPS + bool + config ARCH_HAS_SYNC_DMA_FOR_DEVICE bool
Re: [PATCH 1/2] dma-mapping: add a kconfig symbol for arch_setup_dma_ops availability
In reply to Christoph HellwigHi Christoph,
Quoted 12 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>--- arch/arc/Kconfig | 1 + arch/arc/include/asm/Kbuild | 1 + arch/arc/include/asm/dma-mapping.h | 13 ------------- arch/arm/Kconfig | 1 + arch/arm/include/asm/dma-mapping.h | 4 ---- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/dma-mapping.h | 4 ---- arch/mips/Kconfig | 1 + arch/mips/include/asm/dma-mapping.h | 10 ---------- arch/mips/mm/dma-noncoherent.c | 8 ++++++++
Thanks,
Paul
PATCH 2/2 dma-mapping: add a kconfig symbol for arch_teardown_dma_ops availability
In reply to Christoph Hellwig--- arch/arm/Kconfig | 1 + arch/arm/include/asm/dma-mapping.h | 5 ----- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/dma-mapping.h | 5 ----- include/linux/dma-mapping.h | 10 +++++++--- kernel/dma/Kconfig | 3 +++ 6 files changed, 12 insertions(+), 13 deletions(-)
arch/arm/Kconfig +1 -0
@@ -16,6 +16,7 @@ config ARM select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL select ARCH_HAS_STRICT_MODULE_RWX if MMU + select ARCH_HAS_TEARDOWN_DMA_OPS if MMU select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAS_GCOV_PROFILE_ALL
arch/arm/include/asm/dma-mapping.h +0 -5
@@ -96,11 +96,6 @@ static inline unsigned long dma_max_pfn(struct device *dev) }#define dma_max_pfn (dev) dma_max_pfn(dev) -#ifdef CONFIG_MMU -#define arch_teardown_dma_ops arch_teardown_dma_ops -extern void arch_teardown_dma_ops (struct device *dev); -#endif -/* do not use this function in a driver */ static inline bool is_device_dma_coherent (struct device *dev) {
arch/arm64/Kconfig +1 -0
@@ -29,6 +29,7 @@ config ARM64 select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYSCALL_WRAPPER + select ARCH_HAS_TEARDOWN_DMA_OPS if IOMMU_SUPPORT select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_INLINE_READ_LOCK if !PREEMPT
arch/arm64/include/asm/dma-mapping.h +0 -5
@@ -29,11 +29,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)return NULL ; } -#ifdef CONFIG_IOMMU_DMA -void arch_teardown_dma_ops (struct device *dev); -#define arch_teardown_dma_ops arch_teardown_dma_ops -#endif -/* * Do not use this function in a driver, it is only provided for * arch/arm/mm/xen.c, which is used by arm64 as well.
include/linux/dma-mapping.h +7 -3
@@ -681,9 +681,13 @@ static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, }#endif /* CONFIG_ARCH_HAS_SETUP_DMA_OPS */ -#ifndef arch_teardown_dma_ops -static inline void arch_teardown_dma_ops (struct device *dev) { } -#endif +#ifdef CONFIG_ARCH_HAS_TEARDOWN_DMA_OPS +void arch_teardown_dma_ops (struct device *dev); +#else +static inline void arch_teardown_dma_ops (struct device *dev) +{ +} +#endif /* CONFIG_ARCH_HAS_TEARDOWN_DMA_OPS */ static inline unsigned int dma_get_max_seg_size (struct device *dev) {
kernel/dma/Kconfig +3 -0
@@ -22,6 +22,9 @@ config HAVE_GENERIC_DMA_COHERENT config ARCH_HAS_SETUP_DMA_OPS bool +config ARCH_HAS_TEARDOWN_DMA_OPS + bool + config ARCH_HAS_SYNC_DMA_FOR_DEVICE bool
Signature · 1 line
2.20.1
Any chance to get a quick review on this small series?
Quoted 5 lines · Christoph Hellwig
Hi all,
this series adds kconfig symbols to indicate that the architecture provides the
arch_setup_dma_opsandarch_teardown_dma_opshooks.
Quoted 7 lines
This avoids polluting
dma-mapping.hwhich is included by just about every driver with implementation details, and also removes some clutter.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
---end quoted text---
Quoted 1 line · Christoph Hellwig
Any chance to get a quick review on this small series?
For arm64:
Thanks Catalin and Paul. I've merged this into the dma-mapping for-next branch.