Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Aug 2026 13:46:42 +0000
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 78547d542f77 - main - pci: Skip PF SR-IOV state handling for VFs
Message-ID:  <6a75e1c2.3fc40.28d9dda8@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kbowling:

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

commit 78547d542f776d366c36b5a2fc747ddfe99523c6
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-07 13:30:06 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
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
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a75e1c2.3fc40.28d9dda8>