From nobody Thu Oct 2 05:05:15 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 A43E218A6A5; Mon, 22 Sep 2025 08:28:44 +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=1758529724; cv=none; b=VkFd8tCSxOKc5GQJ40Jb8aH8LRq1GdVSVEfon/Nn0oqa4+E8vFN0SAp92Zll2hV4Px+QEp3U/BjHumLIY53uFAX4ZLD5D2usC5daNYbMAXJyOVDsckgUUHJLqjdcZon8mr7/BpsuD7nTLdxxd0j+Rjqtzby+qm7+LSE6K5kJX7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529724; c=relaxed/simple; bh=PNhSU//BPW9YLsi7ZBnfD4jFD/thyKEGeB39qdpvnP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bRtZVb+bHPWY2K3EUBZJsg9D6dS2JBcDSpZUnn9gVndQ4PsQ+9e92UrymyVZWdVHuB+V8xwrnmvPqLJZ599jzG9ThLofdAkt7bOnQ0i+8E92XTiTxU2SXMurJzds15e0o5hunZ1fXSnyyxZMGEvdPHvSoiAPqSH7H3gQzRPBjnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z+lJwkSs; 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="Z+lJwkSs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C078C4CEF0; Mon, 22 Sep 2025 08:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529724; bh=PNhSU//BPW9YLsi7ZBnfD4jFD/thyKEGeB39qdpvnP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+lJwkSsGLQVPnmRu+p9IFTSUGl1hxXx80G0nvSBLiVLyqNil6qdwedjXcI+e9KiM 4n6YUIbEqL7ChaDIpOtgiGmOxlVZliCG+40rD2Dz1Drp6O+wgmgPl6kVSxFgULxZ1D +wkg3AzAhEVaCaK4O5zN1Amf8dV08pKi4SNMhewzCEflaNHnWgImz0O834aj1ZcLW9 UszsWI2n8ZesNBphQ5K1sUAPgHbzGJ5K0Ryb50fTMIifywQ7ATgiGxMx9aGmznSgsV soCm2tB4NzZPBNVPbFKKdNbx2ef6VtYAdsC8uYrutmscXeq43QJyslWy3a4LTt73Ep RA9JoBcgbYRHA== 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 1v0bub-00000008Kds-40yl; Mon, 22 Sep 2025 08:28:42 +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 , Jonathan Cameron Subject: [PATCH v3 01/26] irqdomain: Add firmware info reporting interface Date: Mon, 22 Sep 2025 09:28:08 +0100 Message-ID: <20250922082833.2038905-2-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- include/linux/irqdomain.h | 27 +++++++++++++++++++++++++++ kernel/irq/irqdomain.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 4a86e6b915dd6..9d6a5e99394fa 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -44,6 +44,23 @@ struct irq_fwspec { u32 param[IRQ_DOMAIN_IRQ_SPEC_PARAMS]; }; =20 +/** + * struct irq_fwspec_info - firmware provided IRQ information structure + * + * @flags: Information validity flags + * @cpumask: Affinity mask for this interrupt + * + * 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 +86,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 +116,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 +623,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 +708,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.47.3 From nobody Thu Oct 2 05:05:15 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 A4495246760; Mon, 22 Sep 2025 08:28:44 +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=1758529724; cv=none; b=dAslxgDHrglUzSjE/oDJNUjlJbpqi7KARskCg9/43zuHAHbfuo49Y7HvtD4u0OAWNIVb2nZ9WptIeRjzY5Fv1SgcwCRQntO1x0kEUMvN7EYwR1fOAnhaXCFw0HxAsyNpbnmN2nTsKg3oQXYC7oMUk7ZA0g24UEd6w+zmJ6JERi8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529724; c=relaxed/simple; bh=uObPw0S3mvMocs9YeKVqpsEPMH1H13oQXDA2ZL7fzjY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p/o9hmUF36ZELAnVpgEt+tI6JFOAQo6QomJpYkRFX3ySiA65H4HfKdgwbfKcBenaMnB2A8wTb8fnQB+dJFA/b2mBumwcjzP/wE4OLLKouYILkbagvVQNzD3+VOSX0FucbB4rZUjyXnDBDRk5YxXixwfLnBMvFOvOnXfqOFXtXRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RViPu+oh; 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="RViPu+oh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FE0BC116B1; Mon, 22 Sep 2025 08:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529724; bh=uObPw0S3mvMocs9YeKVqpsEPMH1H13oQXDA2ZL7fzjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RViPu+oh+Pi7lWBLz2vkZCF9YKlTi7HdzTxcjfDwADvDAYsqf864Amflf/vQRN2hZ I1WuSgTKgtCBMtYiOuk1caJKYvaJ/lxKpqqUmc9JwbKhGMdERAIyXt+E/js07yMwuy dQtAjUw+4FpY9XBkBIvS2eiIJSTqRzQAb24MmAwXfLOiNCIaqM3bCd0nui+5nCDVt+ BJmc8IOZWugNsQEDyuBdmU2oHIQ4tvsyWu3aXkr39Cpt83SsaRHQhK9pjtUHFvGVHv i+WLw26pWozDuTexOcSOpr4CEXsaYkXTidoqIfyKaLnfNTeqdBX43xsOK7bbktA1DG xoarUu6R2FK5w== 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 1v0buc-00000008Kds-0yLT; Mon, 22 Sep 2025 08:28:42 +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 , Jonathan Cameron Subject: [PATCH v3 02/26] ACPI: irq: Add IRQ affinity reporting interface Date: Mon, 22 Sep 2025 09:28:09 +0100 Message-ID: <20250922082833.2038905-3-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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) Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 D046C2FDC25; Mon, 22 Sep 2025 08:28:44 +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=1758529724; cv=none; b=MoSnxr0q71b6koJUWotV1XRH/E6TLCJ5eMS5MRPwgX9oXanJgmeShw7DN7c3VhN8JxBh85LdGpCeE0mOll/KkWQ6edd8aFsAx1RRA6VsDI59FN+v3PH+9ddRB78jBr6Lj8Uy5QIa3Mqe13335EBPiJgZhPaZB0JcOb6gF57tZb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529724; c=relaxed/simple; bh=+tEFpiH2SyGne7krnANKnL8umntjFTGvzqHPthyUCxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Itk3Y29McpbSiWYFu5uIjFgWKbwsHd2PTHHRjRpZALiH5Y8pk1ZPQ/Vlsyutfut7B+1l0JdPUmthQ3NUpNA8m/o+dQPtN+kqRka4FgPSTeSrAQ/SSecUOpMLCIOCJXT5mRNH7b3c3YTqJV8k4E4Tv7v6SFW5qQpQ66oVqexXTWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tu0OU75t; 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="tu0OU75t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 891C5C4CEF5; Mon, 22 Sep 2025 08:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529724; bh=+tEFpiH2SyGne7krnANKnL8umntjFTGvzqHPthyUCxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tu0OU75tau4SKPk+JYe4VzWArSZkTHxkUvjl5cOPg9X0Mn1/Iy+Wyd+Ht7kWDUO5a A5KItxZjEOHVQ0FYI+z4Z/tp7K+bqFD4DrM6OasYoo4a0lufpgjD4TaWax4p67qatd 7cUrZccwf4LNW5jOiAupqIaOBMD4GbYh8b8eNPM7w9tUK3VKPxmHiD1uatrt6+CPVE bUipL0V0EoARbGS5hZTRAqIG4VairOQxOTPiAWYuXGZjX7Ha+Bvego+ZAxAU9FRdCJ Rv9M0n7KY5Yqt6DXyB0m5Y+XLauSY9GVS8kvqoK9CaNLGdqCObsJhpGbYeZ7L12LuR fZ+qSOOAs2pPQ== 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 1v0buc-00000008Kds-29qc; Mon, 22 Sep 2025 08:28:42 +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 , Jonathan Cameron Subject: [PATCH v3 03/26] of/irq: Add IRQ affinity reporting interface Date: Mon, 22 Sep 2025 09:28:10 +0100 Message-ID: <20250922082833.2038905-4-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 130E12FE049; Mon, 22 Sep 2025 08:28:45 +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=1758529725; cv=none; b=jm27EeHQb+R8aSVklXERCjfanJ96VjQkz08ST6HKjqLA/DPFF2Bi2c8yif6Scbwr/VjcceAj0L7z1O0trk/TokK/doc6I2FiXvyvsvw41tlEIpA7zcWJYy4oZPJwX9IpS7cPLPECVrajBhjJMqfADb1aPOKdOAnChMl3sltKQuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529725; c=relaxed/simple; bh=C6E+aBEwGO9hdt1adgFxxn43Y+KPhVq4P5UdcbaK3jQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nXHRHaipJ2BXbqXIBbGGYIk2upEOy4j3enmkvmnsMPEgrL95xQJnsbluwkD9Nm2MuSvXfm3e0imjLJEUyarPooNGtKqpTLvtOxsdIpY6RODoRbKMo3V7FBIATyXSERen0RnKSJpIxZXI2ZHb6fmHoc0wtyM2ZNfRIhEO7sUTuxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LY8MLpCB; 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="LY8MLpCB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC71AC4CEF0; Mon, 22 Sep 2025 08:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529724; bh=C6E+aBEwGO9hdt1adgFxxn43Y+KPhVq4P5UdcbaK3jQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LY8MLpCBLX0GLYkb9PnQBGX3JXCY3s6Ve4syk+SVOeb1idI0OqyzBtTx+tmtoeZUA yStqoW/MQ9WwO01xrNasugarr6r8BQJ0kaPyQmYw+PWBz6gHqw0MoeVB3z/BtoSaRc YAv4isq8YH1glfqHYKzrh2FIhHkatvtmKHsWr3YOqpOQSNPcy6tVeMpNmPoqYZ6fI2 +BdKU6efM4GJLUKJtbmKVrrEdOANoS7b/ARS02vm62Vy/qgSrzTgppF5VTUp+AILUF jFxlQ5Mt2eXjrc3G4Yp7M+r/DceiP0h1hyEa/yyQY0SvcJ6Jts/VNiQKhQ9+00iLYs j8vaL8+6vP1AQ== 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 1v0buc-00000008Kds-3L2U; Mon, 22 Sep 2025 08:28:42 +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 , Jonathan Cameron Subject: [PATCH v3 04/26] platform: Add firmware-agnostic irq and affinity retrieval interface Date: Mon, 22 Sep 2025 09:28:11 +0100 Message-ID: <20250922082833.2038905-5-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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..3a058f63ef0d3 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 affinity for a = device * @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.47.3 From nobody Thu Oct 2 05:05:15 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 A19582FF151; Mon, 22 Sep 2025 08:28:45 +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=1758529725; cv=none; b=fZFF0EP8rJmcG5ymsGa9QYaqDQEKNXmQKLQ2fRSJJ8SqQSpXxaDd2Owt/ROOzm9tkDoivDODu/eefX3cmBZd1A/FlRk2sj2Ayx9stlGmLGpbIDpYvM74FTZ6Rk4YszQh0whcSzhe2FtvbMQBdvxwbVwPXFVNeGx/Idi/VXseMms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529725; c=relaxed/simple; bh=5IBVXncBJM26KBDVMYIUqVm5RyJ3XQl6A/mbG+QlK9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C00I9zfIt5C11+gcUYOc3/vfyVBa71oLq8h4BRfUYeJMYeneBprU8anqdEOmaGkkkJ6AKwXv4+i5V+7rwtSiToQBO4liQekXDOUIUB8waJj5ie4SHEIt1luuRlssbzbumdJ4EsBgniSlZlo/JoVPGUyxVbCvmOZme2UZLFJ359I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oX1fLqJE; 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="oX1fLqJE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A2A8C116B1; Mon, 22 Sep 2025 08:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529725; bh=5IBVXncBJM26KBDVMYIUqVm5RyJ3XQl6A/mbG+QlK9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oX1fLqJEwsS3j2MUHRThVKoYjSlFOCw5Vzzv+l5JZsWhB0jOGXpEn50JjeiPZk1TR eetVE0jRiWNbT/jzI4OPBGFO9TpOOUItkgBLhnLp7irks8MzDVTEn0d14j1bSvj64G I60XQaW4YSKZPk+cAa3r7On243LEOiDWRyrXriKydi13vikcj9xljq7va4m1dQAPAk CtWzOXU0OFZBvEjGdbAKUyH4GCPBXjBzmCw6EmjUhNc5tOX71z6qIzfNSVCO3Xjvcd YuAutRDZv6cIs8i8pXbMaGMoaT521ZNDWNHWmeSlfdNWuPlfkbQJm0n/WQIU9z/+k5 koocJZTyWM2eg== 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 1v0bud-00000008Kds-0NMH; Mon, 22 Sep 2025 08:28:43 +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 , Jonathan Cameron Subject: [PATCH v3 05/26] irqchip/gic-v3: Add FW info retrieval support Date: Mon, 22 Sep 2025 09:28:12 +0100 Message-ID: <20250922082833.2038905-6-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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_fwspec_info() callback into the GICv3 core driver, using some of the existing PPI affinity handling infrastructure. Signed-off-by: Marc Zyngier Tested-by: Will Deacon --- 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..23ef0c285f30b 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_fwnode_handle(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.47.3 From nobody Thu Oct 2 05:05:15 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 928E42FF141; Mon, 22 Sep 2025 08:28:45 +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=1758529725; cv=none; b=TgVXOrx51ZGeYjd/Vj06Y8JJUmD6AaHe7deyAnfZArAsTb6TL3ISs+81B3ZPyfZOsztdWmZ+JWCTApoTKl5uWRKZu12skQju+VfzMrgYTu3+XmH9e3rJsIFUJCNYjmejEXWdZDzI7QjsTpCiN2Gp/6x9OzXbsxawradzq8y/42g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529725; c=relaxed/simple; bh=Lteyum6sORsX/ORFwgAmQ1CfkVj7VaM8cFC9100KNAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rr4uRApjPlYmrUO5jzhIWOD1huYRssC+fR9rL+wA+FdLM10wU9uYtJ8yll3FXKADRaS2SAEURRpqvXcOwGOEYgDk3gOcxoGCn0Qh9IXhzaqk6/LmGNt8zz9Aw9EH3SU8YpjZJHMSMRiy4bh4iLEmm4xDiXH//3p+17DzxGd9bnw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WAlC7Idj; 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="WAlC7Idj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A1E9C4CEF0; Mon, 22 Sep 2025 08:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529725; bh=Lteyum6sORsX/ORFwgAmQ1CfkVj7VaM8cFC9100KNAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WAlC7IdjkueDZd9RKSjdPgM//0FrH3HoKvQA7ESMD7o+rATw7VpfSQrigXiUqCrBY VZsGeOMgl6oHKLoxh/S2XEGoRLwpCF2RU9YQ/PxSchiFPktF3SjWf7R8mGDUHKPMQW hoXbf9RsTcMpCF59nGRm9N99B1TyYWssUG4F8rtXdPaEXLCStNclRDR+LmMAQpfj8N 1UqkpiTzAaacKZxYImR8bAsHIwUBeLdMREtyRhspgar2aPzX8eWYeIPGiCw4s7Se+T xIlm+AZ09pPoR3BjfrE5UUP/IvgMjzVasjjO4irJ9CKroThTSEMLjcIn7W+V2eyZi4 zdaMgyRrtlP9A== 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 1v0bud-00000008Kds-1aCe; Mon, 22 Sep 2025 08:28:43 +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 , Jonathan Cameron Subject: [PATCH v3 06/26] irqchip/apple-aic: Add FW info retrieval support Date: Mon, 22 Sep 2025 09:28:13 +0100 Message-ID: <20250922082833.2038905-7-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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_fwspec_info() callback into the Apple AIC driver, using some of the existing FIQ affinity handling infrastructure. Acked-by: Sven Peter Signed-off-by: Marc Zyngier Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 B841A2FF161; Mon, 22 Sep 2025 08:28:45 +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=1758529725; cv=none; b=kwJRF9zJwvNlA+SY0oW6P9Nfz+1QPSdOZkU6Sujq2cOOT5AHMyusBz+KdCKhP+32g5nE2xap4ptrhzCWox5mkOU1sBfOG9sx0uqV8/YUReXaAAXpfbv9X/y2NMfdfR9Wm1Q2haBmwWPEEZB7I+//5dmCVLwKjJTHVxh73HVIdbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529725; c=relaxed/simple; bh=GPmTGcnQAYM8B7N1QsQQqNrtEpJbo4fB+GVAPv/5vYE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mQLYDmsmNlgRHsncnC1r1WK/ozbW16nJv9o+fqGsmYyApfQvYTbLC3Wk9Xw/mMYx2n4zfyqM5KR0ye2CFUSRVPWKGVXM07lUFOIPOyEUUbh37eRkHnO46OtguYJk7pDEf3GE3nJBCTeCRSua/HWp6+Ln9hWse+JwLTdcPXC/Il8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j0NQ836Y; 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="j0NQ836Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EDCAC19422; Mon, 22 Sep 2025 08:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529725; bh=GPmTGcnQAYM8B7N1QsQQqNrtEpJbo4fB+GVAPv/5vYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j0NQ836YuuIyE4YxBGyRrAuBlMc8ET9ro8tIHtFQCHRf5WvJvhRzlFyk9G4UmCLfv JrOxieZ6ZT0txtgCkdeIKTIdLZqtNjpqiJDCbfmnfOTJznsWMH8n++ACzVabbP73e3 gzCIYh15JcJc77Pltp+n5qTm5jlxptKs1111w+AkZ7S+psc/WGXmfZu0Fnq7FSpx3D sYTyT3lLJDixIp/ERMj3sFJZg7u7yqC23pv0jwQWhD6rDPEcSpGc5hLM0+/ON5/+AY 9FlZRq87FZ6GLg1MwvumXbFsPmL35qbWikmoLF+7Z+VUf12nx5e1p7LAMwQRDbmlAm xwnQOwwkQpsiQ== 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 1v0bud-00000008Kds-2pWF; Mon, 22 Sep 2025 08:28:43 +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 , Jonathan Cameron Subject: [PATCH v3 07/26] coresight: trbe: Convert to new IRQ affinity retrieval API Date: Mon, 22 Sep 2025 09:28:14 +0100 Message-ID: <20250922082833.2038905-8-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 E5FAD2FF64F; Mon, 22 Sep 2025 08:28:45 +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=1758529726; cv=none; b=Vi2oD9QxQ3NhezsgbzKPWbcJh+FIiia9ZTHtMcW6/4KYMYdFP5fykRipjcSMnrVxoJH/dKAcy4bXe6RPfGAH+88jECLc14aHGZtVh0Ygza44C6QzcxlF+l9mhqSJFJvabHsDXLTceIdy66OvDMb8o1CVXJzmMBuyGVf19KhXNwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529726; c=relaxed/simple; bh=hrdjbttIERspzlMoFY+iQP8wEfc0Gh3BVrQ9ANvnM70=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M7p55tJW9sNY7ei+e7RN5RC+TJ354dva7/5Swd9RFllbfB3l6CptqWtVVbJ5PhxhEO/EBid/o5tGVhfD3qIGP9y7ZfnR4fmLluHT+M8io/zoPR22rXeA6cZ0ZJNMjDyy9hKfkFtT3jDVo+qGqCj/+PxA7KN6U+S2TcEGjQX7XVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rXkHPPek; 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="rXkHPPek" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4D42C4CEF0; Mon, 22 Sep 2025 08:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529725; bh=hrdjbttIERspzlMoFY+iQP8wEfc0Gh3BVrQ9ANvnM70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rXkHPPekoZAV2COy79vJqcaFIoe/D8Ov98smXf001V4JptGz2pZJ5iTx/kcoSluyZ IQUR6D4GnMERSe4sbFQw5hDRd6cEUu0Qwn4dwYIGjbP+Ybg7w7UiF8LIgMpiPGqGGU x39jrTDIkvXK+BXhgFU7K3abYHUEyTtrgQdYzrapPjtYi1EW117Pat8/2slJPaJEsL 1o0ehs1ZE0MfMvgS39yw7NFna4zzGLEG+oAf3pNJJGDmbh/GHTkShp7qxuqi8z/Xyp xshfGi9gOwUsilCFNNto3FsTwppK4/dVgkbS9kalOwhjm6UJImTh+D6vJ3Pe6eNBmU Bv4ay5u7m2K4A== 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 1v0bud-00000008Kds-3xnr; Mon, 22 Sep 2025 08:28:44 +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 , Jonathan Cameron Subject: [PATCH v3 08/26] perf: arm_pmu: Convert to new IRQ affinity retrieval API Date: Mon, 22 Sep 2025 09:28:15 +0100 Message-ID: <20250922082833.2038905-9-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 7D8B92FFF83; Mon, 22 Sep 2025 08:28:46 +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=1758529726; cv=none; b=ianfY+VFruZblFcEJnwTHrcjpSW8F+iiKRoXUtFuT9tkdjWdkRo8z0qgQtajXyZ0Eua6qYvX5QBHKEg/mrhCpwe2F3q6ymK+kW2/O9cKvy1/4dVgE8TVGZCmn7rwbb+WNlNtE+LL+GhiUCBdJ3lqh4jx7niSPle4lWc6NT6vH98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529726; c=relaxed/simple; bh=aWSBo2lHQR0VJHlGtar1XrtNXJ6RqCYZkbdnrUFDeQ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kp5EYqNPmb0CDt1SOAppRKeKENKrADF/X9ZIRShYlMBcU2a9Sm3eCY6NUK8cyzCVE0JvmLCEsvA1WldnUvRdpP0VIQN78YKAY4apvlpH1OT9Amk3JorZGOIXhoYSVjaC41p2+0F6axVxkcIJXLegC8ELCFMd1tIERqY5pel6AXA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lLVA0Hrm; 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="lLVA0Hrm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AB0BC4CEF5; Mon, 22 Sep 2025 08:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529726; bh=aWSBo2lHQR0VJHlGtar1XrtNXJ6RqCYZkbdnrUFDeQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lLVA0Hrm7LOPH2SJGYy26ZOqDAvlaKXQJDyb/5qXP9wJt00gXbMTxf4kC4Dq3Q3QT l0GM0j0hZn0VMDXrTS96f/cjk6WtX36n7P4CSndXO0gUCPJ2c5XAUuOsZGxZ7Mdmdb OxE81VWMW1b255zjN55prFVW7iz3dIYhFhmI8gCGd780iJU1xrmD+dSQLG6ljniZAg hG6JTzxlJiXjRNa4IbbB07bQxPSsk9r0Dx3zfmmqlXPe7HuIKBvvuWLh9g6Qs73htf B0Q/sDmZGFUvoOn9LGHrEKJsyfH3hugl3sO95/FAzQU0upRXzU/U1FdlReO5uGK1dC qyDHDhpCTW9rA== 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 1v0bue-00000008Kds-0zpg; Mon, 22 Sep 2025 08:28:44 +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 , Jonathan Cameron Subject: [PATCH v3 09/26] perf: arm_spe_pmu: Convert to new IRQ affinity retrieval API Date: Mon, 22 Sep 2025 09:28:16 +0100 Message-ID: <20250922082833.2038905-10-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 D9FFD2FFFB4; Mon, 22 Sep 2025 08:28:46 +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=1758529726; cv=none; b=iEgtHPe3MtisxqeOvBds0luNgDFjPDM3rwVgKtBjK8njtfyqAdP9aVkHHIZ2o+2jKjYEFPAwiYFVnTuJS+AKdXDSjxYbg+neglBqDzm7QoiBBLv6ZJNuB47+snxA7aPiWXwW2N9fVTqp1f5n2YJAodeChajva4r4Pz68ciPR0Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529726; c=relaxed/simple; bh=Vac5enyF1+7YJx3aHRPivtknN4RVAMzs0FetyAQ41Gc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GvCwBJ6GdiKILSv5eT6A3iNnbVmqkGWsYw38Qbl/kONI16dmTHd5NHR+f7eHUathnqsBskuU8afBbFYKr//oYIBVSwx8z9Ibr/5t+8VCPzCRrs+e3dn3ydFljheSUn9rrUrSvqundC+8Z4nRCZJSey7cc/qcS1N2YL+Wy3kHxuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=exZWUAuC; 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="exZWUAuC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F809C116B1; Mon, 22 Sep 2025 08:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529726; bh=Vac5enyF1+7YJx3aHRPivtknN4RVAMzs0FetyAQ41Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=exZWUAuCvrOxeHAR6lLr56b+BvoyIUJVIhSTdLA+5EqVgNVRIydHoBBxrVCrQ25Ht Xyy65K4mglc8TrgbhDvYrwvD4RhlSktzQTG6x94WcsAPPLn6rJ44OMBA5nPGXbB2Xu m/aLptrfZ/yJPRBzU4ZDpHt6KaEZfdjzDXCibZO3nB4A75QY9+WmxGPAq5AUecbzcD XMd8i3bRUTvT6DNgPqQ5veDQvBYHf3YDkviW6Z/EmDyCOhE4+53Lg52TbhiKfumQMT 2uW5v9PuPtY3jXFGxiPgiN5uLXKQGszYcJnI2vMIwJPeGVFLc+gfa8f7aRsbpZpRS4 n7kg7NYyiqQrw== 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 1v0bue-00000008Kds-2FZv; Mon, 22 Sep 2025 08:28:44 +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 , Jonathan Cameron Subject: [PATCH v3 10/26] irqchip/gic-v3: Switch high priority PPIs over to handle_percpu_devid_irq() Date: Mon, 22 Sep 2025 09:28:17 +0100 Message-ID: <20250922082833.2038905-11-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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 23ef0c285f30b..8b615a2ee463d 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.47.3 From nobody Thu Oct 2 05:05:15 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 CF0262FFFAD; Mon, 22 Sep 2025 08:28:46 +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=1758529726; cv=none; b=slisCeuVvBtlK+wCdo9YJHtlUOEKvXZfaMVsqtgkeXDbc0KRQ74mhs7AgbtQk8PYtmFU8Ed+aJcIkmgixaGPpt1GtclldD/xYHYRwMB/vEKNGhOacvo6pT0GjNpYEfIP/YOM2mK6wr8edXo5NWUXveJ6yEA2azwvJCJUpcVLgEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529726; c=relaxed/simple; bh=9bnWd8U5uJVzMhF0VNM4Fq8zW1CPc18xcTGjzBTs9K4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tKMyIHIv92uwEwurhdRxUdcj18mdMv5uFQPYl1sb62Ro5LopPa/4DeEvpm7X0RbJzKQ7wrt17k4T7im+rH3oyy/VJ0LCXEIRBGCkjxhROY7yYlpw1PyoPeTYH8jHhQBBP0PLvuGnYnsGkWHVhhfE/RULBpMVZhUk2/1uJmuObhQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cvKPJ6yo; 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="cvKPJ6yo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABAF7C4CEF0; Mon, 22 Sep 2025 08:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529726; bh=9bnWd8U5uJVzMhF0VNM4Fq8zW1CPc18xcTGjzBTs9K4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvKPJ6yo3XE1zMlVxa0zyYCqCRg+QyaZH0AgS89N4mvhinGfez7MvNY3GdyBIvqFz j7557PGEljG/RT7LHlH7yw3XJZPLJPr4g07iA2W+R0UqUCdoUy25GutLkf5nKbgUww HTq/AeacIAttwMjQgJN1q5RFHQhkl/RPKDznfmC4sKTQp+cpIzj51iWcPgB4IOVLE7 QdsObwNmNbNaK/zIn4DKYLieKNmctRb0YUP3A8gg0Q16cPzQwMVl76CBMFkDV+xipn jdZCh6FLxc21zw338WxdkfD5x5zNO4d6eCoJuzXhoA9OzrlEeEZ5OFkhtEVHOSRT/4 3D1c3epO0VbtQ== 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 1v0bue-00000008Kds-3Zg8; Mon, 22 Sep 2025 08:28:44 +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 , Jonathan Cameron Subject: [PATCH v3 11/26] genirq: Kill handle_percpu_devid_fasteoi_nmi() Date: Mon, 22 Sep 2025 09:28:18 +0100 Message-ID: <20250922082833.2038905-12-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- include/linux/irq.h | 1 - kernel/irq/chip.c | 25 ------------------------- 2 files changed, 26 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..d1c9e357f64d2 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -929,31 +929,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.47.3 From nobody Thu Oct 2 05:05:15 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 65415301003; Mon, 22 Sep 2025 08:28:47 +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=1758529727; cv=none; b=dw/BXBiZMVoMfQFVLSsHLSbiFpWX8KibTKDMeWVE0pvxuLUYk924SZh1CmhkFmJKzpr3slc61A0PeoR3pMJSTHBsAFtWSYzwLk57l5o42GLbRiZ/sK2SwmvFrEKGnXOoH/dZ2j35Wb9HFWQA/bnP6b0AAariPru2Gw+qTBCsbcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529727; c=relaxed/simple; bh=bFjNQVe7yAr4nDhmaXS6B/2dp3OJbQN2q7Bx3OxCIIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=moNelhN2xwo62UQwFhNw36gfOoBKRJr0mIOG50J+PrMRRxxHg5Ylt5pkMRLOGiJABsulTj3jCGNmjj8IlTe6nKbok5iZJ9Fs3T8swbTxIlxJoeDiTpvKKBUZR4kHUp4MfYaywXDRqpveRPUUmpERDST8/AQjYYgDhwSznvzLguY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jhi07IMm; 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="jhi07IMm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA1FDC116D0; Mon, 22 Sep 2025 08:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529727; bh=bFjNQVe7yAr4nDhmaXS6B/2dp3OJbQN2q7Bx3OxCIIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhi07IMmjK+aV+1jhePCBY3I8PVlfEpzAH3hdonlgM88poHI7HhaXuQYQvfoka/Sz Sw2dwr47p9M5qlyZZZLdZVkV5vn8GYWsNYCwimaFvxjYWopium3MbU/T4dJ9mNjOIi yK25fJWwuop69M7kG8C7UMFqmB1wU++02dl15QGjKo02A/GBNzLyaXb984D9Y3npD1 JpSOYeRBplyh+b/8DWsW3TmNiTRtk1cND4aBd2ghUKgsHyQZerOMPzza5ZQHVeRoyh qRQjvnmx5sHayyOTn/S8PadEXY8seNHAJ6H70HHrbdZIVkm5svpPw0K7wHvzLrfkm9 5LIyJSuZPgyXg== 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 1v0buf-00000008Kds-0ZY1; Mon, 22 Sep 2025 08:28:45 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 12/26] genirq: Merge irqaction::{dev_id,percpu_dev_id} Date: Mon, 22 Sep 2025 09:28:19 +0100 Message-ID: <20250922082833.2038905-13-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 CFB8930146D; Mon, 22 Sep 2025 08:28:47 +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=1758529727; cv=none; b=FgFEIhvK9/e9VnqpPjzmdiwDCeoopn7XdEWOcwiYdy7jBcyMR1BVGi+Z0xU2yBJz1ZTOEQUXJM5Ufn9b6hubUNdk0WNxeqNeuP0ngIWAZw7yYiY4ssQEbFvrGV2MVFiM0tWebZpgEmjCMmgnhJj/Jhb+kq8jVhCbncyDVeBHtas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529727; c=relaxed/simple; bh=wUb93rzYZ46AvuCm0nEYQtzHfIxnso9k5I5Egiwv/gQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RM8gXHVHzYF3yyJGedEbYj6QKJAV61u4Yo3vvPHiIYCv8PgBJX+ajTjQV7ZD18xkPLMNqhjlud9Uu0fOpOarI+4yEhNl4Dt+6iU4ZWmLf+WxMHqdlCNp1OkfkJ9ruQ1YB2DYA39vahlYO5lMqsJJfSn3DJlcSIByKINdbUpACbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gPj0XVCk; 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="gPj0XVCk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A7FEC4CEF0; Mon, 22 Sep 2025 08:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529727; bh=wUb93rzYZ46AvuCm0nEYQtzHfIxnso9k5I5Egiwv/gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPj0XVCkEY3x4shdXEnzhoTL7NxkNREGUzFf8D3rcwHTKETiXq8Ed8rAQlLxLcUam NQGslrB+b/FMJ9fxRTXCbcjFNIxpuEGhsp+Ajo8+1AgmnelN8IHr5qrkbY6jneyHjD 3uFFC8QH8EP1A31L2HeE7+3HD+rqlv370zdTS79No4YEIG8szNkYKPgCb/F8BtvoQH 7uDlzDnQRTvIQFbq1/iYR8vjMBZK3bj/riaD/LIwzFX+m97Uw8v8BtvreE/HHHCxWr X1IEZX5KmcflnYFfOXSQ17oGA4cKPkID5o1EOUowoU+3D3uBVubqSA/MvsrHMEBks5 svtC3kXC4vBNw== 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 1v0buf-00000008Kds-1gEz; Mon, 22 Sep 2025 08:28:45 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 13/26] genirq: Factor-in percpu irqaction creation Date: Mon, 22 Sep 2025 09:28:20 +0100 Message-ID: <20250922082833.2038905-14-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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). Reviewed-by: Jonathan Cameron Signed-off-by: Marc Zyngier Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 9D4C430101E; Mon, 22 Sep 2025 08:28:47 +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=1758529727; cv=none; b=tYf3vvEA67x00Nu+GEiPbJR3L/GMGRyiqrx19qkD/8fP24RY/rmZSvaKbHh8LAC6mr6XGWu/a3VhMMi0xOm8yv361vSPZ5ZCdkWvg2o+05LWTPcqk19MdO1SYb7OsbKvSU+yfo5Y0hRguk0QrttSX5M04QGlJIKTwYXMMLmRkoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529727; c=relaxed/simple; bh=5oCc+dLTBF6I6+VTyZ2PgmQ5+u/2TekQHk9FmxUKaWU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EKUHMbCMHqSvcdB+K8Jn0Q4rLE506Rai7FVJWhV2xp+nXXI2Q0HSY9RfvMOTDDcVckNvisWOXsUte5tQtoODL3cy5dfL3DrpgHYBC4SeFUH/2O+8pvLb7Sph/AXHWZpcZTykSMpcg94IuSR7Dv9QjUFEVHMiAYFFKkh+oan0320= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dICzztiA; 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="dICzztiA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F109C2BCB2; Mon, 22 Sep 2025 08:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529727; bh=5oCc+dLTBF6I6+VTyZ2PgmQ5+u/2TekQHk9FmxUKaWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dICzztiADFw7mPwKkNslW5gqghRlurC9O0SRGucY2k87PX1vZWmEIG9owrjl1U45+ 2pukEh1dSEgng0KEuBu9yT2r4wFEvqiPThfaLZ7NzbK/Jr/CQ6eZpFc7UIT2hyZ9Yc QQFH2R1wVOxQiz7wUDqXaNupnOttj9pw8zbOQQZNIHypmXMfTu6epxA0GS1u5H85JC KGtne6OkwvU8zlTwDuX9CNfbZo04rrxo3IIz7yhAEQ/X69jIcFC7Soj7upLry/KSon uge2SJZCzOkU225tDn/257o0PlyQR7yymiNu1Net8fLz96/SmBvbSZcq1f8B6EF+18 6Bgt0p4pD3iyQ== 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 1v0buf-00000008Kds-2s5s; Mon, 22 Sep 2025 08:28:45 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 14/26] genirq: Add affinity to percpu_devid interrupt requests Date: Mon, 22 Sep 2025 09:28:21 +0100 Message-ID: <20250922082833.2038905-15-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 E2A8B30147A; Mon, 22 Sep 2025 08:28:47 +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=1758529728; cv=none; b=T4z2K5PVYA4LfoTrml3V91SDUw0cAdJ9bCuC95eoA8RzWENxXS1eRpdUlbd4/wc8Q72eu30wnHjLwSexvSmxG076M/rysZ2CBsI7U5BlJjIddNciD3j7pHe9riLJCBpJOFouIo9wPevBRg3Ri8os1ygv78KAeqi3yMNtqE814no= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529728; c=relaxed/simple; bh=cL0dLu/yunYyIA9qv0q4EUwvwvs8MYopt4TvNf98yyM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GVwE6fbBHv3TtkRqeAKonxDxDoEX5SlLP5SB8kqGIZKgcfaJVJy4UucPsfptG4t7f4ykkdiFJlM/nq+oTyZp7rzkIPBWHtQI2BUgVHu7rLOLaa8OOtWAtXm1lCoI2U0BqDVJ7mKOiOxWwG+B6+k525cLWtZ+8yD7TKflOg4b3Kk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dhCLzLiy; 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="dhCLzLiy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0DC0C2BC87; Mon, 22 Sep 2025 08:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529727; bh=cL0dLu/yunYyIA9qv0q4EUwvwvs8MYopt4TvNf98yyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhCLzLiy/FzVqvtaHauaa+xKdbZ+Jo+kp7TSBFh5mqBq5q4+PLXmz8+f8AsCsQSB4 NExFKYDvLRf2aIqy0s5ePGgJR3iMGSUVw0bDEvHQNvWlvCUFU1yXctyN6rGMQ6/o09 FKbE9Zj7cGok8iqqT7TJ75YesJXEtRHUEx5mZv/NEZQddRtORIr/qWSeVwW8tt0sDA QzKyoUiO27ccOugQKwujsTGC3fNf+qT6OWh/WqPLk0cFIe7W93jl03q0vh6ba7cD0D LtFUPCqdFUnKoXNxxgSItaioE1wrfEk08eqQRZgBQgqRpe8bIwXPkijr/CJO+cdzMP IG71cFHSLvdfA== 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 1v0buf-00000008Kds-42RF; Mon, 22 Sep 2025 08:28:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 15/26] genirq: Update request_percpu_nmi() to take an affinity Date: Mon, 22 Sep 2025 09:28:22 +0100 Message-ID: <20250922082833.2038905-16-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- arch/arm64/kernel/smp.c | 2 +- drivers/perf/arm_pmu.c | 2 +- include/linux/interrupt.h | 4 ++-- kernel/irq/manage.c | 12 +++++++----- 4 files changed, 11 insertions(+), 9 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..22c601b46c858 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -659,7 +659,7 @@ 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..81506ab759b81 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 *na= me, + 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..b1a3140e5f3c9 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 @@ -2543,8 +2544,8 @@ EXPORT_SYMBOL_GPL(__request_percpu_irq); * If the interrupt line cannot be used to deliver NMIs, function * will fail returning a negative value. */ -int request_percpu_nmi(unsigned int irq, irq_handler_t handler, - const char *name, void __percpu *dev_id) +int request_percpu_nmi(unsigned int irq, irq_handler_t handler, const char= *name, + const struct cpumask *affinity, void __percpu *dev_id) { struct irqaction *action; struct irq_desc *desc; @@ -2561,12 +2562,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.47.3 From nobody Thu Oct 2 05:05:15 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 BB8AC302149; Mon, 22 Sep 2025 08:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529728; cv=none; b=bkpn2eT7tKu9k/io4iBp8Dd7GTHWgw5RrrLitEMu7MQi5FtzvpTvABLnizLdbbRPJcCSiNWBx98Nk/rS33K8RkMl9k3fMDZJtN4PB3ASczkV+rjY160hNQlBKOC9E+G/Id2cjOVYk7RIA8WimOVSMciYBsCbP1trRS6ty1oGn7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529728; c=relaxed/simple; bh=jatrGPs+V413Qd8HV7Zgw/uWOLMuK2m/cjTK6duu/aA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MgiAES5x9wnjG7qfyaRuOxd1dQkcOfSMUoNp+VvxQpIfdSU0XOemFEYZ18bchCoPu1CSRyaKKJ7qWjX63A48e+LIoTUUoTAnE31iczjW3OGKt9thRWlsGegd5aE9m4OaudFksspsDMYlOXmz1jKijQlQbbtyQumnnF3kBYYh1CY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XKu4E3jk; 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="XKu4E3jk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15BBFC116B1; Mon, 22 Sep 2025 08:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529728; bh=jatrGPs+V413Qd8HV7Zgw/uWOLMuK2m/cjTK6duu/aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKu4E3jkq7i6qS5KQd0f8OsGXDqZocsEaFUa+Q8oOVxLkwQ+x7pUm09ggGY8Mh9gw i7CxK15Hj6JI/fda4vo/ZMX9CB2kTK0dsg2TD+IkAJmvNI3vkB3hB0KA1eb4sLZSGF 8K4+AvbRoo2aK1H9XCBecdka2KdvoXCT5yXBVqfI7BlrOt5CqcHgPORi1tx6cX2cEO P6zpb8WGvttiO6AWBpkTA64OnAZZcnJPMT3OhDlb3wH291uTBXCBw9dNb8K1Pw5+LH +0+8JJOL1h8bDgc4ElVyod5oqWgl5lc+BBlDt2veaCOBcUrd4dS0+YvaArlNjJHG/t Ih4R4hRv9jg+Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v0bug-00000008Kds-165t; Mon, 22 Sep 2025 08:28:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 16/26] genirq: Allow per-cpu interrupt sharing for non-overlapping affinities Date: Mon, 22 Sep 2025 09:28:23 +0100 Message-ID: <20250922082833.2038905-17-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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 d1c9e357f64d2..14caa77076192 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -897,8 +897,9 @@ void handle_percpu_irq(struct irq_desc *desc) void handle_percpu_devid_irq(struct irq_desc *desc) { struct irq_chip *chip =3D irq_desc_get_chip(desc); - struct irqaction *action =3D desc->action; unsigned int irq =3D irq_desc_get_irq(desc); + unsigned int cpu =3D smp_processor_id(); + struct irqaction *action; irqreturn_t res; =20 /* @@ -910,12 +911,15 @@ void handle_percpu_devid_irq(struct irq_desc *desc) if (chip->irq_ack) chip->irq_ack(&desc->irq_data); =20 + for (action =3D desc->action; action; action =3D action->next) + if (cpumask_test_cpu(cpu, action->affinity)) + break; + if (likely(action)) { trace_irq_handler_entry(irq, action); res =3D action->handler(irq, raw_cpu_ptr(action->percpu_dev_id)); trace_irq_handler_exit(irq, action, res); } else { - unsigned int cpu =3D smp_processor_id(); bool enabled =3D cpumask_test_cpu(cpu, desc->percpu_enabled); =20 if (enabled) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index b1a3140e5f3c9..ea3dbf6fee194 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.47.3 From nobody Thu Oct 2 05:05:15 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 999F73019CC; Mon, 22 Sep 2025 08:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529728; cv=none; b=cjHIiRnqmMAWHO0hsNKSq72ERCoaFOUKj1vqnANoDhof3mDXe99Em6pX8KEHTwU4AgDQUcJuOIt68aEsA7t+yG7PcIg8Muu60nHQGlIeng9gizMtuFyGkOqB8rDxp4+Or3jH98TM5HKyB+2Y2TPU2y1YVtu/dVhW9TDVN4rYXs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529728; c=relaxed/simple; bh=IXL+IAJnY+2vKkQwblhiCgALIEf3E4Odr7ea40In+Fs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V1j1ZTUAbqrolsbUZ2PURYIBO/7Pws5c2qcvNGvozrdvxUIcDRo5zVcquzSTODyjef9WT6CzECONsMnkO4H6hPQBQ5pM34J0WKMp2YKui9OIBBm0F2NTK2RCTIC66vv4zTa9VjvXUaX0zxK2FU2iRaHQG1x9wVJtE6XycxDxJ3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ufK8efCt; 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="ufK8efCt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A63FC116C6; Mon, 22 Sep 2025 08:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529728; bh=IXL+IAJnY+2vKkQwblhiCgALIEf3E4Odr7ea40In+Fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ufK8efCtLc3aXcWKqIBHUVcqEce3ZIWNYDANBeCqn68VuoWJL3DqZCerRxLJx8N8w 14Bp/8fyRVzv8y0bP3rYIN09FE/vQfPbllC1C3iVWL2+gvLbOhBwZb9vfSttt6Rxz6 oO11vxLXUUqPRKTw9riZw7AjOFF3kAFvEo/R0GFjjxuvG7y5dWg7ycVWKFhcklRrW+ Y6nMhlekZM4hwf9xX49f3ytGQdr4S/qmbwGzJjHN+RkBTQGOaoX/10HztkrjphLAdF /Yq4za5yrUbFCWQrpWlLL+QktbdXkCI5Khga2oN4VH4ljJJQM0q0BGVXro1NZyqUUx U/86+wJxu6BtA== 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 1v0bug-00000008Kds-2GLT; Mon, 22 Sep 2025 08:28:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 17/26] genirq: Add request_percpu_irq_affinity() helper Date: Mon, 22 Sep 2025 09:28:24 +0100 Message-ID: <20250922082833.2038905-18-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- include/linux/interrupt.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 81506ab759b81..fa62ab556ee32 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 *na= me, const struct cpumask *affinity, void __percpu *dev_id); --=20 2.47.3 From nobody Thu Oct 2 05:05:15 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 0538E302743; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; cv=none; b=P6Dvq88C3czRdmSTRM1eCMWhtyrdHqhnSnfI20hw6nYQNSgh9ZofEJ/lGJUbqyrQPfp1zleFTbwrboopjEtqnmDbXJWrqzt8yY40fpwhTIExYQ9SX6Zovo2dDkVXKVXaqB6Y+8wCMQFg8gsnREoQTbL0DjJuB0em6eDNoG4ER0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; c=relaxed/simple; bh=LdDBGeu/vP85lq7NNzq3G3yDq8UtLVM6D6o0nOOwgZw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CyFytgx5J9bpbsSWxgmyAqMj0wwxlEBXjnBXfq2+gArvIterLzqgmXsaLau4MD+XFLCax3Yzs2wHG2MMSNhaWSmm+JPePfky9jgCnEvDwFBg3wWzk+s7VUVnf2EXM0kDCHmnAhxOd4EEAdnf42PBnzmWzX4kxe8DQwloPYftH2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LrguNaWK; 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="LrguNaWK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A6CC19422; Mon, 22 Sep 2025 08:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529728; bh=LdDBGeu/vP85lq7NNzq3G3yDq8UtLVM6D6o0nOOwgZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LrguNaWKyM+dzFtbYImsxdH5B1vU2VN3vBPkKkduQzcEC1RqepokzmRiA+97Tfg7p BbkRCcx6Wby5kr6YZaE5WdmgJ0cyPT/HDRYxtiHxYou8sJGdiITagvX5AFQxYZIL52 JMe5UnRncGpIyoS+TzIz8x5R7ATO8ivRCs/qWst+hcP0LBDYikpnb8wjhUDMKgdXhX xzAe74qRdGHRvn5ETQBgRZGSmHkMvqCPux2yXZOeCaPM+q61hi/wsA2yqZJjDj21F6 Pg3tT6EM+opuQRrFKpIwHl7bs9gJ7ltPyJbhMiHaKVfSw9JwZsmieeT//5lYijynbi z1qDf1tYP3REg== 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 1v0bug-00000008Kds-3aGB; Mon, 22 Sep 2025 08:28:46 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 18/26] perf: arm_pmu: Request specific affinities for percpu NMI/IRQ Date: Mon, 22 Sep 2025 09:28:25 +0100 Message-ID: <20250922082833.2038905-19-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- drivers/perf/arm_pmu.c | 44 +++++++++++++++++++-------------- drivers/perf/arm_pmu_acpi.c | 2 +- drivers/perf/arm_pmu_platform.c | 4 +-- include/linux/perf/arm_pmu.h | 4 +-- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 22c601b46c858..959ceb3d1f556 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,25 +655,24 @@ 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_armpm= u); =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; @@ -672,7 +680,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.47.3 From nobody Thu Oct 2 05:05:15 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 5A6132F8BF4; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; cv=none; b=IH426csbCOOChpCZdxHSUUkUwBab/emPWPzYJQq8DV0YJ4HJMX2p2QPFW+Kt/29IybnGwdTur3pwDPBjtutdvLNOQefRdJbNScSHtowV94KOtOISK90AIPxlIkaR8idTWguw1KTX3YFvYalZ+9ENQUwMPgwnzXduio7GpQWGF1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; c=relaxed/simple; bh=vkAmqpzgzzyialfvIFVGsoNQTnUld9ORrMfSrzt92bQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gvz2jEK7LJphNtM2IqMSFv+uYDg+CmMc14teXIfas0ro9J4dpd8B7WrUtUIsmzbO4GlX4ylcC4bIvE1wGhGIqwigHjvQSF/tH2VqaBoMbzjFg79lU7H0/K7iNw6JAVyaLsAXEuJkBdA9JXsyIz2OM/w8O8E8EUgSH7j5T6CNtUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bSM/9iwP; 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="bSM/9iwP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4131C4CEF0; Mon, 22 Sep 2025 08:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529728; bh=vkAmqpzgzzyialfvIFVGsoNQTnUld9ORrMfSrzt92bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bSM/9iwPkLJM65GDM45VWPIDMXeDnTV/vJq9/4ahR582wZs+Lqh4k2V1n4LEfB0jV 9VEWgcvUTsKzqxvToOu5NtASX/OMDhQsrpZf/t0ApnmIDYdUuNTO5ZkD3V8Y1+N2WV nqS/lOZ744AZlgla1UB9VaPOO9g/iLuS9A/F6bECZkHK8d7MhWQARZRCHDQdbzC5K5 o0I/Mlh/4mo8yNcw/Mq3cj/rR+Kwkb1Nkk4E8n3BAW7Cm1MMi9dnRR6e9Co/Z4vn29 3AfpxSh5RLmEK/fxDHkIfHfZnpX3xWk/Z0SASpHySZXhtR3OPsDr3f0pkrhOWomo/k SIpqn5Tf1w9vw== 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 1v0buh-00000008Kds-0Utw; Mon, 22 Sep 2025 08:28:47 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 19/26] perf: arm_spe_pmu: Request specific affinities for percpu IRQ Date: Mon, 22 Sep 2025 09:28:26 +0100 Message-ID: <20250922082833.2038905-20-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 5337A302CB2; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; cv=none; b=L3xBaTGXCjmc8v1CPWddsy9ZN2/OfIdzcrLr6xfIX3oNamtgIoDWoBSk7FEjIvKtT9whpwNLeHQwtfDcX9COr15wF6IPSlz6lXFh6oUhHZaXaAQ6f0QK6H5759JXjtPCREXqWdPFjlDpJttxr/l40l5Jg1e/HkBYdM1aP9oCcLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; c=relaxed/simple; bh=B9kVMS1KP6Byn0zyMEHaUwA2iK8UDNHnAZC4Pwhtp14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SnQqjPQ6t/2+RvZn60ue+xHm7UJk0coyZB950eGfrCGNtN7Quv+MYe1Sf4K9Gv0veu+LSIUseUXgx9AiIQrhnzaQxCeRhyuUNmpBFEVn7MLdsu7FQDx1dYpAeuGa1v0IkJRz/vLOjF6t8W8GjNPEproVWdMT33bqg8QdMl6pGs4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rSB5WA6/; 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="rSB5WA6/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32208C116D0; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529729; bh=B9kVMS1KP6Byn0zyMEHaUwA2iK8UDNHnAZC4Pwhtp14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rSB5WA6/7jLOB0XbcgmJdzxVvAE40Ux/TSo9VYS/S331nBFQ44dVAMHk5+jCWVdlY iOHFhQgcf1rKcm8JFJ7JiHZ1pOxyqqoyWZrGlv+HSeXNiFDD8O+r4bQblSHerLTEVO QzJP3MtthyrOkjidwlzhGNV+JiM7o2RjYT+nMREcCebxN6ik+wJiAuYAbVKDH+NBrQ PT7PuGxO3AOwF3I4PDfInFXrPNAl4xt92LHRNENNlqyZpwfGTdoIonkHoNYQUxygGu y/nGLPNjAQ9MaYJj58jc8FHKn2XUF/8GtII1iTEpF94JYbBF8gqOJoaYRXdpFv+vmp CljDh0vyBJn3Q== 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 1v0buh-00000008Kds-1itL; Mon, 22 Sep 2025 08:28:47 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 20/26] coresight: trbe: Request specific affinities for percpu IRQ Date: Mon, 22 Sep 2025 09:28:27 +0100 Message-ID: <20250922082833.2038905-21-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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. Acked-by: Suzuki K Poulose Signed-off-by: Marc Zyngier Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 C3EC6303A31; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; cv=none; b=uT+PlpgN863PONIb/vdifoa5ST3cNrt4R1ZsJpufQCp/JhbkheyYwZ14H6FOqqqpe6Din9aX7R0GSMt/iQtPH7uH5S2EWLZwvQgMfdBZP1B4Nu5bj6O7NS1DJHm0ToDdclBvPjKJ7/2xI6Gu6zJAI9lpE8arMdthzlJOZRSPS78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529729; c=relaxed/simple; bh=A/XF6leqvT7e8gSuNNbqTYexlmnNX9TES+aCttT5e0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AqkWVjQgMdsKd+UIIMXly7uVmq2ZfvmRYJayY/47GUvrnWUugERiE2FdlRnN00Vpxzpk45kFbJ/SnsxSWFGeoSCRs0aI3JRArASfzfCHBo9FaZFVwqwxdG/snnBxsIRveOX0MkWFU4ybx6GcVQVEVNISY49BDIsiFH9NiNcaEsw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cEKvcImM; 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="cEKvcImM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8769CC4CEF5; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529729; bh=A/XF6leqvT7e8gSuNNbqTYexlmnNX9TES+aCttT5e0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cEKvcImMC95/T/hl90rMJLXd2rmQnNby+wy0Oxx996yfTlcmRxMAGsyTqZ48fn2Nz CCps0G88F6E2NnluL/KbjWBCrZC5R+FesDrzLk1ziH8Mvlr4Ghgcm2RAvA5UEREI5P 7LJllYdn8NM5XlV/w3JUvrpqRDSLFq54HQORY4KnwCq3pr4e9SNHpG5wQjXGzesJjQ qyl/gilXofu37ZvBocoK6+lL231VxmxaAAINZ//iXoecQNK8uIdXrQQD/d/erOwnCw HHadhB901nM4hg/AWLpLeueYSI0jsQ+2p69MEf3O2u0akxU8XMQrIn7CUoYwaojGu8 0Ids3g5ovVzTQ== 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 1v0buh-00000008Kds-2u5t; Mon, 22 Sep 2025 08:28:47 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 21/26] irqchip/gic-v3: Drop support for custom PPI partitions Date: Mon, 22 Sep 2025 09:28:28 +0100 Message-ID: <20250922082833.2038905-22-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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 8b615a2ee463d..efb513e79bc55 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.47.3 From nobody Thu Oct 2 05:05:15 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 51F79304982; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; cv=none; b=f+PKF9Btuxg01yr7ZYrst6by4Z7HnI09ZE5/l8sYZR7B3kjG1LSmjYALFIozeN8FX/qbwnnOaQTrmv2AsZw59DfF3R2OucJdhpm2t0bKC1Ozx/5rkLkRmZzcognelScOqUT7QGKUKakFXUE7yPcGE4MBMTQXqsIps4cw0rQEemY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; c=relaxed/simple; bh=VdHLzjxPctdzw7v/CwtNrG0e3DgB4aoWVfgqEs1pc7Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uV07qLWzrTrj4LLHanKLlIp5CcWOKzYgx77LdeyH3qqP6Hk+vhcFEjBA/7eQj9YG5YBDYljrj0OA0Q5GrEzcdCzQPaw7l6t6Utpnu6Ofsn5s4gnjrHpPpbTiqc60+AgIdOnc0btZ5HY4VwRPLXEepWV6QoHiSyPcg02+5XpxGM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I+0rHNCu; 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="I+0rHNCu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5ACCC4CEF0; Mon, 22 Sep 2025 08:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529729; bh=VdHLzjxPctdzw7v/CwtNrG0e3DgB4aoWVfgqEs1pc7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I+0rHNCuAarGwwcHKAI6lHBF3NRJZTmoMjB/mhcwyo66OvZbMxH+LFeGIcSk3CDup 6NG1BhJFxOOEiZ9PZlMFVJQxAskoBIEhIBAyMGYmTxJPl52hbwVPDL2EzQc2+kkS28 30yFNbTjjZFQTQ+Dk3Uq7vn0nkqylAQqJXNsuVT5rQ4zf4chKvumybQ9IQbQO7BR61 zB4A7SfMgHcg7BJPyWnbHLKtJwaVwQjnt+NVsQIfNifZTyQ/pDa3tutgMe+zYdRelV QU9a9yJoGcUzqHcC7Hq7bVsmAHUxagwpwwetedB7cUZk+7V7yfcXQivwNV6ijv2uVM Aex+6zdDkfOLg== 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 1v0buh-00000008Kds-47XW; Mon, 22 Sep 2025 08:28:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 22/26] irqchip/apple-aic: Drop support for custom PMU irq partitions Date: Mon, 22 Sep 2025 09:28:29 +0100 Message-ID: <20250922082833.2038905-23-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Reviewed-by: Sven Peter Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 5807F304BA0; Mon, 22 Sep 2025 08:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; cv=none; b=h/I51ydxX2mLf6VE0wciI/aBpfIjD7H6m+jv5tt+CyDmOpzkAzqsdHR4aC4fUipZbe6sO4VQ4HlQGeJwtpgRQo+j1tfhbBToFYxKzm/QgjdPAkJogqB0IXMebs3CN1f7lyjFPB5zE6X7Wjh36fibvFJbSwhNmnKXs370GS2iWko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; c=relaxed/simple; bh=t699EEFxKxPFwzesa61qP1yBrUEIdyhLy4vHQuVgrl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o4Aob7amtxKwhTN3ZThM5zEdvapzDhM+PcvBKcwNTj27d2pl1BmLyULcUQBiV6mUm/JbycjmyJQaCnYM2jeiab4VKzRo/aLI+RwpE2vdRpabaAERKrRwa5V4+QDW+BJddjfYvWcD00mMSIjEfXpShFluMBr8DxwB2itIMAN8wF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b5H96t7u; 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="b5H96t7u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BD18C116C6; Mon, 22 Sep 2025 08:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529730; bh=t699EEFxKxPFwzesa61qP1yBrUEIdyhLy4vHQuVgrl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b5H96t7ucBRTfDFg/9SxaaUHERbq3eRsWNntjh/0A4ZkJA+Qr/++coQjhNePciRGD JoTJFDM4Sk6o2lqgEznmaaGNdArN5dCUzmHlUbMZDiHdT67qiYhMS0Je12kMGOXBKM 13fBBm7NFVVqJSpzTl9xO/CSp1Vqy3o5w8Jm5Kctxr4GhRTQFZxasd4GQE8tglnCYo Hx2MaFb+36Hl44Te3i1gdpuepOFQImvgSbekGuEmXYFGZD7J9w/lJQZdEqn5u2b9ye 73ZUwVy5xwJJKfS5cuyC51KJ3G5J1o+J8jnS8erF9Hii6LuomBQhPyRejCPvPHntTt o+rYJu4n1ubKw== 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 1v0bui-00000008Kds-15Gs; Mon, 22 Sep 2025 08:28:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 23/26] irqchip: Kill irq-partition-percpu Date: Mon, 22 Sep 2025 09:28:30 +0100 Message-ID: <20250922082833.2038905-24-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 9ED2E305056; Mon, 22 Sep 2025 08:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; cv=none; b=c8P1USpCfvR9BE1THqTNZpnHozJ086jWcPA1+3OPjUC6M0upH9b5nf+o7N5tiAP+hMB9gNfZT+D/hKNgxlmE8uyU7QD5ZUBsLYLWUP37nbEQegfNKch2/rEO+UHXQdCYoWijtFonNqeT5GGVyTseB13jdEU31sKteGFTAUmT0Dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; c=relaxed/simple; bh=cvZ2bG6UgYQzigEKIrFLrXkwQbGabtL1b8+eUxAZgR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PoPHBFHxglKxDqBYjcjybkbSDxP0nh0g/V3Z8LOXjR/wJVjSII3h9cdS40+E9iXyo64+2kWtzqsYMxhSJWCZTQ01M0lwh1V84jL1UKvo5/Hab/xb/ujsBXaHOuBs5U4MlcJX1wVHrcYClnqDlBJqh4LQ9ZnG6JXuPBO6RSQo+a4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gderv2+K; 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="gderv2+K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C831C4CEF5; Mon, 22 Sep 2025 08:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529730; bh=cvZ2bG6UgYQzigEKIrFLrXkwQbGabtL1b8+eUxAZgR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gderv2+Kk/B3Mls0DFGEI98zWvNCig0HqjpwWwcC24CZ4CxHJ2XWjBP4opHh6lQX6 nH72ImXHTfnRgwYk82VPy+upt6V9flZPHJRe8FN8+uHENGjCT4fafzzhqqqznxMxvo Y3QLoNjjz67gpzjT+GIHZz1nWk9DeeRVZ1y0N1P+8zz/AAksQlt4R1x7XUAu/U0Zt0 BZ0vxoKozooP+8xpQVYIAFlShfzMBGXCdKavtS1NEliPvZ8rpDd23Y7VN1StKr6UGf F0vtHM0zc0++g9WABDbkVxIUAh8+aKewXnGXhU9Ti/EZ3vREoJPgyibHsNoTiow6XR nCVyJi9yeEsYg== 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 1v0bui-00000008Kds-2LDP; Mon, 22 Sep 2025 08:28:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 24/26] genirq: Kill irq_{g,s}et_percpu_devid_partition() Date: Mon, 22 Sep 2025 09:28:31 +0100 Message-ID: <20250922082833.2038905-25-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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.47.3 From nobody Thu Oct 2 05:05:15 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 B969C2EFDB5; Mon, 22 Sep 2025 08:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; cv=none; b=d5vOk2uMCZvqhleS2ue0BjdWje5e8v3aSC2phXUxntV7LQysbb+SzFrtYWtECZaG4mIa29kb+kGvFikfw8f+mBaatozfqZu7JWLxpwnSpJnMeBTfxTTlGL/GlfIAlmgbyRz/tyZ3TwXc10q1jwNwGlmEUfH1q6jSAw/3HkxVG8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529730; c=relaxed/simple; bh=Fx/E7oy6R/UrfCZVgp/oGljSUU8nvVLOsITLcZjwrgg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q7wA1MiFitFLC4fsSZCMo3Y9vzbBIcLZ1n/JbfRt23nGscO4nP2mWd8BhYl9Z9kOXCE7StXCUlsqg9o8Dlg0WxsiufFhu0s52DU7ed3g2QZTV9sHMpXdJytLasNPjjfzLy/oOlTooa5eWyCRnrDAoTN6EiCqeI1jdIu2pYGzYMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d2O1utI3; 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="d2O1utI3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9780BC19421; Mon, 22 Sep 2025 08:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529730; bh=Fx/E7oy6R/UrfCZVgp/oGljSUU8nvVLOsITLcZjwrgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d2O1utI3K7Phivaz71zscKCxzb6JQLvDE3hoXpoZ2VOBu+OMSBRmIDU3O+/Doaabt EzxvHROHbgcjvuw9uR09gVay4VfmVtwnYve4G6B6eBBHOdacySxILiN2IMOgA8cpz6 FGN3W/1+eocopJ6rARZT2hg6j9LZfiHctgX6X/HZzCjzXm3WxjIiVg4SUGPxfPCxsA 2lTs2HpweaDTeB5YIcPDV1xAIkg5Uoc6Stl98SjW6+Eh9L28qW23WYIY/YElg2DwT2 kyBSu7u/d1qDUqBdCY3SfE2M2o7e44O3Il+/37J2ABOfT/s7CrnetsbvfyhZ9vWRtH AvzG3fFhaAV7A== 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 1v0bui-00000008Kds-3VXl; Mon, 22 Sep 2025 08:28:48 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 25/26] irqdomain: Kill of_node_to_fwnode() helper Date: Mon, 22 Sep 2025 09:28:32 +0100 Message-ID: <20250922082833.2038905-26-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 users of this helper since b13b41cc3dc18 ("misc: ti_fpc202: Switch to of_fwnode_handle()"), and is replaced with of_fwnode_handle(). Get rid of it. Suggested-by: Jonathan Cameron Signed-off-by: Marc Zyngier Tested-by: Will Deacon --- include/linux/irqdomain.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 9d6a5e99394fa..5907baf6099d9 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -730,12 +730,6 @@ static inline void msi_device_domain_free_wired(struct= irq_domain *domain, unsig } #endif =20 -/* Deprecated functions. Will be removed in the merge window */ -static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *= node) -{ - return node ? &node->fwnode : NULL; -} - static inline struct irq_domain *irq_domain_add_tree(struct device_node *o= f_node, const struct irq_domain_ops *ops, void *host_data) --=20 2.47.3 From nobody Thu Oct 2 05:05:15 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 0D2C93054F8; Mon, 22 Sep 2025 08:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529731; cv=none; b=E+V4VsRU/Bbd+wzH65TaLNs8Dkcp9j2QohOHCDiIqPwvcBVWchgwTszpBItXYhXZl4LfEkrhFFkoo8Ttxv8hCKUpYo4eJuuv/cEEezfvxxiWNp1dSdncr+kzLftrCNQk6VqxZFhAbKD5Gt5T3HUPmgMaYJUkFA2U3IStH20mTro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529731; c=relaxed/simple; bh=tS9i8aN1hYglqnYWNWW11cQTPh7t9Qg/dLKIcWSR4ZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=op1drhDtGPXTUT4q+T53HVTxj9qOBFmA7QUihp5b3PdBWZgx1a9NSEjuzFRdNAdl6r6EcfEmBQ3mAtJEJXPmFHvQTSUGMrVqtpTnRhboBNL1IpG8NLSBUkj2tjqaNe4Srb9ZGeqa0eXl9BK0+8ffcLEfEnnOjLbd5FwrYyo7WXQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lHJ5PRh7; 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="lHJ5PRh7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E17C8C4CEF5; Mon, 22 Sep 2025 08:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529730; bh=tS9i8aN1hYglqnYWNWW11cQTPh7t9Qg/dLKIcWSR4ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lHJ5PRh7Ux8PJQOWAn4d/Lp9A0Hs+pg/NiaxkK9RMYJSmj/+imhD4Q0cMEnZS78FZ ODJdeKP3XzYggV8qOadOgH9Ptig2AU9AmrHhj9utUUHaylwa14n3iluhWrDz38hRGu uu1Pzk1gs8lhfrUPoYllNnBLk08KqZSrp0HZq5OSI432QwC/xUngD6dW8swhNrfPHc EzUbYqoFv0t5WCO2EWh/auYx2KvUjdBjR1wBeWg2m+nb3KKi4AZ6Tyq/itLJ27PLZx mabvJuICtlbgpb4doshTGd9lFb72qHAMDZhFbmpBlpuT9k2NNGmMe+jAHe9+OJ9ZI3 ibdwEi+0QoNNg== 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 1v0buj-00000008Kds-0Thb; Mon, 22 Sep 2025 08:28:49 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 26/26] perf: arm_pmu: Kill last use of per-CPU cpu_armpmu pointer Date: Mon, 22 Sep 2025 09:28:33 +0100 Message-ID: <20250922082833.2038905-27-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-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, jonathan.cameron@huawei.com 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 Tested-by: Will Deacon --- 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 959ceb3d1f556..f7abd13339630 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 @@ -725,8 +724,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); @@ -746,8 +743,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.47.3