Thread (67 messages) 67 messages, 2 authors, 2023-08-16

Re: [PATCH v6 02/25] iommu: Add IOMMU_DOMAIN_PLATFORM

From: Baolu Lu <baolu.lu@linux.intel.com>
Date: 2023-08-12 01:42:07
Also in: linux-arm-kernel, linux-arm-msm, linux-iommu, linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc, linux-sunxi, linux-tegra

On 2023/8/3 8:07, Jason Gunthorpe wrote:
quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help