git: 10409ee40baf - main - pcib: Only apply ARI translation to a bridge's own secondary bus

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 30 Sep 2026 15:04:42 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=10409ee40baf593b810cd0140f3c2f0d737c1a65

commit 10409ee40baf593b810cd0140f3c2f0d737c1a65
Author:     Osvaldo Janeri Filho <ojanerif@amd.com>
AuthorDate: 2026-09-30 15:04:08 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-09-30 15:04:08 +0000

    pcib: Only apply ARI translation to a bridge's own secondary bus
    
    ARI changes RID interpretation only for the device on a downstream
    port's secondary bus.  pcib_xlate_ari() applied that translation to
    every config access through an ARI-enabled bridge, including cycles
    forwarded to a subordinate bus.
    
    A non-zero slot on a subordinate bus then panics an INVARIANTS kernel
    and is misrouted otherwise.  Translate only when the access targets
    this bridge's secondary bus.
    
    Reviewed by:    kib, jhb
    Fixes:          55d3ea1731d1 ("Add support for PCIe ARI")
    Sponsored by:   AMD
    Differential Revision:  https://reviews.freebsd.org/D60033
---
 sys/dev/pci/pci_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index 5cdb1de71c3f..aa04bfa054c1 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -2346,7 +2346,8 @@ pcib_xlate_ari(device_t pcib, int bus, int *slot, int *func)
 	sc = device_get_softc(pcib);
 	ari_func = *func;
 
-	if (sc->flags & PCIB_ENABLE_ARI) {
+	/* ARI applies only to this port's secondary bus. */
+	if ((sc->flags & PCIB_ENABLE_ARI) && bus == sc->bus.sec) {
 		KASSERT(*slot == 0,
 		    ("Non-zero slot number with ARI enabled!"));
 		*slot = PCIE_ARI_SLOT(ari_func);