Skip to content

Commit f091e93

Browse files
rmurphy-armjoergroedel
authored andcommitted
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: Rob Herring <robh@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Michael Kelley <mhklinux@outlook.com> # For Hyper-V Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Tested-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/5291c2326eab405b1aa7693aa964e8d3cb7193de.1713523152.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent b67483b commit f091e93

File tree

10 files changed

+19
-35
lines changed

10 files changed

+19
-35
lines changed

arch/arc/mm/dma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
9090
/*
9191
* Plug in direct dma map ops.
9292
*/
93-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
94-
bool coherent)
93+
void arch_setup_dma_ops(struct device *dev, bool coherent)
9594
{
9695
/*
9796
* IOC hardware snoops all DMA traffic keeping the caches consistent

arch/arm/mm/dma-mapping-nommu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
3333
}
3434
}
3535

36-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
37-
bool coherent)
36+
void arch_setup_dma_ops(struct device *dev, bool coherent)
3837
{
3938
if (IS_ENABLED(CONFIG_CPU_V7M)) {
4039
/*

arch/arm/mm/dma-mapping.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,11 +1709,15 @@ void arm_iommu_detach_device(struct device *dev)
17091709
}
17101710
EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
17111711

1712-
static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
1713-
bool coherent)
1712+
static void arm_setup_iommu_dma_ops(struct device *dev)
17141713
{
17151714
struct dma_iommu_mapping *mapping;
1715+
u64 dma_base = 0, size = 1ULL << 32;
17161716

1717+
if (dev->dma_range_map) {
1718+
dma_base = dma_range_map_min(dev->dma_range_map);
1719+
size = dma_range_map_max(dev->dma_range_map) - dma_base;
1720+
}
17171721
mapping = arm_iommu_create_mapping(dev->bus, dma_base, size);
17181722
if (IS_ERR(mapping)) {
17191723
pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n",
@@ -1744,17 +1748,15 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)
17441748

17451749
#else
17461750

1747-
static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
1748-
bool coherent)
1751+
static void arm_setup_iommu_dma_ops(struct device *dev)
17491752
{
17501753
}
17511754

17521755
static void arm_teardown_iommu_dma_ops(struct device *dev) { }
17531756

17541757
#endif /* CONFIG_ARM_DMA_USE_IOMMU */
17551758

1756-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
1757-
bool coherent)
1759+
void arch_setup_dma_ops(struct device *dev, bool coherent)
17581760
{
17591761
/*
17601762
* 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,
17741776
return;
17751777

17761778
if (device_iommu_mapped(dev))
1777-
arm_setup_iommu_dma_ops(dev, dma_base, size, coherent);
1779+
arm_setup_iommu_dma_ops(dev);
17781780

17791781
xen_setup_dma_ops(dev);
17801782
dev->archdata.dma_ops_setup = true;

arch/arm64/mm/dma-mapping.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ void arch_teardown_dma_ops(struct device *dev)
4646
}
4747
#endif
4848

49-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
50-
bool coherent)
49+
void arch_setup_dma_ops(struct device *dev, bool coherent)
5150
{
5251
int cls = cache_line_size_of_cpu();
5352

arch/mips/mm/dma-noncoherent.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
137137
#endif
138138

139139
#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
140-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
141-
bool coherent)
140+
void arch_setup_dma_ops(struct device *dev, bool coherent)
142141
{
143142
dev->dma_coherent = coherent;
144143
}

arch/riscv/mm/dma-noncoherent.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
128128
ALT_CMO_OP(FLUSH, flush_addr, size, riscv_cbom_block_size);
129129
}
130130

131-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
132-
bool coherent)
131+
void arch_setup_dma_ops(struct device *dev, bool coherent)
133132
{
134133
WARN_TAINT(!coherent && riscv_cbom_block_size > ARCH_DMA_MINALIGN,
135134
TAINT_CPU_OUT_OF_SPEC,

drivers/acpi/scan.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,12 +1675,7 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
16751675
if (ret == -EPROBE_DEFER)
16761676
return -EPROBE_DEFER;
16771677

1678-
/*
1679-
* Historically this routine doesn't fail driver probing due to errors
1680-
* in acpi_iommu_configure_id()
1681-
*/
1682-
1683-
arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT);
1678+
arch_setup_dma_ops(dev, attr == DEV_DMA_COHERENT);
16841679

16851680
return 0;
16861681
}

drivers/hv/hv_common.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,7 @@ EXPORT_SYMBOL_GPL(hv_query_ext_cap);
561561

562562
void hv_setup_dma_ops(struct device *dev, bool coherent)
563563
{
564-
/*
565-
* Hyper-V does not offer a vIOMMU in the guest
566-
* VM, so pass 0/NULL for the IOMMU settings
567-
*/
568-
arch_setup_dma_ops(dev, 0, 0, coherent);
564+
arch_setup_dma_ops(dev, coherent);
569565
}
570566
EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
571567

drivers/of/device.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
9595
{
9696
const struct bus_dma_region *map = NULL;
9797
struct device_node *bus_np;
98-
u64 dma_start = 0;
9998
u64 mask, end = 0;
10099
bool coherent;
101100
int iommu_ret;
@@ -118,7 +117,6 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
118117
return ret == -ENODEV ? 0 : ret;
119118
} else {
120119
/* Determine the overall bounds of all DMA regions */
121-
dma_start = dma_range_map_min(map);
122120
end = dma_range_map_max(map);
123121
}
124122

@@ -175,7 +173,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
175173
} else
176174
dev_dbg(dev, "device is behind an iommu\n");
177175

178-
arch_setup_dma_ops(dev, dma_start, end - dma_start + 1, coherent);
176+
arch_setup_dma_ops(dev, coherent);
179177

180178
if (iommu_ret)
181179
of_dma_set_restricted_buffer(dev, np);

include/linux/dma-map-ops.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,9 @@ bool arch_dma_unmap_sg_direct(struct device *dev, struct scatterlist *sg,
426426
#endif
427427

428428
#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
429-
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
430-
bool coherent);
429+
void arch_setup_dma_ops(struct device *dev, bool coherent);
431430
#else
432-
static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
433-
u64 size, bool coherent)
431+
static inline void arch_setup_dma_ops(struct device *dev, bool coherent)
434432
{
435433
}
436434
#endif /* CONFIG_ARCH_HAS_SETUP_DMA_OPS */

0 commit comments

Comments
 (0)