Re: [PATCH v2] vfio-pci: Accept a non-zero open_count on reset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 01, 2022 at 08:49:28AM +0000, Tian, Kevin wrote:
> > From: Anthony DeRossi <ajderossi@xxxxxxxxx>
> > Sent: Thursday, October 27, 2022 3:43 AM
> > 
> > -static bool vfio_pci_dev_set_needs_reset(struct vfio_device_set *dev_set)
> > +static bool vfio_pci_core_needs_reset(struct vfio_pci_core_device *vdev)
> >  {
> > +	struct vfio_device_set *dev_set = vdev->vdev.dev_set;
> >  	struct vfio_pci_core_device *cur;
> >  	bool needs_reset = false;
> > 
> > +	if (vdev->vdev.open_count > 1)
> > +		return false;
> 
> WARN_ON()
> 
> > +
> >  	list_for_each_entry(cur, &dev_set->device_list, vdev.dev_set_list) {
> > -		/* No VFIO device in the set can have an open device FD */
> > -		if (cur->vdev.open_count)
> > +		/* Only the VFIO device being reset can have an open FD */
> > +		if (cur != vdev && cur->vdev.open_count)
> >  			return false;
> 
> not caused by this patch but while at it...
> 
> open_count is defined not for driver use:
> 
> 	/* Members below here are private, not for driver use */
> 	unsigned int index;
> 	struct device device;   /* device.kref covers object life circle */
> 	refcount_t refcount;    /* user count on registered device*/
> 	unsigned int open_count;
> 	struct completion comp;
> 	struct list_head group_next;
> 	struct list_head iommu_entry;
> 
> prefer to a wrapper or move it to the public section of vfio_device.

I've been meaning to take a deeper look, but I'm thinking vfio_pci
doesn't need open_count at all any more.

open_count was from before we changed the core code to call
open_device only once. If we are only a call chain from
open_device/close_device then we know that the open_count must be 1.

Jason



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux