aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2026-07-28 23:30:28 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-07-30 00:43:03 +0000
commit621498b58cdab36a237d5f0b5c902952ad743fa9 (patch)
tree481e677182ab54d6b372ba26073ccde29d7aa6ed
parente795a31cb4d66368bdbe5ac7f61c0899d3ed39f8 (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. MFC after: 1 week Sponsored by: BBOX.io
-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 932d83536b7f..643f0e59b9b8 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -807,8 +807,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) {