Date: Thu, 29 Jan 2026 15:39:56 +0000 From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Chandrakanth Patil <chandrakanth.patil@broadcom.com> Subject: git: f3ab9690c2ff - stable/14 - pci_iov: Support dynamic subordinate bus growth during VF creation Message-ID: <697b7f4c.3959a.1038041d@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f3ab9690c2ffaed003a9e196d3501efb25890917 commit f3ab9690c2ffaed003a9e196d3501efb25890917 Author: Chandrakanth Patil <chandrakanth.patil@broadcom.com> AuthorDate: 2025-07-29 00:28:51 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2026-01-29 15:22:37 +0000 pci_iov: Support dynamic subordinate bus growth during VF creation Certain SR-IOV devices enumerate Virtual Functions (VFs) on a different PCIe bus than their parent Physical Function (PF). In such cases, the default subordinate bus range assigned by BIOS may be insufficient to cover all VFs. This patch dynamically expands the subordinate bus range by: - Allocating additional bus numbers using bus_alloc_resource() when VFs are initialized - Releasing the reserved bus range during VF deletion via bus_release_resource() Reviewed by: jhb (cherry picked from commit f7951799877c16cb901be1acc8d6643f0693cec4) --- sys/dev/pci/pci_iov.c | 25 +++++++++++++++++++++---- sys/dev/pci/pci_iov_private.h | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c index b9e22fafe103..920d13e99ea0 100644 --- a/sys/dev/pci/pci_iov.c +++ b/sys/dev/pci/pci_iov.c @@ -734,11 +734,18 @@ pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg) first_rid = pci_get_rid(dev) + rid_off; last_rid = first_rid + (num_vfs - 1) * rid_stride; - /* We don't yet support allocating extra bus numbers for VFs. */ if (pci_get_bus(dev) != PCI_RID2BUS(last_rid)) { - device_printf(dev, "not enough PCIe bus numbers for VFs\n"); - error = ENOSPC; - goto out; + int rid = 0; + uint16_t last_rid_bus = PCI_RID2BUS(last_rid); + + iov->iov_bus_res = bus_alloc_resource(bus, PCI_RES_BUS, &rid, + last_rid_bus, last_rid_bus, 1, RF_ACTIVE); + if (iov->iov_bus_res == NULL) { + device_printf(dev, + "failed to allocate PCIe bus number for VFs\n"); + error = ENOSPC; + goto out; + } } if (!ari_enabled && PCI_RID2SLOT(last_rid) != 0) { @@ -788,6 +795,11 @@ out: } } + if (iov->iov_bus_res != NULL) { + bus_release_resource(bus, iov->iov_bus_res); + iov->iov_bus_res = NULL; + } + if (iov->iov_flags & IOV_RMAN_INITED) { rman_fini(&iov->rman); iov->iov_flags &= ~IOV_RMAN_INITED; @@ -900,6 +912,11 @@ pci_iov_delete_iov_children(struct pci_devinfo *dinfo) } } + if (iov->iov_bus_res != NULL) { + bus_release_resource(bus, iov->iov_bus_res); + iov->iov_bus_res = NULL; + } + if (iov->iov_flags & IOV_RMAN_INITED) { rman_fini(&iov->rman); iov->iov_flags &= ~IOV_RMAN_INITED; diff --git a/sys/dev/pci/pci_iov_private.h b/sys/dev/pci/pci_iov_private.h index 7ae2219b936d..ecf0a9b21be5 100644 --- a/sys/dev/pci/pci_iov_private.h +++ b/sys/dev/pci/pci_iov_private.h @@ -39,6 +39,8 @@ struct pcicfg_iov { struct cdev *iov_cdev; nvlist_t *iov_schema; + struct resource *iov_bus_res; + struct pci_iov_bar iov_bar[PCIR_MAX_BAR_0 + 1]; struct rman rman; char rman_name[64];home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?697b7f4c.3959a.1038041d>
