From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1D28B53A7; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; cv=none; b=ODvApukYyEsXIM3NG+KWKIxVcUJNl70py+MQlkHBN7uSzqfeXxesDdkQrTdQ/Jf1TO8/GBEN3EA08XXND3KfGHuQ9RSNrNo0VNPEhk/IEqNXGONQfaqh6usSZySkv4K9jL6yCV8lUx9CEyX3Q72kXWDTih64Pvz2OTKYy6yG/jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; c=relaxed/simple; bh=Lv3GRGs3DimrxVS28LUoV3CfVPD+bzvWL5eodR8hBFc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Prf4XHB/aMyH9TVbeJ296mAv1eOxph7BPFyZtNXV9AmAOlxp0Ycu6e3V3bwsyPXRpxS+FLOMnhB9D15g7Abn5vk+ESStU6TTbZF0z9wCCAGC+pfxYD9L8GE8T7P1EYjgnzhOtnG7iYVZ77c/8ivE6Zggh2+mxCoOMBUFAb913/A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ox1wwNZr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ox1wwNZr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E15F3C4CEF7; Mon, 8 Sep 2025 16:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349107; bh=Lv3GRGs3DimrxVS28LUoV3CfVPD+bzvWL5eodR8hBFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ox1wwNZrXuwyba95P9bL0MHZO+RzRqhEVepB5DhUSl0oVrnIpTw/T04e/BqqeQNIC lqxVfrCMTpm54VczvYkCFhW0N9OCfIfAJVTnUqT6nF+oV2nyKREwssQErTrSm9eSjF t4yc97wEKJ7XXQVUyVyeB//ChdBxYXJI2Je8Znmbg35jxDCbGTY5sxpi0XXOtgVThB SYVSdE5GN4AwNzXi7/fh4gkdpqq8YBJsMKEn1pcs5h6hG1J9WXRuLy8IZaMJ45QZEh 9dTyAxrxnwQHceAbmC9iAuYYEIpQpDL6Ck1aLydHGs0SImiae2PsjLGbRgMp0x7eK5 p/oxISkJSBSRQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemP-00000004NTm-3JAc; Mon, 08 Sep 2025 16:31:45 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 01/25] irqdomain: Add firmware info reporting interface Date: Mon, 8 Sep 2025 17:31:03 +0100 Message-Id: <20250908163127.2462948-2-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Allow an irqdomain callback to report firmware-provided information that is otherwise not available in a generic way. This is reported using a new data structure (struct irq_fwspec_info). This callback is optional and the only information that can be reported currently is the affinity of an interrupt. However, the containing structure is designed to be extensible, allowing other potentially relevant information to be reported in the future. Signed-off-by: Marc Zyngier --- include/linux/irqdomain.h | 30 ++++++++++++++++++++++++++++++ kernel/irq/irqdomain.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 4a86e6b915dd6..9ec93fb2f5753 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -44,6 +44,27 @@ struct irq_fwspec { u32 param[IRQ_DOMAIN_IRQ_SPEC_PARAMS]; }; =20 +/** + * struct irq_fwspec_info - firmware provided IRQ information structure + * + * @fwspec: IRQ specifier + * @cpumask: Affinity mask for this interrupt + * @flags: Information validity flags + * + * This structure reports firmware-specific information about an + * interrupt. The only significant information is the affinity of a + * per-CPU interrupt, but this is designed to be extended as required. + */ +struct irq_fwspec_info { + struct irq_fwspec fwspec; + const struct cpumask *affinity; + +#define IRQ_FWSPEC_INFO_FWSPEC_VALID BIT(0) +#define IRQ_FWSPEC_INFO_AFFINITY_VALID BIT(1) + + unsigned long flags; +}; + /* Conversion function from of_phandle_args fields to fwspec */ void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args, unsigned int count, struct irq_fwspec *fwspec); @@ -69,6 +90,8 @@ void of_phandle_args_to_fwspec(struct device_node *np, co= nst u32 *args, * @translate: Given @fwspec, decode the hardware irq number (@out_hwirq) = and * linux irq type value (@out_type). This is a generalised @xlate * (over struct irq_fwspec) and is preferred if provided. + * @get_info: Given @info, report additional firmware-provided information. + * Optional. * @debug_show: For domains to show specific data for an interrupt in debu= gfs. * * Functions below are provided by the driver and called whenever a new ma= pping @@ -96,6 +119,7 @@ struct irq_domain_ops { void (*deactivate)(struct irq_domain *d, struct irq_data *irq_data); int (*translate)(struct irq_domain *d, struct irq_fwspec *fwspec, unsigned long *out_hwirq, unsigned int *out_type); + int (*get_info)(struct irq_fwspec_info *info); #endif #ifdef CONFIG_GENERIC_IRQ_DEBUGFS void (*debug_show)(struct seq_file *m, struct irq_domain *d, @@ -602,6 +626,8 @@ void irq_domain_free_irqs_parent(struct irq_domain *dom= ain, unsigned int irq_bas =20 int irq_domain_disconnect_hierarchy(struct irq_domain *domain, unsigned in= t virq); =20 +int irq_populate_fwspec_info(struct irq_fwspec_info *info); + static inline bool irq_domain_is_hierarchy(struct irq_domain *domain) { return domain->flags & IRQ_DOMAIN_FLAG_HIERARCHY; @@ -685,6 +711,10 @@ static inline bool irq_domain_is_msi_device(struct irq= _domain *domain) return false; } =20 +static inline int irq_populate_fwspec_info(struct irq_fwspec_info *info) +{ + return -EINVAL; +} #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ =20 #ifdef CONFIG_GENERIC_MSI_IRQ diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index dc473faadcc81..f857606e3ffbe 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -867,13 +867,9 @@ void of_phandle_args_to_fwspec(struct device_node *np,= const u32 *args, } EXPORT_SYMBOL_GPL(of_phandle_args_to_fwspec); =20 -unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) +static struct irq_domain *fwspec_to_domain(struct irq_fwspec *fwspec) { struct irq_domain *domain; - struct irq_data *irq_data; - irq_hw_number_t hwirq; - unsigned int type =3D IRQ_TYPE_NONE; - int virq; =20 if (fwspec->fwnode) { domain =3D irq_find_matching_fwspec(fwspec, DOMAIN_BUS_WIRED); @@ -883,6 +879,33 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwsp= ec *fwspec) domain =3D irq_default_domain; } =20 + return domain; +} + +#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY +int irq_populate_fwspec_info(struct irq_fwspec_info *info) +{ + struct irq_domain *domain; + + domain =3D fwspec_to_domain(&info->fwspec); + if (!domain || !domain->ops->get_info) { + info->flags =3D 0; + return 0; + } + + return domain->ops->get_info(info); +} +#endif + +unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) +{ + struct irq_domain *domain; + struct irq_data *irq_data; + irq_hw_number_t hwirq; + unsigned int type =3D IRQ_TYPE_NONE; + int virq; + + domain =3D fwspec_to_domain(fwspec); if (!domain) { pr_warn("no irq domain found for %s !\n", of_node_full_name(to_of_node(fwspec->fwnode))); --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6FB7C30F928; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; cv=none; b=qyI9qVkJ84UK2l4mwGH3njnljTATRlG9Pmi8AZI3uFeozMG6UoV29uAMaamWDbWaLOUHn+Hp1rAP7UemzJSfDMXRqF1pq9bTx5BmF6ugn5kD0AkA4PhTL29TTmDlckBzyEyxIFbVBgI+BKWry0uEBMpjeiyC1jN3MlHEPh0EH1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; c=relaxed/simple; bh=2U6Z8RxH98hnMaQV8REDzyDMoE+2Jx+42xIbx271+3s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dKoJvl7Tb2H0fAxxI/l/qIBsySdaIKT9fQ6Q52NTyxRU6zv1yU8OH/oUmV03xBJ91fKSZjEdw9417NsckYmyG811O933iPfgn7qr0xPd9GcRhLuVq1LxZfKkZ6igo258CGogHjHzxYdkPvH4d9DnDTiQ8zgJ1+KXNdy7cricvws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U+jhPL21; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U+jhPL21" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B838C4CEF5; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349108; bh=2U6Z8RxH98hnMaQV8REDzyDMoE+2Jx+42xIbx271+3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U+jhPL21Otg8MBgyvrxFvetugXwyghDpLo2xSflV+SYtLXx+bXDQP1AgTsTzdVhG3 bAGkUgZx64V1d0qTs8i5cXtW82Y1GsNs3JXCR2dLJhrbQPVtPdMJtsFSsxF/1mZZK7 MNQKQRcjtDDir026fV1AIYu+XU0Mi76FSuKrZ6xtYKa8fCUZALY18ssyyVLzIhPUNP rH5jP0EWdLL0RGCzlaCNDUy67EEudP571YDJ7laPS4p4mw8bMJw89uByrzny13qzDG T3I3+6RKZF/bIwEmecVWNfoBj5vA+gEW5tQGZhk6yVFjTJL3EuuwzwflAwZvNCDAb0 C9YcHpVaHAPKw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemQ-00000004NTm-0Bsz; Mon, 08 Sep 2025 16:31:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 02/25] ACPI: irq: Add IRQ affinity reporting interface Date: Mon, 8 Sep 2025 17:31:04 +0100 Message-Id: <20250908163127.2462948-3-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Plug the irq_populate_fwspec_info() helper into the ACPI layer to offer an IRQ affinity reporting function. This is currently only supported for the CONFIG_ACPI_GENERIC_GSI configurations, but could later be extended to legacy architectures if necessary. Signed-off-by: Marc Zyngier --- drivers/acpi/irq.c | 15 +++++++++++++++ include/linux/acpi.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index 76a856c32c4d0..22f93fe23ddce 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -300,6 +300,21 @@ int acpi_irq_get(acpi_handle handle, unsigned int inde= x, struct resource *res) } EXPORT_SYMBOL_GPL(acpi_irq_get); =20 +const struct cpumask *acpi_irq_get_affinity(acpi_handle handle, + unsigned int index) +{ + struct irq_fwspec_info info; + unsigned long flags; + + if (!acpi_irq_parse_one(handle, index, &info.fwspec, &flags)) { + if (!irq_populate_fwspec_info(&info) && + info.flags & IRQ_FWSPEC_INFO_AFFINITY_VALID) + return info.affinity; + } + + return NULL; +} + /** * acpi_set_irq_model - Setup the GSI irqdomain information * @model: the value assigned to acpi_irq_model diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 1c5bb1e887cd1..c506ae4bacc86 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1509,12 +1509,19 @@ static inline int acpi_parse_spcr(bool enable_early= con, bool enable_console) =20 #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI) int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *= res); +const struct cpumask *acpi_irq_get_affinity(acpi_handle handle, + unsigned int index); #else static inline int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *= res) { return -EINVAL; } +static inline const struct cpumask *acpi_irq_get_affinity(acpi_handle hand= le, + unsigned int index) +{ + return NULL; +} #endif =20 #ifdef CONFIG_ACPI_LPIT --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D11C830F943; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; cv=none; b=JAVeX2oKtucM1kOzku09tq5021jCONvThUq8hrE4qjp5sjeHrK70VcLOHhCc2pLkwFAjB4HPWoHWt4xqN//omePnLZKLX4dYlmb0lTiOByKwtyvgfi4piTKGitpRDU0wTDnZrbD1OqWQXS1FZdVE0yu/8hsVjqWbFJOlySeLPOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; c=relaxed/simple; bh=sGD9P1+N4V37A0aIJ2eK7vIsS8B9pkkhrv0UN3imJB0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aORTbp4OLeIEtD/XOF3mPzTCIuDgjbrbrzIjLX+PAFTwvY1NaOs1eWt+iWrxMsRuSeZVS1gQYBdtA18DcBlecYnOaNvbaiSKZ3W2OPu4fwZpoOOFNH2JLnwDavuGhTWKVGla4lIaLjOolsDn1hB+BA+yb/PLwNAx3ZuXHw/DE9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fXVqCQ1J; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fXVqCQ1J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 737FFC4CEF9; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349108; bh=sGD9P1+N4V37A0aIJ2eK7vIsS8B9pkkhrv0UN3imJB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fXVqCQ1Jd/RLa8F2YRUK+xt2yn1De/nXFfvsfopMCm81ElEXjPFMo6Sm3fwz1DaAu MaL22A9DwFOYImVF5+aveYxYx7SAgGm9CfgPxo2K/QHWJIqb5mYLaIFUsMREcuUSJX ai5YhvLzY+xklsspr4o/Gr/Ct+L/3WUb/5ku6DgGJ/9NAtdmqBBivYa94I/q6EBp6N uhhACdHoPgZBaOpRNJ7TjyY+BL6NMt5mhL4k5w4qWXWvTtmjDYd7Hh9fMiMIfwipBd xXHrpzA4I1V0TvRX9sucdd3MsogG6DRKjCeZ9bAVSuQmzYX3NbzG5d02VOo6/Mt5D+ U93Tcv2DHuOUA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemQ-00000004NTm-1IZA; Mon, 08 Sep 2025 16:31:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 03/25] of/irq: Add IRQ affinity reporting interface Date: Mon, 8 Sep 2025 17:31:05 +0100 Message-Id: <20250908163127.2462948-4-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Plug the irq_populate_fwspec_info() helper into the OF layer to offer an IRQ affinity reporting function. Signed-off-by: Marc Zyngier --- drivers/of/irq.c | 20 ++++++++++++++++++++ include/linux/of_irq.h | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 74aaea61de13c..cb264f44bd6d8 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -479,6 +479,26 @@ int of_irq_get(struct device_node *dev, int index) } EXPORT_SYMBOL_GPL(of_irq_get); =20 +const struct cpumask *of_irq_get_affinity(struct device_node *dev, int ind= ex) +{ + int rc; + struct of_phandle_args oirq; + struct irq_fwspec_info info; + + rc =3D of_irq_parse_one(dev, index, &oirq); + if (rc) + return NULL; + + of_phandle_args_to_fwspec(oirq.np, oirq.args, oirq.args_count, + &info.fwspec); + + if (!irq_populate_fwspec_info(&info) && + info.flags & IRQ_FWSPEC_INFO_AFFINITY_VALID) + return info.affinity; + + return NULL; +} + /** * of_irq_get_byname - Decode a node's IRQ and return it as a Linux IRQ nu= mber * @dev: pointer to device tree node diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index a480063c9cb19..721cbdbc292df 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -43,6 +43,8 @@ extern int of_irq_parse_one(struct device_node *device, i= nt index, struct of_phandle_args *out_irq); extern int of_irq_count(struct device_node *dev); extern int of_irq_get(struct device_node *dev, int index); +extern const struct cpumask *of_irq_get_affinity(struct device_node *dev, + int index); extern int of_irq_get_byname(struct device_node *dev, const char *name); extern int of_irq_to_resource_table(struct device_node *dev, struct resource *res, int nr_irqs); @@ -77,6 +79,11 @@ static inline int of_irq_get_byname(struct device_node *= dev, const char *name) { return 0; } +static inline const struct cpumask *of_irq_get_affinity(struct device_node= *dev, + int index) +{ + return NULL; +} static inline int of_irq_to_resource_table(struct device_node *dev, struct resource *res, int nr_irqs) { --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D5AC130F946; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; cv=none; b=mq/1rjhfN9PNwaF6YjelEK0oBR1rVgNpR+W+lt9JNn+n/NVDe8SFBOfauK3Dep5N56Gy3nkVIQhH5AfBSu/7u2QFgnJ3+a3SvLRvybFjHlP6NdVd7d5ZApR/DIAnUs7Chg5nMEWo3M6sqRDDvzYLGbft6O3s473EI2BpwaSXcOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349108; c=relaxed/simple; bh=G+swjEVbqFRe3VO4Brd816oEyLNB4BZ+ieu+z8ZYXlk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BOAaI60RW0WB18kSXDmw/26rhlckHoLDOxhLt3wUr16eJ3J+EYZclBDHyiHL1nBmoFhbC3juTvcANIkFzDLHYNvQdIjwKu20U9eCI+6uoeUl1QnO4bZu++HOWkUwYlg4xWsGtW8rAahdahpsDC02rXPuy7QKm9MSwRWrwfBCBjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kHTWYSuP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kHTWYSuP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8B01C4CEF7; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349108; bh=G+swjEVbqFRe3VO4Brd816oEyLNB4BZ+ieu+z8ZYXlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kHTWYSuP0bU3853OaXCg5l9DIuMvx66uOm4gpVe7T/uBz9nPeoGr0Vs4zn/L0wXgj baiclTzTjvT2VJaV/Bu121IMYPe2UvqJVk5KfUES34qx6ug8fv/3jDa/F6EqIltXlv F65V7TasHeaz4YdUDc4/rCsymfbwYSIsqdIKV4r7iL8JTGZnBDpcWVT9N711wKa1uR px2b0BnjbDxPiUrXExgycyFU5sjVNBpeYQGpFKcKVEDMkjdc2vAyfZ6IEb7Tsswt3i aBSyDl709uN/Cpz1+xnuHtUAjCDKPrgEMAHaCVv/1aYiRmLwuUul+jsY5FXB5PnHw2 6Vr/9lIDN+wqQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemQ-00000004NTm-2RZZ; Mon, 08 Sep 2025 16:31:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 04/25] platform: Add firmware-agnostic irq and affinity retrieval interface Date: Mon, 8 Sep 2025 17:31:06 +0100 Message-Id: <20250908163127.2462948-5-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Expand platform_get_irq_optional() to also return an affinity if available, renaming it to platform_get_irq_affinity() in the process. platform_get_irq_optional() is preserved with its current semantics by calling into the new helper with a NULL affinity pointer. Signed-off-by: Marc Zyngier --- drivers/base/platform.c | 60 +++++++++++++++++++++++++++------ include/linux/platform_device.h | 2 ++ 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 09450349cf323..fad33d6b2349a 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -150,25 +150,37 @@ devm_platform_ioremap_resource_byname(struct platform= _device *pdev, EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname); #endif /* CONFIG_HAS_IOMEM */ =20 +static const struct cpumask *get_irq_affinity(struct platform_device *dev, + unsigned int num) +{ + const struct cpumask *mask =3D NULL; +#ifndef CONFIG_SPARC + struct fwnode_handle *fwnode =3D dev_fwnode(&dev->dev); + + if (is_of_node(fwnode)) + mask =3D of_irq_get_affinity(to_of_node(fwnode), num); + else if (is_acpi_device_node(fwnode)) + mask =3D acpi_irq_get_affinity(ACPI_HANDLE_FWNODE(fwnode), num); +#endif + + return mask ?: cpu_possible_mask; +} + /** - * platform_get_irq_optional - get an optional IRQ for a device + * platform_get_irq_affinity - get an optional IRQ and its affnity for a d= evice * @dev: platform device * @num: IRQ number index + * @affinity: optional cpumask pointer to get the affinity of a per-cpu IRQ * * Gets an IRQ for a platform device. Device drivers should check the retu= rn * value for errors so as to not pass a negative integer value to the - * request_irq() APIs. This is the same as platform_get_irq(), except that= it - * does not print an error message if an IRQ can not be obtained. - * - * For example:: - * - * int irq =3D platform_get_irq_optional(pdev, 0); - * if (irq < 0) - * return irq; + * request_irq() APIs. Optional affinity information is provided in the + * affinity pointer if available, and NULL otherwise. * * Return: non-zero IRQ number on success, negative error number on failur= e. */ -int platform_get_irq_optional(struct platform_device *dev, unsigned int nu= m) +int platform_get_irq_affinity(struct platform_device *dev, unsigned int nu= m, + const struct cpumask **affinity) { int ret; #ifdef CONFIG_SPARC @@ -236,8 +248,36 @@ int platform_get_irq_optional(struct platform_device *= dev, unsigned int num) out: if (WARN(!ret, "0 is an invalid IRQ number\n")) return -EINVAL; + + if (ret > 0 && affinity) + *affinity =3D get_irq_affinity(dev, num); + return ret; } +EXPORT_SYMBOL_GPL(platform_get_irq_affinity); + +/** + * platform_get_irq_optional - get an optional IRQ for a device + * @dev: platform device + * @num: IRQ number index + * + * Gets an IRQ for a platform device. Device drivers should check the retu= rn + * value for errors so as to not pass a negative integer value to the + * request_irq() APIs. This is the same as platform_get_irq(), except that= it + * does not print an error message if an IRQ can not be obtained. + * + * For example:: + * + * int irq =3D platform_get_irq_optional(pdev, 0); + * if (irq < 0) + * return irq; + * + * Return: non-zero IRQ number on success, negative error number on failur= e. + */ +int platform_get_irq_optional(struct platform_device *dev, unsigned int nu= m) +{ + return platform_get_irq_affinity(dev, num, NULL); +} EXPORT_SYMBOL_GPL(platform_get_irq_optional); =20 /** diff --git a/include/linux/platform_device.h b/include/linux/platform_devic= e.h index 074754c23d330..ad66333ce85ce 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -102,6 +102,8 @@ devm_platform_ioremap_resource_byname(struct platform_d= evice *pdev, =20 extern int platform_get_irq(struct platform_device *, unsigned int); extern int platform_get_irq_optional(struct platform_device *, unsigned in= t); +extern int platform_get_irq_affinity(struct platform_device *, unsigned in= t, + const struct cpumask **); extern int platform_irq_count(struct platform_device *); extern int devm_platform_get_irqs_affinity(struct platform_device *dev, struct irq_affinity *affd, --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7843430FC23; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; cv=none; b=exOcVo3c7M7HqpXzYVNjiWuB+f0AxGDaqzawQQO63/xrsq4mSETkoUAo6Pnw3CdIHdNRJX9jkd86bHAxK5/HP8JCXo8FGLW3OEHbLL6dD4V3gN2Pcz7Dv9jhzvq3FgEZGorETN+XceTj0bEpJfS4xf6YtLWI7LnZ2JNM9r0GU+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; c=relaxed/simple; bh=t2t1XQhmTu4QwWw1Mvj257XNXGFyRkE9ARKAhPe4oJM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=arvwUjG6OJMKiydBIra5p2ppBCW2Q26n7yBVOn7TqylLkWDIKtDAiA0fZRU5ZxJJV+dqM19hAnzU2gt5vVizRSMJlNeWrT900riKh2rKEBrV7psjsH0W9oEwxIGVEabH2Kry0zmW9xCzM8+BU6k4pmJ8tMXmGKDATdFKKUdoCZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PZGJjwXa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PZGJjwXa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E97C6C4CEFA; Mon, 8 Sep 2025 16:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349109; bh=t2t1XQhmTu4QwWw1Mvj257XNXGFyRkE9ARKAhPe4oJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZGJjwXa4GgFgzXH4FhpcpgeXYYGFHaTE8JKKorNoWhuxqrV+ph71/Wxqz50OWlym fYMU32cIM91+bFkjMDOQh8oFz9ZMg7qtYCcw0Gh/feKnM2DcicJ3IXiX72tXZl6FtB oAqZh0l0J5XNQB5Eb/jRHZ/tdlktjD0U4tA8+UkfAFxgRj4Pi9lrXQEJtzahwgAcU5 TXtMJRHerwY2TRCDoWozvylBTU3zuZmX/iOb5/cu3dMuqgWpFo1T7O9Yl9527BBE7g Z2JJIVGdpT0+j59lajuZtnE4WumAelcS87NXt2JF8JOiGAdRNzv9QZyfBLrb0T5pSY Qu7riyUNDJKTg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemQ-00000004NTm-3YV5; Mon, 08 Sep 2025 16:31:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 05/25] irqchip/gic-v3: Add FW info retrieval support Date: Mon, 8 Sep 2025 17:31:07 +0100 Message-Id: <20250908163127.2462948-6-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Plug the new .get_info() callback into the GICv3 core driver, using some of the existing PPI affinity handling infrastructure. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3.c | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index dbeb85677b08c..4a90dbf9daedb 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -69,6 +69,8 @@ struct gic_chip_data { bool has_rss; unsigned int ppi_nr; struct partition_desc **ppi_descs; + struct partition_affinity *parts; + unsigned int nr_parts; }; =20 #define T241_CHIPS_MAX 4 @@ -1796,11 +1798,60 @@ static int gic_irq_domain_select(struct irq_domain = *d, return d =3D=3D partition_get_domain(gic_data.ppi_descs[ppi_idx]); } =20 +static int gic_irq_get_info(struct irq_fwspec_info *info) +{ + struct irq_fwspec *fwspec =3D &info->fwspec; + const struct cpumask *mask =3D NULL; + + info->flags =3D 0; + info->affinity =3D NULL; + + /* ACPI is not capable of describing PPI affinity -- yet */ + if (!is_of_node(fwspec->fwnode)) + goto out; + + /* If the specifier provides an affinity, use it */ + if (fwspec->param_count =3D=3D 4 && fwspec->param[3]) { + struct fwnode_handle *fw; + + switch (fwspec->param[0]) { + case 1: /* PPI */ + case 3: /* EPPI */ + break; + default: + goto out; + } + + fw =3D of_node_to_fwnode(of_find_node_by_phandle(fwspec->param[3])); + if (!fw) + goto out; + + for (int i =3D 0; i < gic_data.nr_parts; i++) { + if (gic_data.parts[i].partition_id =3D=3D fw) { + mask =3D &gic_data.parts[i].mask; + break; + } + } + + if (!mask) + goto out; + } else { + mask =3D cpu_possible_mask; + } + + info->affinity =3D mask; + info->flags =3D (IRQ_FWSPEC_INFO_FWSPEC_VALID | + IRQ_FWSPEC_INFO_AFFINITY_VALID); +out: + return 0; +} + static const struct irq_domain_ops gic_irq_domain_ops =3D { .translate =3D gic_irq_domain_translate, .alloc =3D gic_irq_domain_alloc, .free =3D gic_irq_domain_free, .select =3D gic_irq_domain_select, + .get_info =3D gic_irq_get_info, }; =20 static int partition_domain_translate(struct irq_domain *d, @@ -1839,6 +1890,7 @@ static int partition_domain_translate(struct irq_doma= in *d, static const struct irq_domain_ops partition_domain_ops =3D { .translate =3D partition_domain_translate, .select =3D gic_irq_domain_select, + .get_info =3D gic_irq_get_info, }; =20 static bool gic_enable_quirk_msm8996(void *data) @@ -2231,6 +2283,9 @@ static void __init gic_populate_ppi_partitions(struct= device_node *gic_node) part_idx++; } =20 + gic_data.parts =3D parts; + gic_data.nr_parts =3D nr_parts; + for (i =3D 0; i < gic_data.ppi_nr; i++) { unsigned int irq; struct partition_desc *desc; --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2E3E930FC02; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; cv=none; b=I7uIBqh1kAB8qDXAcSOhmJLhoYqfqbdqv5GxjGdJz5MKXPIxyQlmGWoQZOw5gjHW+bYxeE+GlZ22BvLOFdSRK6+/cszoKERtbj+xWiszq4hBczPqrc6ZX2GSWuCwGL9z8bOpin6dMM+IudL00a4hcXEFeBXXKgxqfnjmLw9FIiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; c=relaxed/simple; bh=UgM/OqUibOh9R2u8nSkBg+Ss9N12aimxIdS7tXj+GS0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bDuqaFhNchBb5B4a496aLEGfEIw9mFfTvdTGkoU6CM5GvwcsYyu+HnXjfHjuLLS69A7fFPlmZNYoIU+oZ6MwUswNvTS041vJYYeoxcpUH6UBlAhc21Jy1vFkie+5PzOflwPBAIbnFja+93P0+60B1ngwuhgDnnJP0oFglokSv3E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YvqGokMq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YvqGokMq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 081DDC4CEF9; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349109; bh=UgM/OqUibOh9R2u8nSkBg+Ss9N12aimxIdS7tXj+GS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvqGokMqYuzQK5qItVr7GesEOxxrfiRvN/NEUPnLtbx0PXK5Ho4pWEiHiyDJiA1F2 y2oEWjY5WpXqXovP8S2VZiqMkx78MtClRNYj/5KKmKVM7puNQPHoYGrlMxjPuxZTRo 3wTrsB45/T7LpyffrkbBMX3Jy+xn0yFGPANpdiJ6fzSqSjkAnTTzvgIYJRuJk050E7 OiE+IFIO/8ggFTL3T9QX9f1w32TOY3QxsHGXgshVRTIb9qS97bg8W6QxPkNmMeXJ2V tBNiprX8A8W56C+QpMyGPLTk7fKnBMgNTsRaQSVvKe0PvTHB/9ZX/Q63LnAnKA9yuY 9J/8raovlu3Tg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemR-00000004NTm-0XAg; Mon, 08 Sep 2025 16:31:47 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 06/25] irqchip/apple-aic: Add FW info retrieval support Date: Mon, 8 Sep 2025 17:31:08 +0100 Message-Id: <20250908163127.2462948-7-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Plug the new .get_info() callback into the Apple AIC driver, using some of the existing FIQ affinity handling infrastructure. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-apple-aic.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index 032d66dceb8ec..dd89e50a72e83 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -651,6 +651,36 @@ static int aic_irq_domain_map(struct irq_domain *id, u= nsigned int irq, return 0; } =20 +static int aic_irq_get_info(struct irq_fwspec_info *info) +{ + struct irq_fwspec *fwspec =3D &info->fwspec; + const struct cpumask *mask; + u32 intid; + + info->flags =3D 0; + info->affinity =3D NULL; + + if (fwspec->param[0] !=3D AIC_FIQ) + return 0; + + if (fwspec->param_count =3D=3D 3) + intid =3D fwspec->param[1]; + else + intid =3D fwspec->param[2]; + + if (aic_irqc->fiq_aff[intid]) + mask =3D &aic_irqc->fiq_aff[intid]->aff; + else + mask =3D cpu_possible_mask; + + info->affinity =3D mask; + + info->flags =3D (IRQ_FWSPEC_INFO_FWSPEC_VALID | + IRQ_FWSPEC_INFO_AFFINITY_VALID); + + return 0; +} + static int aic_irq_domain_translate(struct irq_domain *id, struct irq_fwspec *fwspec, unsigned long *hwirq, @@ -753,6 +783,7 @@ static const struct irq_domain_ops aic_irq_domain_ops = =3D { .translate =3D aic_irq_domain_translate, .alloc =3D aic_irq_domain_alloc, .free =3D aic_irq_domain_free, + .get_info =3D aic_irq_get_info, }; =20 /* --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5D2A330FC1C; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; cv=none; b=t+KWdjh6/SVRINhNtx1F8UGYeUpCcoJU02RnXY32fIeoXCVd0voKmMkfrEXlRjbVmFn4zyQv9kiMWn+6GVMapJPnL8LqU/jpaWOAQqmBcEngr0Gw10Y8fpvsGwy0cWVoz25dPVuuEvwVxZXNyxzZse6SRntr+lihZ8j0dp5X/gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; c=relaxed/simple; bh=jQHOrUvrdulPrMOQtn05zaOApqc5lhkt4nBzVAEvlWw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WwMIX0vdNGzFA9VC6xi9MQxNuGlzwmDf9dt3YDAYLuDUFKjMCpcQIXn7kfG9b9cwrgivUDkbapRN9BTFmN7pc87qaKWiOQYfnj7pgJPQFIWEs2LwwDoHi4Tgxw4oUwCuLZeqZNHXJ8Xm2vs/5fg5s0W4KyYQPpFQFj5jD/1DLAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=czBXERcP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="czBXERcP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BD22C113D0; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349109; bh=jQHOrUvrdulPrMOQtn05zaOApqc5lhkt4nBzVAEvlWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=czBXERcPZ33eoypWE2xIzk9HQjHljbDix3cn36Hh2mK5gUF1VODYSJBFYDAUJ6FfN Xao2Jr7HDWzJbhTYQeiuhScA9+g1QYJFXD0XuoA3aJyI+bDM2kdcmlDEdl8dqw99r7 k2lmphqCUS7LLR16vmtfF7f0crh3jq0ztn+KDnZjZ0o5F8CoMs6mW1oZAsCAIYAk27 UutSHwagfgmzCShbT/X/w6S1a3lPOh2AamN33Hxj1huPARni8NJjs084ST8cnZz7wr 3uUMmZbPs582U9/20z/SQXmsbCIIFkgnt6+Ec8uL2AXa9uTfgbXqxp4xIWkcCjD043 KeTlQw941xp+Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemR-00000004NTm-1fwn; Mon, 08 Sep 2025 16:31:47 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 07/25] coresight: trbe: Convert to new IRQ affinity retrieval API Date: Mon, 8 Sep 2025 17:31:09 +0100 Message-Id: <20250908163127.2462948-8-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Now that the relevant interrupt controllers are equipped with a callback returning the affinity of per-CPU interrupts, switch the TRBE driver over to this new method. Signed-off-by: Marc Zyngier --- drivers/hwtracing/coresight/coresight-trbe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtraci= ng/coresight/coresight-trbe.c index 8267dd1a2130d..c512f8faa6012 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -1472,9 +1472,10 @@ static void arm_trbe_remove_cpuhp(struct trbe_drvdat= a *drvdata) static int arm_trbe_probe_irq(struct platform_device *pdev, struct trbe_drvdata *drvdata) { + const struct cpumask *affinity; int ret; =20 - drvdata->irq =3D platform_get_irq(pdev, 0); + drvdata->irq =3D platform_get_irq_affinity(pdev, 0, &affinity); if (drvdata->irq < 0) { pr_err("IRQ not found for the platform device\n"); return drvdata->irq; @@ -1485,8 +1486,7 @@ static int arm_trbe_probe_irq(struct platform_device = *pdev, return -EINVAL; } =20 - if (irq_get_percpu_devid_partition(drvdata->irq, &drvdata->supported_cpus= )) - return -EINVAL; + cpumask_copy(&drvdata->supported_cpus, affinity); =20 drvdata->handle =3D alloc_percpu(struct perf_output_handle *); if (!drvdata->handle) --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B9C7030FC3D; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; cv=none; b=V7Ix5R13peUy+Mp8k9dSbgqdy2HqbdEb7W8ub96ut7qXJFx1xw2zSGXD6ToXaFKVBhB6wl1SL8marwoYZeylhNNKtWNc5OUkbkhtLA4n2744vYO4vPtUF2h8G2Og+ShsTzZAmIUVwZu+1DbMEC3A9S+IzzMRJtKmxvwQIMAY82A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349109; c=relaxed/simple; bh=gHNda0QWGnywO22OHTHAtrEXJraB/koPwbnWeNVZoWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bx06waDJThTKTgZaOXR6KI56JdxMhghaNQrMWiodBerEyKM7vci5JgB0vV7ucBCePA8MhQCPndRQk7AR1YOwDxyLiN7Mw3KHkPnpEFfNd/+fqWbS79PeMIVTIGh5uexxQOetvSVmWHMuZ612g2vJRmuSH1+vfc7+RU+FIBmVr9k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DZEnrz9s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DZEnrz9s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9876DC4CEF7; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349109; bh=gHNda0QWGnywO22OHTHAtrEXJraB/koPwbnWeNVZoWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DZEnrz9sJ7lpSZAMHTArsytc/FiUfM49SOwDYW4NrS+2kHDyRvbcSsbUkyyZ0uv1o DOHscDRxurRZjbVQ4avbrca7Lr/4p1LMQZGR0rBoOmWuC6PY2GySrvqk4q6V98rNfD jdGLh7Dj0pNAQ/VgpgcO+S1j+DlLf252vPIsDDsy7TfREddGauciF/X5eXAx77Llti F/mR0l8QMvBhEt1Jly/5wVbXTyMmUr9HtcmUcmHu6WPPRZdER9ZC1bWcCOxNemLhNp OcAUEUQdFIoypvxb6IUTtqiWgSYy9KSYMlss32Aq7V6rni/42LfCpX6vGN4L7EylGL TQUJMuAJkMlYQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemR-00000004NTm-2rZM; Mon, 08 Sep 2025 16:31:47 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 08/25] perf: arm_pmu: Convert to new IRQ affinity retrieval API Date: Mon, 8 Sep 2025 17:31:10 +0100 Message-Id: <20250908163127.2462948-9-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Now that the relevant interrupt controllers are equipped with a callback returning the affinity of per-CPU interrupts, switch the OF side of the ARM PMU driver over to this new method. Signed-off-by: Marc Zyngier --- drivers/perf/arm_pmu_platform.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platfor= m.c index 118170a5cedef..9c0494d8a867a 100644 --- a/drivers/perf/arm_pmu_platform.c +++ b/drivers/perf/arm_pmu_platform.c @@ -42,14 +42,13 @@ static int probe_current_pmu(struct arm_pmu *pmu, return ret; } =20 -static int pmu_parse_percpu_irq(struct arm_pmu *pmu, int irq) +static int pmu_parse_percpu_irq(struct arm_pmu *pmu, int irq, + const struct cpumask *affinity) { - int cpu, ret; struct pmu_hw_events __percpu *hw_events =3D pmu->hw_events; + int cpu; =20 - ret =3D irq_get_percpu_devid_partition(irq, &pmu->supported_cpus); - if (ret) - return ret; + cpumask_copy(&pmu->supported_cpus, affinity); =20 for_each_cpu(cpu, &pmu->supported_cpus) per_cpu(hw_events->irq, cpu) =3D irq; @@ -115,9 +114,12 @@ static int pmu_parse_irqs(struct arm_pmu *pmu) } =20 if (num_irqs =3D=3D 1) { - int irq =3D platform_get_irq(pdev, 0); + const struct cpumask *affinity; + int irq; + + irq =3D platform_get_irq_affinity(pdev, 0, &affinity); if ((irq > 0) && irq_is_percpu_devid(irq)) - return pmu_parse_percpu_irq(pmu, irq); + return pmu_parse_percpu_irq(pmu, irq, affinity); } =20 if (nr_cpu_ids !=3D 1 && !pmu_has_irq_affinity(dev->of_node)) --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2C3493101AD; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349110; cv=none; b=khWAUcann9+EHBkZHuW4DTRM9Njm234+a/ijXkPw9GQfG5TETwyOqPDLn7/f6wXorjlXXpD8XCojzXLutq+XnBjLGojETYcYtFL0TZPN9/PSxFpmL7Ii74Hd82ih/ZEzgAfL6L6nXF89iv8WA2zrCREyV0HIusM1bsR3n4l/uss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349110; c=relaxed/simple; bh=BXehqBShX490v3aAs4Y17GiJfZWz8kwwWxRiKKAQ/G4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MpgXgEpBzQsSgflTuUTj4nOK0Vf/71dJvUvQ4cR0XbqXMu115wd3sdArEhOS4XuYY0wZnPFVzZlLzTGJp2JiQHFnsXZtgfFEQj+DsRiazVY2+BvMbyHqPEl/QaTocLR03uVecrPAKTKx18uUoSqrW2z9dRC7dijBEnbYZ+rm9Rs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qvnvrwSM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qvnvrwSM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD92DC4CEF9; Mon, 8 Sep 2025 16:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349109; bh=BXehqBShX490v3aAs4Y17GiJfZWz8kwwWxRiKKAQ/G4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qvnvrwSM/pNc7BL66L2RweNhYgu1YmKOuWSMcbDHLsDbaV8+V6TRxiE+4Wfw8N8dq DpcvyYGORdOZmvj/HRKmINlJeCBMwoarVbrY6iHOoqV0NIVxidhRnP0LCIgZ0GpEs3 f0wJhHtA07IQ96CycHzKVZKJWrabLBQ3bvJJLCaq8Pn5/cnvn7YL6UdBHm0gsXfH8/ ZoSO8SS4lohs2ezmXWYA8thr7ClB16YS8XK+lZrdKclHzPIoMEn1aMly5eYlp0d0Zd B2s5APdqspWT65zKQeYUzF9knBUjqN+Vruzvpv9XbN5FkwQ/reCFyOFvPtDHqkQW8G iPEpWkmnRBv1Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemR-00000004NTm-3vA9; Mon, 08 Sep 2025 16:31:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 09/25] perf: arm_spe_pmu: Convert to new IRQ affinity retrieval API Date: Mon, 8 Sep 2025 17:31:11 +0100 Message-Id: <20250908163127.2462948-10-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Now that the relevant interrupt controllers are equipped with a callback returning the affinity of per-CPU interrupts, switch the ARM SPE driver over to this new method. Signed-off-by: Marc Zyngier --- drivers/perf/arm_spe_pmu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 369e77ad5f13f..a1c86a1f21427 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -1211,8 +1211,10 @@ static void arm_spe_pmu_dev_teardown(struct arm_spe_= pmu *spe_pmu) static int arm_spe_pmu_irq_probe(struct arm_spe_pmu *spe_pmu) { struct platform_device *pdev =3D spe_pmu->pdev; - int irq =3D platform_get_irq(pdev, 0); + const struct cpumask *affinity; + int irq; =20 + irq =3D platform_get_irq_affinity(pdev, 0, &affinity); if (irq < 0) return -ENXIO; =20 @@ -1221,10 +1223,7 @@ static int arm_spe_pmu_irq_probe(struct arm_spe_pmu = *spe_pmu) return -EINVAL; } =20 - if (irq_get_percpu_devid_partition(irq, &spe_pmu->supported_cpus)) { - dev_err(&pdev->dev, "failed to get PPI partition (%d)\n", irq); - return -EINVAL; - } + cpumask_copy(&spe_pmu->supported_cpus, affinity); =20 spe_pmu->irq =3D irq; return 0; --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 251453101A0; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349110; cv=none; b=pCaLLTFxP2fFo5oxgoORPv3Bb16ucaW9v+xqsAcJj0pUy1TtEe+4GHW3BQssjcmRt2OrBmE4m8Riow4qdroYDBs7Z1JWIsWu3n/6SUrfzook/eITxxR2BOp5PU9E7Go+GMl44zuADWdB2wHwOivgaLfiOO0XrQPKtjrMtzVsCwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349110; c=relaxed/simple; bh=hcTRxpX9qydE6c0M6SiJkgotsgvSQLYSwolxDoJawY4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZuvSg3yIpMtbPB2uUsUrZ9ff4SInGSxljCJrC9+GBto2ZrQctohNbO7KyPuGBgMqjQJXKr+oG7waFwZqy1IvxMI02/YVYttDUq48ub6xd4xpMCt3N2PLPXEHtbmOBoo5ke7+S5R7D5RHcQveBiiOjHYNQj/eECRAPKG9/6DN1cs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E+By+vs2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E+By+vs2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07844C4CEF7; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349110; bh=hcTRxpX9qydE6c0M6SiJkgotsgvSQLYSwolxDoJawY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+By+vs2uH3WX2TdZxlAnscUHM7nb6lslD3pfimdi/HZXVzxyYOEZC79HuxnYKau6 GD9o5c46Ww/nHRBk+0Xj+jg8p3doV1VXS08HwSgppdw5X6NIOXsITmcBpbA/AKyjSm 6i+3SH4SniGWUyOS/uTSkzaayOUR54/n6ovU3fhVleQ2BOBvPSj3Rqiomi369Stxrk lN4YOg+ZfYcMIHsNlnW/BdZhLP4vOEtl1dN3o7ALvL6EJGNDlCDoyI5A7I4UIsSnXw 8paPNWR2aezWc/Kl8WzaYiHXhLsbEpLNg+wkzFZpxyx66+Y081izuxen++mEU2ScYO 8HWdRaaKv4Rbw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemS-00000004NTm-0vcu; Mon, 08 Sep 2025 16:31:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 10/25] perf: arm_pmu: Add PMU/CPU affinity tracking Date: Mon, 8 Sep 2025 17:31:12 +0100 Message-Id: <20250908163127.2462948-11-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" The ARM PMU code is built around the assumption that different CPU affinities (either a single CPU in the case of an SPI, or a group of CPUs for a PPI) must result in different IRQ numbers. This scheme is about to be removed, so the driver must be able to match the new behaviour. For this purpose, add a new per-CPU variable that tracks the PMU affinities on a per-CPU basis, so that the driver can, from any CPU, find out which other CPUs it is sharing an interrupt number with. It is likely that some simplifications could result from this scheme, but this is good enough to get started. Signed-off-by: Marc Zyngier --- drivers/perf/arm_pmu.c | 37 +++++++++++++++++++++++++-------- drivers/perf/arm_pmu_acpi.c | 5 +++++ drivers/perf/arm_pmu_platform.c | 4 ++++ include/linux/perf/arm_pmu.h | 1 + 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 5c310e803dd78..6e3c72e9b41cd 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -26,7 +26,7 @@ =20 #include =20 -static int armpmu_count_irq_users(const int irq); +static int armpmu_count_irq_users(const int this_cpu, const int irq); =20 struct pmu_irq_ops { void (*enable_pmuirq)(unsigned int irq); @@ -64,7 +64,7 @@ static void armpmu_enable_percpu_pmuirq(unsigned int irq) static void armpmu_free_percpu_pmuirq(unsigned int irq, int cpu, void __percpu *devid) { - if (armpmu_count_irq_users(irq) =3D=3D 1) + if (armpmu_count_irq_users(cpu, irq) =3D=3D 1) free_percpu_irq(irq, devid); } =20 @@ -89,7 +89,7 @@ static void armpmu_disable_percpu_pmunmi(unsigned int irq) static void armpmu_free_percpu_pmunmi(unsigned int irq, int cpu, void __percpu *devid) { - if (armpmu_count_irq_users(irq) =3D=3D 1) + if (armpmu_count_irq_users(cpu, irq) =3D=3D 1) free_percpu_nmi(irq, devid); } =20 @@ -100,11 +100,20 @@ static const struct pmu_irq_ops percpu_pmunmi_ops =3D= { }; =20 DEFINE_PER_CPU(struct arm_pmu *, cpu_armpmu); +static DEFINE_PER_CPU(const struct cpumask *, pmu_affinity); static DEFINE_PER_CPU(int, cpu_irq); static DEFINE_PER_CPU(const struct pmu_irq_ops *, cpu_irq_ops); =20 static bool has_nmi; =20 +void armpmu_register_affinity_group(const struct cpumask *aff_grp) +{ + int cpu; + + for_each_cpu(cpu, aff_grp) + per_cpu(pmu_affinity, cpu) =3D aff_grp; +} + static inline u64 arm_pmu_event_max_period(struct perf_event *event) { if (event->hw.flags & ARMPMU_EVT_64BIT) @@ -580,11 +589,16 @@ static const struct attribute_group armpmu_common_att= r_group =3D { .attrs =3D armpmu_common_attrs, }; =20 -static int armpmu_count_irq_users(const int irq) +static int armpmu_count_irq_users(const int this_cpu, const int irq) { + const struct cpumask *affinity; int cpu, count =3D 0; =20 - for_each_possible_cpu(cpu) { + affinity =3D per_cpu(pmu_affinity, this_cpu); + if (WARN_ON(!affinity)) + return 0; + + for_each_cpu(cpu, affinity) { if (per_cpu(cpu_irq, cpu) =3D=3D irq) count++; } @@ -592,12 +606,17 @@ static int armpmu_count_irq_users(const int irq) return count; } =20 -static const struct pmu_irq_ops *armpmu_find_irq_ops(int irq) +static const struct pmu_irq_ops *armpmu_find_irq_ops(int this_cpu, int irq) { const struct pmu_irq_ops *ops =3D NULL; + const struct cpumask *affinity; int cpu; =20 - for_each_possible_cpu(cpu) { + affinity =3D per_cpu(pmu_affinity, this_cpu); + if (!affinity) + return NULL; + + for_each_cpu(cpu, affinity) { if (per_cpu(cpu_irq, cpu) !=3D irq) continue; =20 @@ -658,7 +677,7 @@ int armpmu_request_irq(int irq, int cpu) has_nmi =3D true; irq_ops =3D &pmunmi_ops; } - } else if (armpmu_count_irq_users(irq) =3D=3D 0) { + } else if (armpmu_count_irq_users(cpu, irq) =3D=3D 0) { err =3D request_percpu_nmi(irq, handler, "arm-pmu", &cpu_armpmu); =20 /* If cannot get an NMI, get a normal interrupt */ @@ -672,7 +691,7 @@ int armpmu_request_irq(int irq, int cpu) } } else { /* Per cpudevid irq was already requested by another CPU */ - irq_ops =3D armpmu_find_irq_ops(irq); + irq_ops =3D armpmu_find_irq_ops(cpu, irq); =20 if (WARN_ON(!irq_ops)) err =3D -EINVAL; diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index 05dda19c5359a..a5956fa728070 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -212,6 +212,11 @@ static int arm_pmu_acpi_parse_irqs(void) pr_warn("No ACPI PMU IRQ for CPU%d\n", cpu); } =20 + if (irq_is_percpu_devid(irq)) + armpmu_register_affinity_group(cpu_possible_mask); + else + armpmu_register_affinity_group(cpumask_of(cpu)); + /* * Log and request the IRQ so the core arm_pmu code can manage * it. We'll have to sanity-check IRQs later when we associate diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platfor= m.c index 9c0494d8a867a..0c7d5065e9074 100644 --- a/drivers/perf/arm_pmu_platform.c +++ b/drivers/perf/arm_pmu_platform.c @@ -53,6 +53,8 @@ static int pmu_parse_percpu_irq(struct arm_pmu *pmu, int = irq, for_each_cpu(cpu, &pmu->supported_cpus) per_cpu(hw_events->irq, cpu) =3D irq; =20 + armpmu_register_affinity_group(&pmu->supported_cpus); + return 0; } =20 @@ -152,6 +154,8 @@ static int pmu_parse_irqs(struct arm_pmu *pmu) cpumask_set_cpu(cpu, &pmu->supported_cpus); } =20 + armpmu_register_affinity_group(&pmu->supported_cpus); + return 0; } =20 diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 93c9a26492fcf..7bf548678b288 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -171,6 +171,7 @@ struct pmu_probe_info { int arm_pmu_device_probe(struct platform_device *pdev, const struct of_device_id *of_table, const struct pmu_probe_info *probe_table); +void armpmu_register_affinity_group(const struct cpumask *); =20 #ifdef CONFIG_ACPI int arm_pmu_acpi_probe(armpmu_init_fn init_fn); --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD4C9310647; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; cv=none; b=fXy/EQxhOxsUhXpYevnjzvXXohdglaY66aiFE5zoOGe5kqUgLyPXZ5atlAbAKRTTmg55iFlLAU+EhkTUaJvYQuU4336x3elH6B8CYYUqR6WyuATSHrBMzpOVDMrlBtt40ZWuIKql4yyIzyPv2kzIlMq0ggwVr/OpLLRW4og8UVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; c=relaxed/simple; bh=FpP+wQwpUSsvvoV5l0PFF2kZyltIOuG1yyX8/6val7c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bh18PqbRusg4VOmRM1bo40iNPyWiuAlE3OqHQ2Uf0/cY03BmCKyMBlDfbou36XgN5baHhWUlqEUpbWxlk2nCKy2vbMN4G/WuAJKn/0N8VJYvc+a4gxzEMHhoOfpAJ5FOkA8JfZa04+NuQ/daLlGSwRdb7t9ATX1de1kC4Guw+kA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=awFb+qx9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="awFb+qx9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 970ABC4CEF1; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349110; bh=FpP+wQwpUSsvvoV5l0PFF2kZyltIOuG1yyX8/6val7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=awFb+qx93m7wK7Lp9ei/bQMnb/uaAZw5ZDrOiZoPp80OE+U6MV9OSM8hwjjBHFfTi rE64OCFNiDXu1kVsGT2ZW8iZlAe5e/+UyMjGhlqez3PUK218SC2qcwlay2LklC1ohr hOItsAIzYX2J9zRScejz6nfXvyzG2DlYf2jsO4UBYeABwuO5G60yR72Hkqb/k2mbIN sSHWhUyE4MsrTggGvasug86bfzLwCmhGypdvnI/Eq/08WuUwEI9pBG7WdnSv+oEsw4 VK0UQANe2i0PcLJeirWelzRtb3l3d7PpWbe0uDUt/YS5N4zOI7igp3KH45poBCywRr qE+HFv/n7N1rQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemS-00000004NTm-28Kl; Mon, 08 Sep 2025 16:31:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 11/25] genirq: Merge irqaction::{dev_id,percpu_dev_id} Date: Mon, 8 Sep 2025 17:31:13 +0100 Message-Id: <20250908163127.2462948-12-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" When irqaction::percpu_dev_id was introduced, it was hoped that it could be part of an anonymous union with dev_id, as the two fields are mutually exclusive. However, toolchains used at the time were often showing terrible support for anonymous unions, breaking the build on a number of architectures. It was therefore decided to keep the two fields separate and address this down the line. 14 years later, the compiler dark age is over, and there is universal support for anonymous unions. Let's get a whole pointer back that can immediately be spent on something else. Signed-off-by: Marc Zyngier --- include/linux/interrupt.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 51b6484c04934..0ec1a71ab4e84 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -121,8 +121,10 @@ typedef irqreturn_t (*irq_handler_t)(int, void *); */ struct irqaction { irq_handler_t handler; - void *dev_id; - void __percpu *percpu_dev_id; + union { + void *dev_id; + void __percpu *percpu_dev_id; + }; struct irqaction *next; irq_handler_t thread_fn; struct task_struct *thread; --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD45A31063C; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; cv=none; b=F2MqRYCogtXqqfaMAW9AgbRnuJDEiKNCmVvppM2cQdDS6q9U8xS2glkZvLK3xcZ8iGFUNT85d9B2rNmioEdnYu+k75Gw7O9lN765kY1UpmWIOGGUjsqwWYVXncOG0ZP2HY1DkSYEq5tS+ecj6r4H+Oj32EkuzmJdm9fvqgxaRbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; c=relaxed/simple; bh=XC3nFMPldlcTKlF+TEOKY4soVqHzT0ijx8A2DSyOmkw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lu6Q38WuJazYn5yN0iKZbD+PFcCd9rLp/0R/9b9aeUMNFMtOqCeTwdMvs8TGeLjIRJPQn5/aYrXcm81kHCh/uZqYhguhGuThfRPfeSb4I2+BNrVe3Y/R0lglkPVjrGY03DWZr8uE6bMc6DfI8rzY8GfSieeJYkYMRQoKR8zOeO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jDFD9prO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jDFD9prO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C37EC4CEF9; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349110; bh=XC3nFMPldlcTKlF+TEOKY4soVqHzT0ijx8A2DSyOmkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jDFD9prOYYwCBSfg0kQl7boxExmmU+sjzMOgL0Tqqgj0qyDHRNdYO5ySJ6Kp2IQxi /4OV03FqYsR/f+Q4m/2TiP2Lzqriz1bxA9lwWLUBso68g1d2J3d+VIjPC43LWKS/j7 o1N1DAOsxNydyaXCYL1U3NnXi/BxVQQlH9NTxv0+g8MkWF36Wi5YfzFF+cbXlB7ARJ 6DYy7eRpXYyeH9vwkfXeCIVvTSlFiCF88jikQysvta7X4TtnVKbjntGlR7ZZpH/1xQ nybYWAa1lrcw4V1QeZoF4vcKzQeqQm8dCzW082iBhpE+HpMQxBarUTZYB5pWzLYp2K 5gCwAleIZuCRg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemS-00000004NTm-3EzL; Mon, 08 Sep 2025 16:31:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 12/25] genirq: Factor-in percpu irqaction creation Date: Mon, 8 Sep 2025 17:31:14 +0100 Message-Id: <20250908163127.2462948-13-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Move the code creating a per-cpu irqaction into its own helper, so that future changes to this code can be kept localised. At the same time, fix the documentation which appears to say the wrong thing when it comes to interrupts being automatically enabled (percpu_devid interrupts never are). Signed-off-by: Marc Zyngier --- kernel/irq/manage.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index c94837382037e..980725bd93e95 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2442,6 +2442,26 @@ int setup_percpu_irq(unsigned int irq, struct irqact= ion *act) return retval; } =20 +static +struct irqaction *create_percpu_irqaction(irq_handler_t handler, + unsigned long flags, + const char *devname, + void __percpu *dev_id) +{ + struct irqaction *action; + + action =3D kzalloc(sizeof(struct irqaction), GFP_KERNEL); + if (!action) + return NULL; + + action->handler =3D handler; + action->flags =3D flags | IRQF_PERCPU | IRQF_NO_SUSPEND; + action->name =3D devname; + action->percpu_dev_id =3D dev_id; + + return action; +} + /** * __request_percpu_irq - allocate a percpu interrupt line * @irq: Interrupt line to allocate @@ -2450,9 +2470,9 @@ int setup_percpu_irq(unsigned int irq, struct irqacti= on *act) * @devname: An ascii name for the claiming device * @dev_id: A percpu cookie passed back to the handler function * - * This call allocates interrupt resources and enables the interrupt on the - * local CPU. If the interrupt is supposed to be enabled on other CPUs, it - * has to be done on each CPU using enable_percpu_irq(). + * This call allocates interrupt resources, but doesn't enable the interru= pt + * on any CPU, as all percpu-devid interrupts are flagged with IRQ_NOAUTOE= N. + * It has to be done on each CPU using enable_percpu_irq(). * * @dev_id must be globally unique. It is a per-cpu variable, and * the handler gets called with the interrupted CPU's instance of @@ -2477,15 +2497,10 @@ int __request_percpu_irq(unsigned int irq, irq_hand= ler_t handler, if (flags && flags !=3D IRQF_TIMER) return -EINVAL; =20 - action =3D kzalloc(sizeof(struct irqaction), GFP_KERNEL); + action =3D create_percpu_irqaction(handler, flags, devname, dev_id); if (!action) return -ENOMEM; =20 - action->handler =3D handler; - action->flags =3D flags | IRQF_PERCPU | IRQF_NO_SUSPEND; - action->name =3D devname; - action->percpu_dev_id =3D dev_id; - retval =3D irq_chip_pm_get(&desc->irq_data); if (retval < 0) { kfree(action); @@ -2546,16 +2561,12 @@ int request_percpu_nmi(unsigned int irq, irq_handle= r_t handler, if (irq_is_nmi(desc)) return -EINVAL; =20 - action =3D kzalloc(sizeof(struct irqaction), GFP_KERNEL); + action =3D create_percpu_irqaction(handler, + IRQF_NO_THREAD | IRQF_NOBALANCING, + name, dev_id); if (!action) return -ENOMEM; =20 - action->handler =3D handler; - action->flags =3D IRQF_PERCPU | IRQF_NO_SUSPEND | IRQF_NO_THREAD - | IRQF_NOBALANCING; - action->name =3D name; - action->percpu_dev_id =3D dev_id; - retval =3D irq_chip_pm_get(&desc->irq_data); if (retval < 0) goto err_out; --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 669D73112C3; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; cv=none; b=LtuCQEp5mDcBJawMYT24Oc00ZGvI+Qmju1efiazdarkAUbw3Yo9s8H7x2zLV5xKlkfm+OtFnEmJFc1LFhbkyNfTmOVFcFiFU1wwg8XdflFgbIbyxgi+KgNMVnjMmmO3E4Wh/LDZe9ws1oZSvbU5YABTc8Sa5psUGaKXu4HYUYLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; c=relaxed/simple; bh=sEOwaQI0DOMRXSsbHn/28FN+LFNb2hLejQ1sYBs7F+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OSuJqSYROlGGuHAZv/CWH1Mc5etGN+Sl/PiX0yWDvPvbTSBIUP6GO8GLSwg1SGSql6uMiN8ysfVkI835CsPJQwj5mbX7RX+Si62NOuVxZRhrYomYp6kdxJLQmiOd/2SFFU9v6k7Y6tHfa9/TkytUuI5UUpx+X7FvT6jfaY7m5Ko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D3IlUqh5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D3IlUqh5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1812C4CEF7; Mon, 8 Sep 2025 16:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349110; bh=sEOwaQI0DOMRXSsbHn/28FN+LFNb2hLejQ1sYBs7F+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3IlUqh5gqBgjMMhwQO1HFVXgv5q+agMYWsMDTP1qDxoi7uS4qf/u8o8/gSIXoIUT gbyiux5rvF+in9bPiLm10sJV+UoDjn8b2fe/qBInJnyRinzM2bbSpG6H+1D3qyPtc3 ZGYC7AtYqDZaRBCU5UMFs6XviTSps2vw8JWRR/onXdnxcmp3UXT8vKMxTFxSNbPFOJ ZVOzbyXhZZz8L0KO/1xVtoA7K+SNV3CvQGCM+CiR3+VPT4mtTovZC6bP6MdTWp053H r6Tu0ObaNfZc4V6AHuTe2Uks8ndTGKFehAT2ZYM2zsfqeYtLvA2tEpzBdZbpOKG0Q4 LqxFNjXXi9/iA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemT-00000004NTm-05uU; Mon, 08 Sep 2025 16:31:49 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 13/25] genirq: Add affinity to percpu_devid interrupt requests Date: Mon, 8 Sep 2025 17:31:15 +0100 Message-Id: <20250908163127.2462948-14-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Add an affinity field to both the irqaction structure and the interrupt request primitives. Nothing is making use of it yet, and the only value used it NULL, which is used as a shorthand for cpu_possible_mask. This will shortly get used with actual affinities. Signed-off-by: Marc Zyngier --- include/linux/interrupt.h | 5 +++-- kernel/irq/manage.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 0ec1a71ab4e84..52147d5f432b3 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -125,6 +125,7 @@ struct irqaction { void *dev_id; void __percpu *percpu_dev_id; }; + const struct cpumask *affinity; struct irqaction *next; irq_handler_t thread_fn; struct task_struct *thread; @@ -181,7 +182,7 @@ request_any_context_irq(unsigned int irq, irq_handler_t= handler, extern int __must_check __request_percpu_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *devname, - void __percpu *percpu_dev_id); + const cpumask_t *affinity, void __percpu *percpu_dev_id); =20 extern int __must_check request_nmi(unsigned int irq, irq_handler_t handler, unsigned long flags, @@ -192,7 +193,7 @@ request_percpu_irq(unsigned int irq, irq_handler_t hand= ler, const char *devname, void __percpu *percpu_dev_id) { return __request_percpu_irq(irq, handler, 0, - devname, percpu_dev_id); + devname, NULL, percpu_dev_id); } =20 extern int __must_check diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 980725bd93e95..ac394f0b422b8 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2446,10 +2446,14 @@ static struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned long flags, const char *devname, + const cpumask_t *affinity, void __percpu *dev_id) { struct irqaction *action; =20 + if (!affinity) + affinity =3D cpu_possible_mask; + action =3D kzalloc(sizeof(struct irqaction), GFP_KERNEL); if (!action) return NULL; @@ -2458,6 +2462,7 @@ struct irqaction *create_percpu_irqaction(irq_handler= _t handler, action->flags =3D flags | IRQF_PERCPU | IRQF_NO_SUSPEND; action->name =3D devname; action->percpu_dev_id =3D dev_id; + action->affinity =3D affinity; =20 return action; } @@ -2468,6 +2473,7 @@ struct irqaction *create_percpu_irqaction(irq_handler= _t handler, * @handler: Function to be called when the IRQ occurs. * @flags: Interrupt type flags (IRQF_TIMER only) * @devname: An ascii name for the claiming device + * @affinity: A cpumask describing the target CPUs for this interrupt * @dev_id: A percpu cookie passed back to the handler function * * This call allocates interrupt resources, but doesn't enable the interru= pt @@ -2480,7 +2486,7 @@ struct irqaction *create_percpu_irqaction(irq_handler= _t handler, */ int __request_percpu_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *devname, - void __percpu *dev_id) + const cpumask_t *affinity, void __percpu *dev_id) { struct irqaction *action; struct irq_desc *desc; @@ -2497,7 +2503,8 @@ int __request_percpu_irq(unsigned int irq, irq_handle= r_t handler, if (flags && flags !=3D IRQF_TIMER) return -EINVAL; =20 - action =3D create_percpu_irqaction(handler, flags, devname, dev_id); + action =3D create_percpu_irqaction(handler, flags, devname, + affinity, dev_id); if (!action) return -ENOMEM; =20 @@ -2563,7 +2570,7 @@ int request_percpu_nmi(unsigned int irq, irq_handler_= t handler, =20 action =3D create_percpu_irqaction(handler, IRQF_NO_THREAD | IRQF_NOBALANCING, - name, dev_id); + name, NULL, dev_id); if (!action) return -ENOMEM; =20 --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 47CD43112B3; Mon, 8 Sep 2025 16:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; cv=none; b=Aw60ZpWzzM3M+lvz51KRr7YytuKbZ65kFEC0JCXdPU7yYfiFIQdZmv9zvJYd6BWEJ7LP1Dn4dprvGKo5iWQLHTwH4215poImiKv83cKSeLXcxVVy0+eY93QjKlniJaxIwQKpEn3GHcJZoKCL26KoRPvYLXEqTvHvQ0mZjvDxfn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; c=relaxed/simple; bh=n5HinTVrUC0iRzxGfA4dpDcMkrhdGiAa5ZBfKj1EIe0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S06bVP8CQEd2DYwLrgKHRwGdmpK/koqKmGLyH9PeVLTYG72isWovIw/cmoxZCm5bWgzq9J//PQIaqMfiiucJlql4t/lgW3AzUU4WicRyYQDf56P8lukmtp016+Yp0f42ZuANaQJmL6PS1EjrojNT3ePIiTThUpmYApsVpxkjnsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BMj1Y7n/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BMj1Y7n/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 289F0C4CEF9; Mon, 8 Sep 2025 16:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349111; bh=n5HinTVrUC0iRzxGfA4dpDcMkrhdGiAa5ZBfKj1EIe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BMj1Y7n/8bLj7xCauG1DDxxqWp7/8Fnmr290aYmzsq/zgEalIiJ8h/kqrJKJVtP4O M/HIEVINJFVyTrTbhm+Suo7EZmF9fhhRvpxKVo6CEKR0nVef99pek1FC03DvbiRqAj ZsHda9SdCdT+RlPWH5YA/fKKwME0pfNi5NB07Xek9Ibi+W7sETzFZsUK5Rk2QW5/Jt dHgGk53wrncnhKFZs1L5I5vuHecwiQG/tmS6giHmHbXc1JM7mSXJxW0vBtFCUXDrIW xDq7mvKyEWHsnys31PSSKbm1+9wy1gZPqOADxhhVhrQk5PXx6Boocihse1/+SEiso0 wSr61+9XaQfpg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemT-00000004NTm-1F68; Mon, 08 Sep 2025 16:31:49 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 14/25] genirq: Update request_percpu_nmi() to take an affinity Date: Mon, 8 Sep 2025 17:31:16 +0100 Message-Id: <20250908163127.2462948-15-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Continue spreading the notion of affinity to the percpu interrupt request code by updating the call sites that use request_percpu_nmi() (all two of them) to take an affinity pointer. This pointer is firmly NULL for now. Signed-off-by: Marc Zyngier --- arch/arm64/kernel/smp.c | 2 +- drivers/perf/arm_pmu.c | 4 +++- include/linux/interrupt.h | 4 ++-- kernel/irq/manage.c | 11 +++++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 68cea3a4a35ca..6fb838eee2e7d 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -1094,7 +1094,7 @@ static void ipi_setup_sgi(int ipi) irq =3D ipi_irq_base + ipi; =20 if (ipi_should_be_nmi(ipi)) { - err =3D request_percpu_nmi(irq, ipi_handler, "IPI", &irq_stat); + err =3D request_percpu_nmi(irq, ipi_handler, "IPI", NULL, &irq_stat); WARN(err, "Could not request IRQ %d as NMI, err=3D%d\n", irq, err); } else { err =3D request_percpu_irq(irq, ipi_handler, "IPI", &irq_stat); diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 6e3c72e9b41cd..d1f738eb77f1e 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -678,7 +678,9 @@ int armpmu_request_irq(int irq, int cpu) irq_ops =3D &pmunmi_ops; } } else if (armpmu_count_irq_users(cpu, irq) =3D=3D 0) { - err =3D request_percpu_nmi(irq, handler, "arm-pmu", &cpu_armpmu); + err =3D request_percpu_nmi(irq, handler, "arm-pmu", + NULL, + &cpu_armpmu); =20 /* If cannot get an NMI, get a normal interrupt */ if (err) { diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 52147d5f432b3..2134e7c08c169 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -197,8 +197,8 @@ request_percpu_irq(unsigned int irq, irq_handler_t hand= ler, } =20 extern int __must_check -request_percpu_nmi(unsigned int irq, irq_handler_t handler, - const char *devname, void __percpu *dev); +request_percpu_nmi(unsigned int irq, irq_handler_t handler, const char *de= vname, + const struct cpumask *affinity, void __percpu *dev_id); =20 extern const void *free_irq(unsigned int, void *); extern void free_percpu_irq(unsigned int, void __percpu *); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index ac394f0b422b8..a17ac522622e7 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2530,6 +2530,7 @@ EXPORT_SYMBOL_GPL(__request_percpu_irq); * @irq: Interrupt line to allocate * @handler: Function to be called when the IRQ occurs. * @name: An ascii name for the claiming device + * @affinity: A cpumask describing the target CPUs for this interrupt * @dev_id: A percpu cookie passed back to the handler function * * This call allocates interrupt resources for a per CPU NMI. Per CPU NMIs @@ -2547,7 +2548,8 @@ EXPORT_SYMBOL_GPL(__request_percpu_irq); * will fail returning a negative value. */ int request_percpu_nmi(unsigned int irq, irq_handler_t handler, - const char *name, void __percpu *dev_id) + const char *name, + const struct cpumask *affinity, void __percpu *dev_id) { struct irqaction *action; struct irq_desc *desc; @@ -2564,13 +2566,14 @@ int request_percpu_nmi(unsigned int irq, irq_handle= r_t handler, !irq_supports_nmi(desc)) return -EINVAL; =20 - /* The line cannot already be NMI */ - if (irq_is_nmi(desc)) + /* The line cannot be NMI already if the new request covers all CPUs */ + if (irq_is_nmi(desc) && + (!affinity || cpumask_equal(affinity, cpu_possible_mask))) return -EINVAL; =20 action =3D create_percpu_irqaction(handler, IRQF_NO_THREAD | IRQF_NOBALANCING, - name, NULL, dev_id); + name, affinity, dev_id); if (!action) return -ENOMEM; =20 --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A41A9311580; Mon, 8 Sep 2025 16:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; cv=none; b=Q0lms0xz37fvd9AfB2NKocpYZXnPYGo/F7SO+dc4Z5KT8cJl07W7xCdf+0U5pQ8+QQTOyh8aHLH3+R/HeosUTAlwFaqMjz6uj+EMN2neuTNHxPLyYSyp1yHJ+qteWXX606XZ1W+0R7vwSQMqQmfYq9Wi40/e2h15awY/BmcGdhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; c=relaxed/simple; bh=Q/+zu+5tB3UsN0eWOWfFQqHDuwVMUrvVaWxWsxG4ILA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hoPT96cB5qW0CQsvFVA1WN4OBSsskQ+pAYqAg0ZDKKvk8sl0utjAoLOHmkLFFFdUv3Ir95ggJTDP7SPiuBsQObIGPx2WDo1Sp2hFSCCkt2Myl9fE2LtcDb+kvORODEKEnICaobOkih3fSfX3K3ZrjzzsYsb9ibXCBR2xVfYhD8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AshQby1j; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AshQby1j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66C75C4CEFD; Mon, 8 Sep 2025 16:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349111; bh=Q/+zu+5tB3UsN0eWOWfFQqHDuwVMUrvVaWxWsxG4ILA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AshQby1jiypVhgYFlA/bV62XZaVP5bnskJrcQ/58HrH+2PtgjNbKzxWN+PvCWzYS3 NbXXHSumhHB6odRpwEv9wXoQ8bf7q+6PeOuoxs7oVYTRMzMivgbiccQUv4qGlGglrT fnBuTI5BrtYcJdtSbyOdNT9WxdTcBv3baXCJMcDWDpRzNmtkTZxrzCct0nx1qVuQzZ fQDGquJgqDlmYugFM9ESGK7qksrctdhb9Eb0xbNbepngRYfwdjIPT6vgm7CwGdtunH L2TawKim915dFzIwdKbeoRixmRauwEotkc/jp0mbQqW4DPe6VZ4EeTHv4Sr0clrNZl BEkkDgnuzupHQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemT-00000004NTm-2J2B; Mon, 08 Sep 2025 16:31:49 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 15/25] genirq: Allow per-cpu interrupt sharing for non-overlapping affinities Date: Mon, 8 Sep 2025 17:31:17 +0100 Message-Id: <20250908163127.2462948-16-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Interrupt sharing for percpu-devid interrupts is forbidden, and for good reasons. These are interrupts generated *from* a CPU and handled by itself (timer, for example). Nobody in their right mind would put two devices on the same pin (and if they have, they get to keep the pieces...). But this also prevents more benign cases, where devices are connected to groups of CPUs, and for which the affinities are not overlapping. Effectively, the only thing they share is the interrupt number, and nothing else. Let's tweak the definition of IRQF_SHARED applied to percpu_devid interrupts to allow this particular case. This results in extra validation at the point of the interrupt being setup and freed, as well as a tiny bit of extra complexity for interrupts at handling time (to pick the correct irqaction). Signed-off-by: Marc Zyngier --- kernel/irq/chip.c | 8 ++++-- kernel/irq/manage.c | 67 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 0d0276378c707..af90dd440d5ee 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -897,8 +897,9 @@ void handle_percpu_irq(struct irq_desc *desc) void handle_percpu_devid_irq(struct irq_desc *desc) { struct irq_chip *chip =3D irq_desc_get_chip(desc); - struct irqaction *action =3D desc->action; unsigned int irq =3D irq_desc_get_irq(desc); + unsigned int cpu =3D smp_processor_id(); + struct irqaction *action; irqreturn_t res; =20 /* @@ -910,12 +911,15 @@ void handle_percpu_devid_irq(struct irq_desc *desc) if (chip->irq_ack) chip->irq_ack(&desc->irq_data); =20 + for (action =3D desc->action; action; action =3D action->next) + if (cpumask_test_cpu(cpu, action->affinity)) + break; + if (likely(action)) { trace_irq_handler_entry(irq, action); res =3D action->handler(irq, raw_cpu_ptr(action->percpu_dev_id)); trace_irq_handler_exit(irq, action, res); } else { - unsigned int cpu =3D smp_processor_id(); bool enabled =3D cpumask_test_cpu(cpu, desc->percpu_enabled); =20 if (enabled) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index a17ac522622e7..1ac79df0e5f76 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1418,6 +1418,19 @@ setup_irq_thread(struct irqaction *new, unsigned int= irq, bool secondary) return 0; } =20 +static bool valid_percpu_irqaction(struct irqaction *old, struct irqaction= *new) +{ + do { + if (cpumask_intersects(old->affinity, new->affinity) || + old->percpu_dev_id =3D=3D new->percpu_dev_id) + return false; + + old =3D old->next; + } while (old); + + return true; +} + /* * Internal function to register an irqaction - typically used to * allocate special interrupts that are part of the architecture. @@ -1438,6 +1451,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, = struct irqaction *new) struct irqaction *old, **old_ptr; unsigned long flags, thread_mask =3D 0; int ret, nested, shared =3D 0; + bool per_cpu_devid; =20 if (!desc) return -EINVAL; @@ -1447,6 +1461,8 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, = struct irqaction *new) if (!try_module_get(desc->owner)) return -ENODEV; =20 + per_cpu_devid =3D irq_settings_is_per_cpu_devid(desc); + new->irq =3D irq; =20 /* @@ -1554,13 +1570,20 @@ __setup_irq(unsigned int irq, struct irq_desc *desc= , struct irqaction *new) */ unsigned int oldtype; =20 - if (irq_is_nmi(desc)) { + if (irq_is_nmi(desc) && !per_cpu_devid) { pr_err("Invalid attempt to share NMI for %s (irq %d) on irqchip %s.\n", new->name, irq, desc->irq_data.chip->name); ret =3D -EINVAL; goto out_unlock; } =20 + if (per_cpu_devid && !valid_percpu_irqaction(old, new)) { + pr_err("Overlapping affinities for %s (irq %d) on irqchip %s.\n", + new->name, irq, desc->irq_data.chip->name); + ret =3D -EINVAL; + goto out_unlock; + } + /* * If nobody did set the configuration before, inherit * the one provided by the requester. @@ -1711,7 +1734,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, = struct irqaction *new) if (!(new->flags & IRQF_NO_AUTOEN) && irq_settings_can_autoenable(desc)) { irq_startup(desc, IRQ_RESEND, IRQ_START_COND); - } else { + } else if (!per_cpu_devid) { /* * Shared interrupts do not go well with disabling * auto enable. The sharing interrupt might request @@ -2346,7 +2369,7 @@ void disable_percpu_nmi(unsigned int irq) static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu= *dev_id) { struct irq_desc *desc =3D irq_to_desc(irq); - struct irqaction *action; + struct irqaction *action, **action_ptr; =20 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); =20 @@ -2354,21 +2377,33 @@ static struct irqaction *__free_percpu_irq(unsigned= int irq, void __percpu *dev_ return NULL; =20 scoped_guard(raw_spinlock_irqsave, &desc->lock) { - action =3D desc->action; - if (!action || action->percpu_dev_id !=3D dev_id) { - WARN(1, "Trying to free already-free IRQ %d\n", irq); - return NULL; + action_ptr =3D &desc->action; + for (;;) { + action =3D *action_ptr; + + if (!action) { + WARN(1, "Trying to free already-free IRQ %d\n", irq); + return NULL; + } + + if (action->percpu_dev_id =3D=3D dev_id) + break; + + action_ptr =3D &action->next; } =20 - if (!cpumask_empty(desc->percpu_enabled)) { - WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", - irq, cpumask_first(desc->percpu_enabled)); + if (cpumask_intersects(desc->percpu_enabled, action->affinity)) { + WARN(1, "percpu IRQ %d still enabled on CPU%d!\n", irq, + cpumask_first_and(desc->percpu_enabled, action->affinity)); return NULL; } =20 /* Found it - now remove it from the list of entries: */ - desc->action =3D NULL; - desc->istate &=3D ~IRQS_NMI; + *action_ptr =3D action->next; + + /* Demote from NMI if we killed the last action */ + if (!desc->action) + desc->istate &=3D ~IRQS_NMI; } =20 unregister_handler_proc(irq, action); @@ -2464,6 +2499,14 @@ struct irqaction *create_percpu_irqaction(irq_handle= r_t handler, action->percpu_dev_id =3D dev_id; action->affinity =3D affinity; =20 + /* + * We allow some form of sharing for non-overlapping affinity + * masks. Obviously, covering all CPUs prevents any sharing + * the first place. + */ + if (!cpumask_equal(affinity, cpu_possible_mask)) + action->flags |=3D IRQF_SHARED; + return action; } =20 --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CA84231158E; Mon, 8 Sep 2025 16:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; cv=none; b=XMB/4iNs7JzCTO6xdhmKcjTyiHrKVW4G+KlqzGFGt1pQ3pwzU5nf4e1wAD5TIJGqKhuIFBNjmD+jwCNb/bQY+8eg5IQCcPGaCDU5MdgMjKAHnhjEP3eHL5K1H4nb9+wpwsVJdeCqQ4x/0frrVxmuB6ajxh8tCeo6xK+M0tcoIJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349111; c=relaxed/simple; bh=a5Pq4IyChIRNpCI1Y1MOptr/VB0oiXKYMj/CA7z9q3U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JBciswz1v8hRl2G8i+cekq2UMs2byPWca75u9jI7rZMsNTtKBoF8Dn/UiR72yKXPy4rSFwCP4kuL8Vh4i1uGmvsx61ExwmV0I4lct49FZtk0T6qkCB4qpkWo6UNtchRMq0VCyZZ4V3XxQktQe2T5KLfMll3gX/6WDeHt637J+vw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gy95G8ma; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gy95G8ma" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9F10C4CEFA; Mon, 8 Sep 2025 16:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349111; bh=a5Pq4IyChIRNpCI1Y1MOptr/VB0oiXKYMj/CA7z9q3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gy95G8maMfmMge8QcGPbs+tYvH4MiN/OP8OT3gniHAqU2h5Ck5FJSgJ+QBhs0hqKw sRikmTOW7kvJWgzdo//bRwXLGAZdl/Hb4NlTkl6VrgZE7N46g8CdH9HqJ3/KgGz9i5 5PEcIHYp3jbMyTm8mxarLTZRvjbaGRtsPMWdCESy5lrLSipzOQvlMxSZd6mvfsI4Ec nd56LJQkuA1gcYq4WwcoZbooFMEOrbUmb/0P/2Ot5/Ljaj74JaXmSdst5pZ8K+yevE O15J62feK2gLgIMi9xi390ijkPUq7MZLYnZjC9wq6PSSDbO2siBhBW0xZ37HKcEPZK bOJcEkIGAlHfg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemT-00000004NTm-3XkI; Mon, 08 Sep 2025 16:31:49 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 16/25] genirq: Add request_percpu_irq_affinity() helper Date: Mon, 8 Sep 2025 17:31:18 +0100 Message-Id: <20250908163127.2462948-17-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" While it would be nice to simply make request_percpu_irq() take an affinity mask, the churn is likely to be on the irritating side given that most drivers do not give a damn about affinities. So take the more innocuous path to provide a helper that parallels request_percpu_irq(), with an affinity as a bonus argument. Yes, request_percpu_irq_affinity() is a bit of a mouthful. Signed-off-by: Marc Zyngier --- include/linux/interrupt.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 2134e7c08c169..c8e6f4895782c 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -196,6 +196,15 @@ request_percpu_irq(unsigned int irq, irq_handler_t han= dler, devname, NULL, percpu_dev_id); } =20 +static inline int __must_check +request_percpu_irq_affinity(unsigned int irq, irq_handler_t handler, + const char *devname, const cpumask_t *affinity, + void __percpu *percpu_dev_id) +{ + return __request_percpu_irq(irq, handler, 0, + devname, affinity, percpu_dev_id); +} + extern int __must_check request_percpu_nmi(unsigned int irq, irq_handler_t handler, const char *de= vname, const struct cpumask *affinity, void __percpu *dev_id); --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1E2913115B5; Mon, 8 Sep 2025 16:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349112; cv=none; b=G8dlqYKWZhKOEH/62keQwUrQ/fOmrEe/qtoR+qDLS+ki3XRI2MHemOP9KQxc1QrnV99fLnrs3v5amgaW25uFEyKTLI3lHyKg4uux2KTm6FYTYSjxKJKqc64sEBP1tbm2iS2S0DtqGfeMocnsbixPreOgoE/+tgeJJf/6kPjoI6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349112; c=relaxed/simple; bh=BheY/4Tjx4s0jW8mBSJJ3tgbkDMxPNLTTZYFhhqSOcQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bePzx1jgLL7gXcHehPffO5xwxjY7v+sBc89QWHJ05NMk/LMGJO+zkZL84hThulBJpemVbauELPxgozBn+Al2Q0v7k+rvpxYay/sug5EosrFJXA4qIZA5Ho+QVzPXUC15IDvHsze8euZXMuyco3m0b+VpAqJVLTTrleNzyFKsCCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EqFRbLKd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EqFRbLKd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA470C4CEF7; Mon, 8 Sep 2025 16:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349112; bh=BheY/4Tjx4s0jW8mBSJJ3tgbkDMxPNLTTZYFhhqSOcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EqFRbLKdD5duE5VlTat2zDtmpG9tuOra0yPYcPrKx3AD7lQNnCdqzVLhy4ZfypfKe /DhkH7nW3Xn+jNtljL339pZmySnOB6ElNQ92+PuumUl5q7QB4tZsXPdhSU74CKSjEn KulEOfgTDqG7HCVEJFQzg9ZMQ+flubWCucMv1Mab8uMRSkXPfoWjnu70AJuPanMpYn Au8M4q0cKvUQcfQAumx6HCwvgdYXPA6ahQ+HtPLMeMT0zvILXfMffONOiAqnLaSeht qMfGmtxOFoC6hiWSVHUs0Reolinw8PUZHY4ujlSKdBJSxCqgLGVVhnMBZmfbArCN6t ndNeNIcGMnfig== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemU-00000004NTm-0VTl; Mon, 08 Sep 2025 16:31:50 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 17/25] perf: arm_pmu: Use a backend-specific pointer for percpu interrupt request Date: Mon, 8 Sep 2025 17:31:19 +0100 Message-Id: <20250908163127.2462948-18-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" From: Will Deacon DT and ACPI significantly differ in the way the PMU probing is conducted, resulting in different data being available at different times. Work around this by providing a per-cpu 'struct arm_pmu *' as a parameter, instead of sampling it from a per-cpu variable. Signed-off-by: Will Deacon Signed-off-by: Marc Zyngier --- drivers/perf/arm_pmu.c | 10 +++++----- drivers/perf/arm_pmu_acpi.c | 2 +- drivers/perf/arm_pmu_platform.c | 4 ++-- include/linux/perf/arm_pmu.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index d1f738eb77f1e..044c9c6296997 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -628,20 +628,20 @@ static const struct pmu_irq_ops *armpmu_find_irq_ops(= int this_cpu, int irq) return ops; } =20 -void armpmu_free_irq(int irq, int cpu) +void armpmu_free_irq(struct arm_pmu * __percpu *armpmu, int irq, int cpu) { if (per_cpu(cpu_irq, cpu) =3D=3D 0) return; if (WARN_ON(irq !=3D per_cpu(cpu_irq, cpu))) return; =20 - per_cpu(cpu_irq_ops, cpu)->free_pmuirq(irq, cpu, &cpu_armpmu); + per_cpu(cpu_irq_ops, cpu)->free_pmuirq(irq, cpu, armpmu); =20 per_cpu(cpu_irq, cpu) =3D 0; per_cpu(cpu_irq_ops, cpu) =3D NULL; } =20 -int armpmu_request_irq(int irq, int cpu) +int armpmu_request_irq(struct arm_pmu * __percpu *armpmu, int irq, int cpu) { int err =3D 0; const irq_handler_t handler =3D armpmu_dispatch_irq; @@ -666,12 +666,12 @@ int armpmu_request_irq(int irq, int cpu) IRQF_NO_THREAD; =20 err =3D request_nmi(irq, handler, irq_flags, "arm-pmu", - per_cpu_ptr(&cpu_armpmu, cpu)); + per_cpu_ptr(armpmu, cpu)); =20 /* If cannot get an NMI, get a normal interrupt */ if (err) { err =3D request_irq(irq, handler, irq_flags, "arm-pmu", - per_cpu_ptr(&cpu_armpmu, cpu)); + per_cpu_ptr(armpmu, cpu)); irq_ops =3D &pmuirq_ops; } else { has_nmi =3D true; diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index a5956fa728070..a28352e2bff0a 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -223,7 +223,7 @@ static int arm_pmu_acpi_parse_irqs(void) * them with their PMUs. */ per_cpu(pmu_irqs, cpu) =3D irq; - err =3D armpmu_request_irq(irq, cpu); + err =3D armpmu_request_irq(&probed_pmus, irq, cpu); if (err) goto out_err; } diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platfor= m.c index 0c7d5065e9074..d9b0e8f6debf2 100644 --- a/drivers/perf/arm_pmu_platform.c +++ b/drivers/perf/arm_pmu_platform.c @@ -169,7 +169,7 @@ static int armpmu_request_irqs(struct arm_pmu *armpmu) if (!irq) continue; =20 - err =3D armpmu_request_irq(irq, cpu); + err =3D armpmu_request_irq(&hw_events->percpu_pmu, irq, cpu); if (err) break; } @@ -185,7 +185,7 @@ static void armpmu_free_irqs(struct arm_pmu *armpmu) for_each_cpu(cpu, &armpmu->supported_cpus) { int irq =3D per_cpu(hw_events->irq, cpu); =20 - armpmu_free_irq(irq, cpu); + armpmu_free_irq(&hw_events->percpu_pmu, irq, cpu); } } =20 diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 7bf548678b288..395d03c282e8c 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -191,8 +191,8 @@ bool arm_pmu_irq_is_nmi(void); struct arm_pmu *armpmu_alloc(void); void armpmu_free(struct arm_pmu *pmu); int armpmu_register(struct arm_pmu *pmu); -int armpmu_request_irq(int irq, int cpu); -void armpmu_free_irq(int irq, int cpu); +int armpmu_request_irq(struct arm_pmu * __percpu *armpmu, int irq, int cpu= ); +void armpmu_free_irq(struct arm_pmu * __percpu *armpmu, int irq, int cpu); =20 #define ARMV8_PMU_PDEV_NAME "armv8-pmu" =20 --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5EBA0311950; Mon, 8 Sep 2025 16:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349112; cv=none; b=QmE927BzwmNRVnOtcK6bdJvbJRyfo4Nt1ge//7mNn+n7H1D+S9yM0tuAN9uaSZrKvclnLIq1b7S8u+WKkNjwHdy4XkIlsPEfDDCzSgU3OBbzbEneQtCBG+4IQwQOB099q4ncs2fX4EAQqIDZSANjUTCx55zd8NwsC/zrV1pevTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349112; c=relaxed/simple; bh=34uZqtOIifxx7Qodt8KhbqZ4rpIhHdbh4fyeIBhH5VI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uOsEeg6YJogTiAlE/qtgwcoAXZ5yMnkXmj7OQgxdqH6nluNAGsQ6DuIWGEjhUxf+GffUlqn/lpoDqJu6L2wm/BQorlCCEoN5eQ7Jn+ovLIKammDd4ADiZwRoGdfDJ+U/0Q0tGsBBi3pX9mihkDzVY6Ym6NfzfTX1R/Omky84bPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fb5GFOK+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fb5GFOK+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B4D7C4CEF9; Mon, 8 Sep 2025 16:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349112; bh=34uZqtOIifxx7Qodt8KhbqZ4rpIhHdbh4fyeIBhH5VI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fb5GFOK+rgyb5ds0tm+g9TuE1oDCmwFV0CBYo9vFZmd8YHy+ziAnur9Fc0uODcq70 VlsYxCDDb6mG7ZJxKyMMK3rmARq3vK8/t017NkWGz51+sLNQ/tbyU1cZ4785d0cgdP dZJ2pic9pufNEpJhKg12mQYKuizvSp5N70lC7u6F7zwwmk+7/chpac0c4Q4iB9ouFf fAZvTLW0SJVGcXe71JKHtBEW6DOnA3pl/7/I2HGwajKbthlS49V1Bgn6glOP3n9UeB 2kYD1UZd2Hv941e5oe83PqpGPd8Hgyj9JXy0671n1EKGxoVaGclkrNLTeDJVMcYKUF cOgOpex6toBMA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemU-00000004NTm-1jcW; Mon, 08 Sep 2025 16:31:50 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 18/25] perf: arm_pmu: Request specific affinities for percpu NMI/IRQ Date: Mon, 8 Sep 2025 17:31:20 +0100 Message-Id: <20250908163127.2462948-19-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Let the PMU driver request both NMI and normal IRQs with an affinity mask matching the PMU affinity. Signed-off-by: Marc Zyngier --- drivers/perf/arm_pmu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 044c9c6296997..0d64e929d9bf0 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -679,13 +679,14 @@ int armpmu_request_irq(struct arm_pmu * __percpu *arm= pmu, int irq, int cpu) } } else if (armpmu_count_irq_users(cpu, irq) =3D=3D 0) { err =3D request_percpu_nmi(irq, handler, "arm-pmu", - NULL, - &cpu_armpmu); + per_cpu(pmu_affinity, cpu), + armpmu); =20 /* If cannot get an NMI, get a normal interrupt */ if (err) { - err =3D request_percpu_irq(irq, handler, "arm-pmu", - &cpu_armpmu); + err =3D request_percpu_irq_affinity(irq, handler, "arm-pmu", + per_cpu(pmu_affinity, cpu), + armpmu); irq_ops =3D &percpu_pmuirq_ops; } else { has_nmi =3D true; --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A9FF7311C06; Mon, 8 Sep 2025 16:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349112; cv=none; b=d/VocyPM7fLAYqLSWQl/p5SuH7tkrYJ2KHIM4vMnym970CvZKTzOwBXNb7wB/qE4T1/+puU37GJBDPGwa+6Vv4d3eUOg9mqPhrzcfcxLrGNUrzlsuod+PLxSdfKqBwxffM4fxy63PtjddgWB1rob9DL1zCmuTnAGf/OTSCsRNH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349112; c=relaxed/simple; bh=fWLFQJQCjHkUmgzJrwoVr3TR8ormeAz7AFVrQDQpANU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TTBqee5v0JN+vZws6RRqkCh6qf8JW0lz53LdxgqEeYQI2AA0Fc0U/Hp4srm8UT9AMaa8jPimjZ0L2RZWoPxg6YSDwd+cf9sXpWd5stqR2qW3Uf5MJZgYo+n6t1cZGImUgWu/MU6krVXZLaYM927b1buFu1yKi784G7LQpimT6XQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q4NCKVjt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q4NCKVjt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AEFAC113D0; Mon, 8 Sep 2025 16:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349112; bh=fWLFQJQCjHkUmgzJrwoVr3TR8ormeAz7AFVrQDQpANU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q4NCKVjt4aEI/Ymf/1sLgZyoe86T9ex/Kj9p4I6Z0B4AFpcvdcO6hM+A8rRNbH8EZ RmoQcV6fK8rTsBiysO5qtvGmiFNmowwqmkxpW7dMavzQA2jEgm7/LIbRBYs4YpTTU0 fobJOXMy6OVoEgJ3HZTbA/Rxz/Tlhd7j3eoMVXcxg0hB/ZnXl9qa9DSvPU1czpJHrw cd1DvYIIa88TqAb0PaEmdsd2tstM9MhINwHEWoitXAl1uQ6X/lLKnIc3yKw45Ak12o Oxsa5aJfi8DKAQVBRe163FRCHh+0Hlh9O1zDOF5KHEs0E3QESaAfrHjC9YQhD7p0FL sBVpFohL2ym6w== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemU-00000004NTm-2rYr; Mon, 08 Sep 2025 16:31:50 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 19/25] perf: arm_spe_pmu: Request specific affinities for percpu IRQ Date: Mon, 8 Sep 2025 17:31:21 +0100 Message-Id: <20250908163127.2462948-20-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Let the SPE driver request IRQs with an affinity mask matching the SPE implementation affinity. Signed-off-by: Marc Zyngier --- drivers/perf/arm_spe_pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index a1c86a1f21427..f8763f0771776 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -1183,8 +1183,8 @@ static int arm_spe_pmu_dev_init(struct arm_spe_pmu *s= pe_pmu) return -ENXIO; =20 /* Request our PPIs (note that the IRQ is still disabled) */ - ret =3D request_percpu_irq(spe_pmu->irq, arm_spe_pmu_irq_handler, DRVNAME, - spe_pmu->handle); + ret =3D request_percpu_irq_affinity(spe_pmu->irq, arm_spe_pmu_irq_handler, + DRVNAME, mask, spe_pmu->handle); if (ret) return ret; =20 --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 442043126D0; Mon, 8 Sep 2025 16:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349113; cv=none; b=j3WoJ4ozQAjo1A6gEOEsJaSRwFpqBvj2Rk/frL8IIWuz9hY7APdG/4CKx6MQJ1dhTWtmwXtThsK1Prcyd0Xdm2I+QS6mFyo3Zf2wLwvhi7A9IIYKXruHRSHrr3u+R91EIfCNHpu0u4mRfgEIFi5Wm2zqR3/QbKC64ggotdaBjoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349113; c=relaxed/simple; bh=Cd0M6Ctqz2mIs5KmsrNG7gPuEf0W9llFNTYE/JJTtFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fdxB5j+Cq8Yx8Wk/FTvejyBxarb4Bux32Tu+4nC1DlZ3Tk9W8ptx3iEY4FYBWQMK3sLn4PB9SYZYFWOOn95UrOeyWGaHNayBcPwmCS5k7EUwtWnWDgssLwf2ziMFLEcZhT3XxBXqb0ur8VAItky/6pd5Uv5dshV2vqUrqXiZX+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DIesmYif; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DIesmYif" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAE5CC4CEF1; Mon, 8 Sep 2025 16:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349112; bh=Cd0M6Ctqz2mIs5KmsrNG7gPuEf0W9llFNTYE/JJTtFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DIesmYifOvdX16j3YCLD9lZ9Az/eixAzUC8f9KuHxRA/QucvUQpSJkPNaZT3nPaZM gtVtf4KzPjKVs8EZhPBUUv9B/CaZc0QwEsO+r5L1mZM3F6m/oSSEM6Gu2yjgmIItkg 7VvwD97cUwm+NV5snctx9AE+UhN3xjmjsskQ2mwY5hKKckP9K3laRAf0M6THwr85CM EdYtvcVaX6nIuhdJerqEKzqGvP1kAV9D1flVysx67arg/GoOwQahiESu6A9cMZv5gR dfju2bgIiBWAKDVW/AQ4HU4rXzjhYfDL5Sox0z0i3rb3NfTZh3wED4OHXcGa4GjLTZ dEFv6EBrOizLg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemU-00000004NTm-41co; Mon, 08 Sep 2025 16:31:51 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 20/25] coresight: trbe: Request specific affinities for percpu IRQ Date: Mon, 8 Sep 2025 17:31:22 +0100 Message-Id: <20250908163127.2462948-21-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Let the TRBE driver request IRQs with an affinity mask matching the TRBE implementation affinity. Signed-off-by: Marc Zyngier --- drivers/hwtracing/coresight/coresight-trbe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtraci= ng/coresight/coresight-trbe.c index c512f8faa6012..4a84a6bc2e8fc 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -1492,7 +1492,8 @@ static int arm_trbe_probe_irq(struct platform_device = *pdev, if (!drvdata->handle) return -ENOMEM; =20 - ret =3D request_percpu_irq(drvdata->irq, arm_trbe_irq_handler, DRVNAME, d= rvdata->handle); + ret =3D request_percpu_irq_affinity(drvdata->irq, arm_trbe_irq_handler, D= RVNAME, + affinity, drvdata->handle); if (ret) { free_percpu(drvdata->handle); return ret; --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 480013126D1; Mon, 8 Sep 2025 16:31:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349113; cv=none; b=JVwy80csCrtNDLzpEgIXiBwcvjvsdcSBCSMAumonRMYvXjnt3TvmSX+lT7fuJiBO2rzOWR3WMHgSN8vR5oxTzdet7iHeGA0c0VsYnLdLWCFZ8d4GJ7q5pCAZcmvnSycHynz7Kwlk1vH8EFnRPWbnvT9oGrsFDuW01tur13CEy40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349113; c=relaxed/simple; bh=zMQRaJoyFUYzTVpLFAFRUWCGuYufHSxl4b1HcSp9Kzk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fmOI3s6HD0xNusF2vXEwlhmVwYS505oO9AoF0GINACGbpoL9finAASXjpwuk2BbuGpjByBTni2lVlfl2kfCKSTIlWy892W4G2yzUhJeLsQDSni56fUeei0LN4fucquADdsSyTQMJsJjq25r4nYPlwLCJOT+AiaI84HxfwN/yTII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f3V3amZs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f3V3amZs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 082EFC4AF0C; Mon, 8 Sep 2025 16:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349113; bh=zMQRaJoyFUYzTVpLFAFRUWCGuYufHSxl4b1HcSp9Kzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3V3amZsFt/DMSg/6ruYiOpg02JWsF8FSgfy4jJMdovBwN5rC36sF06JSoBXoMr1Q ifPdvY02d6yhKOi8a0Y0se3BgZ1x9+bfPhcLnKAU8elG8O8JYjN6bUMD3VbR5fJU47 o1RiYzVE4IcETTO46mz4Cq/pVBKpaEbpXCu1LLMob/bU/WkPJ6M21xGcGH2+l5LC3+ 4TJfap10a7QYCYpvnNarygNFxA2VadF/62vHBO+mQ91eXMBq4zA3yZcFzJU0dXi0Pi ZdPkwWJuAeXlgIpysulJ1rNAwmAZTWdrTV6s4q9lptnwLgdkPkbksz4kVQC0NY6B+Z tpNaVVuAIL9vw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemV-00000004NTm-0x1e; Mon, 08 Sep 2025 16:31:51 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 21/25] irqchip/gic-v3: Drop support for custom PPI partitions Date: Mon, 8 Sep 2025 17:31:23 +0100 Message-Id: <20250908163127.2462948-22-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" We are finally getting there. The only thing getting in the way of correctly handling PPIs in the way they were intended is to drop the GICv3 hack that deals with PPI partitions. Signed-off-by: Marc Zyngier --- drivers/irqchip/Kconfig | 1 - drivers/irqchip/irq-gic-v3.c | 133 +++-------------------------------- 2 files changed, 8 insertions(+), 126 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 6d12c6ab9ea47..c31d2f99d7b91 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -36,7 +36,6 @@ config GIC_NON_BANKED config ARM_GIC_V3 bool select IRQ_DOMAIN_HIERARCHY - select PARTITION_PERCPU select GENERIC_IRQ_EFFECTIVE_AFF_MASK if SMP select HAVE_ARM_SMCCC_DISCOVERY select IRQ_MSI_IOMMU diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 4a90dbf9daedb..cdf6fac32908d 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -46,8 +45,6 @@ static u8 dist_prio_nmi __ro_after_init =3D GICV3_PRIO_NM= I; #define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 2) #define FLAGS_WORKAROUND_INSECURE (1ULL << 3) =20 -#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1) - static struct cpumask broken_rdists __read_mostly __maybe_unused; =20 struct redist_region { @@ -68,11 +65,15 @@ struct gic_chip_data { u64 flags; bool has_rss; unsigned int ppi_nr; - struct partition_desc **ppi_descs; struct partition_affinity *parts; unsigned int nr_parts; }; =20 +struct partition_affinity { + cpumask_t mask; + struct fwnode_handle *partition_id; +}; + #define T241_CHIPS_MAX 4 static void __iomem *t241_dist_base_alias[T241_CHIPS_MAX] __read_mostly; static DEFINE_STATIC_KEY_FALSE(gic_nvidia_t241_erratum); @@ -596,18 +597,6 @@ static void gic_irq_set_prio(struct irq_data *d, u8 pr= io) writeb_relaxed(prio, base + offset + index); } =20 -static u32 __gic_get_ppi_index(irq_hw_number_t hwirq) -{ - switch (__get_intid_range(hwirq)) { - case PPI_RANGE: - return hwirq - 16; - case EPPI_RANGE: - return hwirq - EPPI_BASE_INTID + 16; - default: - unreachable(); - } -} - static u32 __gic_get_rdist_index(irq_hw_number_t hwirq) { switch (__get_intid_range(hwirq)) { @@ -1668,13 +1657,6 @@ static int gic_irq_domain_translate(struct irq_domai= n *d, case GIC_IRQ_TYPE_LPI: /* LPI */ *hwirq =3D fwspec->param[1]; break; - case GIC_IRQ_TYPE_PARTITION: - *hwirq =3D fwspec->param[1]; - if (fwspec->param[1] >=3D 16) - *hwirq +=3D EPPI_BASE_INTID - 16; - else - *hwirq +=3D 16; - break; default: return -EINVAL; } @@ -1683,10 +1665,8 @@ static int gic_irq_domain_translate(struct irq_domai= n *d, =20 /* * Make it clear that broken DTs are... broken. - * Partitioned PPIs are an unfortunate exception. */ - WARN_ON(*type =3D=3D IRQ_TYPE_NONE && - fwspec->param[0] !=3D GIC_IRQ_TYPE_PARTITION); + WARN_ON(*type =3D=3D IRQ_TYPE_NONE); return 0; } =20 @@ -1743,32 +1723,11 @@ static void gic_irq_domain_free(struct irq_domain *= domain, unsigned int virq, } } =20 -static bool fwspec_is_partitioned_ppi(struct irq_fwspec *fwspec, - irq_hw_number_t hwirq) -{ - enum gic_intid_range range; - - if (!gic_data.ppi_descs) - return false; - - if (!is_of_node(fwspec->fwnode)) - return false; - - if (fwspec->param_count < 4 || !fwspec->param[3]) - return false; - - range =3D __get_intid_range(hwirq); - if (range !=3D PPI_RANGE && range !=3D EPPI_RANGE) - return false; - - return true; -} - static int gic_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec, enum irq_domain_bus_token bus_token) { - unsigned int type, ret, ppi_idx; + unsigned int type, ret; irq_hw_number_t hwirq; =20 /* Not for us */ @@ -1787,15 +1746,7 @@ static int gic_irq_domain_select(struct irq_domain *= d, if (WARN_ON_ONCE(ret)) return 0; =20 - if (!fwspec_is_partitioned_ppi(fwspec, hwirq)) - return d =3D=3D gic_data.domain; - - /* - * If this is a PPI and we have a 4th (non-null) parameter, - * then we need to match the partition domain. - */ - ppi_idx =3D __gic_get_ppi_index(hwirq); - return d =3D=3D partition_get_domain(gic_data.ppi_descs[ppi_idx]); + return d =3D=3D gic_data.domain; } =20 static int gic_irq_get_info(struct irq_fwspec_info *info) @@ -1854,45 +1805,6 @@ static const struct irq_domain_ops gic_irq_domain_op= s =3D { .get_info =3D gic_irq_get_info, }; =20 -static int partition_domain_translate(struct irq_domain *d, - struct irq_fwspec *fwspec, - unsigned long *hwirq, - unsigned int *type) -{ - unsigned long ppi_intid; - struct device_node *np; - unsigned int ppi_idx; - int ret; - - if (!gic_data.ppi_descs) - return -ENOMEM; - - np =3D of_find_node_by_phandle(fwspec->param[3]); - if (WARN_ON(!np)) - return -EINVAL; - - ret =3D gic_irq_domain_translate(d, fwspec, &ppi_intid, type); - if (WARN_ON_ONCE(ret)) - return 0; - - ppi_idx =3D __gic_get_ppi_index(ppi_intid); - ret =3D partition_translate_id(gic_data.ppi_descs[ppi_idx], - of_fwnode_handle(np)); - if (ret < 0) - return ret; - - *hwirq =3D ret; - *type =3D fwspec->param[2] & IRQ_TYPE_SENSE_MASK; - - return 0; -} - -static const struct irq_domain_ops partition_domain_ops =3D { - .translate =3D partition_domain_translate, - .select =3D gic_irq_domain_select, - .get_info =3D gic_irq_get_info, -}; - static bool gic_enable_quirk_msm8996(void *data) { struct gic_chip_data *d =3D data; @@ -2225,12 +2137,7 @@ static void __init gic_populate_ppi_partitions(struc= t device_node *gic_node) if (!parts_node) return; =20 - gic_data.ppi_descs =3D kcalloc(gic_data.ppi_nr, sizeof(*gic_data.ppi_desc= s), GFP_KERNEL); - if (!gic_data.ppi_descs) - goto out_put_node; - nr_parts =3D of_get_child_count(parts_node); - if (!nr_parts) goto out_put_node; =20 @@ -2286,30 +2193,6 @@ static void __init gic_populate_ppi_partitions(struc= t device_node *gic_node) gic_data.parts =3D parts; gic_data.nr_parts =3D nr_parts; =20 - for (i =3D 0; i < gic_data.ppi_nr; i++) { - unsigned int irq; - struct partition_desc *desc; - struct irq_fwspec ppi_fwspec =3D { - .fwnode =3D gic_data.fwnode, - .param_count =3D 3, - .param =3D { - [0] =3D GIC_IRQ_TYPE_PARTITION, - [1] =3D i, - [2] =3D IRQ_TYPE_NONE, - }, - }; - - irq =3D irq_create_fwspec_mapping(&ppi_fwspec); - if (WARN_ON(!irq)) - continue; - desc =3D partition_create_desc(gic_data.fwnode, parts, nr_parts, - irq, &partition_domain_ops); - if (WARN_ON(!desc)) - continue; - - gic_data.ppi_descs[i] =3D desc; - } - out_put_node: of_node_put(parts_node); } --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6881F312807; Mon, 8 Sep 2025 16:31:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349113; cv=none; b=eONJcn3b0GHSbo6lAYCj8u5Ofp94Nh0pU13nkwNcdKw9X12QgGteKe+oA0S88bq08sc6DjDBuoPiLCYKQMMd626JhgAD18E3D02o6wP4J6fgg7E9tMMFeZ+aYU29S6l8vYLrM9YR2S5Y5KbotyVu5h+WzN2sZim49uq2YPXhZt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349113; c=relaxed/simple; bh=cD24s1uQR7hSRj6QtBcBYKfVWIxSnzm+C5Yja2jxp7U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IeMgg/voGNs/LaBEM41ryjKIQ+LY1Qko7cVCexrg0AWV2y86aRo9+8914T3u4T63RvXE9a2AKg16B7Iccac025jOYdEj9kxkpqnVnOTwlOmanNS3AfZYUxU0I+f48gP3hj5eeAPx8z0oK2YUmxkZX/Wwh3+FlCH4Jk2U12eYg5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qlEhDJ4Y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qlEhDJ4Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C024C4CEF5; Mon, 8 Sep 2025 16:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349113; bh=cD24s1uQR7hSRj6QtBcBYKfVWIxSnzm+C5Yja2jxp7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qlEhDJ4YAXGuC8EFmcfFBAjs9NdaOGJZqIfnRCty4WPY7LHj8weCszBSl4zMA76UH NFBQePEMrtcI4jjwb8i58GZ7/dFpoV3Ck9/srAuwI+dtDWZLLG8Y7ooGatlvx3mwiX JQikxaKLfmCSpSZvNy6/BR+jflouvdrujfERNKcRBXcWJSYO4PGfdNlXrBmp0xBeuw n3nPnr4kPbPNcnj2QkY49FowVHQ9goETcI4M6k9VaTM8tikDIFcxn1qxzNqvhGwB28 mNoNUo7aUQ/6mqYEHpq48A9eGCFMNGKD6pKscum0w5j/bqY/BQ21MTTC21vOQ2R0LS ATC7oGHV8hgng== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemV-00000004NTm-2IEJ; Mon, 08 Sep 2025 16:31:51 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 22/25] irqchip/apple-aic: Drop support for custom PMU irq partitions Date: Mon, 8 Sep 2025 17:31:24 +0100 Message-Id: <20250908163127.2462948-23-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Similarly to what has been done for GICv3, drop the irq partitioning support from the AIC driver, effectively merging the two per-cpu interrupts for the PMU. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-apple-aic.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index dd89e50a72e83..5688411f9f0b8 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -578,16 +578,9 @@ static void __exception_irq_entry aic_handle_fiq(struc= t pt_regs *regs) } =20 if ((read_sysreg_s(SYS_IMP_APL_PMCR0_EL1) & (PMCR0_IMODE | PMCR0_IACT)) = =3D=3D - (FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_FIQ) | PMCR0_IACT)) { - int irq; - if (cpumask_test_cpu(smp_processor_id(), - &aic_irqc->fiq_aff[AIC_CPU_PMU_P]->aff)) - irq =3D AIC_CPU_PMU_P; - else - irq =3D AIC_CPU_PMU_E; + (FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_FIQ) | PMCR0_IACT)) generic_handle_domain_irq(aic_irqc->hw_domain, - AIC_FIQ_HWIRQ(irq)); - } + AIC_FIQ_HWIRQ(AIC_CPU_PMU_P)); =20 if (static_branch_likely(&use_fast_ipi) && (FIELD_GET(UPMCR0_IMODE, read_sysreg_s(SYS_IMP_APL_UPMCR0_EL1)) =3D= =3D UPMCR0_IMODE_FIQ) && @@ -632,18 +625,7 @@ static int aic_irq_domain_map(struct irq_domain *id, u= nsigned int irq, handle_fasteoi_irq, NULL, NULL); irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(irq))); } else { - int fiq =3D FIELD_GET(AIC_EVENT_NUM, hw); - - switch (fiq) { - case AIC_CPU_PMU_P: - case AIC_CPU_PMU_E: - irq_set_percpu_devid_partition(irq, &ic->fiq_aff[fiq]->aff); - break; - default: - irq_set_percpu_devid(irq); - break; - } - + irq_set_percpu_devid(irq); irq_domain_set_info(id, irq, hw, &fiq_chip, id->host_data, handle_percpu_devid_irq, NULL, NULL); } @@ -735,6 +717,10 @@ static int aic_irq_domain_translate(struct irq_domain = *id, break; } } + + /* Merge the two PMUs on a single interrupt */ + if (*hwirq =3D=3D AIC_CPU_PMU_E) + *hwirq =3D AIC_CPU_PMU_P; break; default: return -EINVAL; --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E13143128B2; Mon, 8 Sep 2025 16:31:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349114; cv=none; b=levi5nYWOya/CCt+fAiiC/PQ8+VXOjEN9VNRHb6G9tgBdYHg9NLO0veYRYtxLT+1V9y9RZrQYnlMFEjlmqZugE3spUArRiH1NWaN7BhApTnUy+BuWIqbygzoeYqmbsaXNoHhJeJ2ITcfdBSMkYZoTZHHPYCATRDgos50oCf1fP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349114; c=relaxed/simple; bh=zjGTnTXeZxX9IWdZqt0xePIPCnSCFLQrvT6nM+URiUE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C+R+c3A3DMY98MWi84juhp27lOXhBWLL3leTbI2AKNQ6VtrLy5WIozCguEeDngZQPoRZq/T+dQQhRHx/Ns5T+l/32QxGe0aPXPcCdOXnWq0cIBgqaMVic5DrP9VzKWrUYxBDgRJLwv7d35XqxBDcARdEQSAv+DDQblVbzp3HZh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vFq5Dti8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vFq5Dti8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3327C4CEF1; Mon, 8 Sep 2025 16:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349113; bh=zjGTnTXeZxX9IWdZqt0xePIPCnSCFLQrvT6nM+URiUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vFq5Dti8PJHKE+88Zmky9NegJ5gfXElnVKOw8fX2FA2zcRmR7D8c//pF4aj5zAfek KzDNIMXowfuN+Qa/y8uJgj1UfHynAO1x9wX+2+Ixxnj8/Nwp9X2d+j6HkXzqw4eZK1 VeFJFRHA0teXtEPRHtS4ITZq9iAgRFQ7ZIhtFlJramkhcSvcBeBzU5qOnWC0qofkQP JEbGGa3GF74AHWstjFPzV6RQJxgRCFU+00wyp5cwIrGDXfQNaXQbPNmkgVWKCQ1D/d RHpGop9vVq3to5OsNqlbe0UWHoZ+mlrYYIIIq1yzI9yHwmb3ZoyOKnOXn69uws7c3N gFWj1/JJFZI1w== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemV-00000004NTm-3O5w; Mon, 08 Sep 2025 16:31:51 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 23/25] irqchip: Kill irq-partition-percpu Date: Mon, 8 Sep 2025 17:31:25 +0100 Message-Id: <20250908163127.2462948-24-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" This code is now completely unused, and nobody will ever miss it. Signed-off-by: Marc Zyngier --- drivers/irqchip/Kconfig | 3 - drivers/irqchip/Makefile | 1 - drivers/irqchip/irq-partition-percpu.c | 241 ------------------- include/linux/irqchip/irq-partition-percpu.h | 53 ---- 4 files changed, 298 deletions(-) delete mode 100644 drivers/irqchip/irq-partition-percpu.c delete mode 100644 include/linux/irqchip/irq-partition-percpu.h diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index c31d2f99d7b91..4bb25d21f6e9b 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -450,9 +450,6 @@ config LS_SCFG_MSI depends on PCI_MSI select IRQ_MSI_LIB =20 -config PARTITION_PERCPU - bool - config STM32MP_EXTI tristate "STM32MP extended interrupts and event controller" depends on (ARCH_STM32 && !ARM_SINGLE_ARMV7M) || COMPILE_TEST diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 93e3ced023bb8..da429f3e29ec7 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -36,7 +36,6 @@ obj-$(CONFIG_ARM_GIC_V3) +=3D irq-gic-v3.o irq-gic-v3-mb= i.o irq-gic-common.o obj-$(CONFIG_ARM_GIC_ITS_PARENT) +=3D irq-gic-its-msi-parent.o obj-$(CONFIG_ARM_GIC_V3_ITS) +=3D irq-gic-v3-its.o irq-gic-v4.o obj-$(CONFIG_ARM_GIC_V3_ITS_FSL_MC) +=3D irq-gic-v3-its-fsl-mc-msi.o -obj-$(CONFIG_PARTITION_PERCPU) +=3D irq-partition-percpu.o obj-$(CONFIG_ARM_GIC_V5) +=3D irq-gic-v5.o irq-gic-v5-irs.o irq-gic-v5-it= s.o \ irq-gic-v5-iwb.o obj-$(CONFIG_HISILICON_IRQ_MBIGEN) +=3D irq-mbigen.o diff --git a/drivers/irqchip/irq-partition-percpu.c b/drivers/irqchip/irq-p= artition-percpu.c deleted file mode 100644 index 4441ffe149ea0..0000000000000 --- a/drivers/irqchip/irq-partition-percpu.c +++ /dev/null @@ -1,241 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (C) 2016 ARM Limited, All Rights Reserved. - * Author: Marc Zyngier - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -struct partition_desc { - int nr_parts; - struct partition_affinity *parts; - struct irq_domain *domain; - struct irq_desc *chained_desc; - unsigned long *bitmap; - struct irq_domain_ops ops; -}; - -static bool partition_check_cpu(struct partition_desc *part, - unsigned int cpu, unsigned int hwirq) -{ - return cpumask_test_cpu(cpu, &part->parts[hwirq].mask); -} - -static void partition_irq_mask(struct irq_data *d) -{ - struct partition_desc *part =3D irq_data_get_irq_chip_data(d); - struct irq_chip *chip =3D irq_desc_get_chip(part->chained_desc); - struct irq_data *data =3D irq_desc_get_irq_data(part->chained_desc); - - if (partition_check_cpu(part, smp_processor_id(), d->hwirq) && - chip->irq_mask) - chip->irq_mask(data); -} - -static void partition_irq_unmask(struct irq_data *d) -{ - struct partition_desc *part =3D irq_data_get_irq_chip_data(d); - struct irq_chip *chip =3D irq_desc_get_chip(part->chained_desc); - struct irq_data *data =3D irq_desc_get_irq_data(part->chained_desc); - - if (partition_check_cpu(part, smp_processor_id(), d->hwirq) && - chip->irq_unmask) - chip->irq_unmask(data); -} - -static int partition_irq_set_irqchip_state(struct irq_data *d, - enum irqchip_irq_state which, - bool val) -{ - struct partition_desc *part =3D irq_data_get_irq_chip_data(d); - struct irq_chip *chip =3D irq_desc_get_chip(part->chained_desc); - struct irq_data *data =3D irq_desc_get_irq_data(part->chained_desc); - - if (partition_check_cpu(part, smp_processor_id(), d->hwirq) && - chip->irq_set_irqchip_state) - return chip->irq_set_irqchip_state(data, which, val); - - return -EINVAL; -} - -static int partition_irq_get_irqchip_state(struct irq_data *d, - enum irqchip_irq_state which, - bool *val) -{ - struct partition_desc *part =3D irq_data_get_irq_chip_data(d); - struct irq_chip *chip =3D irq_desc_get_chip(part->chained_desc); - struct irq_data *data =3D irq_desc_get_irq_data(part->chained_desc); - - if (partition_check_cpu(part, smp_processor_id(), d->hwirq) && - chip->irq_get_irqchip_state) - return chip->irq_get_irqchip_state(data, which, val); - - return -EINVAL; -} - -static int partition_irq_set_type(struct irq_data *d, unsigned int type) -{ - struct partition_desc *part =3D irq_data_get_irq_chip_data(d); - struct irq_chip *chip =3D irq_desc_get_chip(part->chained_desc); - struct irq_data *data =3D irq_desc_get_irq_data(part->chained_desc); - - if (chip->irq_set_type) - return chip->irq_set_type(data, type); - - return -EINVAL; -} - -static void partition_irq_print_chip(struct irq_data *d, struct seq_file *= p) -{ - struct partition_desc *part =3D irq_data_get_irq_chip_data(d); - struct irq_chip *chip =3D irq_desc_get_chip(part->chained_desc); - struct irq_data *data =3D irq_desc_get_irq_data(part->chained_desc); - - seq_printf(p, "%5s-%lu", chip->name, data->hwirq); -} - -static struct irq_chip partition_irq_chip =3D { - .irq_mask =3D partition_irq_mask, - .irq_unmask =3D partition_irq_unmask, - .irq_set_type =3D partition_irq_set_type, - .irq_get_irqchip_state =3D partition_irq_get_irqchip_state, - .irq_set_irqchip_state =3D partition_irq_set_irqchip_state, - .irq_print_chip =3D partition_irq_print_chip, -}; - -static void partition_handle_irq(struct irq_desc *desc) -{ - struct partition_desc *part =3D irq_desc_get_handler_data(desc); - struct irq_chip *chip =3D irq_desc_get_chip(desc); - int cpu =3D smp_processor_id(); - int hwirq; - - chained_irq_enter(chip, desc); - - for_each_set_bit(hwirq, part->bitmap, part->nr_parts) { - if (partition_check_cpu(part, cpu, hwirq)) - break; - } - - if (unlikely(hwirq =3D=3D part->nr_parts)) - handle_bad_irq(desc); - else - generic_handle_domain_irq(part->domain, hwirq); - - chained_irq_exit(chip, desc); -} - -static int partition_domain_alloc(struct irq_domain *domain, unsigned int = virq, - unsigned int nr_irqs, void *arg) -{ - int ret; - irq_hw_number_t hwirq; - unsigned int type; - struct irq_fwspec *fwspec =3D arg; - struct partition_desc *part; - - BUG_ON(nr_irqs !=3D 1); - ret =3D domain->ops->translate(domain, fwspec, &hwirq, &type); - if (ret) - return ret; - - part =3D domain->host_data; - - set_bit(hwirq, part->bitmap); - irq_set_chained_handler_and_data(irq_desc_get_irq(part->chained_desc), - partition_handle_irq, part); - irq_set_percpu_devid_partition(virq, &part->parts[hwirq].mask); - irq_domain_set_info(domain, virq, hwirq, &partition_irq_chip, part, - handle_percpu_devid_irq, NULL, NULL); - irq_set_status_flags(virq, IRQ_NOAUTOEN); - - return 0; -} - -static void partition_domain_free(struct irq_domain *domain, unsigned int = virq, - unsigned int nr_irqs) -{ - struct irq_data *d; - - BUG_ON(nr_irqs !=3D 1); - - d =3D irq_domain_get_irq_data(domain, virq); - irq_set_handler(virq, NULL); - irq_domain_reset_irq_data(d); -} - -int partition_translate_id(struct partition_desc *desc, void *partition_id) -{ - struct partition_affinity *part =3D NULL; - int i; - - for (i =3D 0; i < desc->nr_parts; i++) { - if (desc->parts[i].partition_id =3D=3D partition_id) { - part =3D &desc->parts[i]; - break; - } - } - - if (WARN_ON(!part)) { - pr_err("Failed to find partition\n"); - return -EINVAL; - } - - return i; -} - -struct partition_desc *partition_create_desc(struct fwnode_handle *fwnode, - struct partition_affinity *parts, - int nr_parts, - int chained_irq, - const struct irq_domain_ops *ops) -{ - struct partition_desc *desc; - struct irq_domain *d; - - BUG_ON(!ops->select || !ops->translate); - - desc =3D kzalloc(sizeof(*desc), GFP_KERNEL); - if (!desc) - return NULL; - - desc->ops =3D *ops; - desc->ops.free =3D partition_domain_free; - desc->ops.alloc =3D partition_domain_alloc; - - d =3D irq_domain_create_linear(fwnode, nr_parts, &desc->ops, desc); - if (!d) - goto out; - desc->domain =3D d; - - desc->bitmap =3D bitmap_zalloc(nr_parts, GFP_KERNEL); - if (WARN_ON(!desc->bitmap)) - goto out; - - desc->chained_desc =3D irq_to_desc(chained_irq); - desc->nr_parts =3D nr_parts; - desc->parts =3D parts; - - return desc; -out: - if (d) - irq_domain_remove(d); - kfree(desc); - - return NULL; -} - -struct irq_domain *partition_get_domain(struct partition_desc *dsc) -{ - if (dsc) - return dsc->domain; - - return NULL; -} diff --git a/include/linux/irqchip/irq-partition-percpu.h b/include/linux/i= rqchip/irq-partition-percpu.h deleted file mode 100644 index b35ee22c278f8..0000000000000 --- a/include/linux/irqchip/irq-partition-percpu.h +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) 2016 ARM Limited, All Rights Reserved. - * Author: Marc Zyngier - */ - -#ifndef __LINUX_IRQCHIP_IRQ_PARTITION_PERCPU_H -#define __LINUX_IRQCHIP_IRQ_PARTITION_PERCPU_H - -#include -#include -#include - -struct partition_affinity { - cpumask_t mask; - void *partition_id; -}; - -struct partition_desc; - -#ifdef CONFIG_PARTITION_PERCPU -int partition_translate_id(struct partition_desc *desc, void *partition_id= ); -struct partition_desc *partition_create_desc(struct fwnode_handle *fwnode, - struct partition_affinity *parts, - int nr_parts, - int chained_irq, - const struct irq_domain_ops *ops); -struct irq_domain *partition_get_domain(struct partition_desc *dsc); -#else -static inline int partition_translate_id(struct partition_desc *desc, - void *partition_id) -{ - return -EINVAL; -} - -static inline -struct partition_desc *partition_create_desc(struct fwnode_handle *fwnode, - struct partition_affinity *parts, - int nr_parts, - int chained_irq, - const struct irq_domain_ops *ops) -{ - return NULL; -} - -static inline -struct irq_domain *partition_get_domain(struct partition_desc *dsc) -{ - return NULL; -} -#endif - -#endif /* __LINUX_IRQCHIP_IRQ_PARTITION_PERCPU_H */ --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 47A2E313275; Mon, 8 Sep 2025 16:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349114; cv=none; b=hwoAvZhNKqzsDdOFRzfRHr+mgMEG/9u66idVpVXTq5gju4nU/EkzAex0X3Q+XNBWBwx9aNF1ZwEyiXMwNV3RuJ7lAC+DDnFCE31xeaUZFuLNh35vEnzxH3sBmj3ZXtxmkkqomTvCsvIrG8S7tvIwo4fledrcRoBExQL5Ujt8q0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349114; c=relaxed/simple; bh=KIJcpIexVQbBm6Ag9j1A9KzXh+prYf68HNMhwvq9l5o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ehj1iWW432yLQckpaEC4a2DHbTcn+ZuUVDhfEA0YA0JXLEp2ileW/FBnMNM/14t9W0IzkExlzqcBXqTbeE38UdkJgHqTrNHard/TdS/yXRwHGat6dCagd9x5e5ed/5DS4j30Rk/BoL7U5eXerYAjYWG/1GINfpnh+VlosIvIE+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cDZX1/JN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cDZX1/JN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5202C4CEFA; Mon, 8 Sep 2025 16:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349113; bh=KIJcpIexVQbBm6Ag9j1A9KzXh+prYf68HNMhwvq9l5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cDZX1/JNlb4r2uU1AjAxVyJM39NYejF5rT4wyY1vHWXef8d8wNTeK7ZULgzgnfTZi 1Lyf/p96nwBoYXolir4tLvohykR7IsJBY0xSx1mMPt+SC93w0AVNXsrvMt9VWUxHIW LG1vo48Ha6iR3Hi9Pe31Rrq5fi3kj9mfKmXtB8GgcH9DwtR2pbluFcAGOdrQ6TOh+k bptld+JfJlFkat535noN5f0t21t1UZrcXga4cD3/VrVKMTwqsdOL1fCUCk5DhWNhNT 3Ffetr7w5u7eBAcgANidtrOtzDl+FlfC4IOO+P3Pr848KsiZlljg9q+SRdSrUuFU5y wxW6KwgywAVZA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemW-00000004NTm-0M5u; Mon, 08 Sep 2025 16:31:52 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 24/25] genirq: Kill irq_{g,s}et_percpu_devid_partition() Date: Mon, 8 Sep 2025 17:31:26 +0100 Message-Id: <20250908163127.2462948-25-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" These two helpers do not have any user anymore, and can be removed, together with the affinity field kept in the irqdesc structure. Signed-off-by: Marc Zyngier --- include/linux/irq.h | 4 ---- include/linux/irqdesc.h | 1 - kernel/irq/irqdesc.c | 24 +----------------------- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index 1d6b606a81efe..c107125f51283 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -717,10 +717,6 @@ static inline void irq_set_chip_and_handler(unsigned i= nt irq, } =20 extern int irq_set_percpu_devid(unsigned int irq); -extern int irq_set_percpu_devid_partition(unsigned int irq, - const struct cpumask *affinity); -extern int irq_get_percpu_devid_partition(unsigned int irq, - struct cpumask *affinity); =20 extern void __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chai= ned, diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h index fd091c35d5721..37e0b5b5600a4 100644 --- a/include/linux/irqdesc.h +++ b/include/linux/irqdesc.h @@ -82,7 +82,6 @@ struct irq_desc { int threads_handled_last; raw_spinlock_t lock; struct cpumask *percpu_enabled; - const struct cpumask *percpu_affinity; #ifdef CONFIG_SMP const struct cpumask *affinity_hint; struct irq_affinity_notify *affinity_notify; diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index b64c57b44c203..79df6e3bc3958 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -886,8 +886,7 @@ void __irq_put_desc_unlock(struct irq_desc *desc, unsig= ned long flags, bool bus) chip_bus_sync_unlock(desc); } =20 -int irq_set_percpu_devid_partition(unsigned int irq, - const struct cpumask *affinity) +int irq_set_percpu_devid(unsigned int irq) { struct irq_desc *desc =3D irq_to_desc(irq); =20 @@ -899,31 +898,10 @@ int irq_set_percpu_devid_partition(unsigned int irq, if (!desc->percpu_enabled) return -ENOMEM; =20 - desc->percpu_affinity =3D affinity ? : cpu_possible_mask; - irq_set_percpu_devid_flags(irq); return 0; } =20 -int irq_set_percpu_devid(unsigned int irq) -{ - return irq_set_percpu_devid_partition(irq, NULL); -} - -int irq_get_percpu_devid_partition(unsigned int irq, struct cpumask *affin= ity) -{ - struct irq_desc *desc =3D irq_to_desc(irq); - - if (!desc || !desc->percpu_enabled) - return -EINVAL; - - if (affinity) - cpumask_copy(affinity, desc->percpu_affinity); - - return 0; -} -EXPORT_SYMBOL_GPL(irq_get_percpu_devid_partition); - void kstat_incr_irq_this_cpu(unsigned int irq) { kstat_incr_irqs_this_cpu(irq_to_desc(irq)); --=20 2.39.2 From nobody Wed Sep 10 01:54:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A0FC0313537; Mon, 8 Sep 2025 16:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349114; cv=none; b=Tpo7zkG6FM7spyXV5g+f6t0QzcH9q9cA3ZzIofSw1g9fffPaMxbSofW+R0ZaqOoUksV7Ke0vb6myZDvLP0rEo+TxBH3gokWWLgaV2Iaa60UdISlE1HDvWA8nfFNpo/kgDn3PHtzAGHxU9OhLRHyo34Bbly/58LbfMOORwD5wVhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757349114; c=relaxed/simple; bh=mLfNgEe8vQvBs2HQCL9WyKiYdn23StzVUW+mSl2pM2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dtb6d82xQOhNPvCwwcIBtrrNJRJ9LrUk0ICM3n2B3xcpj71/2PCp//MHaHE7Jf2wAO+HTP+/GOdUwi8zvWPS5ZH1Z0RhkVAYFLbDN5BOwO+Uhv0zTf1wcLuyz3RWSnZ+JD6S5skVyFtwgG7RKlFP6CVwQI3mfY0UHfrnfcoK608= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FFNpqPio; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FFNpqPio" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C399C4CEF7; Mon, 8 Sep 2025 16:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757349114; bh=mLfNgEe8vQvBs2HQCL9WyKiYdn23StzVUW+mSl2pM2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFNpqPio6CG2cvl32kT6FfYkxqeMwmiyPSqr1/uefqh32Iuc/G19EPrwwLVRC+h1p 3kDnP7c5WyQqnwmCUYWnZNUjOUsbFINwb4gGxwXTmkdrxVjbvJFZuQ2zo2A36TWFI+ YBI3CS69BwckS7DFp54HJNx0lPGCEnRkOIhx/g9w5Ch78daOpDZbVQ0gT57stxeqV2 lJ1bDtJztN+7h/ShDNLhXHDKYa9XO2EkNdxUTuNldUxzJz6bBB70tEKrGZLEqJ5Oc9 tIQGyzjRaBIS4SSnFpfOVMV2wAYQrbsh7WLh1r7FhT7XmLtuemqJTdibrz68Y/+WUg cbp92rZqRkEmQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uvemW-00000004NTm-1XQ8; Mon, 08 Sep 2025 16:31:52 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark Subject: [PATCH 25/25] perf: arm_pmu: Kill last use of per-CPU cpu_armpmu pointer Date: Mon, 8 Sep 2025 17:31:27 +0100 Message-Id: <20250908163127.2462948-26-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250908163127.2462948-1-maz@kernel.org> References: <20250908163127.2462948-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Having removed the use of the cpu_armpmu per-CPU variable from the interrupt handling, the only user left is the BRBE scheduler hook. It is easy to drop the use of this variable by following the pointer to the generic PMU structure, and get the arm_pmu structure from there. Perform the conversion and kill cpu_armpmu altogether. Suggested-by: Will Deacon Signed-off-by: Marc Zyngier --- drivers/perf/arm_pmu.c | 5 ----- drivers/perf/arm_pmuv3.c | 2 +- include/linux/perf/arm_pmu.h | 2 -- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 0d64e929d9bf0..8b3d7022a2d83 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -99,7 +99,6 @@ static const struct pmu_irq_ops percpu_pmunmi_ops =3D { .free_pmuirq =3D armpmu_free_percpu_pmunmi }; =20 -DEFINE_PER_CPU(struct arm_pmu *, cpu_armpmu); static DEFINE_PER_CPU(const struct cpumask *, pmu_affinity); static DEFINE_PER_CPU(int, cpu_irq); static DEFINE_PER_CPU(const struct pmu_irq_ops *, cpu_irq_ops); @@ -739,8 +738,6 @@ static int arm_perf_starting_cpu(unsigned int cpu, stru= ct hlist_node *node) if (pmu->reset) pmu->reset(pmu); =20 - per_cpu(cpu_armpmu, cpu) =3D pmu; - irq =3D armpmu_get_cpu_irq(pmu, cpu); if (irq) per_cpu(cpu_irq_ops, cpu)->enable_pmuirq(irq); @@ -760,8 +757,6 @@ static int arm_perf_teardown_cpu(unsigned int cpu, stru= ct hlist_node *node) if (irq) per_cpu(cpu_irq_ops, cpu)->disable_pmuirq(irq); =20 - per_cpu(cpu_armpmu, cpu) =3D NULL; - return 0; } =20 diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index f6d7bab5d555c..2dee2d928aaef 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -1039,7 +1039,7 @@ static int armv8pmu_user_event_idx(struct perf_event = *event) static void armv8pmu_sched_task(struct perf_event_pmu_context *pmu_ctx, struct task_struct *task, bool sched_in) { - struct arm_pmu *armpmu =3D *this_cpu_ptr(&cpu_armpmu); + struct arm_pmu *armpmu =3D to_arm_pmu(pmu_ctx->pmu); struct pmu_hw_events *hw_events =3D this_cpu_ptr(armpmu->hw_events); =20 if (!hw_events->branch_users) diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 395d03c282e8c..b54c309a74f0f 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -132,8 +132,6 @@ struct arm_pmu { =20 #define to_arm_pmu(p) (container_of(p, struct arm_pmu, pmu)) =20 -DECLARE_PER_CPU(struct arm_pmu *, cpu_armpmu); - u64 armpmu_event_update(struct perf_event *event); =20 int armpmu_event_set_period(struct perf_event *event); --=20 2.39.2