Linux-PCI Archive on
 help / color / Atom feed
* [PATCH v2] PCI/IOV: avoid giving back wrong numvfs
@ 2019-09-11  7:27 Pierre Crégut
  0 siblings, 0 replies; only message in thread
From: Pierre Crégut @ 2019-09-11  7:27 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-kernel, Pierre Crégut

When numvfs is being updated, reply to numvfs queries with EAGAIN.
As drivers may notify changes on numvfs before they are implemented,
it is advisable to not reply rather than giving back an outdated value.
Clients will notice that the value is still unknown and will retry
to get it.

The patch relies on the status of the device mutex as an
overapproximation of when numvfs is modified.

Signed-off-by: Pierre Crégut <>

This is an updated version of "PCI/IOV: update num_VFs earlier" and a
reply to your mail sent on 14/06/19. Sorry I completely missed it.
The commit message was changed as the implementation principle was

 drivers/pci/pci-sysfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 965c72104150..493eea261d40 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -568,6 +568,8 @@ static ssize_t sriov_numvfs_show(struct device *dev,
 	struct pci_dev *pdev = to_pci_dev(dev);
+	if (mutex_is_locked(&dev->mutex))
+		return -EAGAIN;
 	return sprintf(buf, "%u\n", pdev->sriov->num_VFs);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11  7:27 [PATCH v2] PCI/IOV: avoid giving back wrong numvfs Pierre Crégut

Linux-PCI Archive on

Archives are clonable:
	git clone --mirror linux-pci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pci linux-pci/ \
	public-inbox-index linux-pci

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox