Thread (60 messages) 60 messages, 5 authors, 2025-02-21

Re: [PATCH v6 06/14] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2025-02-18 15:31:58
Also in: linux-doc, linux-iommu, linux-kselftest, linux-patches, lkml

On Fri, Jan 24, 2025 at 04:30:35PM -0800, Nicolin Chen wrote:
This is a reverse search v.s. iommufd_viommu_find_dev, as drivers may want
to convert a struct device pointer (physical) to its virtual device ID for
an event injection to the user space VM.

Again, this avoids exposing more core structures to the drivers, than the
iommufd_viommu alone.

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Nicolin Chen <redacted>
---
 include/linux/iommufd.h        |  9 +++++++++
 drivers/iommu/iommufd/driver.c | 24 ++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
+	xa_lock(&viommu->vdevs);
+	xa_for_each(&viommu->vdevs, index, vdev) {
+		if (vdev->dev == dev) {
+			*vdev_id = (unsigned long)vdev->id;
I don't think we need this cast

Jason
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help