git: 44fd85b1a55a - stable/14 - pci: Skip PF SR-IOV state handling for VFs

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a879f84.24365.79ffda1e__27396.4368084975$1787273223$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=44fd85b1a55ad95fdc9c2ddf173151dcd8fb2d6c

commit 44fd85b1a55ad95fdc9c2ddf173151dcd8fb2d6c
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-08-07 13:30:06 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-21 00:43:03 +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 b56a6052e855..714e0498294f 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -6693,7 +6693,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
 }
@@ -6809,7 +6811,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.