From nobody Mon Jun 8 08:32:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5EA9399031; Wed, 3 Jun 2026 08:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474896; cv=none; b=fS2Bvp0dUcMwBRGMZF5GRa0I6R2XuN+rWeA+bdFpoeRU3MRRF6QXaILWsHbNmC0M6S3+D5+sQKqSyN9ZdOKljqkEi1ZwzShhCX0e7UDAdFRO1jR/bkfZY7EsoGjZfxtcmiH3luzCZVNlve5PVtUCziwYOUhfjAKHLN4R2mVKi5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474896; c=relaxed/simple; bh=ZH3O1czfozrN63XMS5d8GPzOp866A+WZMTs8T/fKj2A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lq1QzodzQog9msyESRw9m7CHrcOEXjiEReBSpwHJhealhLaYJYh0YgPPRSsnNq3kLxwvp+E7qiAdcfJ5+aSIXjcVeH7xhqlSRh0gGBclrNf90kHPrWFegf2XKtNRfxy7fhmH/kPERdCDzLlcWrSkmqH5n0CPO9LBjTHm99fCt2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I8zGp/Su; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I8zGp/Su" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2AEE1F00898; Wed, 3 Jun 2026 08:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780474895; bh=DtPsyAAM9L9RpV0wzLX+t9PSNnuH7YnorG5sG9N5qyY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=I8zGp/SuIIc/MyHSmJDvHq47bFp6Q8K0XNKpF+OdFaZbEKdUMPOECPu3YD9z3Q+ZK v+2qwkJ8zwOXfb7r7IGIe468DNyg75zfnWYKFXk3jqDghn1bxQB6P8mEdchw6nCqjG SHPWyO6++bMMSx4leBFKw1bakRXubGyUySwEcFus93FUv6nM5W9jso01Md1cfzb9aU ClaBce8zWXkNa/LgD/d50FO5JNDDymIJ+h7vDU1BVSaCJO/em5Y8z/XXn0ihgeHJAq jxJwzgq8gR5/jgSkcK1f6EIIAuASySWOScFyjcIfQOKsXvihCd5xMnZOPnBjdabi0b crJEd7duELnOw== From: Lorenzo Pieralisi Date: Wed, 03 Jun 2026 10:20:57 +0200 Subject: [PATCH v2 1/6] ACPI: RISC-V: Fix riscv_acpi_irq_get_dep() loop termination Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-1-23ffa16b6ebb@kernel.org> References: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> In-Reply-To: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> To: "Rafael J. Wysocki" , Len Brown , Sunil V L , Marc Zyngier , Thomas Gleixner , Huacai Chen , Anup Patel , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, Lorenzo Pieralisi X-Mailer: b4 0.15.2 In riscv_acpi_add_irq_dep() the main loop condition would currently stop the loop if an interrupt descriptor contains an interrupt for which the respective GSI handle is NULL, which is not correct because subsequent interrupts in the interrupt descriptor might still have a GSI dependency that must not be skipped. Rework riscv_acpi_add_irq_dep() and the riscv_acpi_irq_get_dep() call chain to fix it - by not forcing the loop to stop in order to guarantee dependency detection for all the interrupt entries in the CRS descriptor. Signed-off-by: Lorenzo Pieralisi Cc: "Rafael J. Wysocki" Cc: Sunil V L --- drivers/acpi/riscv/irq.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 9b88d0993e88..cd83c3035cf6 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -299,6 +299,7 @@ static acpi_status riscv_acpi_irq_get_parent(struct acp= i_resource *ares, void *c return AE_OK; =20 ctx->handle =3D riscv_acpi_get_gsi_handle(eirq->interrupts[ctx->index]); + ctx->rc =3D 0; return AE_CTRL_TERMINATE; } =20 @@ -314,10 +315,8 @@ static int riscv_acpi_irq_get_dep(acpi_handle handle, = unsigned int index, acpi_h =20 acpi_walk_resources(handle, METHOD_NAME__CRS, riscv_acpi_irq_get_parent, = &ctx); *gsi_handle =3D ctx.handle; - if (*gsi_handle) - return 1; =20 - return 0; + return ctx.rc; } =20 static u32 riscv_acpi_add_prt_dep(acpi_handle handle) @@ -381,8 +380,11 @@ static u32 riscv_acpi_add_irq_dep(acpi_handle handle) int i; =20 for (i =3D 0; - riscv_acpi_irq_get_dep(handle, i, &gsi_handle); + !riscv_acpi_irq_get_dep(handle, i, &gsi_handle); i++) { + if (!gsi_handle) + continue; + dep_devices.count =3D 1; dep_devices.handles =3D kzalloc_objs(*dep_devices.handles, 1); if (!dep_devices.handles) { --=20 2.54.0 From nobody Mon Jun 8 08:32:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59916410D16; Wed, 3 Jun 2026 08:21:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474901; cv=none; b=CrloN3ED09gWmBmgq1U+36sAqWKOrUMd88wbpPfBKncA073p3T3y+THMWyL7Xwe9yzqPm/8ZnM1sPe8AIyYC+cP5ehcuWIFsmjOknCvi0ofOAeNifFsv0yiOwln9uxuJLivCMnncMbM6YX+kTxQrF4+BJKuLQumyf33AmEUkczI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474901; c=relaxed/simple; bh=Yl974pojDpKqEpnSLuagZUOwMHghmNN3zNAM92cuaec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CUUIQ9t1/VVhTfY5nceXtKU1rc/nyN83qGGnLzut6in8giFSB+tvSZ8yxte37ckhWQWMyDs6WcoooDJGw+ny+4QKQfgS01OWQ3ibiRu6naGgx4wWS24BbaMdvIvztgF0nnhkDYag8gaM9VBAKkEHzE0rppq+dh18SOlaT6pTLCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UV7+otxr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UV7+otxr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F8421F00893; Wed, 3 Jun 2026 08:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780474899; bh=G3J6B2wwZ8nlMNmtNYnVu0NFww9ipBOtwt+oR1HOegI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=UV7+otxrRpsGFCIT5jwSzDvpOuUbknuas3TVVTutaGY5qRF950r5oSoxcsT2s3sky jeN00ChBJ0TYcBIpvW+l2jUft6/5oe06Ttw7lMuqRdKwhYPAop6cYI4HMSfk7HDegy 4T3As6/69X/TDI4Zg5Qmi+iBWaeDZDO3Cjevd9NM89obHjUGLwexu00Egcmb5ZCMm9 mCBVxdE7uATNtHCrxUJO6HpL+cU7hs2VP+iDNoY9x3QRqoc2cT5pv16zOtiy83J8C6 W0Uxo4mlI3LfrLGfSI6QJ0s2zTcUPmEB/Dp075SZu1xstFtYddmBdlxocXC2JBmjS4 cVT0FwyBfIrcQ== From: Lorenzo Pieralisi Date: Wed, 03 Jun 2026 10:20:58 +0200 Subject: [PATCH v2 2/6] ACPI: RISC-V: Check acpi_get_handle() status in riscv_acpi_add_prt_dep() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-2-23ffa16b6ebb@kernel.org> References: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> In-Reply-To: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> To: "Rafael J. Wysocki" , Len Brown , Sunil V L , Marc Zyngier , Thomas Gleixner , Huacai Chen , Anup Patel , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, Lorenzo Pieralisi X-Mailer: b4 0.15.2 In riscv_acpi_add_prt_dep(), the acpi_get_handle() call can fail which would leave link_handle uninitialized. Fix it by checking the acpi_get_handle() return status and skip the entry if it fails. Signed-off-by: Lorenzo Pieralisi Cc: "Rafael J. Wysocki" Cc: Sunil V L --- drivers/acpi/riscv/irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index cd83c3035cf6..75170151c614 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -339,7 +339,9 @@ static u32 riscv_acpi_add_prt_dep(acpi_handle handle) entry =3D buffer.pointer; while (entry && (entry->length > 0)) { if (entry->source[0]) { - acpi_get_handle(handle, entry->source, &link_handle); + status =3D acpi_get_handle(handle, entry->source, &link_handle); + if (ACPI_FAILURE(status)) + continue; dep_devices.count =3D 1; dep_devices.handles =3D kzalloc_objs(*dep_devices.handles, 1); --=20 2.54.0 From nobody Mon Jun 8 08:32:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E90B410D16; Wed, 3 Jun 2026 08:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474905; cv=none; b=akge1VqoJI4Vsrh+MmNS2Lf0IWCNUTTweYcb/SVUtjtiI0+4U2KsVW69Damzlswduj5mmPAwbUp7t/lkPuoUuhbDNCi0jyYrbNbzczUjQlrVd5V4ScP21nJNhIUCELfVgqgXR37cUDjA7qQ03P4P36+12+tHgGAS4GldM1h+zWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474905; c=relaxed/simple; bh=Zirg5zLISuUGrrZvV/HeyIlS4z8UH5EkGvwvdimhiWs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qWRrB/hRRPkUl3dRkyIxmuusXnmL/QHADukkdmbLSPMwDHMQZhzzRcJik82vU37s70g/xLgxmFG4Epe+GUuMtZ0QEIkQ++w2JWivT+gltab29Wwa6YSNSn3SGqhv6H/tTM2cGQHRIA/ilGz1Ji1BnLEhX8C/BlD82PPvxQGzwSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fS750F7T; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fS750F7T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6295E1F00898; Wed, 3 Jun 2026 08:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780474904; bh=Pamo4jTIx9z4Xf6mq2Ox//K3gj7hfSbjLsah6wBCtzc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=fS750F7TFs/HKsUEE1WJvRe800uTXJ+WBlUN3gohTW06px4gbGfVc5plSSa3Ug4qD 68TcWoVkKWcWiYkY4W5a83z46yA96TzsbwfRhsBxsDRiabwQkWns/Tif8yiaS6gKL6 A/7d7E0N43yTcUZVyIGSyzY65ASgvfB6Z5RjtduLCL+hVMiQk4gdZYnvheIlDcS7QX R4djuzdFmUEX6fxvHS+FyNqDYvCURwcZeps3YwrHy88ZagnuyleM1tL3kJIK30DByL YwjOeO69BVtUNRPMBdiM3PgfdZMhDZlXyx9pwU7s4tlEHkwL3frYSNef6rIkZu7rmK 2ocvGnzUFW+Xg== From: Lorenzo Pieralisi Date: Wed, 03 Jun 2026 10:20:59 +0200 Subject: [PATCH v2 3/6] ACPI: RISC-V: Fix riscv_acpi_add_prt_dep() loop handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-3-23ffa16b6ebb@kernel.org> References: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> In-Reply-To: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> To: "Rafael J. Wysocki" , Len Brown , Sunil V L , Marc Zyngier , Thomas Gleixner , Huacai Chen , Anup Patel , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, Lorenzo Pieralisi X-Mailer: b4 0.15.2 The loop in riscv_acpi_add_prt_dep() includes error conditions that are handled in a dubious - if not outright wrong - way, by continuining the loop (which skips and misses the entry pointer update to point to the next entry). Rewrite the loop as a for loop (that handles the continuation correctly) and wrap the condition and update statements using helper functions to make it cleaner. Signed-off-by: Lorenzo Pieralisi Cc: "Rafael J. Wysocki" Cc: Sunil V L --- drivers/acpi/riscv/irq.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 75170151c614..0cdec5dd575e 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -319,6 +319,20 @@ static int riscv_acpi_irq_get_dep(acpi_handle handle, = unsigned int index, acpi_h return ctx.rc; } =20 +static bool acpi_prt_entry_valid(void *prt_entry) +{ + struct acpi_pci_routing_table *entry =3D prt_entry; + + return entry && entry->length > 0; +} + +static void *acpi_prt_next_entry(void *prt_entry) +{ + struct acpi_pci_routing_table *entry =3D prt_entry; + + return prt_entry + entry->length; +} + static u32 riscv_acpi_add_prt_dep(acpi_handle handle) { struct acpi_buffer buffer =3D { ACPI_ALLOCATE_BUFFER, NULL }; @@ -337,7 +351,7 @@ static u32 riscv_acpi_add_prt_dep(acpi_handle handle) } =20 entry =3D buffer.pointer; - while (entry && (entry->length > 0)) { + for (; acpi_prt_entry_valid(entry); entry =3D acpi_prt_next_entry(entry))= { if (entry->source[0]) { status =3D acpi_get_handle(handle, entry->source, &link_handle); if (ACPI_FAILURE(status)) @@ -365,9 +379,6 @@ static u32 riscv_acpi_add_prt_dep(acpi_handle handle) dep_devices.handles[0] =3D gsi_handle; count +=3D acpi_scan_add_dep(handle, &dep_devices); } - - entry =3D (struct acpi_pci_routing_table *) - ((unsigned long)entry + entry->length); } =20 kfree(buffer.pointer); --=20 2.54.0 From nobody Mon Jun 8 08:32:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8C2E41C30A; Wed, 3 Jun 2026 08:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474910; cv=none; b=eRjKWTIVHbIVEam4UDJfKjojsXz/UkX98MVd+8vnkCHW/oBAwBW9Y6gYeJVFrNGT7FVfyOyRZOQUOv4500REPUTN15JUyV/ZS197x54hBllSfeYKRYnjANwpTTKAysJYRWqo8tF/+7F1U5ifVMwW9oXETZSPFjNBEGkno1j8Wqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474910; c=relaxed/simple; bh=1Q/IrgqNxQ5SzKeep/5tmTP3t1LnXA63V0N9D8X4eU8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hgm/yDJMYmVXNv9+5sO6Ca1SU4KWjPZbZE5IiZEcmRaC5l5Q1G3HO5qTFvGnjozd51vRSSjRqLjBGhP6x5gEOUt05/FOROVGSorno0txPHB/GE9hvAKC4NR0STaWYjrrGTt6yK/mf4FhjuAc/bcPGI82tfe9e909ple4LPFAhVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CRMCPip/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CRMCPip/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B24C31F0089B; Wed, 3 Jun 2026 08:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780474908; bh=+c6I6O8H6R8wK16tJafp//Q3hM2yaItZBtpbSmuFnlU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CRMCPip/DqO0aUQeNbnlDdGTwNcXLm693RaqcngSHsZcDxWkOaMUiffH1+7MGiZGA X4QORV3DuoDmxrwup6YU9H7dv1Pp5GHl1mKk35t0sX1YIuTuUG3t6/aUS9FiF/p99U qs7LD6qDCj5H2oK93fqWJ2dE1Vt5kcoHipv1Z7sjJXt9RqzHzouIRK/tUqbsuyGCrz pNmVGruB0WV6+EF5MJh1mgoV0+F2hhDWygQBJDTMllWW7j0LL/XcVeMK/SXSwTlAXg bvdGI1qqJfyoX78ugTXoeypme1oTIY+WuVeeMbV4SF1anjmmuqdkBo9R7UtLLxcoim 5UVgP7768Vi6w== From: Lorenzo Pieralisi Date: Wed, 03 Jun 2026 10:21:00 +0200 Subject: [PATCH v2 4/6] ACPI: irq: Move RISC-V interrupt controllers autodep to ACPI IRQ code Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-4-23ffa16b6ebb@kernel.org> References: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> In-Reply-To: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> To: "Rafael J. Wysocki" , Len Brown , Sunil V L , Marc Zyngier , Thomas Gleixner , Huacai Chen , Anup Patel , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, Lorenzo Pieralisi X-Mailer: b4 0.15.2 RISC-V implements arch code to detect probe dependencies for devices and the interrupt controller the devices GSIs are routed to. The code itself is arch agnostic apart from an arch specific helper function required to retrieve the acpi_handle of the interrupt controller that manages the device GSI interrupt. In order to enable IRQ probe dependencies detection on other architectures, move RISC-V IRQ probe dependency detection code to generic ACPI IRQ code. Allow interrupt controller drivers to register an arch specific function to determine the acpi_handle for a specific GSI number to use the mechanism if needed by the respective interrupt controller drivers. Signed-off-by: Lorenzo Pieralisi Cc: Huacai Chen Cc: Thomas Gleixner Cc: Anup Patel Cc: "Rafael J. Wysocki" Cc: Sunil V L Cc: Marc Zyngier --- arch/riscv/include/asm/acpi.h | 1 + drivers/acpi/irq.c | 172 ++++++++++++++++++++++++++++++++= +++- drivers/acpi/riscv/irq.c | 156 +------------------------------- drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic-v5.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- drivers/irqchip/irq-loongarch-cpu.c | 2 +- drivers/irqchip/irq-riscv-intc.c | 3 +- include/linux/acpi.h | 5 +- 9 files changed, 181 insertions(+), 164 deletions(-) diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index 26ab37c171bc..f598520ac903 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -67,6 +67,7 @@ int acpi_get_riscv_isa(struct acpi_table_header *table, =20 void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_si= ze, u32 *cboz_size, u32 *cbop_size); +acpi_handle acpi_get_riscv_gsi_handle(u32 gsi); #else static inline void acpi_init_rintc_map(void) { } static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index d1595156c86a..e4293458bf61 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -13,6 +13,7 @@ enum acpi_irq_model_id acpi_irq_model; =20 static acpi_gsi_domain_disp_fn acpi_get_gsi_domain_id; +static acpi_gsi_handle_disp_fn acpi_get_gsi_handle; static u32 (*acpi_gsi_to_irq_fallback)(u32 gsi); =20 /** @@ -321,15 +322,19 @@ const struct cpumask *acpi_irq_get_affinity(acpi_hand= le handle, =20 /** * acpi_set_irq_model - Setup the GSI irqdomain information - * @model: the value assigned to acpi_irq_model - * @fn: a dispatcher function that will return the domain fwnode - * for a given GSI + * @model: the value assigned to acpi_irq_model + * @fn: a dispatcher function that will return the domain fwnode + * for a given GSI + * @gsi_dep_fn: a function to retrieve the acpi_handle a GSI interrupt is + * dependent on + * */ void __init acpi_set_irq_model(enum acpi_irq_model_id model, - acpi_gsi_domain_disp_fn fn) + acpi_gsi_domain_disp_fn fn, acpi_gsi_handle_disp_fn gsi_dep_fn) { acpi_irq_model =3D model; acpi_get_gsi_domain_id =3D fn; + acpi_get_gsi_handle =3D gsi_dep_fn; } =20 /* @@ -385,3 +390,162 @@ struct irq_domain *acpi_irq_create_hierarchy(unsigned= int flags, host_data); } EXPORT_SYMBOL_GPL(acpi_irq_create_hierarchy); + +struct acpi_irq_dep_ctx { + int rc; + unsigned int index; + acpi_handle handle; +}; + +static acpi_status acpi_irq_get_parent(struct acpi_resource *ares, void *c= ontext) +{ + struct acpi_irq_dep_ctx *ctx =3D context; + struct acpi_resource_irq *irq; + struct acpi_resource_extended_irq *eirq; + + switch (ares->type) { + case ACPI_RESOURCE_TYPE_IRQ: + irq =3D &ares->data.irq; + if (ctx->index >=3D irq->interrupt_count) { + ctx->index -=3D irq->interrupt_count; + return AE_OK; + } + ctx->handle =3D acpi_get_gsi_handle(irq->interrupts[ctx->index]); + ctx->rc =3D 0; + return AE_CTRL_TERMINATE; + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + eirq =3D &ares->data.extended_irq; + if (eirq->producer_consumer =3D=3D ACPI_PRODUCER) + return AE_OK; + + if (ctx->index >=3D eirq->interrupt_count) { + ctx->index -=3D eirq->interrupt_count; + return AE_OK; + } + + /* Support GSIs only */ + if (eirq->resource_source.string_length) + return AE_OK; + + ctx->handle =3D acpi_get_gsi_handle(eirq->interrupts[ctx->index]); + ctx->rc =3D 0; + return AE_CTRL_TERMINATE; + } + + return AE_OK; +} + +static int acpi_irq_get_dep(acpi_handle handle, unsigned int index, acpi_h= andle *gsi_handle) +{ + struct acpi_irq_dep_ctx ctx =3D {-EINVAL, index, NULL}; + + if (!gsi_handle) + return -EINVAL; + + acpi_walk_resources(handle, METHOD_NAME__CRS, acpi_irq_get_parent, &ctx); + *gsi_handle =3D ctx.handle; + + return ctx.rc; +} + +static bool acpi_prt_entry_valid(void *prt_entry) +{ + struct acpi_pci_routing_table *entry =3D prt_entry; + + return entry && entry->length > 0; +} + +static void *acpi_prt_next_entry(void *prt_entry) +{ + struct acpi_pci_routing_table *entry =3D prt_entry; + + return prt_entry + entry->length; +} + +static u32 acpi_add_prt_dep(acpi_handle handle) +{ + struct acpi_buffer buffer =3D { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_pci_routing_table *entry; + struct acpi_handle_list dep_devices; + acpi_handle gsi_handle; + acpi_handle link_handle; + acpi_status status; + u32 count =3D 0; + + status =3D acpi_get_irq_routing_table(handle, &buffer); + if (ACPI_FAILURE(status)) { + acpi_handle_err(handle, "failed to get IRQ routing table\n"); + kfree(buffer.pointer); + return 0; + } + + entry =3D buffer.pointer; + for (; acpi_prt_entry_valid(entry); entry =3D acpi_prt_next_entry(entry))= { + if (entry->source[0]) { + status =3D acpi_get_handle(handle, entry->source, &link_handle); + if (ACPI_FAILURE(status)) + continue; + dep_devices.count =3D 1; + dep_devices.handles =3D kcalloc(1, sizeof(*dep_devices.handles), GFP_KE= RNEL); + if (!dep_devices.handles) { + acpi_handle_err(handle, "failed to allocate memory\n"); + continue; + } + + dep_devices.handles[0] =3D link_handle; + count +=3D acpi_scan_add_dep(handle, &dep_devices); + } else { + gsi_handle =3D acpi_get_gsi_handle(entry->source_index); + if (!gsi_handle) + continue; + dep_devices.count =3D 1; + dep_devices.handles =3D kcalloc(1, sizeof(*dep_devices.handles), GFP_KE= RNEL); + if (!dep_devices.handles) { + acpi_handle_err(handle, "failed to allocate memory\n"); + continue; + } + + dep_devices.handles[0] =3D gsi_handle; + count +=3D acpi_scan_add_dep(handle, &dep_devices); + } + } + + kfree(buffer.pointer); + return count; +} + +static u32 acpi_add_irq_dep(acpi_handle handle) +{ + struct acpi_handle_list dep_devices; + acpi_handle gsi_handle; + u32 count =3D 0; + int i; + + for (i =3D 0; !acpi_irq_get_dep(handle, i, &gsi_handle); i++) { + if (!gsi_handle) + continue; + + dep_devices.count =3D 1; + dep_devices.handles =3D kcalloc(1, sizeof(*dep_devices.handles), GFP_KER= NEL); + if (!dep_devices.handles) { + acpi_handle_err(handle, "failed to allocate memory\n"); + continue; + } + + dep_devices.handles[0] =3D gsi_handle; + count +=3D acpi_scan_add_dep(handle, &dep_devices); + } + + return count; +} + +u32 acpi_irq_add_auto_dep(acpi_handle handle) +{ + if (!acpi_get_gsi_handle) + return 0; + + if (acpi_has_method(handle, "_PRT")) + return acpi_add_prt_dep(handle); + + return acpi_add_irq_dep(handle); +} diff --git a/drivers/acpi/riscv/irq.c b/drivers/acpi/riscv/irq.c index 0cdec5dd575e..da2c42e0ebfd 100644 --- a/drivers/acpi/riscv/irq.c +++ b/drivers/acpi/riscv/irq.c @@ -23,12 +23,6 @@ struct riscv_ext_intc_list { struct list_head list; }; =20 -struct acpi_irq_dep_ctx { - int rc; - unsigned int index; - acpi_handle handle; -}; - LIST_HEAD(ext_intc_list); =20 static int irqchip_cmp_func(const void *in0, const void *in1) @@ -254,7 +248,7 @@ void __init riscv_acpi_init_gsi_mapping(void) acpi_get_devices("RSCV0006", riscv_acpi_create_gsi_map_smsi, NULL, NULL); } =20 -static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) +acpi_handle acpi_get_riscv_gsi_handle(u32 gsi) { struct riscv_ext_intc_list *ext_intc_element; struct list_head *i; @@ -269,153 +263,7 @@ static acpi_handle riscv_acpi_get_gsi_handle(u32 gsi) return NULL; } =20 -static acpi_status riscv_acpi_irq_get_parent(struct acpi_resource *ares, v= oid *context) -{ - struct acpi_irq_dep_ctx *ctx =3D context; - struct acpi_resource_irq *irq; - struct acpi_resource_extended_irq *eirq; - - switch (ares->type) { - case ACPI_RESOURCE_TYPE_IRQ: - irq =3D &ares->data.irq; - if (ctx->index >=3D irq->interrupt_count) { - ctx->index -=3D irq->interrupt_count; - return AE_OK; - } - ctx->handle =3D riscv_acpi_get_gsi_handle(irq->interrupts[ctx->index]); - return AE_CTRL_TERMINATE; - case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - eirq =3D &ares->data.extended_irq; - if (eirq->producer_consumer =3D=3D ACPI_PRODUCER) - return AE_OK; - - if (ctx->index >=3D eirq->interrupt_count) { - ctx->index -=3D eirq->interrupt_count; - return AE_OK; - } - - /* Support GSIs only */ - if (eirq->resource_source.string_length) - return AE_OK; - - ctx->handle =3D riscv_acpi_get_gsi_handle(eirq->interrupts[ctx->index]); - ctx->rc =3D 0; - return AE_CTRL_TERMINATE; - } - - return AE_OK; -} - -static int riscv_acpi_irq_get_dep(acpi_handle handle, unsigned int index, = acpi_handle *gsi_handle) -{ - struct acpi_irq_dep_ctx ctx =3D {-EINVAL, index, NULL}; - - if (!gsi_handle) - return 0; - - acpi_walk_resources(handle, METHOD_NAME__CRS, riscv_acpi_irq_get_parent, = &ctx); - *gsi_handle =3D ctx.handle; - - return ctx.rc; -} - -static bool acpi_prt_entry_valid(void *prt_entry) -{ - struct acpi_pci_routing_table *entry =3D prt_entry; - - return entry && entry->length > 0; -} - -static void *acpi_prt_next_entry(void *prt_entry) -{ - struct acpi_pci_routing_table *entry =3D prt_entry; - - return prt_entry + entry->length; -} - -static u32 riscv_acpi_add_prt_dep(acpi_handle handle) -{ - struct acpi_buffer buffer =3D { ACPI_ALLOCATE_BUFFER, NULL }; - struct acpi_pci_routing_table *entry; - struct acpi_handle_list dep_devices; - acpi_handle gsi_handle; - acpi_handle link_handle; - acpi_status status; - u32 count =3D 0; - - status =3D acpi_get_irq_routing_table(handle, &buffer); - if (ACPI_FAILURE(status)) { - acpi_handle_err(handle, "failed to get IRQ routing table\n"); - kfree(buffer.pointer); - return 0; - } - - entry =3D buffer.pointer; - for (; acpi_prt_entry_valid(entry); entry =3D acpi_prt_next_entry(entry))= { - if (entry->source[0]) { - status =3D acpi_get_handle(handle, entry->source, &link_handle); - if (ACPI_FAILURE(status)) - continue; - dep_devices.count =3D 1; - dep_devices.handles =3D kzalloc_objs(*dep_devices.handles, - 1); - if (!dep_devices.handles) { - acpi_handle_err(handle, "failed to allocate memory\n"); - continue; - } - - dep_devices.handles[0] =3D link_handle; - count +=3D acpi_scan_add_dep(handle, &dep_devices); - } else { - gsi_handle =3D riscv_acpi_get_gsi_handle(entry->source_index); - dep_devices.count =3D 1; - dep_devices.handles =3D kzalloc_objs(*dep_devices.handles, - 1); - if (!dep_devices.handles) { - acpi_handle_err(handle, "failed to allocate memory\n"); - continue; - } - - dep_devices.handles[0] =3D gsi_handle; - count +=3D acpi_scan_add_dep(handle, &dep_devices); - } - } - - kfree(buffer.pointer); - return count; -} - -static u32 riscv_acpi_add_irq_dep(acpi_handle handle) -{ - struct acpi_handle_list dep_devices; - acpi_handle gsi_handle; - u32 count =3D 0; - int i; - - for (i =3D 0; - !riscv_acpi_irq_get_dep(handle, i, &gsi_handle); - i++) { - if (!gsi_handle) - continue; - - dep_devices.count =3D 1; - dep_devices.handles =3D kzalloc_objs(*dep_devices.handles, 1); - if (!dep_devices.handles) { - acpi_handle_err(handle, "failed to allocate memory\n"); - continue; - } - - dep_devices.handles[0] =3D gsi_handle; - count +=3D acpi_scan_add_dep(handle, &dep_devices); - } - - return count; -} - u32 arch_acpi_add_auto_dep(acpi_handle handle) { - if (acpi_has_method(handle, "_PRT")) - return riscv_acpi_add_prt_dep(handle); - - return riscv_acpi_add_irq_dep(handle); + return acpi_irq_add_auto_dep(handle); } diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 99444a1b2ffa..2673954d4577 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -2588,7 +2588,7 @@ gic_acpi_init(union acpi_subtable_headers *header, co= nst unsigned long end) if (err) goto out_fwhandle_free; =20 - acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, gic_v3_get_gsi_domain_id); + acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, gic_v3_get_gsi_domain_id, NULL); =20 if (static_branch_likely(&supports_deactivate_key)) gic_acpi_setup_kvm_info(); diff --git a/drivers/irqchip/irq-gic-v5.c b/drivers/irqchip/irq-gic-v5.c index 6b0903be8ebf..03cc2830b260 100644 --- a/drivers/irqchip/irq-gic-v5.c +++ b/drivers/irqchip/irq-gic-v5.c @@ -1242,7 +1242,7 @@ static int __init gic_acpi_init(union acpi_subtable_h= eaders *header, const unsig if (ret) goto out_irs; =20 - acpi_set_irq_model(ACPI_IRQ_MODEL_GIC_V5, gic_v5_get_gsi_domain_id); + acpi_set_irq_model(ACPI_IRQ_MODEL_GIC_V5, gic_v5_get_gsi_domain_id, NULL); =20 return 0; =20 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index ec70c84e9f91..f6bc29f515fb 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1690,7 +1690,7 @@ static int __init gic_v2_acpi_init(union acpi_subtabl= e_headers *header, return ret; } =20 - acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, gic_v2_get_gsi_domain_id); + acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, gic_v2_get_gsi_domain_id, NULL); =20 if (IS_ENABLED(CONFIG_ARM_GIC_V2M)) gicv2m_init(NULL, gic_data[0].domain); diff --git a/drivers/irqchip/irq-loongarch-cpu.c b/drivers/irqchip/irq-loon= garch-cpu.c index 950bc087e388..84ce24889488 100644 --- a/drivers/irqchip/irq-loongarch-cpu.c +++ b/drivers/irqchip/irq-loongarch-cpu.c @@ -168,7 +168,7 @@ static int __init cpuintc_acpi_init(union acpi_subtable= _headers *header, panic("Failed to add irqdomain for LoongArch CPU"); =20 set_handle_irq(&handle_cpu_irq); - acpi_set_irq_model(ACPI_IRQ_MODEL_LPIC, lpic_get_gsi_domain_id); + acpi_set_irq_model(ACPI_IRQ_MODEL_LPIC, lpic_get_gsi_domain_id, NULL); acpi_set_gsi_to_irq_fallback(lpic_gsi_to_irq); ret =3D acpi_cascade_irqdomain_init(); =20 diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-i= ntc.c index 84418dbd5a27..0595144116e2 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -384,7 +384,8 @@ static int __init riscv_intc_acpi_init(union acpi_subta= ble_headers *header, if (rc) irq_domain_free_fwnode(fn); else - acpi_set_irq_model(ACPI_IRQ_MODEL_RINTC, riscv_acpi_get_gsi_domain_id); + acpi_set_irq_model(ACPI_IRQ_MODEL_RINTC, riscv_acpi_get_gsi_domain_id, + acpi_get_riscv_gsi_handle); =20 return rc; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 67effb91fa98..468fc6a54651 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -360,9 +360,10 @@ int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi); =20 typedef struct fwnode_handle *(*acpi_gsi_domain_disp_fn)(u32); +typedef acpi_handle (*acpi_gsi_handle_disp_fn)(u32); =20 void acpi_set_irq_model(enum acpi_irq_model_id model, - acpi_gsi_domain_disp_fn fn); + acpi_gsi_domain_disp_fn fn, acpi_gsi_handle_disp_fn gsi_dep_fn); acpi_gsi_domain_disp_fn acpi_get_gsi_dispatcher(void); void acpi_set_gsi_to_irq_fallback(u32 (*)(u32)); =20 @@ -372,6 +373,8 @@ struct irq_domain *acpi_irq_create_hierarchy(unsigned i= nt flags, const struct irq_domain_ops *ops, void *host_data); =20 +u32 acpi_irq_add_auto_dep(acpi_handle handle); + #ifdef CONFIG_X86_IO_APIC extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); #else --=20 2.54.0 From nobody Mon Jun 8 08:32:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 678B1421EE8; Wed, 3 Jun 2026 08:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474914; cv=none; b=a3+ViAjs2fQ1bS5ThbwEbmm2REqWRox2UVD5bR9HinUZarEEF6/U0KcmxZRF78yY6rPG0Oj1/k3FNPg5VW8davEeYZkHriNNyKUVzCQ2pnsuNW/jVtK1DQ3aathPQ5TPZ9UZ5KA094c5VHV8J98H2OHGRQV9W846noV3/zHr4Hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474914; c=relaxed/simple; bh=b+ZGB8vRP3G0qYMMdpOjw19Lv1GxCd0pMHceXbBcwq0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f5GYbfjusQQRe5InwRvQ7/K/EiN3S6V7K2hGw7lRXM8SRkp8ei16sfj5YUomQs/WwsEQyRxz5zRbQHJM2IudB5upRz/H0NuwxlRNk2FeQ/qvXhKRI/UIaeZWKvUkVL5RcpDLW7QebQVTlnVl8UW3WLRK0lD7MQEvaYeyyhUmWzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ABBhZrjq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ABBhZrjq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46AE91F00893; Wed, 3 Jun 2026 08:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780474913; bh=ZXGjepFLBlF5CYmJKu9nzonog+TjUvQLSqr6dGfFK2E=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ABBhZrjqOU3o537lh2MnRYUpYMrAMI0ROn0RsyvtsI8PXipIkR061ks9udXEF2C0h If3i0UetpaEvv3OrWUZmz4KSy5bQw4ttj0XV5p8H3AqqM7/KgXEDY/YmOhiUrI0GAG FN2f8lQQNU9nuQTNyBN9u8N2HfgXpZt7imZnGJlYPEtqXYUr5W7wh+S2eDopa987I1 3kIHecyEJsrk3xPW9OyOuJhGNieglEb8tZX+2QzifZQckprT5MvOTYLMMSHNJ5HZY2 EF0ucrZb2UKmy77Rp6L4/gRBiE0L2kZZYsmUHc16Urh7rw7/dKM50uBu4pQ+7nM77Y aucxO+nLtV0rQ== From: Lorenzo Pieralisi Date: Wed, 03 Jun 2026 10:21:01 +0200 Subject: [PATCH v2 5/6] ACPI/IORT: Implement ACPI infrastructure to enable GICv5 IWB probe deferral Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-5-23ffa16b6ebb@kernel.org> References: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> In-Reply-To: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> To: "Rafael J. Wysocki" , Len Brown , Sunil V L , Marc Zyngier , Thomas Gleixner , Huacai Chen , Anup Patel , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, Lorenzo Pieralisi X-Mailer: b4 0.15.2 Implement an IORT ACPI hook to retrieve the acpi_handle of the interrupt controller handling a specific GSI (if any, on GICv5 systems only the IWB is represented in firmware with an ACPI device object) and add the IWB to the list of devices whose dependencies can be detected (and cleared) in ACPI core to guarantee that probe dependencies for the IWB can be satisfied. Enable autodep detection for arm64 by adding the arch_acpi_add_auto_dep() callback in the ACPI IORT driver. Signed-off-by: Lorenzo Pieralisi Cc: Hanjun Guo Cc: Sudeep Holla Cc: "Rafael J. Wysocki" --- drivers/acpi/arm64/iort.c | 22 +++++++++++++++++++--- drivers/acpi/scan.c | 1 + include/linux/acpi_iort.h | 3 ++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index af7a9b2fd5bc..34412cd697d8 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -789,11 +789,9 @@ struct irq_domain *iort_get_device_domain(struct devic= e *dev, u32 id, return irq_find_matching_fwnode(handle, bus_token); } =20 -struct fwnode_handle *iort_iwb_handle(u32 iwb_id) +acpi_handle iort_iwb_handle(u32 iwb_id) { - struct fwnode_handle *fwnode; struct acpi_iort_node *node; - struct acpi_device *device; struct acpi_iort_iwb *iwb; acpi_status status; acpi_handle handle; @@ -808,6 +806,19 @@ struct fwnode_handle *iort_iwb_handle(u32 iwb_id) if (ACPI_FAILURE(status)) return NULL; =20 + return handle; +} + +struct fwnode_handle *iort_iwb_handle_fwnode(u32 iwb_id) +{ + struct fwnode_handle *fwnode; + struct acpi_device *device; + acpi_handle handle; + + handle =3D iort_iwb_handle(iwb_id); + if (!handle) + return NULL; + device =3D acpi_get_acpi_dev(handle); if (!device) return NULL; @@ -2090,6 +2101,11 @@ static void __init iort_init_platform_devices(void) } } =20 +u32 arch_acpi_add_auto_dep(acpi_handle handle) +{ + return acpi_irq_add_auto_dep(handle); +} + void __init acpi_iort_init(void) { acpi_status status; diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 530547cda8b2..ba15da9058dc 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -856,6 +856,7 @@ static const char * const acpi_ignore_dep_ids[] =3D { =20 /* List of HIDs for which we honor deps of matching ACPI devs, when checki= ng _DEP lists. */ static const char * const acpi_honor_dep_ids[] =3D { + "ARMH0003", /* ARM GICv5 IWB */ "INT3472", /* Camera sensor PMIC / clk and regulator info */ "INTC1059", /* IVSC (TGL) driver must be loaded to allow i2c access to ca= mera sensors */ "INTC1095", /* IVSC (ADL) driver must be loaded to allow i2c access to ca= mera sensors */ diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h index 17bb3374f4ca..931eaa7bbf6a 100644 --- a/include/linux/acpi_iort.h +++ b/include/linux/acpi_iort.h @@ -27,7 +27,8 @@ int iort_register_domain_token(int trans_id, phys_addr_t = base, struct fwnode_handle *fw_node); void iort_deregister_domain_token(int trans_id); struct fwnode_handle *iort_find_domain_token(int trans_id); -struct fwnode_handle *iort_iwb_handle(u32 iwb_id); +acpi_handle iort_iwb_handle(u32 iwb_id); +struct fwnode_handle *iort_iwb_handle_fwnode(u32 iwb_id); =20 #ifdef CONFIG_ACPI_IORT u32 iort_msi_map_id(struct device *dev, u32 id); --=20 2.54.0 From nobody Mon Jun 8 08:32:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C66464219F6; Wed, 3 Jun 2026 08:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474918; cv=none; b=pB3nOgMW4gJeYPldLSY1UqM7QJX1rKvbQnl3HsChZHtMXiBePDb5vr0OTwbUqbGN63VU/PCKA+Wp0cuVCYTM6iCPYngeW+Q/8cjuHOlqbKvesy1ToYZ8tmw0Mr6kSIY55gxt1poVTlJe6MMnpKF/koYasdk2jVfasdK0zxzyJ/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780474918; c=relaxed/simple; bh=4+5N4uxvLWBFk2eIXBRg1DHQVb0VGvLDEOpHtIMC4/M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ODhW9UqjeywhubHDgrq71acMoG5rvMEWuXIRl0nc8fjIgXeFYafcuyZCWQKUl1vpC8luAiXBrGWwDVIvSRBnnpDhcn/upD1mh8yZmlEI4GCplfzeIf8VlqSRvh4OG/VIacdiMDGqek+0vnkRu9JGjSWTa3bof84FZaK35vkUnQk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gm3Yv3Za; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gm3Yv3Za" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98C5A1F00899; Wed, 3 Jun 2026 08:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780474917; bh=m+5k6g5V08oIf0zyIc0HtMgKRyoeGZij4UaZCAbhjl4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=gm3Yv3ZaferZ76474cGhOraU0cQUJRTFq09a7OoW6Gnr0QvP0dbYge9HrxDMwy0rU Vsq3FQq7GzRlxIryPMbchjYGIFZVJGbh5zyv5uqQiFcVY2oZ7k1UJABr6LK2RzMS3u n0erUHnhlqTg0SAYlGwh5uaMO9W+LaFvVakEYwoSolQDR4pZLfVX7+TIDB2eI575lK QJJ6XxodqXXEKPYYrZ/tjrffvZoZZcJCfBCT82eHtakWjrkfXKMNpxo0bRY3RhRXFP ADo2IgymnLL2GlTzDAjtinN5uN8tvDiLppx9P7Iu0N7HTgUPdbT2c84Cw5wyIx71/c fr1kKInZ6bjSA== From: Lorenzo Pieralisi Date: Wed, 03 Jun 2026 10:21:02 +0200 Subject: [PATCH v2 6/6] irqchip/gic-v5: Enable GICv5 IWB ACPI probe ordering detection Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-6-23ffa16b6ebb@kernel.org> References: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> In-Reply-To: <20260603-gic-v5-acpi-iwb-probe-deferral-v2-0-23ffa16b6ebb@kernel.org> To: "Rafael J. Wysocki" , Len Brown , Sunil V L , Marc Zyngier , Thomas Gleixner , Huacai Chen , Anup Patel , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, Lorenzo Pieralisi X-Mailer: b4 0.15.2 Register an ACPI hook in the ACPI interrupt management code for GICv5 to retrieve the ACPI interrupt controller handle (if any) of the controller handling a specific GSI, by updating the acpi_set_irq_model() call with the gic_v5_get_gsi_handle() function pointer parameter. gicv5_get_gsi_handle() allows ACPI core to detect the ACPI handle of the controller that manages a specific GSI interrupt. Update the IWB driver to clear device dependencies in ACPI core once the IWB driver has probed. Signed-off-by: Lorenzo Pieralisi Cc: Thomas Gleixner Cc: Marc Zyngier --- drivers/irqchip/irq-gic-v5-iwb.c | 5 +++++ drivers/irqchip/irq-gic-v5.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v5-iwb.c b/drivers/irqchip/irq-gic-v5-= iwb.c index 9103feb70ce8..a02cb9537b15 100644 --- a/drivers/irqchip/irq-gic-v5-iwb.c +++ b/drivers/irqchip/irq-gic-v5-iwb.c @@ -269,6 +269,11 @@ static int gicv5_iwb_device_probe(struct platform_devi= ce *pdev) if (IS_ERR(iwb_node)) return PTR_ERR(iwb_node); =20 +#ifdef CONFIG_ACPI + if (has_acpi_companion(&pdev->dev)) + acpi_dev_clear_dependencies(ACPI_COMPANION(&pdev->dev)); +#endif + return 0; } =20 diff --git a/drivers/irqchip/irq-gic-v5.c b/drivers/irqchip/irq-gic-v5.c index 03cc2830b260..26cfaea1af41 100644 --- a/drivers/irqchip/irq-gic-v5.c +++ b/drivers/irqchip/irq-gic-v5.c @@ -1217,11 +1217,19 @@ static struct fwnode_handle *gsi_domain_handle; static struct fwnode_handle *gic_v5_get_gsi_domain_id(u32 gsi) { if (FIELD_GET(GICV5_GSI_IC_TYPE, gsi) =3D=3D GICV5_GSI_IWB_TYPE) - return iort_iwb_handle(FIELD_GET(GICV5_GSI_IWB_FRAME_ID, gsi)); + return iort_iwb_handle_fwnode(FIELD_GET(GICV5_GSI_IWB_FRAME_ID, gsi)); =20 return gsi_domain_handle; } =20 +static acpi_handle gic_v5_get_gsi_handle(u32 gsi) +{ + if (FIELD_GET(GICV5_GSI_IC_TYPE, gsi) =3D=3D GICV5_GSI_IWB_TYPE) + return iort_iwb_handle(FIELD_GET(GICV5_GSI_IWB_FRAME_ID, gsi)); + + return NULL; +} + static int __init gic_acpi_init(union acpi_subtable_headers *header, const= unsigned long end) { struct acpi_madt_gicv5_irs *irs =3D (struct acpi_madt_gicv5_irs *)header; @@ -1242,7 +1250,8 @@ static int __init gic_acpi_init(union acpi_subtable_h= eaders *header, const unsig if (ret) goto out_irs; =20 - acpi_set_irq_model(ACPI_IRQ_MODEL_GIC_V5, gic_v5_get_gsi_domain_id, NULL); + acpi_set_irq_model(ACPI_IRQ_MODEL_GIC_V5, gic_v5_get_gsi_domain_id, + gic_v5_get_gsi_handle); =20 return 0; =20 --=20 2.54.0