[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e0ec920dd80c3d7e19ef4aa6641eacbe70b11687.1740705776.git.nicolinc@nvidia.com>
Date: Thu, 27 Feb 2025 17:31:18 -0800
From: Nicolin Chen <nicolinc@...dia.com>
To: <jgg@...dia.com>, <kevin.tian@...el.com>, <robin.murphy@....com>,
<joro@...tes.org>, <will@...nel.org>
CC: <iommu@...ts.linux.dev>, <linux-kernel@...r.kernel.org>
Subject: [PATCH v2 4/4] iommu: Turn iova_cookie to dma-iommu private pointer
Now that iommufd does not rely on dma-iommu.c for any purpose. We can
combine the dma-iommu.c iova_cookie and the iommufd_hwpt under the same
union. This union is effectively 'owner data' and can be used by the
entity that allocated the domain. Note that legacy vfio type1 flows
continue to use dma-iommu.c for sw_msi and still need iova_cookie.
Suggested-by: Jason Gunthorpe <jgg@...dia.com>
Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
---
include/linux/iommu.h | 2 +-
drivers/iommu/dma-iommu.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 29400060d648..5c6bca1ace27 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -221,10 +221,10 @@ struct iommu_domain {
const struct iommu_ops *owner; /* Whose domain_alloc we came from */
unsigned long pgsize_bitmap; /* Bitmap of page sizes in use */
struct iommu_domain_geometry geometry;
- struct iommu_dma_cookie *iova_cookie;
int (*iopf_handler)(struct iopf_group *group);
union { /* Pointer usable by owner of the domain */
+ struct iommu_dma_cookie *iova_cookie; /* dma-iommu */
struct iommufd_hw_pagetable *iommufd_hwpt; /* iommufd */
};
union { /* Fault handler */
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 7ee71b9c53bd..ee2fcc058aa3 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -443,12 +443,13 @@ EXPORT_SYMBOL(iommu_get_msi_cookie);
*/
void iommu_put_dma_cookie(struct iommu_domain *domain)
{
- struct iommu_dma_cookie *cookie = domain->iova_cookie;
struct iommu_dma_msi_page *msi, *tmp;
+ struct iommu_dma_cookie *cookie;
if (domain->private_data_owner != IOMMU_DOMAIN_DATA_OWNER_DMA)
return;
+ cookie = domain->iova_cookie;
if (!cookie)
return;
--
2.43.0
Powered by blists - more mailing lists