Re: [PATCH] pci: iov: use device lock to protect IOV sysfs accesses

From: Christoph Hellwig
Date: Tue May 23 2017 - 01:25:53 EST


On Mon, May 22, 2017 at 03:50:23PM -0700, Jakub Kicinski wrote:
> PCI core sets the driver pointer before calling ->probe() and only
> clears it after ->remove(). This means driver's ->sriov_configure()
> callback will happily race with probe() and remove(), most likely
> leading to BUGs, since drivers don't expect this.
>
> We could reorder pointer assignments, or try detecting races in all
> drivers, but it seems simpler and cleaner to just hold the device lock
> instead of special SR-IOV lock, since that lock is already supposed
> to synchronize the driver callbacks.
>
> Remove the iov lock completely, since we remove the last user.

Having just debugged a different method vs ->remove race I violently
agree.

Reviewed-by: Christoph Hellwig <hch@xxxxxx>