[Intel-gfx] [PATCH v6 16/24] vfio: Make vfio_device_first_open() to cover the noiommu mode in cdev path

Tian, Kevin kevin.tian at intel.com
Fri Mar 10 08:30:03 UTC 2023


> From: Liu, Yi L <yi.l.liu at intel.com>
> Sent: Wednesday, March 8, 2023 9:29 PM
> 
> +/*
> + * This shall be used without group lock as group and group->container
> + * should be fixed before group is set to df->group.
> + */

/* No group lock since df->group and df->group->container cannot change */

> +bool vfio_device_group_uses_container(struct vfio_device_file *df)
> +{
> +	/*
> +	 * Use the df->group instead of the df->device->group as no
> +	 * lock is acquired here.
> +	 */

remove

> 
> +	/*
> +	 * The handling here depends on what the user is using.
> +	 *
> +	 * If user uses iommufd in the group compat mode or the
> +	 * cdev path, call vfio_iommufd_bind().
> +	 *
> +	 * If user uses container in the group legacy mode, call
> +	 * vfio_device_group_use_iommu().

this is what code does.

> +	 *
> +	 * If user doesn't use iommufd nor container, this is
> +	 * the noiommufd mode in the cdev path, nothing needs
> +	 * to be done here just go ahead to open device.
> +	 */
>  	if (iommufd)
>  		ret = vfio_iommufd_bind(device, iommufd);
> -	else
> +	else if (vfio_device_group_uses_container(df))
>  		ret = vfio_device_group_use_iommu(device);

with earlier suggestion then iommufd=NULL always means
noiommu in this function. 

Then the comment could be simple as:

/*
 * if neither iommufd nor container is used the device is in
 * noiommu mode then just go ahead to open it.
 */


More information about the Intel-gfx mailing list