From nobody Sat Nov 14 16:03:31 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jRf776r8mz71K7P for ; Sat, 14 Nov 2026 16:03:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jRf775n40z4ZDf for ; Sat, 14 Nov 2026 16:03:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794672211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PV3lp6j55WysIjC3l3kioVEL5jIUvu1mugZFWmgOKmA=; b=Emgqo8Sh0tmFeU43yEph/3B7/fwY3Sq7c+rwcbPku9UnZXbXHxdf49ODESvEACXumvrcYI fJl9lhugDCrBO6uhZ31+DPQIHY9Z3/3YcJaDdUVonJ2fgut3ct9imDp+427ejcdV0R1xx7 YIpEp5p9uNqiJj6+uLZK/Qfmof+Ehtt7N4uiDAeKrTiNGLEpEmWbd8y82P+OU86210761R A3JfQpFSsnsLtL7AgbOmxn1sv5KeTeqoPCfXG5xK0mODpZj9B7Zf44CfTH1O2YvEk/odpf gsTTvq6Aoi/Bbb9HT4iDBpJ161CsvyeS2xY/3dw/FEj8yC/tcecVlGeT5tPZrw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794672211; b=JoGMxmAqd/o+IY0zeVnQLDDG8mztvF7Awokf20ryZnycE3J3gA3wLL3rTiuBZMW+WyyDFy 8447cJnfStds9/j/N2fKLwXxpfY2J07EjUAjWPyE4yhTnzkKobhYZ34s+SUiO8Bx67vNHK bJpRmOrDxAogImxpiXKEcQb3jaK4LDrIoqwmHbyx1Ea1cPP98QuPrFzKUKpcR7o/N747Od LwwBJKrEFFmVngMWxBS6x5w4c/EbbbfY8pkU47ario9NIwh42MQXoTPJNyCNrjDbWYyLup HZP39si4asmtsZk768bYYUdsb62X8dq7ZZhuIGK3YJt19G/c8NimpUuMXynXyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794672211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PV3lp6j55WysIjC3l3kioVEL5jIUvu1mugZFWmgOKmA=; b=P91kMZ6fyp4o2GwtBP6G8wx33mTQhz0EGg16s+f4G8BQbRTVSSk+GjudOBFUIBH4EDn5r3 TBXz9YA2gJ2jPO6TIt7sFaR+vkfNSw1OSlilUUWhuLmv5WPbmIRMRQ8G3kSU4Cl/vg0VtY BmiMqiYM7vnQjPJlGz+fRaq5FVFaCx+7yXCCVMDdkr5tbn9RZpQB9gxXGjDBYu1ZVVaNfV FjTD0CpKa0ctVq1bO8lVNLQhDEgOyaMyXH5+mk1UG9r/capAYFrBXsc74FBxUxYxFZLOIl 2bqKZbW06pdRss2FWMCKwJfC7kb4UAVRnsBRs0PFxQ9yZ08rghfYReUS1JMsZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jRf7757sXzQlF for ; Sat, 14 Nov 2026 16:03:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 16504 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 16:03:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 931a5d8866bc - main - acpi_pci_link: Handle IRQ values > 255 List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 931a5d8866bcd7163272f6a9a65ed87fe481763b Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 16:03:31 +0000 Message-Id: <6af88653.16504.4fa64931@gitrepo.freebsd.org> The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=931a5d8866bcd7163272f6a9a65ed87fe481763b commit 931a5d8866bcd7163272f6a9a65ed87fe481763b Author: John Baldwin AuthorDate: 2026-11-14 16:02:38 +0000 Commit: John Baldwin CommitDate: 2026-11-14 16:02:38 +0000 acpi_pci_link: Handle IRQ values > 255 Some systems use a stub PCI link device for hardwired interrupts instead of static _PRT entries. These link devices can use an IRQ > 255. The current driver was designed to handle PCI link devices on x86 used for legacy INTx IRQs which were < 255. These changes handle larger IRQ values while making a few tradeoffs. - Expand most IRQ fields from 8 bits to 32-bits. The BIOS IRQ (read from the PCIR_INTLINE config register which is an 8-bit register) remains 8 bits. - Add a wrapper API for managing interrupt weights and avoid tracking weights for IRQs > 255 and instead report a constant weight of 0 for IRQs > 255. PR: 300476 Reported by: Aviv Bakal Tested by: cperciva --- sys/dev/acpica/acpi_pci_link.c | 59 +++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/sys/dev/acpica/acpi_pci_link.c b/sys/dev/acpica/acpi_pci_link.c index b10f9614c5bc..0848b7fb5a81 100644 --- a/sys/dev/acpica/acpi_pci_link.c +++ b/sys/dev/acpica/acpi_pci_link.c @@ -49,6 +49,15 @@ ACPI_MODULE_NAME("PCI_LINK") ACPI_SERIAL_DECL(pci_link, "ACPI PCI link"); +/* + * Link devices are (mostly) used for legacy INTx interrupts on x86 + * systems. The PCI config register for INTx interrupts is only an + * 8-bit register. However, some non-x86 systems also use link + * devices (even for hardwired interrupts that can't be routed) with + * GSI values above 255. + * + * NB: Due to API constraints a GSI value of exactly 255 can't be used. + */ #define NUM_ISA_INTERRUPTS 16 #define NUM_ACPI_INTERRUPTS 256 @@ -95,12 +104,12 @@ struct acpi_pci_link_softc { struct link { struct acpi_pci_link_softc *l_sc; uint8_t l_bios_irq; - uint8_t l_irq; - uint8_t l_initial_irq; + uint32_t l_irq; + uint32_t l_initial_irq; UINT32 l_crs_type; int l_res_index; - int l_num_irqs; - int *l_irqs; + u_int l_num_irqs; + uint32_t *l_irqs; int l_references; bool l_routed:1; bool l_isa_irq:1; @@ -126,6 +135,26 @@ static int pci_link_bios_isa_irqs; static char *pci_link_ids[] = { "PNP0C0F", NULL }; +/* + * For traditional INTx IRQ values, this driver maintains a set of + * weights to distribute IRQs more evenly. For values > 255, just + * punt and treat the weights as always being zero. + */ +static void +acpi_pci_link_add_weight(u_int irq, int refs) +{ + if (irq < nitems(pci_link_interrupt_weights)) + pci_link_interrupt_weights[irq] += refs; +} + +static int +acpi_pci_link_interrupt_weight(u_int irq) +{ + if (irq < nitems(pci_link_interrupt_weights)) + return (pci_link_interrupt_weights[irq]); + return (0); +} + /* * Fetch the short name associated with an ACPI handle and save it in the * passed in buffer. @@ -385,7 +414,7 @@ link_add_prs(ACPI_RESOURCE *res, void *context) } static bool -link_valid_irq(struct link *link, int irq) +link_valid_irq(struct link *link, u_int irq) { int i; @@ -423,17 +452,17 @@ acpi_pci_link_dump(struct acpi_pci_link_softc *sc, int header, const char *tag) if (header) { snprintf(buf, sizeof(buf), "%s:", device_get_nameunit(sc->pl_dev)); - printf("%-16.16s Index IRQ Rtd Ref IRQs\n", buf); + printf("%-16.16s Index IRQ Rtd Ref IRQs\n", buf); } for (i = 0; i < sc->pl_num_links; i++) { link = &sc->pl_links[i]; - printf(" %-14.14s %5d %3d %c %3d ", i == 0 ? tag : "", i, + printf(" %-14.14s %5d %5u %c %3d ", i == 0 ? tag : "", i, link->l_irq, link->l_routed ? 'Y' : 'N', link->l_references); if (link->l_num_irqs == 0) printf(" none"); else for (j = 0; j < link->l_num_irqs; j++) - printf(" %d", link->l_irqs[j]); + printf(" %u", link->l_irqs[j]); printf("\n"); } } @@ -664,7 +693,7 @@ acpi_pci_link_add_reference(device_t dev, int index, device_t pcib, int slot, } link->l_references++; if (link->l_routed) - pci_link_interrupt_weights[link->l_irq]++; + acpi_pci_link_add_weight(link->l_irq, 1); /* * The BIOS only routes interrupts via ISA IRQs using the ATPICs @@ -907,8 +936,8 @@ acpi_pci_link_route_irqs(device_t dev) PCI_INTERRUPT_VALID(link->l_irq)) { link->l_routed = true; acpi_config_intr(dev, resource); - pci_link_interrupt_weights[link->l_irq] += - link->l_references; + acpi_pci_link_add_weight(link->l_irq, + link->l_references); } link++; i++; @@ -955,11 +984,11 @@ acpi_pci_link_resume(device_t dev) /* * Pick an IRQ to use for this unrouted link. */ -static uint8_t +static u_int acpi_pci_link_choose_irq(device_t dev, struct link *link) { char tunable_buffer[64], link_name[5]; - u_int8_t best_irq, pos_irq; + u_int best_irq, pos_irq; int best_weight, pos_weight, i; KASSERT(!link->l_routed, ("%s: link already routed", __func__)); @@ -1017,7 +1046,7 @@ acpi_pci_link_choose_irq(device_t dev, struct link *link) if (pos_irq < NUM_ISA_INTERRUPTS && (pci_link_bios_isa_irqs & 1 << pos_irq) == 0) continue; - pos_weight = pci_link_interrupt_weights[pos_irq]; + pos_weight = acpi_pci_link_interrupt_weight(pos_irq); if (pos_weight < best_weight) { best_weight = pos_weight; best_irq = pos_irq; @@ -1030,7 +1059,7 @@ acpi_pci_link_choose_irq(device_t dev, struct link *link) */ if (link->l_isa_irq) { pos_irq = AcpiGbl_FADT.SciInterrupt; - pos_weight = pci_link_interrupt_weights[pos_irq]; + pos_weight = acpi_pci_link_interrupt_weight(pos_irq); if (pos_weight < best_weight) { best_weight = pos_weight; best_irq = pos_irq;