Re: [PATCH v2 02/22] iommu: Pass in a driver-level user data structure to viommu_alloc op

Nicolin Chen
2025-04-28T17:19:52Z

On Sun, Apr 27, 2025 at 02:31:54PM +0800, Baolu Lu wrote:
> On 4/26/25 13:57, Nicolin Chen wrote:
> > The new type of vIOMMU for tegra241-cmdqv needs to pass in a driver-level
> > data structure from user space via iommufd, so add a user_data to the op.
> >
> > Reviewed-by: Jason Gunthorpe<jgg@nvidia.com>
> > Signed-off-by: Nicolin Chen<nicolinc@nvidia.com>
>
> It would be better to add some words explaining what kind of user data
> can be passed when allocating a vIOMMU object and the reason why this
> might be necessary.
>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

Sure. Will do something like this:

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 (vm_pgoff and size), iommufd should add a driver
specific data structure to the IOMMUFD_CMD_VIOMMU_ALLOC ioctl, for driver
to output the info (during the allocation) back to user space.

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

Thanks
Nicolin