]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommufd/viommu: Explicitly define vdev->virt_id
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 10 Jul 2025 05:58:55 +0000 (22:58 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 10 Jul 2025 15:38:50 +0000 (12:38 -0300)
The "id" is too general to get its meaning easily. Rename it explicitly to
"virt_id" and update the kdocs for readability. No functional changes.

Link: https://patch.msgid.link/r/1fac22d645e6ee555675726faf3798a68315b044.1752126748.git.nicolinc@nvidia.com
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/driver.c
drivers/iommu/iommufd/iommufd_private.h
drivers/iommu/iommufd/viommu.c

index 2fee399a148ef66dbd0c65e448d17b00aa6f3e7e..887719016804cecf37409b58668b10fd8e5bb7eb 100644 (file)
@@ -30,7 +30,7 @@ int iommufd_viommu_get_vdev_id(struct iommufd_viommu *viommu,
        xa_lock(&viommu->vdevs);
        xa_for_each(&viommu->vdevs, index, vdev) {
                if (vdev->dev == dev) {
-                       *vdev_id = vdev->id;
+                       *vdev_id = vdev->virt_id;
                        rc = 0;
                        break;
                }
index 4f5e8cd99c9655e1304fdc962be1ab1bd76fe62d..320635a177b774d575e7f3e17708fbd3ae436981 100644 (file)
@@ -634,7 +634,12 @@ struct iommufd_vdevice {
        struct iommufd_object obj;
        struct iommufd_viommu *viommu;
        struct device *dev;
-       u64 id; /* per-vIOMMU virtual ID */
+
+       /*
+        * Virtual device ID per vIOMMU, e.g. vSID of ARM SMMUv3, vDeviceID of
+        * AMD IOMMU, and vRID of Intel VT-d
+        */
+       u64 virt_id;
 };
 
 #ifdef CONFIG_IOMMUFD_TEST
index 25ac08fbb52a76112e9b5a6d4a2207f2648d012d..bc8796e6684e38566c83356d6bc5257051dc71cf 100644 (file)
@@ -111,7 +111,7 @@ void iommufd_vdevice_destroy(struct iommufd_object *obj)
        struct iommufd_viommu *viommu = vdev->viommu;
 
        /* xa_cmpxchg is okay to fail if alloc failed xa_cmpxchg previously */
-       xa_cmpxchg(&viommu->vdevs, vdev->id, vdev, NULL, GFP_KERNEL);
+       xa_cmpxchg(&viommu->vdevs, vdev->virt_id, vdev, NULL, GFP_KERNEL);
        refcount_dec(&viommu->obj.users);
        put_device(vdev->dev);
 }
@@ -150,7 +150,7 @@ int iommufd_vdevice_alloc_ioctl(struct iommufd_ucmd *ucmd)
                goto out_put_idev;
        }
 
-       vdev->id = virt_id;
+       vdev->virt_id = virt_id;
        vdev->dev = idev->dev;
        get_device(idev->dev);
        vdev->viommu = viommu;