[PATCH v4 05/23] iommufd/driver: Let iommufd_viommu_alloc helper save ictx to viommu->ictx

Jason Gunthorpe jgg at nvidia.com
Fri May 16 06:28:45 PDT 2025


On Thu, May 15, 2025 at 07:05:45PM -0700, Nicolin Chen wrote:

> Otherwise, they would be something like:
> 	// in my_viommu_alloc()
> 	my_viommu = iommufd_viommu_alloc(ucmd, ...);
> 	iommufd_viommu_alloc_mmap(ucmd->ictx, my_viommu, ...);
> 	iommufd_viommu_destroy_mmap(ucmd->ictx, my_viommu, ...);
> 	// in my_viommu_destory()
> 	iommufd_viommu_destroy_mmap(my_viommu->ictx, my_viommu ...);

Yes, this is how the other objects work..

> That being said, I ended up doing something more in this patch
> for the ucmd rework and Kevin's comments:
> 
> diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h
> index 98fe5a49c9606..ddd144031af5d 100644
> --- a/drivers/iommu/iommufd/iommufd_private.h
> +++ b/drivers/iommu/iommufd/iommufd_private.h
> @@ -136,14 +136,6 @@ int iopt_pin_pages(struct io_pagetable *iopt, unsigned long iova,
>  void iopt_unpin_pages(struct io_pagetable *iopt, unsigned long iova,
>  		      unsigned long length);
>  
> -struct iommufd_ucmd {
> -	struct iommufd_ctx *ictx;
> -	void __user *ubuffer;
> -	u32 user_size;
> -	void *cmd;
> -	struct iommufd_object *alloced_obj;
> -};

You don't need to move this unless you are using inlines. Just use a
forward declaration.

Jason



More information about the linux-arm-kernel mailing list