git: 3481a9cdc4dc - main - pci: Expose a VF's owning PF to bus subclasses
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 22 Aug 2026 03:19:59 UTC
The branch main has been updated by kbowling:
URL: https://cgit.FreeBSD.org/src/commit/?id=3481a9cdc4dc26ef583bb0f46a04d5d059cde466
commit 3481a9cdc4dc26ef583bb0f46a04d5d059cde466
Author: Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-22 03:14:37 +0000
Commit: Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-22 03:19:16 +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.
Fixes: f003e86335c9 ofw_pcibus: Inherit PF locality for SR-IOV VFs
MFC after: 2 weeks
Sponsored by: BBOX.io
---
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 430eca38c0b9..9472095bc058 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -4414,10 +4414,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;
@@ -4429,6 +4442,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);
@@ -4442,6 +4460,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 5d39de605c22..393582193318 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -664,7 +664,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 8a63af046aae..bfa7df899322 100644
--- a/sys/dev/pci/pci_private.h
+++ b/sys/dev/pci/pci_private.h
@@ -118,6 +118,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,