aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2026-07-28 23:30:28 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-08-06 07:34:23 +0000
commit98588007421144a968f0de4212a803cd0d7e143c (patch)
tree35c97b0b7c0b571df9eafca7d37b31c61b7b689b
parent2733e053372b67c86e65699c67c934460b8f36c4 (diff)
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)
-rw-r--r--sys/dev/pci/pci_iov.c4
1 files changed, 3 insertions, 1 deletions
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) {