Skip to content

Commit 1874619

Browse files
thierryredingBen Skeggs
authored andcommitted
ARM: dma-mapping: Set proper DMA ops in arm_iommu_detach_device()
Instead of setting the DMA ops pointer to NULL, set the correct, non-IOMMU ops depending on the device's coherency setting. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Russell King <rmk+kernel@armlinux.org.uk> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1 parent 0d46690 commit 1874619

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/arm/mm/dma-mapping.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,11 @@ int arm_dma_supported(struct device *dev, u64 mask)
11511151
return __dma_supported(dev, mask, false);
11521152
}
11531153

1154+
static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
1155+
{
1156+
return coherent ? &arm_coherent_dma_ops : &arm_dma_ops;
1157+
}
1158+
11541159
#ifdef CONFIG_ARM_DMA_USE_IOMMU
11551160

11561161
static int __dma_info_to_prot(enum dma_data_direction dir, unsigned long attrs)
@@ -2296,7 +2301,7 @@ void arm_iommu_detach_device(struct device *dev)
22962301
iommu_detach_device(mapping->domain, dev);
22972302
kref_put(&mapping->kref, release_iommu_mapping);
22982303
to_dma_iommu_mapping(dev) = NULL;
2299-
set_dma_ops(dev, NULL);
2304+
set_dma_ops(dev, arm_get_dma_map_ops(dev->archdata.dma_coherent));
23002305

23012306
pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
23022307
}
@@ -2357,11 +2362,6 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }
23572362

23582363
#endif /* CONFIG_ARM_DMA_USE_IOMMU */
23592364

2360-
static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)
2361-
{
2362-
return coherent ? &arm_coherent_dma_ops : &arm_dma_ops;
2363-
}
2364-
23652365
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
23662366
const struct iommu_ops *iommu, bool coherent)
23672367
{

0 commit comments

Comments
 (0)