diff mbox series

[v3,2/2] PCI/IOV: set iov->num_VFs before VFs are probed

Message ID 170795158776.2393.11628830004240634947.stgit@bgt-140510-bm01.eng.stellus.in
State New, archived
Headers show
Series PCI/IOV: sriov_numvfs bug fixes | expand

Commit Message

Jim Harris Feb. 14, 2024, 10:59 p.m. UTC
Ensure userspace can see the updated number of VFs
via sysfs sriov_numvfs before those VFs are probed.

Suggested-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jim Harris <jim.harris@samsung.com>
---
 drivers/pci/iov.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 0ca20cd518d5..ebb7c6892ad6 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -673,12 +673,14 @@  static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
 	msleep(100);
 	pci_cfg_access_unlock(dev);
 
+	iov->num_VFs = nr_virtfn;
 	rc = sriov_add_vfs(dev, initial);
-	if (rc)
+	if (rc) {
+		iov->num_VFs = 0;
 		goto err_pcibios;
+	}
 
 	kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE);
-	iov->num_VFs = nr_virtfn;
 
 	return 0;