[Intel-gfx] [PATCH v4 16/19] vfio: Add VFIO_DEVICE_BIND_IOMMUFD
Yan Zhao
yan.y.zhao at intel.com
Mon Feb 27 04:46:03 UTC 2023
On Fri, Feb 24, 2023 at 10:31:35AM -0400, Jason Gunthorpe wrote:
> On Fri, Feb 24, 2023 at 12:58:22PM +0800, Yan Zhao wrote:
> > On Wed, Feb 22, 2023 at 08:59:51AM -0400, Jason Gunthorpe wrote:
> > > On Wed, Feb 22, 2023 at 07:44:12AM +0000, Liu, Yi L wrote:
> > > > > From: Tian, Kevin <kevin.tian at intel.com>
> > > > > Sent: Wednesday, February 22, 2023 3:40 PM
> > > > >
> > > > > > From: Liu, Yi L <yi.l.liu at intel.com>
> > > > > > Sent: Tuesday, February 21, 2023 11:48 AM
> > > > > >
> > > > > > +
> > > > > > +void vfio_device_cdev_close(struct vfio_device_file *df)
> > > > > > +{
> > > > > > + struct vfio_device *device = df->device;
> > > > > > +
> > > > > > + mutex_lock(&device->dev_set->lock);
> > > > > > + if (!smp_load_acquire(&df->access_granted)) {
> > > > >
> > > > > there is no contention with another one changing this flag at this
> > > > > point so directly accessing it is fine.
> > > >
> > > > make sense.
> > >
> > > Have to use READ_ONCE though
> > >
> > Just a curious question:
> > given df->access_granted is now written with device->dev_set->lock held and
> > also read with this lock held in vfio_device_cdev_close(), is READ_ONCE
> > still required? And what about df->iommufd ?
>
> No, if the writer is under a lock held by the reader then it is always
> OK to use naked read. Best to document it with a comment
>
Thanks for the clarification!
More information about the Intel-gfx
mailing list