[RFC PATCH 7/8] PCI/IOV: Register virtual functions through the staged sysfs path

From: Pavol Sakac

Date: Fri Sep 11 2026 - 13:55:17 EST


SR-IOV enablement registers up to thousands of virtual functions, each
building its own sysfs directory tree under the sysfs root's
kernfs_rwsem. The sibling VF additions that an earlier patch in this
series runs concurrently within one PF, and VF enables running on several
PFs at once, all serialize on that one lock.

Opt VF registration in to staged registration by calling
dev_set_sysfs_staged() on the VF's device before pci_device_add() in
__pci_iov_add_virtfn(), the single path through which every VF is added:
the synchronous VF0 add, the async workers, and the pci_iov_add_virtfn()
wrapper. Each VF's directory is then built off the root lock and
published in one step.

Assisted-by: LLM
Signed-off-by: Pavol Sakac <sakacpav@xxxxxxxxx>
---
drivers/pci/iov.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index ac2ddda4bf14..79258d4791a3 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -387,6 +387,8 @@ static int __pci_iov_add_virtfn(struct pci_dev *dev, struct pci_bus *bus,
BUG_ON(rc);
}

+ /* must precede pci_device_add(); see DEV_FLAG_SYSFS_STAGED */
+ dev_set_sysfs_staged(&virtfn->dev);
pci_device_add(virtfn, virtfn->bus);
rc = pci_iov_sysfs_link(dev, virtfn, id);
if (rc)
--
2.47.3