Commit f091e933 authored by Robin Murphy's avatar Robin Murphy Committed by Joerg Roedel
Browse files

dma-mapping: Simplify arch_setup_dma_ops()



The dma_base, size and iommu arguments are only used by ARM, and can
now easily be deduced from the device itself, so there's no need to pass
them through the callchain as well.

Acked-by: default avatarRob Herring <robh@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: Michael Kelley <mhklinux@outlook.com> # For Hyper-V
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Tested-by: default avatarHanjun Guo <guohanjun@huawei.com>
Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/5291c2326eab405b1aa7693aa964e8d3cb7193de.1713523152.git.robin.murphy@arm.com


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent b67483b3
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -90,8 +90,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
/*
 * Plug in direct dma map ops.
 */
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
			bool coherent)
void arch_setup_dma_ops(struct device *dev, bool coherent)
{
	/*
	 * IOC hardware snoops all DMA traffic keeping the caches consistent
+1 −2
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
	}
}

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
			bool coherent)
void arch_setup_dma_ops(struct device *dev, bool coherent)
{
	if (IS_ENABLED(CONFIG_CPU_V7M)) {
		/*
+9 −7
Original line number Diff line number Diff line
@@ -1709,11 +1709,15 @@ void arm_iommu_detach_device(struct device *dev)
}
EXPORT_SYMBOL_GPL(arm_iommu_detach_device);

static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
				    bool coherent)
static void arm_setup_iommu_dma_ops(struct device *dev)
{
	struct dma_iommu_mapping *mapping;
	u64 dma_base = 0, size = 1ULL << 32;

	if (dev->dma_range_map) {
		dma_base = dma_range_map_min(dev->dma_range_map);
		size = dma_range_map_max(dev->dma_range_map) - dma_base;
	}
	mapping = arm_iommu_create_mapping(dev->bus, dma_base, size);
	if (IS_ERR(mapping)) {
		pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n",
@@ -1744,8 +1748,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)

#else

static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
				    bool coherent)
static void arm_setup_iommu_dma_ops(struct device *dev)
{
}

@@ -1753,8 +1756,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }

#endif	/* CONFIG_ARM_DMA_USE_IOMMU */

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
			bool coherent)
void arch_setup_dma_ops(struct device *dev, bool coherent)
{
	/*
	 * Due to legacy code that sets the ->dma_coherent flag from a bus
@@ -1774,7 +1776,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
		return;

	if (device_iommu_mapped(dev))
		arm_setup_iommu_dma_ops(dev, dma_base, size, coherent);
		arm_setup_iommu_dma_ops(dev);

	xen_setup_dma_ops(dev);
	dev->archdata.dma_ops_setup = true;
+1 −2
Original line number Diff line number Diff line
@@ -46,8 +46,7 @@ void arch_teardown_dma_ops(struct device *dev)
}
#endif

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
			bool coherent)
void arch_setup_dma_ops(struct device *dev, bool coherent)
{
	int cls = cache_line_size_of_cpu();

+1 −2
Original line number Diff line number Diff line
@@ -137,8 +137,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
#endif

#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
		bool coherent)
void arch_setup_dma_ops(struct device *dev, bool coherent)
{
	dev->dma_coherent = coherent;
}
Loading