On Thu, 3 Nov 2022 19:25:06 -0300 Jason Gunthorpe <jgg@xxxxxxxx> wrote: > On Wed, Nov 02, 2022 at 03:45:27PM -0600, Alex Williamson wrote: > > > 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. > > > > That accounts for the first test, we don't need to test open_count on > > the calling device in this path, but the idea here is that we want to > > test whether we're the last close_device among the set. Not sure how > > we'd do that w/o some visibility to open_count. Maybe we need a > > vfio_device_set_open_count() that when 1 we know we're the first open > > or last close? Thanks, > > Right, we are checking the open count on all the devices in the set, > so I think that just this hunk is fine: > > > > > > - if (cur->vdev.open_count) > > > > > + if (cur != vdev && cur->vdev.open_count) > > > > > return false; > > Because vfio_pci_dev_set_needs_reset() is always called from > open/close (which is how it picks up the devset lock), so we never > need to consider the current device by definition, it is always "just > being closed" > > A little comment to explain this and that should be it? Yes, but the open question Kevin raised was that open_count is listed as private in the header, so we ought not to be looking at it at all from vfio-pci-core unless we want to change that or provide an alternate interface to it. Thanks, Alex