The ARM_DMA_USE_IOMMU DMA API implementation keeps its state in a struct
dma_iommu_mapping. Currently that struct owns an IOMMU domain -- to
allow inverting that relation, add a cookie type pointing to a struct
dma_iommu_mapping, more in line with how other architectures work.

Signed-off-by: Mikko Perttunen <[email protected]>
---
 drivers/iommu/iommu.c | 1 +
 include/linux/iommu.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 75687d1aafe9..43dd69662fac 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2127,6 +2127,7 @@ void iommu_domain_free(struct iommu_domain *domain)
 {
        switch (domain->cookie_type) {
        case IOMMU_COOKIE_DMA_IOVA:
+       case IOMMU_COOKIE_ARM_DMA:
                iommu_put_dma_cookie(domain);
                break;
        case IOMMU_COOKIE_DMA_MSI:
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index d20aa6f6863a..e2f8513d2067 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -43,6 +43,7 @@ struct notifier_block;
 struct iommu_sva;
 struct iommu_dma_cookie;
 struct iommu_dma_msi_cookie;
+struct dma_iommu_mapping;
 struct iommu_fault_param;
 struct iommufd_ctx;
 struct iommufd_viommu;
@@ -174,6 +175,7 @@ enum iommu_domain_cookie_type {
        IOMMU_COOKIE_FAULT_HANDLER,
        IOMMU_COOKIE_SVA,
        IOMMU_COOKIE_IOMMUFD,
+       IOMMU_COOKIE_ARM_DMA,
 };
 
 /* Domain feature flags */
@@ -234,6 +236,7 @@ struct iommu_domain {
        union { /* cookie */
                struct iommu_dma_cookie *iova_cookie;
                struct iommu_dma_msi_cookie *msi_cookie;
+               struct dma_iommu_mapping *arm_cookie;
                struct iommufd_hw_pagetable *iommufd_hwpt;
                struct {
                        iommu_fault_handler_t handler;

-- 
2.55.0

Reply via email to