> From: Tian, Kevin <[email protected]>
> Sent: Tuesday, February 7, 2023 2:25 PM
> 
> > From: Liu, Yi L <[email protected]>
> > 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/bn9pr11mb5276fa68e8cad6394a8887848c...@bn9pr11mb5276.namprd11.prod.outlook.com/

Regards,
Yi Liu

Reply via email to