[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eae828f3190b89d0a1026ae9e97747210cf96bbc.1723061378.git.nicolinc@nvidia.com>
Date: Wed, 7 Aug 2024 13:10:50 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: <jgg@...dia.com>, <kevin.tian@...el.com>, <will@...nel.org>
CC: <joro@...tes.org>, <suravee.suthikulpanit@....com>,
<robin.murphy@....com>, <dwmw2@...radead.org>, <baolu.lu@...ux.intel.com>,
<shuah@...nel.org>, <linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kselftest@...r.kernel.org>
Subject: [PATCH v1 09/16] iommufd/viommu: Make iommufd_viommu_find_device a public API
Now, an IOMMU driver can use viommu to invalidate a device cache via the
viommu_cache_invalidate op. Very likely, this would require the driver to
lookup a virtual device ID for a physical device (or just its ID). Since
the core already has a helper, make it public.
Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
---
drivers/iommu/iommufd/viommu.c | 2 +-
include/linux/iommufd.h | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/iommufd/viommu.c b/drivers/iommu/iommufd/viommu.c
index ada9f968b9f6..2304f199b033 100644
--- a/drivers/iommu/iommufd/viommu.c
+++ b/drivers/iommu/iommufd/viommu.c
@@ -148,7 +148,7 @@ int iommufd_viommu_set_vdev_id(struct iommufd_ucmd *ucmd)
return rc;
}
-static struct device *
+struct device *
iommufd_viommu_find_device(struct iommufd_viommu *viommu, u64 id)
{
struct iommufd_vdev_id *vdev_id;
diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h
index 7da5140fa1b0..e0d7a53acbd5 100644
--- a/include/linux/iommufd.h
+++ b/include/linux/iommufd.h
@@ -89,6 +89,8 @@ int iommufd_access_rw(struct iommufd_access *access, unsigned long iova,
int iommufd_vfio_compat_ioas_get_id(struct iommufd_ctx *ictx, u32 *out_ioas_id);
int iommufd_vfio_compat_ioas_create(struct iommufd_ctx *ictx);
int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ictx);
+struct device *
+iommufd_viommu_find_device(struct iommufd_viommu *viommu, u64 id);
#else /* !CONFIG_IOMMUFD */
static inline struct iommufd_ctx *iommufd_ctx_from_file(struct file *file)
{
@@ -129,5 +131,11 @@ static inline int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ictx)
{
return -EOPNOTSUPP;
}
+
+static inline struct device *
+iommufd_viommu_find_device(struct iommufd_viommu *viommu, u64 id)
+{
+ return NULL;
+}
#endif /* CONFIG_IOMMUFD */
#endif
--
2.43.0
Powered by blists - more mailing lists