On Wed, Dec 21, 2022 at 04:07:42AM +0000, Tian, Kevin wrote: > > From: Liu, Yi L <yi.l.liu@xxxxxxxxx> > > Sent: Monday, December 19, 2022 4:47 PM > > > > +static bool vfio_device_enforced_coherent(struct vfio_device *device) > > +{ > > + bool ret; > > + > > + if (!vfio_device_try_get_registration(device)) > > + return true; > > + > > + ret = device_iommu_capable(device->dev, > > + > > IOMMU_CAP_ENFORCE_CACHE_COHERENCY); > > + > > + vfio_device_put_registration(device); > > + return ret; > > +} > > This probably needs an explanation that recounting is required because > this might be called before vfio_device_open() is called to hold the > count. How does that happen? The only call site already has a struct file and the struct file implicitly holds the registration. This should be removed. Just inline the whole thing and make it clear: device = vfio_device_from_file(file); if (device) return device_iommu_capable(device->dev, IOMMU_CAP_ENFORCE_CACHE_COHERENCY); Jason