git: 78547d542f77 - main - pci: Skip PF SR-IOV state handling for VFs

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a75e1c2.3fc40.28d9dda8__47610.1294088707$1786110437$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=78547d542f776d366c36b5a2fc747ddfe99523c6

commit 78547d542f776d366c36b5a2fc747ddfe99523c6
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-08-07 13:30:06 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-07 13:46:35 +0000

    pci: Skip PF SR-IOV state handling for VFs
    
    A VF's pci_devinfo references its PF's pcicfg_iov for resource
    bookkeeping, but only the PF implements the SR-IOV capability.
    pci_cfg_save() and pci_cfg_restore() treated any non-NULL cfg.iov as
    an owned capability and accessed the PF capability offset in VF
    configuration space. Saving a VF could therefore replace the shared
    PF settings with unrelated VF register values.
    
    Skip SR-IOV capability save and restore for PCICFG_VF children. The
    generic PCI and PCIe state of the VF remains preserved. This is also
    required by drivers that save VF state around a PF-driven
    function-level reset.
    
    MFC after:      2 weeks
---
 sys/dev/pci/pci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 749ee71b195f..83ea487bdaa5 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -6691,7 +6691,9 @@ pci_cfg_restore(device_t dev, struct pci_devinfo *dinfo)
 		pci_resume_msix(dev);
 
 #ifdef PCI_IOV
-	if (dinfo->cfg.iov != NULL)
+	/* The SR-IOV capability is implemented only by PFs. */
+	if (dinfo->cfg.iov != NULL &&
+	    (dinfo->cfg.flags & PCICFG_VF) == 0)
 		pci_iov_cfg_restore(dev, dinfo);
 #endif
 }
@@ -6807,7 +6809,9 @@ pci_cfg_save(device_t dev, struct pci_devinfo *dinfo, int setstate)
 		pci_cfg_save_pcix(dev, dinfo);
 
 #ifdef PCI_IOV
-	if (dinfo->cfg.iov != NULL)
+	/* The SR-IOV capability is implemented only by PFs. */
+	if (dinfo->cfg.iov != NULL &&
+	    (dinfo->cfg.flags & PCICFG_VF) == 0)
 		pci_iov_cfg_save(dev, dinfo);
 #endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.