[Intel-gfx] [PATCH v2 11/14] vfio: Make vfio_device_open() exclusive between group path and device cdev path
Liu, Yi L
yi.l.liu at intel.com
Tue Feb 7 08:54:33 UTC 2023
> From: Tian, Kevin <kevin.tian at intel.com>
> Sent: Tuesday, February 7, 2023 2:25 PM
>
> > From: Liu, Yi L <yi.l.liu at intel.com>
> > Sent: Monday, February 6, 2023 5:05 PM
> >
> > struct vfio_device_file *
> > -vfio_allocate_device_file(struct vfio_device *device)
> > +vfio_allocate_device_file(struct vfio_device *device, bool
> is_cdev_device)
> > {
> > struct vfio_device_file *df;
> >
> > @@ -407,6 +407,7 @@ vfio_allocate_device_file(struct vfio_device
> *device)
> > return ERR_PTR(-ENOMEM);
> >
> > df->device = device;
> > + df->is_cdev_device = is_cdev_device;
>
> You missed Alex's comment that the one caller can open code the
> assignment instead of introducing an unmemorable Boolean arg here.
Oh, yes. will open code to set it in cdev path.
> >
> > + /*
> > + * Device cdev path cannot support multiple device open since
> > + * it doesn't have a secure way for it. So a second device
> > + * open attempt should be failed if the caller is from a cdev
> > + * path or the device has already been opened by a cdev path.
> > + */
> > + if (device->open_count != 0 &&
> > + (df->is_cdev_device || device->single_open))
> > + return -EINVAL;
> > +
>
> If we are gonna handle the exclusive open via dma ownership, then
> here we don't need a new single_open flag inside vfio_device since
> only one interface (cdev or group) could be used to open this device.
>
> Just preventing multi-open in cdev is sufficient here.
I see. Per below discussion, just need to make group path always
use vfio_group pointer as DMA marker.
https://lore.kernel.org/kvm/BN9PR11MB5276FA68E8CAD6394A8887848CDB9@BN9PR11MB5276.namprd11.prod.outlook.com/
Regards,
Yi Liu
More information about the Intel-gfx
mailing list