Skip to content

Commit 4720287

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu: Remove struct iommu_ops *iommu from arch_setup_dma_ops()
This is not being used to pass ops, it is just a way to tell if an iommu driver was probed. These days this can be detected directly via device_iommu_mapped(). Call device_iommu_mapped() in the two places that need to check it and remove the iommu parameter everywhere. Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Moritz Fischer <mdf@kernel.org> Acked-by: Christoph Hellwig <hch@lst.de> Acked-by: Rob Herring <robh@kernel.org> Tested-by: Hector Martin <marcan@marcan.st> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/1-v2-16e4def25ebb+820-iommu_fwspec_p1_jgg@nvidia.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 7be4233 commit 4720287

10 files changed

Lines changed: 16 additions & 17 deletions

File tree

arch/arc/mm/dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
9191
* Plug in direct dma map ops.
9292
*/
9393
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
94-
const struct iommu_ops *iommu, bool coherent)
94+
bool coherent)
9595
{
9696
/*
9797
* IOC hardware snoops all DMA traffic keeping the caches consistent

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
3434
}
3535

3636
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
37-
const struct iommu_ops *iommu, bool coherent)
37+
bool coherent)
3838
{
3939
if (IS_ENABLED(CONFIG_CPU_V7M)) {
4040
/*

arch/arm/mm/dma-mapping.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ void arm_iommu_detach_device(struct device *dev)
17131713
EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
17141714

17151715
static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
1716-
const struct iommu_ops *iommu, bool coherent)
1716+
bool coherent)
17171717
{
17181718
struct dma_iommu_mapping *mapping;
17191719

@@ -1748,7 +1748,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)
17481748
#else
17491749

17501750
static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
1751-
const struct iommu_ops *iommu, bool coherent)
1751+
bool coherent)
17521752
{
17531753
}
17541754

@@ -1757,7 +1757,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }
17571757
#endif /* CONFIG_ARM_DMA_USE_IOMMU */
17581758

17591759
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
1760-
const struct iommu_ops *iommu, bool coherent)
1760+
bool coherent)
17611761
{
17621762
/*
17631763
* Due to legacy code that sets the ->dma_coherent flag from a bus
@@ -1776,8 +1776,8 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
17761776
if (dev->dma_ops)
17771777
return;
17781778

1779-
if (iommu)
1780-
arm_setup_iommu_dma_ops(dev, dma_base, size, iommu, coherent);
1779+
if (device_iommu_mapped(dev))
1780+
arm_setup_iommu_dma_ops(dev, dma_base, size, coherent);
17811781

17821782
xen_setup_dma_ops(dev);
17831783
dev->archdata.dma_ops_setup = true;

arch/arm64/mm/dma-mapping.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void arch_teardown_dma_ops(struct device *dev)
4747
#endif
4848

4949
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
50-
const struct iommu_ops *iommu, bool coherent)
50+
bool coherent)
5151
{
5252
int cls = cache_line_size_of_cpu();
5353

@@ -58,7 +58,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
5858
ARCH_DMA_MINALIGN, cls);
5959

6060
dev->dma_coherent = coherent;
61-
if (iommu)
61+
if (device_iommu_mapped(dev))
6262
iommu_setup_dma_ops(dev, dma_base, dma_base + size - 1);
6363

6464
xen_setup_dma_ops(dev);

arch/mips/mm/dma-noncoherent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
138138

139139
#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
140140
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
141-
const struct iommu_ops *iommu, bool coherent)
141+
bool coherent)
142142
{
143143
dev->dma_coherent = coherent;
144144
}

arch/riscv/mm/dma-noncoherent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
129129
}
130130

131131
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
132-
const struct iommu_ops *iommu, bool coherent)
132+
bool coherent)
133133
{
134134
WARN_TAINT(!coherent && riscv_cbom_block_size > ARCH_DMA_MINALIGN,
135135
TAINT_CPU_OUT_OF_SPEC,

drivers/acpi/scan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,8 +1641,7 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
16411641
if (PTR_ERR(iommu) == -EPROBE_DEFER)
16421642
return -EPROBE_DEFER;
16431643

1644-
arch_setup_dma_ops(dev, 0, U64_MAX,
1645-
iommu, attr == DEV_DMA_COHERENT);
1644+
arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT);
16461645

16471646
return 0;
16481647
}

drivers/hv/hv_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ void hv_setup_dma_ops(struct device *dev, bool coherent)
488488
* Hyper-V does not offer a vIOMMU in the guest
489489
* VM, so pass 0/NULL for the IOMMU settings
490490
*/
491-
arch_setup_dma_ops(dev, 0, 0, NULL, coherent);
491+
arch_setup_dma_ops(dev, 0, 0, coherent);
492492
}
493493
EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
494494

drivers/of/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
193193
dev_dbg(dev, "device is%sbehind an iommu\n",
194194
iommu ? " " : " not ");
195195

196-
arch_setup_dma_ops(dev, dma_start, size, iommu, coherent);
196+
arch_setup_dma_ops(dev, dma_start, size, coherent);
197197

198198
if (!iommu)
199199
of_dma_set_restricted_buffer(dev, np);

include/linux/dma-map-ops.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ bool arch_dma_unmap_sg_direct(struct device *dev, struct scatterlist *sg,
427427

428428
#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
429429
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
430-
const struct iommu_ops *iommu, bool coherent);
430+
bool coherent);
431431
#else
432432
static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
433-
u64 size, const struct iommu_ops *iommu, bool coherent)
433+
u64 size, bool coherent)
434434
{
435435
}
436436
#endif /* CONFIG_ARCH_HAS_SETUP_DMA_OPS */

0 commit comments

Comments
 (0)