]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu: Pass in a driver-level user data structure to viommu_init op
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 10 Jul 2025 05:58:58 +0000 (22:58 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 10 Jul 2025 15:38:51 +0000 (12:38 -0300)
The new type of vIOMMU for tegra241-cmdqv allows user space VM to use one
of its virtual command queue HW resources exclusively. This requires user
space to mmap the corresponding MMIO page from kernel space for direct HW
control.

To forward the mmap info (offset and length), iommufd should add a driver
specific data structure to the IOMMUFD_CMD_VIOMMU_ALLOC ioctl, for driver
to output the info during the vIOMMU initialization back to user space.

Similar to the existing ioctls and their IOMMU handlers, add a user_data
to viommu_init op to bridge between iommufd and drivers.

Link: https://patch.msgid.link/r/90bd5637dab7f5507c7a64d2c4826e70431e45a4.1752126748.git.nicolinc@nvidia.com
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.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/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
drivers/iommu/iommufd/selftest.c
drivers/iommu/iommufd/viommu.c
include/linux/iommu.h

index 69bbe39e28de854a2c71cab08e7d11cd1546db09..170d6916284870bd1cd4d12237b737ebf1247fc8 100644 (file)
@@ -419,7 +419,8 @@ size_t arm_smmu_get_viommu_size(struct device *dev,
 }
 
 int arm_vsmmu_init(struct iommufd_viommu *viommu,
-                  struct iommu_domain *parent_domain)
+                  struct iommu_domain *parent_domain,
+                  const struct iommu_user_data *user_data)
 {
        struct arm_vsmmu *vsmmu = container_of(viommu, struct arm_vsmmu, core);
        struct arm_smmu_device *smmu =
index 04463a4aaa2628b2027a050438547b2ed4d4d4c7..c1ced4d4b6d1a39ddb047f6a8c8ce9a9971c4a05 100644 (file)
@@ -1038,7 +1038,8 @@ void *arm_smmu_hw_info(struct device *dev, u32 *length,
 size_t arm_smmu_get_viommu_size(struct device *dev,
                                enum iommu_viommu_type viommu_type);
 int arm_vsmmu_init(struct iommufd_viommu *viommu,
-                  struct iommu_domain *parent_domain);
+                  struct iommu_domain *parent_domain,
+                  const struct iommu_user_data *user_data);
 int arm_smmu_attach_prepare_vmaster(struct arm_smmu_attach_state *state,
                                    struct arm_smmu_nested_domain *nested_domain);
 void arm_smmu_attach_commit_vmaster(struct arm_smmu_attach_state *state);
index 7a9abe3f47d5bc1bb5c0b7d35c24e0b1c36f0347..0d896a89ace7523dee65d467b35457980d71f1b0 100644 (file)
@@ -779,7 +779,8 @@ static size_t mock_get_viommu_size(struct device *dev,
 }
 
 static int mock_viommu_init(struct iommufd_viommu *viommu,
-                           struct iommu_domain *parent_domain)
+                           struct iommu_domain *parent_domain,
+                           const struct iommu_user_data *user_data)
 {
        struct mock_iommu_device *mock_iommu = container_of(
                viommu->iommu_dev, struct mock_iommu_device, iommu_dev);
index bc8796e6684e38566c83356d6bc5257051dc71cf..2009a421efae28c72cc217276a09f9fc5ea68c4f 100644 (file)
@@ -84,7 +84,7 @@ int iommufd_viommu_alloc_ioctl(struct iommufd_ucmd *ucmd)
         */
        viommu->iommu_dev = __iommu_get_iommu_dev(idev->dev);
 
-       rc = ops->viommu_init(viommu, hwpt_paging->common.domain);
+       rc = ops->viommu_init(viommu, hwpt_paging->common.domain, NULL);
        if (rc)
                goto out_put_hwpt;
 
index fd7319706684a074a89946268336eb2d84c41ba5..e06a0fbe4bc77dfb5cc20a215af31aa2b47bf65b 100644 (file)
@@ -700,7 +700,8 @@ struct iommu_ops {
        size_t (*get_viommu_size)(struct device *dev,
                                  enum iommu_viommu_type viommu_type);
        int (*viommu_init)(struct iommufd_viommu *viommu,
-                          struct iommu_domain *parent_domain);
+                          struct iommu_domain *parent_domain,
+                          const struct iommu_user_data *user_data);
 
        const struct iommu_domain_ops *default_domain_ops;
        unsigned long pgsize_bitmap;