Message ID | 20230401144429.88673-11-yi.l.liu@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Introduce new methods for verifying ownership in vfio PCI hot reset | expand |
On 4/1/23 16:44, Yi Liu wrote: > There are users that need to check if vfio_device is opened as cdev. > e.g. vfio-pci. This adds a flag in vfio_device, it will be set in the > cdev path when device is opened. This is not used at this moment, but > a preparation for vfio device cdev support. better to squash this patch with the patch setting cdev_opened then? Thanks Eric > > Signed-off-by: Yi Liu <yi.l.liu@intel.com> > --- > include/linux/vfio.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/linux/vfio.h b/include/linux/vfio.h > index f8fb9ab25188..d9a0770e5fc1 100644 > --- a/include/linux/vfio.h > +++ b/include/linux/vfio.h > @@ -62,6 +62,7 @@ struct vfio_device { > struct iommufd_device *iommufd_device; > bool iommufd_attached; > #endif > + bool cdev_opened; > }; > > /** > @@ -151,6 +152,12 @@ vfio_iommufd_physical_devid(struct vfio_device *vdev, u32 *id) > ((int (*)(struct vfio_device *vdev, u32 *pt_id)) NULL) > #endif > > +static inline bool vfio_device_cdev_opened(struct vfio_device *device) > +{ > + lockdep_assert_held(&device->dev_set->lock); > + return device->cdev_opened; > +} > + > /** > * @migration_set_state: Optional callback to change the migration state for > * devices that support migration. It's mandatory for
> From: Eric Auger <eric.auger@redhat.com> > Sent: Wednesday, April 5, 2023 7:48 PM > > On 4/1/23 16:44, Yi Liu wrote: > > There are users that need to check if vfio_device is opened as cdev. > > e.g. vfio-pci. This adds a flag in vfio_device, it will be set in the > > cdev path when device is opened. This is not used at this moment, but > > a preparation for vfio device cdev support. > > better to squash this patch with the patch setting cdev_opened then? But that would be in the cdev series. Maybe only add this helper to return false and add the cdev_opened in below patch. Will this be better? https://lore.kernel.org/kvm/20230401151833.124749-23-yi.l.liu@intel.com/ > Thanks > > Eric > > > > Signed-off-by: Yi Liu <yi.l.liu@intel.com> > > --- > > include/linux/vfio.h | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/include/linux/vfio.h b/include/linux/vfio.h > > index f8fb9ab25188..d9a0770e5fc1 100644 > > --- a/include/linux/vfio.h > > +++ b/include/linux/vfio.h > > @@ -62,6 +62,7 @@ struct vfio_device { > > struct iommufd_device *iommufd_device; > > bool iommufd_attached; > > #endif > > + bool cdev_opened; > > }; > > > > /** > > @@ -151,6 +152,12 @@ vfio_iommufd_physical_devid(struct vfio_device *vdev, > u32 *id) > > ((int (*)(struct vfio_device *vdev, u32 *pt_id)) NULL) > > #endif > > > > +static inline bool vfio_device_cdev_opened(struct vfio_device *device) > > +{ > > + lockdep_assert_held(&device->dev_set->lock); > > + return device->cdev_opened; > > +} > > + > > /** > > * @migration_set_state: Optional callback to change the migration state for > > * devices that support migration. It's mandatory for
diff --git a/include/linux/vfio.h b/include/linux/vfio.h index f8fb9ab25188..d9a0770e5fc1 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -62,6 +62,7 @@ struct vfio_device { struct iommufd_device *iommufd_device; bool iommufd_attached; #endif + bool cdev_opened; }; /** @@ -151,6 +152,12 @@ vfio_iommufd_physical_devid(struct vfio_device *vdev, u32 *id) ((int (*)(struct vfio_device *vdev, u32 *pt_id)) NULL) #endif +static inline bool vfio_device_cdev_opened(struct vfio_device *device) +{ + lockdep_assert_held(&device->dev_set->lock); + return device->cdev_opened; +} + /** * @migration_set_state: Optional callback to change the migration state for * devices that support migration. It's mandatory for
There are users that need to check if vfio_device is opened as cdev. e.g. vfio-pci. This adds a flag in vfio_device, it will be set in the cdev path when device is opened. This is not used at this moment, but a preparation for vfio device cdev support. Signed-off-by: Yi Liu <yi.l.liu@intel.com> --- include/linux/vfio.h | 7 +++++++ 1 file changed, 7 insertions(+)