about [UPDATING] [RELNOTES]summaryrefslograw-logtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2026-08-22 04:14:37 +0100
committerKevin Bowling <kbowling@FreeBSD.org>2026-09-05 01:31:07 +0100
commitb88d20eb024110e563352ad2beb83817ed1f08bc (patch) (diff)
tree06f8a206a85ab0e48e6ca9fc826ceb1938907b5d
downloadsrc-stable/14.tar.gz
 
previous commit7e2631981e2465e44d992ca115b468cda1be7221 (e1000: Limit the TSO sentinel to lem(4) controllers)
pci: Expose a VF's owning PF to bus subclasses HEADstable/14
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)
-rw-r--r--sys/dev/pci/pci.c[diff] [file]25
-rw-r--r--sys/dev/pci/pci_iov.c[diff] [file]1
-rw-r--r--sys/dev/pci/pci_private.h[diff] [file]1
3 files changed, 26 insertions, 1 deletions
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
@@ -4395,9 +4395,22 @@ 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,
This site is maintained by Jamie Landeg-Jones <jamie@catflap.org>, and is not an official FreeBSD project, nor is it endorsed by the FreeBSD team.