The branch stable/14 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=b88d20eb024110e563352ad2beb83817ed1f08bc
commit b88d20eb024110e563352ad2beb83817ed1f08bc Author: Kevin Bowling <[email protected]> AuthorDate: 2026-08-22 03:14:37 +0000 Commit: Kevin Bowling <[email protected]> CommitDate: 2026-09-05 00:31:07 +0000 pci: Expose a VF's owning PF to bus subclasses ofw_pcibus now uses pci_iov_get_pf() to inherit PF locality for VFs, but the accessor was inadvertently left in an uncommited ACPI change. This breaks powerpc builds. Expose the accessor from the PCI core and provide a stub when PCI_IOV is omitted. Record VF ownership before pci_add_child() so child added callbacks can safely query it, and remove the later redundant assignment. Sponsored by: BBOX.io (cherry picked from commit 3481a9cdc4dc26ef583bb0f46a04d5d059cde466) --- sys/dev/pci/pci.c | 25 +++++++++++++++++++++++++ sys/dev/pci/pci_iov.c | 1 - sys/dev/pci/pci_private.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index e947d9b4f6b4..becda495f92a 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -4394,10 +4394,23 @@ pci_rescan_method(device_t dev) } #ifdef PCI_IOV +device_t +pci_iov_get_pf(device_t dev) +{ + struct pci_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + if (dinfo == NULL || (dinfo->cfg.flags & PCICFG_VF) == 0 || + dinfo->cfg.iov == NULL) + return (NULL); + return (dinfo->cfg.iov->iov_pf); +} + device_t pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, uint16_t did) { + struct pci_devinfo *pf_dinfo; struct pci_devinfo *vf_dinfo; device_t pcib; int busno, slot, func; @@ -4409,6 +4422,11 @@ pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, vf_dinfo = pci_fill_devinfo(pcib, bus, pci_get_domain(pcib), busno, slot, func, vid, did); + /* Make the VF-to-PF relationship available to child-added callbacks. */ + pf_dinfo = device_get_ivars(pf); + KASSERT(pf_dinfo->cfg.iov != NULL, + ("SR-IOV PF %s has no IOV state", device_get_nameunit(pf))); + vf_dinfo->cfg.iov = pf_dinfo->cfg.iov; vf_dinfo->cfg.flags |= PCICFG_VF; pci_add_child(bus, vf_dinfo); @@ -4422,6 +4440,13 @@ pci_create_iov_child_method(device_t bus, device_t pf, uint16_t rid, return (pci_add_iov_child(bus, pf, rid, vid, did)); } +#else +device_t +pci_iov_get_pf(device_t dev __unused) +{ + + return (NULL); +} #endif static int diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c index ecae70ca0d4a..60547983277d 100644 --- a/sys/dev/pci/pci_iov.c +++ b/sys/dev/pci/pci_iov.c @@ -658,7 +658,6 @@ pci_iov_enumerate_vfs(struct pci_devinfo *dinfo, const nvlist_t *config, vfinfo = device_get_ivars(vf); - vfinfo->cfg.iov = iov; vfinfo->cfg.vf.index = i; pci_iov_add_bars(iov, vfinfo); diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h index 0b20f20fbb42..9dd03e56bd14 100644 --- a/sys/dev/pci/pci_private.h +++ b/sys/dev/pci/pci_private.h @@ -120,6 +120,7 @@ void pci_add_children(device_t dev, int domain, int busno); void pci_add_child(device_t bus, struct pci_devinfo *dinfo); /* Call after cold enumeration and before attaching the bus's children. */ void pcie_reconcile_link_mps(device_t bus); +device_t pci_iov_get_pf(device_t dev); device_t pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid, uint16_t did); void pci_add_resources(device_t bus, device_t dev, int force,
