git: 063f93740793 - stable/15 - pci: Skip PF SR-IOV state handling for VFs

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a879c87.22dc4.713546a4__15529.0978773095$1787272343$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=063f937407938322b0d5c19777487ce83e00aae5

commit 063f937407938322b0d5c19777487ce83e00aae5
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-08-07 13:30:06 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-21 00:31:59 +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.
    
    (cherry picked from commit 78547d542f776d366c36b5a2fc747ddfe99523c6)
---
 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 fd4dc7413785..f40f68a48db9 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -6692,7 +6692,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
 }
@@ -6808,7 +6810,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.