dma-mapping: make support for dma ops optional

Avoid the overhead of the dma ops support for tiny builds that only
use the direct mapping.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
Christoph Hellwig 2020-07-08 09:30:00 +02:00
parent b417417300
commit 2f9237d4f6
19 changed files with 43 additions and 6 deletions

View file

@ -7,6 +7,7 @@ config ALPHA
select ARCH_NO_PREEMPT select ARCH_NO_PREEMPT
select ARCH_NO_SG_CHAIN select ARCH_NO_SG_CHAIN
select ARCH_USE_CMPXCHG_LOCKREF select ARCH_USE_CMPXCHG_LOCKREF
select DMA_OPS if PCI
select FORCE_PCI if !ALPHA_JENSEN select FORCE_PCI if !ALPHA_JENSEN
select PCI_DOMAINS if PCI select PCI_DOMAINS if PCI
select PCI_SYSCALL if PCI select PCI_SYSCALL if PCI

View file

@ -41,6 +41,7 @@ config ARM
select CPU_PM if SUSPEND || CPU_IDLE select CPU_PM if SUSPEND || CPU_IDLE
select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS select DCACHE_WORD_ACCESS if HAVE_EFFICIENT_UNALIGNED_ACCESS
select DMA_DECLARE_COHERENT select DMA_DECLARE_COHERENT
select DMA_OPS
select DMA_REMAP if MMU select DMA_REMAP if MMU
select EDAC_SUPPORT select EDAC_SUPPORT
select EDAC_ATOMIC_SCRUB select EDAC_ATOMIC_SCRUB

View file

@ -192,6 +192,7 @@ config IA64_SGI_UV
config IA64_HP_SBA_IOMMU config IA64_HP_SBA_IOMMU
bool "HP SBA IOMMU support" bool "HP SBA IOMMU support"
select DMA_OPS
default y default y
help help
Say Y here to add support for the SBA IOMMU found on HP zx1 and Say Y here to add support for the SBA IOMMU found on HP zx1 and

View file

@ -367,6 +367,7 @@ config MACH_JAZZ
select ARC_PROMLIB select ARC_PROMLIB
select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_MIGHT_HAVE_PC_SERIO select ARCH_MIGHT_HAVE_PC_SERIO
select DMA_OPS
select FW_ARC select FW_ARC
select FW_ARC32 select FW_ARC32
select ARCH_MAY_HAVE_PC_FDC select ARCH_MAY_HAVE_PC_FDC

View file

@ -14,6 +14,7 @@ config PARISC
select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_HAS_UBSAN_SANITIZE_ALL
select ARCH_NO_SG_CHAIN select ARCH_NO_SG_CHAIN
select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_SUPPORTS_MEMORY_FAILURE
select DMA_OPS
select RTC_CLASS select RTC_CLASS
select RTC_DRV_GENERIC select RTC_DRV_GENERIC
select INIT_ALL_POSSIBLE select INIT_ALL_POSSIBLE

View file

@ -151,6 +151,7 @@ config PPC
select BUILDTIME_TABLE_SORT select BUILDTIME_TABLE_SORT
select CLONE_BACKWARDS select CLONE_BACKWARDS
select DCACHE_WORD_ACCESS if PPC64 && CPU_LITTLE_ENDIAN select DCACHE_WORD_ACCESS if PPC64 && CPU_LITTLE_ENDIAN
select DMA_OPS if PPC64
select DYNAMIC_FTRACE if FUNCTION_TRACER select DYNAMIC_FTRACE if FUNCTION_TRACER
select EDAC_ATOMIC_SCRUB select EDAC_ATOMIC_SCRUB
select EDAC_SUPPORT select EDAC_SUPPORT

View file

@ -113,6 +113,7 @@ config S390
select ARCH_WANT_IPC_PARSE_VERSION select ARCH_WANT_IPC_PARSE_VERSION
select BUILDTIME_TABLE_SORT select BUILDTIME_TABLE_SORT
select CLONE_BACKWARDS2 select CLONE_BACKWARDS2
select DMA_OPS if PCI
select DYNAMIC_FTRACE if FUNCTION_TRACER select DYNAMIC_FTRACE if FUNCTION_TRACER
select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS
select GENERIC_CPU_AUTOPROBE select GENERIC_CPU_AUTOPROBE

View file

@ -15,6 +15,7 @@ config SPARC
default y default y
select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI
select ARCH_MIGHT_HAVE_PC_SERIO select ARCH_MIGHT_HAVE_PC_SERIO
select DMA_OPS
select OF select OF
select OF_PROMTREE select OF_PROMTREE
select HAVE_ASM_MODVERSIONS select HAVE_ASM_MODVERSIONS

View file

@ -909,6 +909,7 @@ config DMI
config GART_IOMMU config GART_IOMMU
bool "Old AMD GART IOMMU support" bool "Old AMD GART IOMMU support"
select DMA_OPS
select IOMMU_HELPER select IOMMU_HELPER
select SWIOTLB select SWIOTLB
depends on X86_64 && PCI && AMD_NB depends on X86_64 && PCI && AMD_NB

View file

@ -1183,6 +1183,8 @@ static void setup_dma_device(struct ib_device *device)
struct device *parent = device->dev.parent; struct device *parent = device->dev.parent;
WARN_ON_ONCE(device->dma_device); WARN_ON_ONCE(device->dma_device);
#ifdef CONFIG_DMA_OPS
if (device->dev.dma_ops) { if (device->dev.dma_ops) {
/* /*
* The caller provided custom DMA operations. Copy the * The caller provided custom DMA operations. Copy the
@ -1203,7 +1205,9 @@ static void setup_dma_device(struct ib_device *device)
else else
WARN_ON_ONCE(true); WARN_ON_ONCE(true);
} }
} else { } else
#endif /* CONFIG_DMA_OPS */
{
/* /*
* The caller did not provide custom DMA operations. Use the * The caller did not provide custom DMA operations. Use the
* DMA mapping operations of the parent device. * DMA mapping operations of the parent device.

View file

@ -97,6 +97,7 @@ config OF_IOMMU
# IOMMU-agnostic DMA-mapping layer # IOMMU-agnostic DMA-mapping layer
config IOMMU_DMA config IOMMU_DMA
bool bool
select DMA_OPS
select IOMMU_API select IOMMU_API
select IOMMU_IOVA select IOMMU_IOVA
select IRQ_MSI_IOMMU select IRQ_MSI_IOMMU
@ -183,6 +184,7 @@ config DMAR_TABLE
config INTEL_IOMMU config INTEL_IOMMU
bool "Support for Intel IOMMU using DMA Remapping Devices" bool "Support for Intel IOMMU using DMA Remapping Devices"
depends on PCI_MSI && ACPI && (X86 || IA64) depends on PCI_MSI && ACPI && (X86 || IA64)
select DMA_OPS
select IOMMU_API select IOMMU_API
select IOMMU_IOVA select IOMMU_IOVA
select NEED_DMA_MAP_STATE select NEED_DMA_MAP_STATE

View file

@ -382,7 +382,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
dma_set_max_seg_size(&dev->ofdev.dev, 65536); dma_set_max_seg_size(&dev->ofdev.dev, 65536);
dma_set_seg_boundary(&dev->ofdev.dev, 0xffffffff); dma_set_seg_boundary(&dev->ofdev.dev, 0xffffffff);
#ifdef CONFIG_PCI #if defined(CONFIG_PCI) && defined(CONFIG_DMA_OPS)
/* Set the DMA ops to the ones from the PCI device, this could be /* Set the DMA ops to the ones from the PCI device, this could be
* fishy if we didn't know that on PowerMac it's always direct ops * fishy if we didn't know that on PowerMac it's always direct ops
* or iommu ops that will work fine * or iommu ops that will work fine
@ -391,7 +391,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
*/ */
dev->ofdev.dev.archdata = chip->lbus.pdev->dev.archdata; dev->ofdev.dev.archdata = chip->lbus.pdev->dev.archdata;
dev->ofdev.dev.dma_ops = chip->lbus.pdev->dev.dma_ops; dev->ofdev.dev.dma_ops = chip->lbus.pdev->dev.dma_ops;
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI && CONFIG_DMA_OPS */
#ifdef DEBUG #ifdef DEBUG
printk("preparing mdev @%p, ofdev @%p, dev @%p, kobj @%p\n", printk("preparing mdev @%p, ofdev @%p, dev @%p, kobj @%p\n",

View file

@ -4,6 +4,7 @@ menu "Intel MIC & related support"
config INTEL_MIC_BUS config INTEL_MIC_BUS
tristate "Intel MIC Bus Driver" tristate "Intel MIC Bus Driver"
depends on 64BIT && PCI && X86 depends on 64BIT && PCI && X86
select DMA_OPS
help help
This option is selected by any driver which registers a This option is selected by any driver which registers a
device or driver on the MIC Bus, such as CONFIG_INTEL_MIC_HOST, device or driver on the MIC Bus, such as CONFIG_INTEL_MIC_HOST,
@ -19,6 +20,7 @@ config INTEL_MIC_BUS
config SCIF_BUS config SCIF_BUS
tristate "SCIF Bus Driver" tristate "SCIF Bus Driver"
depends on 64BIT && PCI && X86 depends on 64BIT && PCI && X86
select DMA_OPS
help help
This option is selected by any driver which registers a This option is selected by any driver which registers a
device or driver on the SCIF Bus, such as CONFIG_INTEL_MIC_HOST device or driver on the SCIF Bus, such as CONFIG_INTEL_MIC_HOST
@ -33,6 +35,7 @@ config SCIF_BUS
config VOP_BUS config VOP_BUS
tristate "VOP Bus Driver" tristate "VOP Bus Driver"
select DMA_OPS
help help
This option is selected by any driver which registers a This option is selected by any driver which registers a
device or driver on the VOP Bus, such as CONFIG_INTEL_MIC_HOST device or driver on the VOP Bus, such as CONFIG_INTEL_MIC_HOST
@ -49,6 +52,7 @@ config INTEL_MIC_HOST
tristate "Intel MIC Host Driver" tristate "Intel MIC Host Driver"
depends on 64BIT && PCI && X86 depends on 64BIT && PCI && X86
depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS
select DMA_OPS
help help
This enables Host Driver support for the Intel Many Integrated This enables Host Driver support for the Intel Many Integrated
Core (MIC) family of PCIe form factor coprocessor devices that Core (MIC) family of PCIe form factor coprocessor devices that

View file

@ -11,6 +11,7 @@ if VDPA
config VDPA_SIM config VDPA_SIM
tristate "vDPA device simulator" tristate "vDPA device simulator"
depends on RUNTIME_TESTING_MENU && HAS_DMA depends on RUNTIME_TESTING_MENU && HAS_DMA
select DMA_OPS
select VHOST_RING select VHOST_RING
default n default n
help help

View file

@ -179,6 +179,7 @@ config XEN_GRANT_DMA_ALLOC
config SWIOTLB_XEN config SWIOTLB_XEN
def_bool y def_bool y
select DMA_OPS
select SWIOTLB select SWIOTLB
config XEN_PCIDEV_BACKEND config XEN_PCIDEV_BACKEND

View file

@ -568,8 +568,9 @@ struct device {
#ifdef CONFIG_GENERIC_MSI_IRQ #ifdef CONFIG_GENERIC_MSI_IRQ
struct list_head msi_list; struct list_head msi_list;
#endif #endif
#ifdef CONFIG_DMA_OPS
const struct dma_map_ops *dma_ops; const struct dma_map_ops *dma_ops;
#endif
u64 *dma_mask; /* dma mask (if dma'able device) */ u64 *dma_mask; /* dma mask (if dma'able device) */
u64 coherent_dma_mask;/* Like dma_mask, but for u64 coherent_dma_mask;/* Like dma_mask, but for
alloc_coherent mappings as alloc_coherent mappings as

View file

@ -191,6 +191,7 @@ static inline int dma_mmap_from_global_coherent(struct vm_area_struct *vma,
#ifdef CONFIG_HAS_DMA #ifdef CONFIG_HAS_DMA
#include <asm/dma-mapping.h> #include <asm/dma-mapping.h>
#ifdef CONFIG_DMA_OPS
static inline const struct dma_map_ops *get_dma_ops(struct device *dev) static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{ {
if (dev->dma_ops) if (dev->dma_ops)
@ -203,7 +204,16 @@ static inline void set_dma_ops(struct device *dev,
{ {
dev->dma_ops = dma_ops; dev->dma_ops = dma_ops;
} }
#else /* CONFIG_DMA_OPS */
static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
return NULL;
}
static inline void set_dma_ops(struct device *dev,
const struct dma_map_ops *dma_ops)
{
}
#endif /* CONFIG_DMA_OPS */
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{ {

View file

@ -5,6 +5,9 @@ config HAS_DMA
depends on !NO_DMA depends on !NO_DMA
default y default y
config DMA_OPS
bool
config NEED_SG_DMA_LENGTH config NEED_SG_DMA_LENGTH
bool bool
@ -60,6 +63,7 @@ config DMA_NONCOHERENT_CACHE_SYNC
config DMA_VIRT_OPS config DMA_VIRT_OPS
bool bool
depends on HAS_DMA depends on HAS_DMA
select DMA_OPS
config SWIOTLB config SWIOTLB
bool bool

View file

@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_HAS_DMA) += mapping.o direct.o dummy.o obj-$(CONFIG_HAS_DMA) += mapping.o direct.o
obj-$(CONFIG_DMA_OPS) += dummy.o
obj-$(CONFIG_DMA_CMA) += contiguous.o obj-$(CONFIG_DMA_CMA) += contiguous.o
obj-$(CONFIG_DMA_DECLARE_COHERENT) += coherent.o obj-$(CONFIG_DMA_DECLARE_COHERENT) += coherent.o
obj-$(CONFIG_DMA_VIRT_OPS) += virt.o obj-$(CONFIG_DMA_VIRT_OPS) += virt.o