PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes
authorPierre Crégut <pierre.cregut@orange.com>
Wed, 11 Sep 2019 07:27:36 +0000 (09:27 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 15 Oct 2019 21:39:12 +0000 (16:39 -0500)
commit35ff867b76576e32f34c698ccd11343f7d616204
tree8475dcbce83eebc0c4761b8565e27f7e721f6be5
parent56b4cd4b7da9ee95778eb5c8abea49f641ebfd91
PCI/IOV: Serialize sysfs sriov_numvfs reads vs writes

When sriov_numvfs is being updated, we call the driver->sriov_configure()
function, which may enable VFs and call probe functions, which may make new
devices visible.  This all happens before before sriov_numvfs_store()
updates sriov->num_VFs, so previously, concurrent sysfs reads of
sriov_numvfs returned stale values.

Serialize the sysfs read vs the write so the read returns the correct
num_VFs value.

[bhelgaas: hold device_lock instead of checking mutex_is_locked()]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=202991
Link: https://lore.kernel.org/r/20190911072736.32091-1-pierre.cregut@orange.com
Signed-off-by: Pierre Crégut <pierre.cregut@orange.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/iov.c