From nobody Thu Oct 2 15:32:37 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 CFF5A2F28FC; Mon, 15 Sep 2025 08:57:13 +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=1757926633; cv=none; b=f/VXfMjT1pzPSQ9sFjZGWPmgcXw5bv2vFQF8nYgB+iciLJ1bWLi+SRd+d1ByRfz6AIV+NiDxN7RDaJfQe8/YDA7Z7/bCxznMdZiO8o8fW9ubKBsBO+zXx9JA2d+L0il5wyhPN5ZNocFRxIrxeUFg3ooXwG6pO4VX9rXl9c0NGtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926633; c=relaxed/simple; bh=q2Fd2zOOtwDOEGTqhcpca89zH4earoptsab0Q+WSvVs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KwRZvPT9hP2CerZFchuIsjLJy8LNVE86sLJe+wRxikYJl2S+wjALmAyYBSlk6AARd+hjofDS2BjM4hz3+EibiCdC6NHSoRETiIeAhg4BJz66Xm4wWg8g0jhZdJf0TO9+E9J6t1b4ozVsVsT9iHOx/Bh4lnNzK48RWxFUCyXCBWw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YV4w1Ufh; 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="YV4w1Ufh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78770C4CEFD; Mon, 15 Sep 2025 08:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926633; bh=q2Fd2zOOtwDOEGTqhcpca89zH4earoptsab0Q+WSvVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YV4w1UfhCsKJsuEcBo34WQ7uWNxd0d2npcHg+kdjaQG3gqsirvyRQ/gsN1VW3/EO1 +pA7/mycME+T/F6Os6A/TGie5ajwbKRfRaHCgve89fKpxUoVoD/ihlHlqo8//nSLUX qyI+GAH+8DDoEL50IiMj6/HEs0BFEac+ZaucGYSCYsH3BuxNZfUKUcHBiheMjsQr1x n1msHRssXGuqW7QkO/iRH+h2uF8EmwHV2DBOtNAXiFFI2nnSeUp5FnQb+K+1seX5ZL iPeCqaFS7bnlTlUEg6HyCb6BN9hhjn2Xm+BHyLKIes9HLEwhCaUn4rXdWpn8ugQGwk 7yuIkS0ku5wjQ== 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 1uy51L-00000006IHP-1gOa; Mon, 15 Sep 2025 08:57:11 +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 v2 01/25] irqdomain: Add firmware info reporting interface Date: Mon, 15 Sep 2025 09:56:38 +0100 Message-Id: <20250915085702.519996-2-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 | 28 ++++++++++++++++++++++++++++ kernel/irq/irqdomain.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 4a86e6b915dd6..34993bf8293c4 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -44,6 +44,24 @@ struct irq_fwspec { u32 param[IRQ_DOMAIN_IRQ_SPEC_PARAMS]; }; =20 +/** + * struct irq_fwspec_info - firmware provided IRQ information structure + * + * @fwspec: Firmware-specific interrupt 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 { + unsigned long flags; + const struct cpumask *affinity; +}; + +#define IRQ_FWSPEC_INFO_AFFINITY_VALID BIT(0) + /* 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 +87,9 @@ 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_fwspec_info: + * Given @fwspec, report additional firmware-provided information in + * @info. 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 +117,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_fwspec_info)(struct irq_fwspec *fwspec, struct irq_fwspec_info = *info); #endif #ifdef CONFIG_GENERIC_IRQ_DEBUGFS void (*debug_show)(struct seq_file *m, struct irq_domain *d, @@ -602,6 +624,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 *fwspec, 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 +709,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 *fwspec, stru= ct 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..2652c4cfd877f 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,32 @@ 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 *fwspec, struct irq_fwspec_= info *info) +{ + struct irq_domain *domain =3D fwspec_to_domain(fwspec); + + memset(info, 0, sizeof(*info)); + + if (!domain || !domain->ops->get_fwspec_info) + return 0; + + return domain->ops->get_fwspec_info(fwspec, info); +} +#endif + +unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) +{ + unsigned int type =3D IRQ_TYPE_NONE; + struct irq_domain *domain; + struct irq_data *irq_data; + irq_hw_number_t hwirq; + 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 Thu Oct 2 15:32:37 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 51FD22F3637; Mon, 15 Sep 2025 08:57:14 +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=1757926634; cv=none; b=GKFpKVRDG44olp/Z1zb4ovkKjOA4HOYdLvNvhPxFh7P3PaLHjMUUGJUofKbHF5Sn4pA31gIF9KglUT1OB57hAGt2F3paNwYSgPzE2q17dGG1SAQjIccVtXj//qc8qCG33FBSNujPAgbuc0OqRkkGBgrXv2WdPWX/gFD4231qZrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926634; c=relaxed/simple; bh=y+qpBialO0nK2NwGIINlkbx5XK+5lv6J5C1jwN7r+FU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z3RGQO0urhJzxpHZmO7R8wTmBUYgxmiR6Is8wunSC8RiDaQEC1mabxJGBPOTx/l5ou+nQzOKNXA7nW3ARP/YyURPxR98AEwmz2K21JNWvXbcfAbttQ84FBkzF+lyLVNCTTDBAs0M/wz/iqnWIbos00Roji8xQuCws7UyWucudE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QNaHcKRH; 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="QNaHcKRH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF935C4CEFA; Mon, 15 Sep 2025 08:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926634; bh=y+qpBialO0nK2NwGIINlkbx5XK+5lv6J5C1jwN7r+FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QNaHcKRH0c7bVGWjnYeS/q4So/+5khBagqnRwl20V97B1GZaeT3XGgeeI1cbOUIXR KyBLjmfpxjIaj8xkPeTOa+KjtOHQLm5ul7faZa+waTq+zT5sHkXuxOkS2LjYtjYZUY q4BRZS4ocvhRBp2VxmRnq0uIb/IqTy1/T2xXv8fpFWPn3826gt5s2aTQkvUXc9+xIB oOyr603CWkd5fORJljlxPRu3Pl4PIvUezGf/9gY/UClIu/RcF8W2Jw/bkqHnH0kzRo shuJw6sxhYq5Kc4kfSrle9owXBRQLOA1csanO6EuwFnmzKxbFK41Zfd6jkmDMRJt7E 92nz22j2VX1bA== 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 1uy51L-00000006IHP-2mj4; Mon, 15 Sep 2025 08:57:11 +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 v2 02/25] ACPI: irq: Add IRQ affinity reporting interface Date: Mon, 15 Sep 2025 09:56:39 +0100 Message-Id: <20250915085702.519996-3-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Acked-by: Rafael J. Wysocki (Intel) --- drivers/acpi/irq.c | 19 +++++++++++++++++++ include/linux/acpi.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c index 76a856c32c4d0..d1595156c86a4 100644 --- a/drivers/acpi/irq.c +++ b/drivers/acpi/irq.c @@ -300,6 +300,25 @@ 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; + struct irq_fwspec fwspec; + unsigned long flags; + + if (acpi_irq_parse_one(handle, index, &fwspec, &flags)) + return NULL; + + if (irq_populate_fwspec_info(&fwspec, &info)) + return NULL; + + if (!(info.flags & IRQ_FWSPEC_INFO_AFFINITY_VALID)) + return NULL; + + return info.affinity; +} + /** * 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 Thu Oct 2 15:32:37 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 520432F3638; Mon, 15 Sep 2025 08:57:14 +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=1757926634; cv=none; b=OoTZXd2/UjBObAkJXNX7uidnceMS7xtbsHoyHaTOt+m7E2UokqF7/KFnKWQy1tWK8ouDmdeexVukfWJVkrzrbYb+QugLqhi66HuWw/6TlWvIg33JY3jpLq9Kb9KN8LheYl6G7qK+2bdwly5WsRP14P+MDG7Ut/8MeI/6sds0ly8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926634; c=relaxed/simple; bh=Tg++jEb0qzQoJaPtBtzDLbCLFkMuRzXyuZynLSvq9z8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MMeZfgqXRyX/9L70UEh0HzIUgyQ+W1J/T2aZne5Gb7s5R6Y/bQ6yeEruS2nPr7TD3i/cacgd1LwEZbIh9VAf1K0QMCvbyeoyRB+xS279amT3i7kn9Qsb0WRstGPuQSFTuafkDHvN28DRO93TzfL4cHftQcgCVcYy97b2utNt1zo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s8MyW1t/; 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="s8MyW1t/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0717C4CEFF; Mon, 15 Sep 2025 08:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926634; bh=Tg++jEb0qzQoJaPtBtzDLbCLFkMuRzXyuZynLSvq9z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s8MyW1t/KY+ePpGZ7kfxfZRZBXGE5f4b73es1XFslk69eaQaAMgtMaeZGI3L8/NsK KAGz3FyHUAZOTmeog5TG72kUiRUp5CsuVPy7AuLErJFu2MKSVeh+F3Li51dPbqb7LZ bPXRm2bBsjYxqlVm2zUvWTj9uTLXg3D2yNm7pAb6NcUBG2B7EQUDyZ65/xtg+aFaDR k6qgSiUX1HOt8GldVlOEr9GuOZ8s8cI9InmQLHrgAQ1wK4ZTW4P1ckeHFrBsmMvlQU jq58QzrVRPj/0SUZHzQl7mwB8VUSiKBV3xVbgKdfUkfyfTaaL1XqRqHEzdN031SJZK n7YoGq73YbgPg== 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 1uy51L-00000006IHP-3rFH; Mon, 15 Sep 2025 08:57:11 +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 v2 03/25] of/irq: Add IRQ affinity reporting interface Date: Mon, 15 Sep 2025 09:56:40 +0100 Message-Id: <20250915085702.519996-4-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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..9a205cb033bda 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) +{ + struct of_phandle_args oirq; + struct irq_fwspec_info info; + struct irq_fwspec fwspec; + int rc; + + 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, + &fwspec); + + if (!irq_populate_fwspec_info(&fwspec, &info)) + 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 Thu Oct 2 15:32:37 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 C241B2F39B7; Mon, 15 Sep 2025 08:57:14 +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=1757926634; cv=none; b=tKfESgu3HNY2wnrIQr9Apjxhj0f9iZ5AAdHfeXn7hCR/KQd+d23cCYlYfW0rinsionsSQpfk+VI9r03oDvT+ZnJQQo8NVAyrTZN/i5/04iDTXX+IkY6SD4f7BpZrUZLpxeJPxiX5hHsHu9pDKMPaD8as80rzQUNKRtwbYWaPTwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926634; c=relaxed/simple; bh=G+swjEVbqFRe3VO4Brd816oEyLNB4BZ+ieu+z8ZYXlk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lrNjUszxbviplI0Vf7XL0mTXerpdBWoGtXqYN8Jk/t05xjpUACG5RdFbqggCAH5IohtgTbdKYi0MCgxoYLFbZewShxoGqKxAKIoPrMW9RQ/jR5DdKW01mpW/0PvbblOXWk6ednIEmLouQs4NIJASKlrFeSku6aGtx3QkJa/W4gQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gw/QiK76; 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="gw/QiK76" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F2BBC4CEFB; Mon, 15 Sep 2025 08:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926634; bh=G+swjEVbqFRe3VO4Brd816oEyLNB4BZ+ieu+z8ZYXlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gw/QiK76jERLB8zjuHvtUssZ/oo+7K45Fslr8NWx2K7Cm1NY/vSfbeZe01fBct85p qwyEwOpa5+V44BbgN9FcKDhvTQq+lZdGcX/tGkLBcdiOEqmMV2Bvo6Wrq1LiGVHkqU 3YGKk30ETbnS0Alm6h69mYnuaKS8IEq4r/QYv+uKeE5JYbwFFF+Z3WiJF51dnLG5iD uw90c4kW5sghtPWaCX1d6G+f5SXr3MQyqZGFsrMfKQ+iA0IaKYOfOhFhtUmqt70R5Z QdKY5VSSLj+GIOvipebvuwyFPAclKJyLRg6tgQJQaKxwZ8PXnp493SDv4FrtjPOY96 ORqSXjq76XxnA== 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 1uy51M-00000006IHP-0hZF; Mon, 15 Sep 2025 08:57:12 +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 v2 04/25] platform: Add firmware-agnostic irq and affinity retrieval interface Date: Mon, 15 Sep 2025 09:56:41 +0100 Message-Id: <20250915085702.519996-5-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Thu Oct 2 15:32:37 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 C23A02F39B5; Mon, 15 Sep 2025 08:57:14 +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=1757926634; cv=none; b=I2IGkfh6xCSyX0xqpjnWbJAYm/2NPiBoqyWb4aGWsy6+VpHYomEHWZ7R8q2i4V5qgAiY5DJjdF7dk7e77PO5L+wKp/GX0nta+6LKq2+jNHt/u4ouBQYu/9T/WfG2w86UhE/GX1Z6we4dGxMmmOQ9aX1wMg9uBb7vZjjiT9lxjY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926634; c=relaxed/simple; bh=b54oXtSJ1jOB+4cqyMvjMq57VTZoxc0ThWvLI8ltuVk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RrFgpaSHt5tq5t87zmaXviILCBLavB53X0oyR9O2DPpaJmSmkmlaDOK7GMARZr+Swr4Dp4CUwGZ/o8LxjZCG8OG/lGGWSwF87G9DLN0IyOBhTC4oMlQL8YYbvsaUtvSLmTtNx+Wj45aUP9QIe0S04zLroPxse9JvfZCRNWhyxHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KjPSf40E; 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="KjPSf40E" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6571EC4CEFE; Mon, 15 Sep 2025 08:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926634; bh=b54oXtSJ1jOB+4cqyMvjMq57VTZoxc0ThWvLI8ltuVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjPSf40E6TotVtFTseCZ7k5hHBxe+ZImDQR8/ElNulpp1ve3o5p7KZtWzGE1Uievc HNEo1y0XrLTxaI+SS7UgL5iihkLl4XwI1HrDaVkNG5jVMH41Y8giZbualFPiUGSupB ADA2Xj49/pL8+VMyijdfe2CSY/h4EwDaQ3I6kyOqU5lbKqqwGQogwlZdUv/AM5+wah Q+1KtZu2QYlaXID8IHFsUfizBmipkYTno0xtl/ZPrdmgJD0SOcXrWTnTjmIK+iMCtS UlF4BP4og2EADhqlcbUPOPkW8BFFli5xuCGxoAo8/DcXiZjQRDn7mvFqHACbtPmspZ Ymky/Wof7u3yw== 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 1uy51M-00000006IHP-1kaB; Mon, 15 Sep 2025 08:57:12 +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 v2 05/25] irqchip/gic-v3: Add FW info retrieval support Date: Mon, 15 Sep 2025 09:56:42 +0100 Message-Id: <20250915085702.519996-6-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index dbeb85677b08c..71c278ddd1e39 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,58 @@ 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_fwspec_info(struct irq_fwspec *fwspec, struct irq_f= wspec_info *info) +{ + 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)) + return 0; + + /* 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: + return 0; + } + + fw =3D of_node_to_fwnode(of_find_node_by_phandle(fwspec->param[3])); + if (!fw) + return -ENOENT; + + 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) + return -ENOENT; + } else { + mask =3D cpu_possible_mask; + } + + info->affinity =3D mask; + info->flags =3D IRQ_FWSPEC_INFO_AFFINITY_VALID; + + 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_fwspec_info =3D gic_irq_get_fwspec_info, }; =20 static int partition_domain_translate(struct irq_domain *d, @@ -1839,6 +1888,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_fwspec_info =3D gic_irq_get_fwspec_info, }; =20 static bool gic_enable_quirk_msm8996(void *data) @@ -2231,6 +2281,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 Thu Oct 2 15:32:38 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 14AB72F5319; Mon, 15 Sep 2025 08:57:14 +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=1757926636; cv=none; b=qN+pqqe/Sg3wvdGncO8VTswgyhZhISEWk/GAStXc9AU7xLUpNKwPsZE5blnjmzu+oc72FCxwBl0G71puozIJis+9/cfI1S+QWM8N1h71aKPJTMxRdh940QaQwv5QNbE+Y+p+qVd+IJs7CgOSjaKUlzGVQwQxtQ4zS/YWPQcj0vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926636; c=relaxed/simple; bh=4u1DgiC0kHhkv9VtJrOAXn89dh7UYCtkT3pFEWYEx0k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t7lpJXmArJK8oiMwFcxSt/+DBe5HTaVEvYA1pQ7WZbDj3C9CcljnSbRVaegMWN3rRU5vZZqqVjdQcWa0xdfpDF8svtc1FEdBzEJtbFP3YxM52fZzKDoyoms/cw5CvH9hRyqDF6DFUlgkr3VaznviOR2g8wwUr+fx1cLnQ+GHJGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h+2r6WO+; 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="h+2r6WO+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F308C4CEFC; Mon, 15 Sep 2025 08:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926634; bh=4u1DgiC0kHhkv9VtJrOAXn89dh7UYCtkT3pFEWYEx0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h+2r6WO+SKBzliTvYSVlZgZ0OWsTN+miH21Dd7EWrVPNWoBydRGxWdC5Kvj73b72T DvhuY3FKkPSwde1c+lKgRHcyDdgDZnQ+AJZAW9YIkbOQpBRpvr9HROeCFSHQvElV9K nk30kpWEIbNTMldBbfI3bmDvWK2t0CSMx7hGGzr9OIuLdMqmwlb2kuKJRPI+Q+UEWo J7tQB3vQmsyw3hDfKduAeI3f2+AW5P/htZKgHPxmkI0RciYV8HrD+NZ7sAfzI55Cl1 wRZKEH3vr9tWlx0E+Pftp83LDFxL3kFqK62n+fmo4nbg5L/DQDCFr6GoKDiRIVGz3r BQrGERW9/WEdw== 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 1uy51M-00000006IHP-2rPw; Mon, 15 Sep 2025 08:57:12 +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 v2 06/25] irqchip/apple-aic: Add FW info retrieval support Date: Mon, 15 Sep 2025 09:56:43 +0100 Message-Id: <20250915085702.519996-7-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Acked-by: Sven Peter --- drivers/irqchip/irq-apple-aic.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-ai= c.c index 032d66dceb8ec..cb8b6f40ce8d3 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -651,6 +651,33 @@ static int aic_irq_domain_map(struct irq_domain *id, u= nsigned int irq, return 0; } =20 +static int aic_irq_get_fwspec_info(struct irq_fwspec *fwspec, struct irq_f= wspec_info *info) +{ + 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_AFFINITY_VALID; + + return 0; +} + static int aic_irq_domain_translate(struct irq_domain *id, struct irq_fwspec *fwspec, unsigned long *hwirq, @@ -753,6 +780,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_fwspec_info =3D aic_irq_get_fwspec_info, }; =20 /* --=20 2.39.2 From nobody Thu Oct 2 15:32:38 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 EAC3D2F39CF; Mon, 15 Sep 2025 08:57:14 +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=1757926635; cv=none; b=ri/mb+o/UVzAa7jpdWuoR19nNWBCiSbz2yWf3sisnPr0rBolcNr9zieflgI4uoQNSmu3NA/QP+bz6SlrA1ikRVY0cnqm2/rKVG9UFDDRycK8iSi3/kU52nvT8pWXz38QqqhFFN3Liu3RmXA1hZ+VCswjKVdjYCq9kfM4Nxda//c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926635; c=relaxed/simple; bh=jQHOrUvrdulPrMOQtn05zaOApqc5lhkt4nBzVAEvlWw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CG8CuLayg5HYFhfmmudVmUI7+AlKxbk510cCzXUFKFBE8eTtjJGHXk2U0iwOjs0CrxDesqFf9nzQZeIuvGkLliJ9g/Jcs4TCcYpjdxQw9Z+vB2Si8LzBv0QkrQQGyc9+7adi2OETPVWp54aFeFlcX4b0fTleg5RLzZeOyGxyJRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mhEZNaJC; 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="mhEZNaJC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C74A6C4CEF1; Mon, 15 Sep 2025 08:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926634; bh=jQHOrUvrdulPrMOQtn05zaOApqc5lhkt4nBzVAEvlWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhEZNaJCOef+kjuudwquagxii3vPQdIanoRj6OFfUnBUUlN8fm1rbJPQ9S/BKrvQ5 Zp9O5ZOgux068/m4Ixy7HyArw1cavqKQCIG38Ty619Yol5Zrpg9fcoHnpiSutswoEP ZhDyAmdGgCwSHjwH3sboQ6OpDdH0E4elI7JagqhJjLI53VC2RTjb8Kqyq8VUaDSZgV ts6gu2rdjlmbLjaRoL7cmjuVkxlfhkI0LTSEi4w5vHM8nEU2+7kJ+5Ll21n2HS6b0i tGNT0O39khZcX2QW0P2fgLQfe3cZ7uehBs4plY/jSX62UgLhJCd2pFoxO3mhpaHt07 0Gmrl39nppT7g== 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 1uy51M-00000006IHP-3uqQ; Mon, 15 Sep 2025 08:57:12 +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 v2 07/25] coresight: trbe: Convert to new IRQ affinity retrieval API Date: Mon, 15 Sep 2025 09:56:44 +0100 Message-Id: <20250915085702.519996-8-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Acked-by: Suzuki K Poulose --- 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 Thu Oct 2 15:32:38 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 202592F3C00; Mon, 15 Sep 2025 08:57:15 +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=1757926635; cv=none; b=ZZZyJTmNm5EpkxvWRZeiMyqbVVIWC2CE4mMskZtnHzTR5f5AzB+3/rS3+sp3nr1wlAKIst888MJ5vjOfE8oPd6ppTNXCb2UiZLEAcf75Vm1TyGBw4PX0WwcvLbuPR9VM//k9TFNHLxZuun8iA8EuUsT8zQeAFrWCjT0r/6kEZGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926635; c=relaxed/simple; bh=gHNda0QWGnywO22OHTHAtrEXJraB/koPwbnWeNVZoWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=chwpimlQwWdIivuoZe1tcrl1vAYa0E1BpinMMHI68XhdM1Ghe0fIlp/X+/XoZnK0ZOXe2JyeX34ObdM947Y2uTEvUb1HkhJ/WQ3NmaukhGfqgHIcxKclboRr3TLptvM/MGJDOXqJ2RQG9D5pk1pTEu5N+mdFnEDjhJKo2QRUWIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mt8lf4DK; 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="Mt8lf4DK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 021D7C4CEFA; Mon, 15 Sep 2025 08:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926635; bh=gHNda0QWGnywO22OHTHAtrEXJraB/koPwbnWeNVZoWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mt8lf4DK5Em0WPwF/BQK2uapI4QT3/pn42dQjrg/IFg0v+jJOrd+iTrjmnAk1uMYh hqkIGL7Jo1NqFaEiaUCrfdQDBwx9dYIJ2vZRX8mNl+gGun5LLY3N3WSoNn9e6rJQET hhWTNWl11cZ+xlCq2IZK10lGzUuwu6QFi+oipOL+Vxwrrf8aJYNYP4pyhDNt1J1YBX oAuVhFdaQCFF/jLMeBSe3Da3uz8h9FNhUw3LbpSuBlHwOuMBuIH+kpY8qPZ4aaO2p6 BuWgbBiaPGmJSfwoRqNcbPCz1ftB54JKMsFYSt3mWK2rdwK/m8+AtqN8XbfmsHngPZ rc+0wNp2f8Trw== 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 1uy51N-00000006IHP-0kQD; Mon, 15 Sep 2025 08:57:13 +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 v2 08/25] perf: arm_pmu: Convert to new IRQ affinity retrieval API Date: Mon, 15 Sep 2025 09:56:45 +0100 Message-Id: <20250915085702.519996-9-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Thu Oct 2 15:32:38 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 7AB902F3C21; Mon, 15 Sep 2025 08:57:15 +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=1757926635; cv=none; b=SsjClj46OzOvLxB2R2GRXx9+8ux0gIiUuFDhjVuSuNdj7uapotYkYVX3y2znSZ70CBJ6wNniMGLXLLWLD7Ved+czMeHFhAjBwvab8XUtiA+nT69oQvumw9mudO+sdhRYlpeynSHL5sQHCHnhXc6KAxKQm0Pi6u7dkx4nuwChBYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926635; c=relaxed/simple; bh=BXehqBShX490v3aAs4Y17GiJfZWz8kwwWxRiKKAQ/G4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bg1tbrTwbLYxKwD3Irb3nzHVaOqUX4P8qnoml5rFgQ/HtJOINRqXMJdR82TUJOO5q4YuqgnMql93TPArJ4O3bCTMiOV8XKboX+Grv+qhF0nZ0pf8wVRTs3D6pKX2zci/1eVkFQz0ePeBa6oKZwDyqAotEaBuvp85vRWpjSks+Ug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qAsY1YT7; 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="qAsY1YT7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CA99C4CEF1; Mon, 15 Sep 2025 08:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926635; bh=BXehqBShX490v3aAs4Y17GiJfZWz8kwwWxRiKKAQ/G4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAsY1YT7BX7Y2ZvUjVN7i60TuTZ4MLoaL/jzxgNJbpn/6PhDH2lq8DJpAwXIXnsHz q462/cB/WUB9SZozwJt42UEg9YOCuwN189CFnW54lc9ph4V8gduKbOLZqKE6RjRe0x eHZY68uGfnipL3VkqiPyGtga5bCQxtK2pnP1iNCRgbnzvpUu7ap+aiFVxZdDnjv/b0 ETfFhh5keGo1IeSUEW8J1oTGZLMDoYI/d27c5yA50wAUhrO+tCNSoVtvgCX8C2BWFQ TyLRfOA1JADSRmI9VklliNSDlfLP470uvYEXy86WTlcbQuarjsPWc403REPT6EiVA5 LSrm9KkwybNAg== 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 1uy51N-00000006IHP-1mgI; Mon, 15 Sep 2025 08:57:13 +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 v2 09/25] perf: arm_spe_pmu: Convert to new IRQ affinity retrieval API Date: Mon, 15 Sep 2025 09:56:46 +0100 Message-Id: <20250915085702.519996-10-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Thu Oct 2 15:32:38 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 95DE12F3C2B; Mon, 15 Sep 2025 08:57:15 +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=1757926635; cv=none; b=Tyu1pBI23RlYAkkXPhI6hpRXV5AL/42/P/EMEFj+NmBiY1+5a6e/5mJ8nlHUFH5C+zfn1KXPgVvPgaUoWWI8vJCQKMDFbBDXZMGc/N3S5gOJ/rJRnYoGw6zC+mIxr6UT0pZgVvpOSSxliSRaN8wEkI/J9fb5+7vo2HFc+gCmb8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926635; c=relaxed/simple; bh=LS/6pQnqvUs94je+PqhhpjHJ2ODMwCZtOl3YKu+7+1c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=flDPkcSHdsot3yK8irLRf5d7YR9aSXfjupkV7y7jouKPBKTu0KdMowJ49xj+tarm03dfAnNQ6z6q3vPXImHuxHu7dEww4SG04wWgXlN5yhY+fhceSHkP2h4B+CzibecKQ9R5Q95FR5XK8XLX4mCS48IRWJ0TUF4puafOOmDl224= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d/apNTYq; 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="d/apNTYq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71F22C4CEFB; Mon, 15 Sep 2025 08:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926635; bh=LS/6pQnqvUs94je+PqhhpjHJ2ODMwCZtOl3YKu+7+1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/apNTYqb5kJnYJRCWD7XnZSi3e5U9QUxYhRb5F2Hvqc/lFZ1hyKydq0UpRZo3q8a QaFFFlG/sB/TG5T0xN/tAX8DVMt5sS/QoJpRnU4iz94ySdOYVCyVf7JsNHs1bhEeN8 4yd5wKbk4pH8H1/+aZ6GwN//QR73Gdr0UgSpXtX5r4casN4oQYQMhWKM1lWCb9H5fJ ZH3xguLshnWxq9jIa3di2ybchTuU9rjpQzU9D3XLa6mCqI0snmdjpLuBclkhLp/jES a/ByZxceMbF98S3Edst48KKNBvwyNdS1wFrbRW7BBSFFJ8Q1GiBkxNF9XAt46UDtqp JQAMU28U8LDNQ== 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 1uy51N-00000006IHP-2re3; Mon, 15 Sep 2025 08:57:13 +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 v2 10/25] irqchip/gic-v3: Switch high priority PPIs over to handle_percpu_devid_irq() Date: Mon, 15 Sep 2025 09:56:47 +0100 Message-Id: <20250915085702.519996-11-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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" It so appears that handle_percpu_devid_irq() is extremely similar to handle_percpu_devid_fasteoi_nmi(), and that the differences do no justify the horrid machinery we have in the GICv3 driver to handle the flow handler switch. Let's stick with the standard flow handler, even for NMIs. Suggested-by: Will Deacon Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3.c | 54 ++---------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 71c278ddd1e39..a14fd4c269692 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -230,9 +230,6 @@ static void __init gic_prio_init(void) !cpus_have_group0); } =20 -/* rdist_nmi_refs[n] =3D=3D number of cpus having the rdist interrupt n se= t as NMI */ -static refcount_t *rdist_nmi_refs; - static struct gic_kvm_info gic_v3_kvm_info __initdata; static DEFINE_PER_CPU(bool, has_rss); =20 @@ -608,24 +605,6 @@ static u32 __gic_get_ppi_index(irq_hw_number_t hwirq) } } =20 -static u32 __gic_get_rdist_index(irq_hw_number_t hwirq) -{ - switch (__get_intid_range(hwirq)) { - case SGI_RANGE: - case PPI_RANGE: - return hwirq; - case EPPI_RANGE: - return hwirq - EPPI_BASE_INTID + 32; - default: - unreachable(); - } -} - -static u32 gic_get_rdist_index(struct irq_data *d) -{ - return __gic_get_rdist_index(d->hwirq); -} - static int gic_irq_nmi_setup(struct irq_data *d) { struct irq_desc *desc =3D irq_to_desc(d->irq); @@ -646,20 +625,8 @@ static int gic_irq_nmi_setup(struct irq_data *d) return -EINVAL; =20 /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx =3D gic_get_rdist_index(d); - - /* - * Setting up a percpu interrupt as NMI, only switch handler - * for first NMI - */ - if (!refcount_inc_not_zero(&rdist_nmi_refs[idx])) { - refcount_set(&rdist_nmi_refs[idx], 1); - desc->handle_irq =3D handle_percpu_devid_fasteoi_nmi; - } - } else { + if (!gic_irq_in_rdist(d)) desc->handle_irq =3D handle_fasteoi_nmi; - } =20 gic_irq_set_prio(d, dist_prio_nmi); =20 @@ -686,15 +653,8 @@ static void gic_irq_nmi_teardown(struct irq_data *d) return; =20 /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx =3D gic_get_rdist_index(d); - - /* Tearing down NMI, only switch handler for last NMI */ - if (refcount_dec_and_test(&rdist_nmi_refs[idx])) - desc->handle_irq =3D handle_percpu_devid_irq; - } else { + if (!gic_irq_in_rdist(d)) desc->handle_irq =3D handle_fasteoi_irq; - } =20 gic_irq_set_prio(d, dist_prio_irq); } @@ -2079,19 +2039,9 @@ static const struct gic_quirk gic_quirks[] =3D { =20 static void gic_enable_nmi_support(void) { - int i; - if (!gic_prio_masking_enabled() || nmi_support_forbidden) return; =20 - rdist_nmi_refs =3D kcalloc(gic_data.ppi_nr + SGI_NR, - sizeof(*rdist_nmi_refs), GFP_KERNEL); - if (!rdist_nmi_refs) - return; - - for (i =3D 0; i < gic_data.ppi_nr + SGI_NR; i++) - refcount_set(&rdist_nmi_refs[i], 0); - pr_info("Pseudo-NMIs enabled using %s ICC_PMR_EL1 synchronisation\n", gic_has_relaxed_pmr_sync() ? "relaxed" : "forced"); =20 --=20 2.39.2 From nobody Thu Oct 2 15:32:38 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 DCCB32F4A0F; Mon, 15 Sep 2025 08:57:15 +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=1757926635; cv=none; b=t/bvT1yDOASTj56uSffuQut+9TPKT92t91M/iB1UBruLawwjDOjXS1TosXvvm65FFHyPa7VKyTYPJ8GeuWEhlQlltOg767Bn1vwoOI50matnT0gJRzKL7gdU88a/7v/w4EmypFdZnv/fPmlKd/mrwLC5tOk3iHrymbGGv18DWJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926635; c=relaxed/simple; bh=6u/gpZ6YckoKaeQpYH44xQmuVDlG8thNzuOSAyOF6/E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XEVCeLLsqnLSw27dv+60N7TuHImn3/aJqPtWVzBbemfO7w0mdWblGgS3Y6MQe/W2emmS/ZnHgsljoWhP5Y00gwuLJluymhFOzy9nT4pKRs6A0VPHJKAEx5C+Iw1DFKxrALNEAzEXtKKGkZfLxB/+InwoPXvJCcyE4BBKM6tk5Zc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hj2pEWdZ; 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="Hj2pEWdZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC9A9C113D0; Mon, 15 Sep 2025 08:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926635; bh=6u/gpZ6YckoKaeQpYH44xQmuVDlG8thNzuOSAyOF6/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hj2pEWdZSAR5UvhIlIEYVYke8cAsRdBmoGlEn4cI7Na9ib8+5xeSIqSfBYXjP8Pjc dBqdxQ2IRUWWNsity5FW9r1UTjU5nc7rlSK/aZ3O82o6VlZGNiUko7d7BOj8TQJj7G Bv2G4ZiPUYdW/4H59gwYxBJpp6GvqSotJfnogXcojU0LgrzAi2CBbIZznInqYel5GT 9diPInSRJlX0M1kT++phoEu7isTX9dZlXu+XX6w7BtzQRDEFXa4qDjodE1oAxZNt+W hdrvSU99cLwChdAhvUE8mP1q2V/RGmhZM19RikO4+6Np/MCcrbJszzo21Yglwd1H/U 8WQNfStISdhCg== 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 1uy51N-00000006IHP-412L; Mon, 15 Sep 2025 08:57:14 +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 v2 11/25] genirq: Kill handle_percpu_devid_fasteoi_nmi() Date: Mon, 15 Sep 2025 09:56:48 +0100 Message-Id: <20250915085702.519996-12-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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" There is no in-tree user of this flow handler anymore, so simply remove it. Suggested-by: Will Deacon Signed-off-by: Marc Zyngier --- include/linux/irq.h | 1 - kernel/irq/chip.c | 28 ++-------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index 1d6b606a81efe..1381f9d1f5c9d 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -655,7 +655,6 @@ extern void handle_bad_irq(struct irq_desc *desc); extern void handle_nested_irq(unsigned int irq); =20 extern void handle_fasteoi_nmi(struct irq_desc *desc); -extern void handle_percpu_devid_fasteoi_nmi(struct irq_desc *desc); =20 extern int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg = *msg); extern int irq_chip_pm_get(struct irq_data *data); diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 0d0276378c707..869068ec6ac91 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -892,7 +892,8 @@ void handle_percpu_irq(struct irq_desc *desc) * * action->percpu_dev_id is a pointer to percpu variables which * contain the real device id for the cpu on which this handler is - * called + * called. This is also used for per-CPU NMIs, so special care is + * required. */ void handle_percpu_devid_irq(struct irq_desc *desc) { @@ -929,31 +930,6 @@ void handle_percpu_devid_irq(struct irq_desc *desc) chip->irq_eoi(&desc->irq_data); } =20 -/** - * handle_percpu_devid_fasteoi_nmi - Per CPU local NMI handler with per cpu - * dev ids - * @desc: the interrupt description structure for this irq - * - * Similar to handle_fasteoi_nmi, but handling the dev_id cookie - * as a percpu pointer. - */ -void handle_percpu_devid_fasteoi_nmi(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); - irqreturn_t res; - - __kstat_incr_irqs_this_cpu(desc); - - 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); - - if (chip->irq_eoi) - chip->irq_eoi(&desc->irq_data); -} - static void __irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle, int is_chained, const char *name) --=20 2.39.2 From nobody Thu Oct 2 15:32:38 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 138B42F5316; Mon, 15 Sep 2025 08:57:16 +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=1757926636; cv=none; b=LBde9gpscWYteD8xJTk96a4Pa9Pcoeqh3uJUvxF8kYyzx9lL/x9X8/GP/Xx4ZtcPIm4nV8Lz+e4EDjNDbfPD6Xkx+lmr37DIpJzNtmBV6kAI37BcXtBjxzIEjID0SUCHMoPth+TXN7T5oJiJn8mz+RCvQPkORL+jsx/WINqB2Ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926636; c=relaxed/simple; bh=FpP+wQwpUSsvvoV5l0PFF2kZyltIOuG1yyX8/6val7c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IBA5QY0V+Dz9H0Z7STrknNs/b2xhEDKinvSRaV9qsJxqKtDm1pg8JsR2dn1daI3YVn7mMY7h/p3Tq/QK7+urJHAWq88T1bB9cQTGxS2v5q+gMFchemMqkhLSfhjorxRuxshcY+FJR6K5yEqy05Z2okrwQji0q6zDMkt+7DqgT6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HwOMJ1Qs; 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="HwOMJ1Qs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E79BDC4CEF9; Mon, 15 Sep 2025 08:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926635; bh=FpP+wQwpUSsvvoV5l0PFF2kZyltIOuG1yyX8/6val7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HwOMJ1QsCKHum3+O6tpah9nAC+QaK2hT3MKttI5GVKDkep/VY13D4hs+pACNcCe/U D8EcTkXezdYRdovltwMnP+CYLor7PI4IgvPmqkvguLV8qzCGFntnwD0VV/WPUGi5wZ MxHni98v4JFcoqLMIgfRHSdoNhyMZgo8h0zAKvvfBX4QY+sWDcchXqGTFV42Xrgrkj buA+Ace9YFsWz3HMAUSXkfbSb2Nw5wYmHODCTJL0x7vziXV+wYmfwTSGT7sjT0WMST 84ThnVflZxJ3g424ApIBph6C4BLCP4zZ09mdViZvsYrORa2RgjwgpbPMACEOI0E2uo rEDPvVpf/E+Nw== 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 1uy51O-00000006IHP-0wPL; Mon, 15 Sep 2025 08:57:14 +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 v2 12/25] genirq: Merge irqaction::{dev_id,percpu_dev_id} Date: Mon, 15 Sep 2025 09:56:49 +0100 Message-Id: <20250915085702.519996-13-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Thu Oct 2 15:32:38 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 AB8C72F6567; Mon, 15 Sep 2025 08:57:16 +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=1757926637; cv=none; b=VeoeCVL21aM392sKJBTwvsmIsXHyBzpOUHIxAwwlfqDsg+pd8Z0ibT+gqsIwsWFs0s4TFEs7q4uy9qjAWo5SfxqHdUkooW+ENSH3dw/smqCLP/PtYOSXQ/xfduGvzKmAjIhApQGl+73LpyfsvnX8H3POo3S8PbZZOxpcSWqDoTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926637; c=relaxed/simple; bh=Guk8n6/b1YLuhiRYFvNKDDOTih1DJLDZjQ/MgdDE/uI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gpD+LUgVTq+2iZoF1baa9Zijx8GFhbwJEs65cStBC+mqhHYrFoGodAPh/nARi9P8+3WLTC9cXHVLISVRsXzEIHRSk+UaReVHzTliBnc16+ngwlkZ7A2kO05Y7rjtEkKPYMwGAefqIrXVbYaqhkY+bURW7ucxB6expFHPPFq7NwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XR17KXaS; 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="XR17KXaS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49064C4CEFE; Mon, 15 Sep 2025 08:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926636; bh=Guk8n6/b1YLuhiRYFvNKDDOTih1DJLDZjQ/MgdDE/uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XR17KXaSC/YvOWLt4YEscxJ5UGR3ahv++IZYFJsyCBLM6bai3fxliBp8sGLKnSn/7 0NHgpc6R8s+nZBGg54NXu1Hi8OLVdMzxgEF/dAs+l6EYLmsbnm6gV4tC+GeBMYaK/D 0GEk7gfRD5reIFnBLqmpAlRzIm3Hjex/7hZNfONq4xNXIyXtbmc+DL0/fMR80NVazk yXFkwICk1Kr/i31k5MY3JfPqdLFwM1I6ONHG/c/OLSc7ofJ/Epjg2kMqUii6aScZUS jdOzt/DDtWknNgFnCcuyaj+XGBcv+Rh/7nRgj36FteXv4X9QMe52/M9XeBCvJN6zvZ qW3pshMCy10gg== 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 1uy51O-00000006IHP-1ybI; Mon, 15 Sep 2025 08:57:14 +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 v2 13/25] genirq: Factor-in percpu irqaction creation Date: Mon, 15 Sep 2025 09:56:50 +0100 Message-Id: <20250915085702.519996-14-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Reviewed-by: Jonathan Cameron --- kernel/irq/manage.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index c94837382037e..d9ddc30678b5d 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2442,6 +2442,24 @@ 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 +2468,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 +2495,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 +2559,11 @@ 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_NOBALAN= CING, + 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 Thu Oct 2 15:32:38 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 AB84E2F6566; Mon, 15 Sep 2025 08:57:16 +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=1757926637; cv=none; b=F5AjD87yglM0vbhNoUd6FUhVG0keHFs0OlWGtYk25SIsENN0RXzTq/+/ZJecDSnQ7m8NjL98Wj53UYmnkjK9jq1NxTOWvuajMRlMPeG5BFfzPV2g4fLd4tTxokrPtL2Itf8dsCzLVhkh/iZc3FKFGLE9VvIULfSGhp5vdCjbY1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926637; c=relaxed/simple; bh=moQDT67ADmkTc/Mnh9WXwV014se3hfJE6513Q++4pLs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KfZba40LKyhwG/pDK/OaC4F/yf0o4Imic2sa7Dk24RA4x/WgJd4iy/0+R20kZedvj+bz+ZMyWPd/eV30VD2V16jKrPMM/Jo2AvLTSat75Qv0PMXTStgvRC7yjN4Af/WYeppAzcw2mkMZ8AGOsaHNAaJOSdW86dLaqiZnICRnCR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kcjqmj2y; 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="Kcjqmj2y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E86FC4CEF1; Mon, 15 Sep 2025 08:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926636; bh=moQDT67ADmkTc/Mnh9WXwV014se3hfJE6513Q++4pLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kcjqmj2yMMjEqP929aRLFlnnlvBiks8066D23nBefSg3Xo3PVdJy6cGWoX0140Y8k OYUF/NCJvfX0XBxRYPfX04AoQf4un58gya7xETHlq86SCXv4epzOa/kvhz2OJWTOnU Hsu7KckNF1fRdjtVBk8f6Vg7jWYRKZDZWg0svz+v3GPLoNPhomoFYC1FB6jObXDtCk mkBwMgcMJZWiEnMMwNEHbBW2crqgagXHL2weEb50LqNIvdOHaF5jLjttUjGSBNSaDR 8cIyQDC/8q6bKuZMBklDJLEYqM72a+ggfQiPHJOkNASS9hgwiNcf/xXPmTsdPM144e MCrO5utozHyxw== 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 1uy51O-00000006IHP-31vQ; Mon, 15 Sep 2025 08:57:14 +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 v2 14/25] genirq: Add affinity to percpu_devid interrupt requests Date: Mon, 15 Sep 2025 09:56:51 +0100 Message-Id: <20250915085702.519996-15-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 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 d9ddc30678b5d..5f4c651677436 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2444,10 +2444,14 @@ int setup_percpu_irq(unsigned int irq, struct irqac= tion *act) =20 static struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned = long flags, - const char *devname, void __percpu *dev_id) + 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; @@ -2456,6 +2460,7 @@ struct irqaction *create_percpu_irqaction(irq_handler= _t handler, unsigned long f 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; } @@ -2466,6 +2471,7 @@ struct irqaction *create_percpu_irqaction(irq_handler= _t handler, unsigned long f * @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 @@ -2478,7 +2484,7 @@ struct irqaction *create_percpu_irqaction(irq_handler= _t handler, unsigned long f */ 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; @@ -2495,7 +2501,7 @@ 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 @@ -2560,7 +2566,7 @@ int request_percpu_nmi(unsigned int irq, irq_handler_= t handler, return -EINVAL; =20 action =3D create_percpu_irqaction(handler, IRQF_NO_THREAD | IRQF_NOBALAN= CING, - name, dev_id); + name, NULL, dev_id); if (!action) return -ENOMEM; =20 --=20 2.39.2 From nobody Thu Oct 2 15:32:38 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 D13002F616F; Mon, 15 Sep 2025 08:57:16 +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=1757926636; cv=none; b=aWK4bOa3MGbH03+AVNdY8f2xVKqnPxJ2OAkbMoOe+GH3yf6nSIIlmUCIudXGO7WpKo1ZJqb7gL+0fEv+WtmWtvPEyLOFDOI7qp3Ht9gOuueT/W4HF2tDJegs+3p5BF4VPPQZYKZS6SSE8eEDxgBadpQOXP27R95xTVTgmDA05jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926636; c=relaxed/simple; bh=EZQ4JrqHharY6q8WNQFJbTXtkce/9D5/UoLm8tht2Z4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bnQSkiAk4zhnHMWCW4MBS1k1msU+IPjU5E5ZHVV38EfA7debJx4t5vRx4bonF+sVAA3VKNC+Q6kjO9pSlP4HQC55Uc8UfsuNs4IyQqMeH6bQHb+kuc8CuzzXrk/nhpbsQurOl4jupBqqeF02cQVYF4PJ5K8Q3l5YUmoNs8ri6go= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jtlC0EEL; 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="jtlC0EEL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0516C4CEFB; Mon, 15 Sep 2025 08:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926636; bh=EZQ4JrqHharY6q8WNQFJbTXtkce/9D5/UoLm8tht2Z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jtlC0EELpPCRFAtkDfYPeiH7WNB1BsZ0mnjdn6xtexr6OJNvwUJSgswNjbDr0kQXk /yL7DdaTGcq7b03y2EYlurobTXdBoPl3TK3x8wBxGE67CNA4YRQELhCKAAHHIhUnAm Lh9NIzh21ByLRvufhT+X9adGDMF2r0+M/E5xR3FRSp+iQuSQI5jyFSqz+MXN/uDuVH C4U789t+OFxeUBcot5BvmVR7K5+V9RX8bftukUn8+vSdUkwjxBERTrJB2dDCrYi5v8 xeFQ6UGh2fSIbpzk1W6yOsRWmDAIEsVmSYIgJ6HjKsHp+QGCdW4xA5+QmS9vxPlhU6 sUx3ubxdoWOvQ== 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 1uy51O-00000006IHP-44RS; Mon, 15 Sep 2025 08:57:15 +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 v2 15/25] genirq: Update request_percpu_nmi() to take an affinity Date: Mon, 15 Sep 2025 09:56:52 +0100 Message-Id: <20250915085702.519996-16-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 5c310e803dd78..de9eca2290a97 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -659,7 +659,9 @@ int armpmu_request_irq(int irq, int cpu) irq_ops =3D &pmunmi_ops; } } else if (armpmu_count_irq_users(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 5f4c651677436..49c237aca2a70 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2527,6 +2527,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 @@ -2544,7 +2545,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; @@ -2561,12 +2563,13 @@ 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_NOBALAN= CING, - name, NULL, dev_id); + name, affinity, dev_id); if (!action) return -ENOMEM; =20 --=20 2.39.2 From nobody Thu Oct 2 15:32:38 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 38ED42F6182; Mon, 15 Sep 2025 08:57:17 +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=1757926637; cv=none; b=qMkRLoJYa1jCSkdXE2GNXuR62l+wbcGeUaWN8ji+REa7KhHYb44YrOFYCJYnnbf9//+dP8dhhDVAObdwMoJP7lZsJOp+soxypAJdLubtDG9h9RzS36rnf/9lok0pM7a2ev7Oygv4OPysD5Hw5aAgREDC+0c5pRoN8rhO16ZTkjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926637; c=relaxed/simple; bh=ObJzm88OJ49mVZNrIXgLd5Q7+GhtWwWLGemAvCRoya0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M0/pvF7FtmkRph5FZXUWuR4hUeIWPseVkoJsMIXsBnUhp0cwzP7g73mjLHm8HdVnSQ8ylPxM5GXPFKuohIRd08/1YN9VXrz5aYEGLECDAA1qUEk71dmdWhTMz/07qT9e2XwFii6P4qrlBYa3c3xEZhTGvbhNCujo/WLF0usG5vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LgP5RyLa; 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="LgP5RyLa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F14CFC4CEF9; Mon, 15 Sep 2025 08:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926637; bh=ObJzm88OJ49mVZNrIXgLd5Q7+GhtWwWLGemAvCRoya0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LgP5RyLabbg6LSTg5bpNOSmiVY6wQkC0XwjFuhIGyyo5S8tPuBLMs7kztQnSIrZ9Z GzaVXR6B9q7rqI2nNURJzuvhY0ArAXqKKngj1vgPj/BOVXZya+TUZTLR1qwTmTrgUA g32LoxILkX0wrOqaNvRB8YaU6Aym3BAdnlUKuSD//nyQ1SSXdLtT0l3/8vyTXDS88K qGN62vNzej0GdTuYKjEwosyGFJwQAv0Yj5WA0YE/KpFX5GBzy9z6CKWD56lSvLKkK4 Tlgh7k5TWM0sQJOGCjCfynfdoppgnCAErMQyhe8ovfP9q/fI+vwwJo9z1ZxzFxrPtX pGfrnCOI/ADxA== 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 1uy51P-00000006IHP-0xfB; Mon, 15 Sep 2025 08:57:15 +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 v2 16/25] genirq: Allow per-cpu interrupt sharing for non-overlapping affinities Date: Mon, 15 Sep 2025 09:56:53 +0100 Message-Id: <20250915085702.519996-17-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 869068ec6ac91..f60a2268fad1f 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -898,8 +898,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 /* @@ -911,12 +912,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 49c237aca2a70..39db60a5f36f3 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); @@ -2462,6 +2497,14 @@ struct irqaction *create_percpu_irqaction(irq_handle= r_t handler, unsigned long f 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 Thu Oct 2 15:32:38 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 621C52F618E; Mon, 15 Sep 2025 08:57:17 +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=1757926637; cv=none; b=PGiBnc1d2Ehnp2L8Ub1wjmwpeJvpsDciPFvxZEKv9e3JZ4/fRt8wYDExwsb0/tRP2SW2/I9mw1KQxwLRy/IZWtDjaDeSOQ5Ca7yay3I1AZH8uVtMN2G7StxTjydRkTAmMxpN2dWcIUSkqf/CHEqLoX7yVhr9H5dSh+W3KaT01+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926637; c=relaxed/simple; bh=a5Pq4IyChIRNpCI1Y1MOptr/VB0oiXKYMj/CA7z9q3U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rybZyS/k/utiiHNj+N2f5P5rMzzz2TCWpDXhbk9lRkqQzCQgSVwRvx1OurhhMSaSu4IsI88ZRlkSGZzQC0QIZh/bvM3GudMQgwb1ZzDD4+T2ZNRL/i+JTsRcZ9GuTs58oBZ5ZS/IRIJNdL85/5HTV08wtKtaherUf8G5+SsFqbU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qt2suhNt; 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="qt2suhNt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40A83C4CEFB; Mon, 15 Sep 2025 08:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926637; bh=a5Pq4IyChIRNpCI1Y1MOptr/VB0oiXKYMj/CA7z9q3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qt2suhNtBryNbVM6DmZ8ZNhYrUzzxxAGTLn4ERk+k7tzEwRvzafwQ6VfjIMqfXSxa 8zX9+meYdetpRmN/NuHhlox0X8NsejOuszCIH316PfWfK1auIo6YbwmwWtNQdDbMZp iGhDIS4rFdEyTAQBvpfRWCG7jdX83+MGY5/uGG5Jq6SWFvGce/5TcMqvmJr4ikZHXD ZXFe3/53qH//uGugC3cv1IeWh91KElkNK5pj44gII5yh/mI63Vh+7/nxGKUDn4OgGV ivlf1g2rRFsFP0rac7Tk9VRyo2LgaoHaouXU7B/5zujfKErLpGcX8J+EV1q27KM+ai ji5DCEuT7/oWQ== 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 1uy51P-00000006IHP-23aU; Mon, 15 Sep 2025 08:57:15 +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 v2 17/25] genirq: Add request_percpu_irq_affinity() helper Date: Mon, 15 Sep 2025 09:56:54 +0100 Message-Id: <20250915085702.519996-18-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Thu Oct 2 15:32:38 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 CAF882F656E; Mon, 15 Sep 2025 08:57:17 +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=1757926637; cv=none; b=ZHRuQRHT5ImSTtdu62xB3cxRh67fImA1UIhacIQJUxzt6gVlU4CYJw3NvqmsZCOo9uYzk8Mc+HWjwSYWDJLDmfRd0ciIyBJ48vI//uYBTUlF7FXdKv4PrN4LsWQNjFnk7GEqVHV+5WqgS24IC/mKs6Ofd57Uqp47hNArbPnxkW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926637; c=relaxed/simple; bh=dDSsFz9x4AmxLScs5OfHreE4DSm6G7XuVulYGS4eOWw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a2E1BAaVLr7LRhLUfO+nTfcHsK1/gjJ/ByaLktp1NwCoPbMK8hDNI0ErpSZEhFoLJkdmJbw0jM6dXC5FDy6VegcMtkk6CNFcw0yq+8HBPqmGc0rknkNdjWMLOCsWjGFWQsQ8BC8aVopRzMBXIrVggEmPY0qnNnFFP3xLz/oBCQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rImKniBZ; 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="rImKniBZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EDBCC4CEFA; Mon, 15 Sep 2025 08:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926637; bh=dDSsFz9x4AmxLScs5OfHreE4DSm6G7XuVulYGS4eOWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rImKniBZSsgRcQC5sVu7hMc7vjrQLMyFNruICGSLCXQEA+64WVHnfhK3GK47VtTOB nXOMEcam9ubQayNuGpCgJ0dWrTNQq73Wmzb/LyGu3i7iuXp7exS9iUGNz23I2e++ui emIiPxzu3UrKJhaur3QVXUw4Q2RTptWmZRg/qpmWr9KY2d49GGoNfikNtyqZ4JjCnx SMAIhifhtmD1D2rPv+258rQWykWzfCk1AnJaCLJRLSKQfFIRQNCOeNofan+Ln2tu8A c001EM/6yeQvuE8TwQ1+/Gbfs6gQ2H7l57trLHtPdjvV0y51bpzbUXNWOPCVSjZfNs VxPXIpm4z78QA== 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 1uy51P-00000006IHP-3DZu; Mon, 15 Sep 2025 08:57:15 +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 v2 18/25] perf: arm_pmu: Request specific affinities for percpu NMI/IRQ Date: Mon, 15 Sep 2025 09:56:55 +0100 Message-Id: <20250915085702.519996-19-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Let the PMU driver request both NMI and normal IRQs with an affinity mask matching the PMU affinity. Signed-off-by: Will Deacon Signed-off-by: Marc Zyngier --- drivers/perf/arm_pmu.c | 47 +++++++++++++++++++-------------- drivers/perf/arm_pmu_acpi.c | 2 +- drivers/perf/arm_pmu_platform.c | 4 +-- include/linux/perf/arm_pmu.h | 4 +-- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index de9eca2290a97..23814707cf771 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -26,7 +26,8 @@ =20 #include =20 -static int armpmu_count_irq_users(const int irq); +static int armpmu_count_irq_users(const struct cpumask *affinity, + const int irq); =20 struct pmu_irq_ops { void (*enable_pmuirq)(unsigned int irq); @@ -64,7 +65,9 @@ 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) + struct arm_pmu *armpmu =3D *per_cpu_ptr((void * __percpu *)devid, cpu); + + if (armpmu_count_irq_users(&armpmu->supported_cpus, irq) =3D=3D 1) free_percpu_irq(irq, devid); } =20 @@ -89,7 +92,9 @@ 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) + struct arm_pmu *armpmu =3D *per_cpu_ptr((void * __percpu *)devid, cpu); + + if (armpmu_count_irq_users(&armpmu->supported_cpus, irq) =3D=3D 1) free_percpu_nmi(irq, devid); } =20 @@ -580,11 +585,11 @@ 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 struct cpumask *affinity, const in= t irq) { int cpu, count =3D 0; =20 - for_each_possible_cpu(cpu) { + for_each_cpu(cpu, affinity) { if (per_cpu(cpu_irq, cpu) =3D=3D irq) count++; } @@ -592,12 +597,13 @@ 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(const struct cpumask *affinity, int irq) { const struct pmu_irq_ops *ops =3D NULL; int cpu; =20 - for_each_possible_cpu(cpu) { + for_each_cpu(cpu, affinity) { if (per_cpu(cpu_irq, cpu) !=3D irq) continue; =20 @@ -609,22 +615,25 @@ static const struct pmu_irq_ops *armpmu_find_irq_ops(= 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 *pcpu_armpmu, int irq, in= t cpu) { int err =3D 0; + struct arm_pmu **armpmu =3D per_cpu_ptr(pcpu_armpmu, cpu); + const struct cpumask *affinity =3D *armpmu ? &(*armpmu)->supported_cpus : + cpu_possible_mask; /* ACPI */ const irq_handler_t handler =3D armpmu_dispatch_irq; const struct pmu_irq_ops *irq_ops; =20 @@ -646,27 +655,25 @@ int armpmu_request_irq(int irq, int cpu) IRQF_NOBALANCING | IRQF_NO_AUTOEN | IRQF_NO_THREAD; =20 - err =3D request_nmi(irq, handler, irq_flags, "arm-pmu", - per_cpu_ptr(&cpu_armpmu, cpu)); + err =3D request_nmi(irq, handler, irq_flags, "arm-pmu", armpmu); =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)); + armpmu); irq_ops =3D &pmuirq_ops; } else { has_nmi =3D true; irq_ops =3D &pmunmi_ops; } - } else if (armpmu_count_irq_users(irq) =3D=3D 0) { - err =3D request_percpu_nmi(irq, handler, "arm-pmu", - NULL, - &cpu_armpmu); + } else if (armpmu_count_irq_users(affinity, irq) =3D=3D 0) { + err =3D request_percpu_nmi(irq, handler, "arm-pmu", affinity, + pcpu_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", + affinity, pcpu_armpmu); irq_ops =3D &percpu_pmuirq_ops; } else { has_nmi =3D true; @@ -674,7 +681,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(affinity, 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..e80f76d95e68b 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -218,7 +218,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 9c0494d8a867a..1c9e50a132015 100644 --- a/drivers/perf/arm_pmu_platform.c +++ b/drivers/perf/arm_pmu_platform.c @@ -165,7 +165,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; } @@ -181,7 +181,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 93c9a26492fcf..6690bd77aa4ee 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -190,8 +190,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 Thu Oct 2 15:32:38 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 EBE022F6581; Mon, 15 Sep 2025 08:57:17 +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=1757926638; cv=none; b=dQIYGSLC5UUJkcsNgqJ1ydxBRtLqO1ImI2LM94r7PwMMHaxpYAf/JXmccLl8s9JSsAK+qpoEw7iyIAxJRO8mMJIFLVe8IdjQe2P3+AE6zCQr0Jh5n3Af9hZManyiLeViGuXelNUGMACApqBdeEvU2Pr4N9uav/cA7+MOPpzSS/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926638; c=relaxed/simple; bh=fWLFQJQCjHkUmgzJrwoVr3TR8ormeAz7AFVrQDQpANU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bnKyWbPyAYhfTwoaCHPmQdPdP/YhgE6+7kjhhkTcVYxqetxesNIGTh08aZAYHU13swopmSgHoqtGZ/8YouQDkLIOnCHEgWoNK6fnDtSzKThseG3zOYVJa1QIorBEq8tXL6by5JkNwbZjtHxzvyznvYpQo6IzdHRHI/xyicjtGrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VnA1dcGA; 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="VnA1dcGA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCA1BC4CEFD; Mon, 15 Sep 2025 08:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926637; bh=fWLFQJQCjHkUmgzJrwoVr3TR8ormeAz7AFVrQDQpANU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VnA1dcGAWiexuI6w+IKEAW0AKhpD9wxz1i1f364cFyecz5nyEiN4ldn27bBvVJ5nx 37Axx2muW1VsAJcbyYk6Tq0H51RmxyvA16KSPdQZjeIwptOTef6KXVUK+hgwFcoaJK lA5OKaSwXlLE8YikuVy1sT7RK7xfh+2eHORK3Qlrl6VziHrUg1FXZoDktD78Ab7GLH VLVRwMkeO+RZJM9TbILn6GfFyT8s3nZkjW7kqYbcG2E9P/PRnWs2aHUkVlLIgor88u LwntpESCRIchcUHsagNxhEgBf/DpCWuHYPWQ6yLgjsaLN1CXMC910tMXRogVtohhDS MJmje0oFtxD0w== 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 1uy51Q-00000006IHP-09bv; Mon, 15 Sep 2025 08:57:16 +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 v2 19/25] perf: arm_spe_pmu: Request specific affinities for percpu IRQ Date: Mon, 15 Sep 2025 09:56:56 +0100 Message-Id: <20250915085702.519996-20-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Thu Oct 2 15:32:38 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 443A92F745F; Mon, 15 Sep 2025 08:57:18 +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=1757926638; cv=none; b=Yg6Mxf5T0PAeugCpS8tJEqaJU6+1IS1BOaceFdzrWrtI3jg0v1A+fvfZZRwLVlk1vE6bOb7IEg0o9tTjuqmYSZ5phgtA6MHxy5Y6/98v2ZWMdPrKwAxOEOdEMZMMaTT+UOWPSzw3tcXLAmX+yoDaqubKycZxnDdHO1EfP+vwdQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926638; c=relaxed/simple; bh=Cd0M6Ctqz2mIs5KmsrNG7gPuEf0W9llFNTYE/JJTtFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=srxUG13SaaeQBtrGJ+GYKs4HxFQ3PnTx8kLLSKeHVON7vgznfwaRGcAmAJkzq0nQWADUpd9Ul3n324Ge3RM/BkBHCVYrQeJLuF8eU5XXXfp/yq1xPM9MozlBxKQlCiGuFURlHOm0WtZ+GomYcvMqfKdnDigwzZurCODwgV1xdEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mDp0tfF6; 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="mDp0tfF6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 261EDC4CEF9; Mon, 15 Sep 2025 08:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926638; bh=Cd0M6Ctqz2mIs5KmsrNG7gPuEf0W9llFNTYE/JJTtFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mDp0tfF6k68R8ROhzn5O52Xa2JXOkXJe0iGU44AyngmY9O4NJhu91UZvWywCLWgqe MBbDYisBTdGB6+tfyzhYubwaR+ncKGJhpObY6LXNKLViCK6XYTl+6Y6u5C30rFBwD3 odeALTB/iFNRpYe/uQNdDUOiOG7SXyIUkO0Z1bGSVgQ2s5e7vkvV64VxG/gsHVVCu6 YYtGU2VhlYdSnnvarqXJ6B0l7L3613AKnHLUJR6TEFUt72D73pDntzCdZPK6VeIkCy yb4P7bpqMGjg9wrdlMm5KU1U5ffP5EfhSMS1aK24oQOpu1rjuhDwEw2+mIzBHHxVun Luijc+/ENQxkQ== 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 1uy51Q-00000006IHP-1REL; Mon, 15 Sep 2025 08:57:16 +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 v2 20/25] coresight: trbe: Request specific affinities for percpu IRQ Date: Mon, 15 Sep 2025 09:56:57 +0100 Message-Id: <20250915085702.519996-21-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Acked-by: Suzuki K Poulose --- 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 Thu Oct 2 15:32:38 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 467562F83CB; Mon, 15 Sep 2025 08:57:18 +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=1757926639; cv=none; b=DUJ7gId3+z8MiKRjUuNzAZ47X/cBWIW1ljO1Kf/OH3vNdthh3quMqX/crGaTdymyWWjrm1ABCvXDqLFufT+wZpOhgAXycNKUtgpdHCBSsgp9mBAqYVRulMRF0lw9OyVpjtcq0T/wVyUXSoJKgyr07LltBy+tLDGajqd+cPRUIoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926639; c=relaxed/simple; bh=f+QGIJt0TLdWgJhUimSN2JgMtMX5elof6Y6UFU21JN0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uQzry09PIU7ljp1sxtUdXd0g9L89h1gJNK7GjvhnlK3nRrFruh0K42S+SGUr8vKz1cQtm8snvx7zhrShgDvPCrnFv40NKhtd8LDulSu+WuoBTy04SNp3Z2hXFsDV1wbc1nzq6nsPLvnvYlWM1oGfsfyw6fbcdHa85ae3S1gDs1Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mLZ5PQKr; 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="mLZ5PQKr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B781C4CEF9; Mon, 15 Sep 2025 08:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926638; bh=f+QGIJt0TLdWgJhUimSN2JgMtMX5elof6Y6UFU21JN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mLZ5PQKrGeL+mKmYZ4G2h/tpozhllluN3lpiXEsqAQuPuklDYRdWwBRBxtP1SBTeg gpMaDOoOHnXzOZeSjeG5c3ihWQmc9xR9WGu/V/dCbQ87cgRerKj5X0/gfhLaKvWbLU hIPkXdmj/MDroN17yaflfqmHUlFvN3vKudg9hKLIdVlj6nNUtpvHWgOzPUXLpqvixx wr9mwlZh7mM2ObBZuM2sgayCCUcj1WcmERv0L75zoEKdHBweyylROYMzaSOjiolUXl Q8ADc63+e/8w11+Q5nxtflHAQlqvivlmxrAqPoUTVWpzFLwjD0+lPCxagXqgThJDKH 9JHuBQKuxv78g== 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 1uy51Q-00000006IHP-2bf4; Mon, 15 Sep 2025 08:57:16 +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 v2 21/25] irqchip/gic-v3: Drop support for custom PPI partitions Date: Mon, 15 Sep 2025 09:56:58 +0100 Message-Id: <20250915085702.519996-22-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 only thing getting in the way of correctly handling PPIs the way they were intended is the GICv3 hack that deals with PPI partitions. Remove that code, allowing the common code to kick in. 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 a14fd4c269692..0d8a6f46e9300 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); @@ -593,18 +594,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 int gic_irq_nmi_setup(struct irq_data *d) { struct irq_desc *desc =3D irq_to_desc(d->irq); @@ -1628,13 +1617,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; } @@ -1643,10 +1625,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 @@ -1703,32 +1683,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 */ @@ -1747,15 +1706,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_fwspec_info(struct irq_fwspec *fwspec, struct irq_f= wspec_info *info) @@ -1812,45 +1763,6 @@ static const struct irq_domain_ops gic_irq_domain_op= s =3D { .get_fwspec_info =3D gic_irq_get_fwspec_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_fwspec_info =3D gic_irq_get_fwspec_info, -}; - static bool gic_enable_quirk_msm8996(void *data) { struct gic_chip_data *d =3D data; @@ -2173,12 +2085,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 @@ -2234,30 +2141,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 Thu Oct 2 15:32:38 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 D9A2B2F7ACA; Mon, 15 Sep 2025 08:57:18 +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=1757926638; cv=none; b=u1LRq787ufu02iI+2CHmDmg3D6z+CIuMjsyXTF+RImfNxISoJ60CkhaEoCh5Ym+UbZNL1Xivan1lTogdYOYqABcaYHF2lekLVS6gHTMYSnTX8K1Eq3MolLRC0U+5d9YznWV6Wl4LUCFwqqrq2u27bVpOSstV7KRtxlLdeaKtVVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926638; c=relaxed/simple; bh=TmkHLg0e7YJMiml9l6eg+ELPovgCrjl75ki0cbExAjg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YL8QC7FlXbksh2eWzof59m/RkE6BZs4lSjpX+rOwNfDebpJWTi2af/28LvFXqmJ3ZsCbiKJcGxJ6mHTdPudd32YamvqFvqz++mHR2sPO7KIaykzFcBVC+gyaeA3m1yAU/INfTZJX+jOn0InWlPJZuRt7K3mn9upau0ELqr+z1v4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uw4sRLJY; 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="uw4sRLJY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB434C4CEFB; Mon, 15 Sep 2025 08:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926638; bh=TmkHLg0e7YJMiml9l6eg+ELPovgCrjl75ki0cbExAjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uw4sRLJYbO9/7+Cq4OHlqG2QRyfv9rLjY9e/5esK6iQNUxi69otS1zmXwoLYaCiPA dacAs/yXQdDFcqYRDdjhGciO8pt9jujmEq/o87UAtmt0eL2P0YLC8Kl0FKgFUbsIpV c1iRvjSJVA8RoegK+VRQpzOnDu3Wn4kRngHlDihPS3qwLRoz5vOESpLEaT4NllPl+e BKypyLbq3XYO7miYoDklj6i45bSOQQntFqh3V8CYaM6lVaZkNLwlSvLQONH7H65Rfx TpyMWos1F1rRbFtQaaL0JyDGCtMgvii9Br1rITzQ5ephDujBLEXnl54xNjTuOSBgCY VC95dIKzXi5mg== 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 1uy51Q-00000006IHP-3mQz; Mon, 15 Sep 2025 08:57:16 +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 v2 22/25] irqchip/apple-aic: Drop support for custom PMU irq partitions Date: Mon, 15 Sep 2025 09:56:59 +0100 Message-Id: <20250915085702.519996-23-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 cb8b6f40ce8d3..6305d25b9e77b 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); } @@ -732,6 +714,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 Thu Oct 2 15:32:38 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 3CF2D2F83C0; Mon, 15 Sep 2025 08:57:19 +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=1757926639; cv=none; b=q2nn99lykwnzP5YluLDlnZ7SbKZVdTdhoQ56/oTM9n+U+N/XlcKt42y2169LmGOwBcotIGakmyIAt7jZ4M7+PwT1MHCZO9O1w0h2eYY0Z9NB8CEAiDSY2VDKM+ZKuInwYT7ugfBZpQlX/qu7rZdQtbgGvpoDIOpuQ/fksVU7RCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926639; c=relaxed/simple; bh=zjGTnTXeZxX9IWdZqt0xePIPCnSCFLQrvT6nM+URiUE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n18cqXfTZZF+4KuQsJlkAMadBc8S3Ki81lFUJhctq68yiwMxdTGrBbhqaponYAkaWKDN7dw6B1OSDaDJ79nGCvYH3Rs4OkgZeyC66QQMxWVqgl2rFSiAkvkZ/8T7sU0BhQoFlnH3+YiKJS7VQ0vns0Pmd/cg8BX2fQz+InJaIyY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ruTyMvFv; 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="ruTyMvFv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3253C4CEFA; Mon, 15 Sep 2025 08:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926639; bh=zjGTnTXeZxX9IWdZqt0xePIPCnSCFLQrvT6nM+URiUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ruTyMvFvXi5wF4RTv9vNiyAy7u3vGpdMJohif3vDGXUanFxhSoNICzHSCsyJDRBEf SEyC80MXODrLsEYqf/0r3eJvAqgNTyTY20on6N4auQtugLBrQ1NH9t5sHVoGLmEmJT 9Zyj+oTMOFZhBnd6POBl1jfKUwTJZFePhXWdfDLv89PAn/qyKh+e6wN6YplNG+K0ld WAviNoAaQV9KAMGW8jmVpIQLVD/Fsz6ypUP4Q9moy5vxxGnS6Ap8LWrF6jdi7pMWsj EbBrwH4DRi2vnO35EcFHNuJv0//FLzWoK4k3lwMoPkbfnSDmLfP+iE4Z4VaoYQOxTU aKCqhnsy+MHTw== 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 1uy51R-00000006IHP-0ena; Mon, 15 Sep 2025 08:57:17 +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 v2 23/25] irqchip: Kill irq-partition-percpu Date: Mon, 15 Sep 2025 09:57:00 +0100 Message-Id: <20250915085702.519996-24-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 Thu Oct 2 15:32:38 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 5314E2F83D6; Mon, 15 Sep 2025 08:57:19 +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=1757926639; cv=none; b=YoaLNPdzLnBuaNuRo1X0kTKLJI5DLY91qWd68GXFB00j3zU2lTFtZoOrp/yO/07ODWtCxckLWvyLr0dux/a8Q6R4iGok5hINEhZWovyQ0zsgb7eLJ8aahbnhD0zwycdejgxoMWzqDEvqEpVTjFedFEBuAUo9LT5x7qNXsHPSo2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926639; c=relaxed/simple; bh=KvIlOqxzhmHWGaaeC2n7SGz/r3v3wz0YFXzklQ5EErE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=drxfNkfXqX4ssqKP2hkR1GYbSJWijQkITwyUttmt6iUw7C5H7tkZApVPFNSl3EPc2qyLhpGCYNsQFucanmXXpczuZfz69JAcUMa5z0qtxlZnfzDDszxYU+3q3qyMER0G/FQ0XtmWAn/SuY1ZBU1/TY8fadiGbz79TEPsbdnfZX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KFvgN8Kz; 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="KFvgN8Kz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31D5EC4CEFC; Mon, 15 Sep 2025 08:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926639; bh=KvIlOqxzhmHWGaaeC2n7SGz/r3v3wz0YFXzklQ5EErE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFvgN8KzHTmB5mmIOkZNYVQ2CZ6RHtTLkV03SfDetznJerYGBdl+c1BzWx11lhdKr 33NXiTJhMP7tdQ01SX3MeFIpGYAyo0kkK9XS9aOYLVm3DgZAJ/x5xb6eNLn8DNhqpD UfTV6QLamah5bn32DKeDhET6/BRzgBgj5dSqT4Hpsm4zPT5iQwO042fTz5Wmh3sRoD bP+IHF9b+cFAhQ7YPMRQzxCzz7Q2sixHU0BJENnRPbIOx+h2WsMg+TId7Lbjx4Qvw5 bg9CblwrYTrSxYLR4DDWQ1Bg8x3jBb5P3Ty/z5ASSJATCjW3srz65LpbX/mPArTWp9 svp/lxsgl3YDg== 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 1uy51R-00000006IHP-1szD; Mon, 15 Sep 2025 08:57:17 +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 v2 24/25] genirq: Kill irq_{g,s}et_percpu_devid_partition() Date: Mon, 15 Sep 2025 09:57:01 +0100 Message-Id: <20250915085702.519996-25-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 1381f9d1f5c9d..4cac9bc33aa34 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -716,10 +716,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 Thu Oct 2 15:32:38 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 A53AE2F90D6; Mon, 15 Sep 2025 08:57:19 +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=1757926639; cv=none; b=GoU3Sv3F7DDBU/xvzLTx1wiZQ2F3O6w0RWj64i/vNkQENyf9Vcdcep6COqL0l94oG66o3Zwd7VfB46jqjaPFXoZXi8SEb4HgSFVjfCvRVQckhs48bVGUxiRWZFx8Qkm0lYXtnQhV/4MFrwEfAc/y+yYWTbDH2WfQM0Nwfk3jtxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757926639; c=relaxed/simple; bh=kzh4j/H3RZDe7ZkyacsAHuKMIz0DQecjQ2j642GjAyI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LPt2RO2A/f5KmtPA/v7K46mdYt7wC71MD1N9HzUVMy64j9hMkAPs3jwt19G/Pd0oQHoeMQJxEsavT9nTKdrfDH2jCd+xT7DMau8cgYvOlNSzZXg+/xBLsGj5lXxRqh7+6n9DJiZEgK+yAG3gFTwJDI/XWGTFDcQObFgcZ7Zxgc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EZRFfemI; 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="EZRFfemI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8313DC4CEFA; Mon, 15 Sep 2025 08:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757926639; bh=kzh4j/H3RZDe7ZkyacsAHuKMIz0DQecjQ2j642GjAyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZRFfemIR5d70YvHXUxHp3+8Vxolt0dIQTzuIr4clY0Q98Rqrh23wn43RwVLJvkJB 31nzSVBxTqHyxXad5F1a9BG3tauYuL7SQjzZg3qIobMrtk5X8Ytw2SQbglnTUK2Y6f 0BI7tVuwilMo3hzV5dGBRu3ne+fxeU7EPtaAWMBdhkH1esQ695ZiQEdAtXG+xV1+g7 7MVNI1LFCLbqH8YghRl2VSpeUH+DNS+av3XDH4HhstMDKoMV+v1xp/+N1MrIrlLiPy v3OisHFj/WdWvDNn/8IQuuOaRRaRlDeV1VdtL02DB3OCTcFmYZZSLwxEdSuZwlNyQA JttL69Zgls4nA== 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 1uy51R-00000006IHP-2wOa; Mon, 15 Sep 2025 08:57:17 +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 v2 25/25] perf: arm_pmu: Kill last use of per-CPU cpu_armpmu pointer Date: Mon, 15 Sep 2025 09:57:02 +0100 Message-Id: <20250915085702.519996-26-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250915085702.519996-1-maz@kernel.org> References: <20250915085702.519996-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 23814707cf771..7171d8e0d27a5 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -104,7 +104,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(int, cpu_irq); static DEFINE_PER_CPU(const struct pmu_irq_ops *, cpu_irq_ops); =20 @@ -726,8 +725,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); @@ -747,8 +744,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 6690bd77aa4ee..bab26a7d79f4c 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