diff mbox series

[v1,09/16] iommufd/viommu: Make iommufd_viommu_find_device a public API

Message ID eae828f3190b89d0a1026ae9e97747210cf96bbc.1723061378.git.nicolinc@nvidia.com (mailing list archive)
State New
Headers show
Series iommufd: Add VIOMMU infrastructure (Part-1) | expand

Commit Message

Nicolin Chen Aug. 7, 2024, 8:10 p.m. UTC
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@nvidia.com>
---
 drivers/iommu/iommufd/viommu.c | 2 +-
 include/linux/iommufd.h        | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

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