Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Aug 2026 07:38:47 +0000
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 985880074211 - stable/15 - pci_iov: Clear NumVFs when configuration fails
Message-ID:  <6a743a07.347e4.f6f8d07@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=98588007421144a968f0de4212a803cd0d7e143c

commit 98588007421144a968f0de4212a803cd0d7e143c
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-07-28 23:30:28 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-06 07:34:23 +0000

    pci_iov: Clear NumVFs when configuration fails
    
    pci_iov_config() programs NumVFs before validating the final VF RID
    layout and allocating all generic resources. A subsequent error ran the
    driver uninit callback but left the hardware NumVFs register programmed
    while the software VF count returned to zero.
    
    Clear NumVFs in the error path after the driver uninit callback,
    matching normal SR-IOV teardown ordering. This prevents stale hardware
    state after a failed configuration and permits a clean retry.
    
    Sponsored by:   BBOX.io
    
    (cherry picked from commit 621498b58cdab36a237d5f0b5c902952ad743fa9)
---
 sys/dev/pci/pci_iov.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c
index 0efcfeac9eff..68b18fc15471 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -781,8 +781,10 @@ pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg)
 
 	return (0);
 out:
-	if (iov_inited)
+	if (iov_inited) {
 		PCI_IOV_UNINIT(dev);
+		IOV_WRITE(dinfo, PCIR_SRIOV_NUM_VFS, 0, 2);
+	}
 
 	for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
 		if (iov->iov_bar[i].res != NULL) {


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a743a07.347e4.f6f8d07>