[PATCH 01/11] iommu: Add iommu_teardown_dma_ops
From: Mikko Perttunen
Date: Mon Sep 14 2026 - 22:16:01 EST
Add a counterpart to iommu_setup_dma_ops, tearing down state set by it.
Currently this teardown is open-coded in iommu_deinit_device; however
when 32-bit ARM gains a parallel implementation of iommu_setup_dma_ops
it becomes nicer to have a matching parallel iommu_teardown_dma_ops as
well.
Signed-off-by: Mikko Perttunen <mperttunen@xxxxxxxxxx>
---
drivers/iommu/dma-iommu.c | 5 +++++
drivers/iommu/dma-iommu.h | 5 +++++
drivers/iommu/iommu.c | 3 +--
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 9abaec0703ef..26674eec5996 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -2166,6 +2166,11 @@ void iommu_setup_dma_ops(struct device *dev, struct iommu_domain *domain)
dev_clear_dma_iommu(dev);
}
+void iommu_teardown_dma_ops(struct device *dev)
+{
+ dev_clear_dma_iommu(dev);
+}
+
static bool has_msi_cookie(const struct iommu_domain *domain)
{
return domain && (domain->cookie_type == IOMMU_COOKIE_DMA_IOVA ||
diff --git a/drivers/iommu/dma-iommu.h b/drivers/iommu/dma-iommu.h
index 040d00252563..349d6a57e5a0 100644
--- a/drivers/iommu/dma-iommu.h
+++ b/drivers/iommu/dma-iommu.h
@@ -10,6 +10,7 @@
#ifdef CONFIG_IOMMU_DMA
void iommu_setup_dma_ops(struct device *dev, struct iommu_domain *domain);
+void iommu_teardown_dma_ops(struct device *dev);
int iommu_get_dma_cookie(struct iommu_domain *domain);
void iommu_put_dma_cookie(struct iommu_domain *domain);
@@ -31,6 +32,10 @@ static inline void iommu_setup_dma_ops(struct device *dev,
{
}
+static inline void iommu_teardown_dma_ops(struct device *dev)
+{
+}
+
static inline int iommu_dma_init_fq(struct iommu_domain *domain)
{
return -EINVAL;
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index e8f13dcebbde..75687d1aafe9 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -611,8 +611,7 @@ static void iommu_deinit_device(struct device *dev)
dev->iommu_group = NULL;
module_put(ops->owner);
dev_iommu_free(dev);
- if (IS_ENABLED(CONFIG_IOMMU_DMA))
- dev_clear_dma_iommu(dev);
+ iommu_teardown_dma_ops(dev);
}
static struct iommu_domain *pasid_array_entry_to_domain(void *entry)
--
2.55.0