git: 8b74806161a1 - main - acpi_pci: Do not match SR-IOV VFs to ACPI devices

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 27 Aug 2026 05:01:12 UTC
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=8b74806161a188103666387013cdd93fb3f5dc07

commit 8b74806161a188103666387013cdd93fb3f5dc07
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-18 02:39:41 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-27 05:00:38 +0000

    acpi_pci: Do not match SR-IOV VFs to ACPI devices
    
    SR-IOV VFs are instantiated dynamically from their PF rather than
    enumerated from ACPI.  A VF's runtime slot and function can match an
    unrelated _ADR below the bridge.  acpi_pci_save_handle() stores that
    handle in the VF's devinfo before acpi_pci_update_device() runs.
    
    If the handle is already bound to another device_t whose parent is not
    acpi0, acpi_pci_update_device() panics under INVARIANTS.  Without
    INVARIANTS, the VF retains the unrelated handle, so subsequent ACPI
    lookups, including NUMA and power-management operations, can act on the
    wrong namespace node.
    
    Skip ACPI namespace matching for VFs.
    
    Reviewed by:    jhb
    MFC after:      2 weeks
    Sponsored by:   BBOX.io
    Differential Revision:  https://reviews.freebsd.org/D59061
---
 sys/dev/acpica/acpi_pci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c
index 1912350bbc48..0ff938cfd6b8 100644
--- a/sys/dev/acpica/acpi_pci.c
+++ b/sys/dev/acpica/acpi_pci.c
@@ -338,6 +338,18 @@ acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level, void *context,
 void
 acpi_pci_child_added(device_t dev, device_t child)
 {
+	struct acpi_pci_devinfo *dinfo;
+
+	dinfo = device_get_ivars(child);
+
+	/*
+	 * VFs are instantiated dynamically from their PF rather than enumerated
+	 * from ACPI.  A VF's runtime slot and function can match an unrelated
+	 * _ADR below the bridge, causing the ACPI handle for that device to be
+	 * attached to the VF.
+	 */
+	if ((dinfo->ap_dinfo.cfg.flags & PCICFG_VF) != 0)
+		return;
 
 	/*
 	 * PCI devices are added via the bus scan in the normal PCI