On 2023/8/3 8:07, Jason Gunthorpe wrote:
@@ -1967,7 +1978,8 @@ void iommu_domain_free(struct iommu_domain *domain)
        if (domain->type == IOMMU_DOMAIN_SVA)
                mmdrop(domain->mm);
        iommu_put_dma_cookie(domain);
-       domain->ops->free(domain);
+       if (domain->ops->free)
+               domain->ops->free(domain);
  }
  EXPORT_SYMBOL_GPL(iommu_domain_free);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index e05c93b6c37fba..87aebba474e093 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -64,6 +64,7 @@ struct iommu_domain_geometry {
  #define __IOMMU_DOMAIN_DMA_FQ (1U << 3)  /* DMA-API uses flush queue    */
#define __IOMMU_DOMAIN_SVA (1U << 4) /* Shared process address space */
+#define __IOMMU_DOMAIN_PLATFORM        (1U << 5)
#define IOMMU_DOMAIN_ALLOC_FLAGS ~__IOMMU_DOMAIN_DMA_FQ
  /*
@@ -81,6 +82,8 @@ struct iommu_domain_geometry {
   *                              invalidation.
   *    IOMMU_DOMAIN_SVA        - DMA addresses are shared process addresses
   *                              represented by mm_struct's.
+ *     IOMMU_DOMAIN_PLATFORM   - Legacy domain for drivers that do their own
+ *                               dma_api stuff. Do not use in new drivers.
   */
  #define IOMMU_DOMAIN_BLOCKED  (0U)
  #define IOMMU_DOMAIN_IDENTITY (__IOMMU_DOMAIN_PT)
@@ -91,6 +94,7 @@ struct iommu_domain_geometry {
                                 __IOMMU_DOMAIN_DMA_API |       \
                                 __IOMMU_DOMAIN_DMA_FQ)
  #define IOMMU_DOMAIN_SVA      (__IOMMU_DOMAIN_SVA)
+#define IOMMU_DOMAIN_PLATFORM  (__IOMMU_DOMAIN_PLATFORM)

Nit: As a default domain could be the type of IOMMU_DOMAIN_PLATFORM,

static const char *iommu_domain_type_str(unsigned int t)

needs to be updated, so that users can get a right string when reading /sys/.../[group_id]/type.

Best regards,
baolu

Reply via email to