Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp912236rwb; Tue, 4 Oct 2022 12:25:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dguwwcmNCxr3Y7nqyxNNvVfRAZOT5lsh9XuDc/RIV0N8Ma3rzwd5OSKqZNYqWKzMK8RQX X-Received: by 2002:aa7:c849:0:b0:453:9543:6ef3 with SMTP id g9-20020aa7c849000000b0045395436ef3mr25198456edt.105.1664911552942; Tue, 04 Oct 2022 12:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664911552; cv=none; d=google.com; s=arc-20160816; b=KOsg2D6HqN0BXsLzKupl/9mJcggeI2ZAYoOBb8PWUh61Vez3jqcPNRNeM+wTrL06KN 4B9y65vU78DphgYGeCq9b3Z4lK2ds6f2Z0Dp59bKUj48KDt+S7iq2yrhxfcdSoA4iIyS 9k0nxCGefambuWnG8tiR2wf+rqf7dAIIzJgjwaXpVxCYSbrTJekvGLHHVh3cOSv4le7E ubEGWDDpZDvQzPc2Do81M2M1bGV3IUaSy+ry9ihK+VniZCOpwJTDcvPOmN32wX7hBdfS lBU3gh7hMZWChIqb3kMNXmEouAmsK687d6Sfg+BzzRbVgs5Ai5Cn2xf2F+Q9OvdSen+F LZ5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=JeSLoXpIStGitpJq+1LN7eN2qBShURNAiA4QCnEm68U=; b=SNlBCZ2PXhnxYYPBBPd9YMoFFhY3VUQvqOoyImGcC2xvocmXSbQpn8YOfNSVUQf/Uq 6X67XT2H8VwgAzn50tmuWow3RsbeyYgB6QWk/Pm5iDqxAieNaYipZfsjUXxIbdQI3DFT /4A7g23P+P8vCBFMMVAZtmZvIGC3LbBvX39jotl5x38t4RPYmIXia0BDgWapCMLZsjwq obUjFgfaYHAYCcLbaIR1jgI3HkLGmLpqr0rDgR1cqfVxD498sHtzAfU5NfGcYOhebDKz l7KTvWEwryoKy81CfN/qQHrZ2d6cGnEO+GpzY1CSPkPpACCYgfFMAVcXKs1W9mY5zaNg 0QTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=niNm40Ig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb27-20020a170907961b00b00783a9ea980dsi11566144ejc.811.2022.10.04.12.25.26; Tue, 04 Oct 2022 12:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=niNm40Ig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbiJDTOc (ORCPT + 99 others); Tue, 4 Oct 2022 15:14:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiJDTO3 (ORCPT ); Tue, 4 Oct 2022 15:14:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8294332C; Tue, 4 Oct 2022 12:14:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 364EC61503; Tue, 4 Oct 2022 19:14:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B74FC433C1; Tue, 4 Oct 2022 19:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664910867; bh=AI/bhdO9mDt2AJiBTy/DR5WJsm0u8LzDoxfCIICGnNw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=niNm40Ige5jvXdzikYXbvFRhCnsVrejQ9vC/UzB6lHinYg3V18+BeU8W0NpIgvVt0 J4MskZtq62uP1UMptL1pqj/LNZjPvxt5j4RPVu9ePciX1LcFsRMZE0L/vgqWu9dv/t 11Wj9pb7kVH8ti6f4wRcjHQEIXFP5b9RlJuS/W4tSgvhw2ghGOdkji7pj8TcQ6PUNA HVVLvYV958jPMpFwKbjs3Nsa1p2RMv0/vRd5dRNDkcWfRPLv6VE0HzZCiZ62nzUGkk Qa1nhM4ht2qyt9fO5hsPiEQ1EkOmgphAk8l/AAoGsTELQUtv/wpTLjssvroA5AOgxf xOq8d/xjamKYg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ofnN3-00EagJ-5M; Tue, 04 Oct 2022 20:14:25 +0100 Date: Tue, 04 Oct 2022 20:14:24 +0100 Message-ID: <86a66b8kq7.wl-maz@kernel.org> From: Marc Zyngier To: Konrad Dybcio Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, towinchenmi@gmail.com, Hector Martin , Sven Peter , Alyssa Rosenzweig , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 2/2] irqchip/apple-aic: Add support for A7-A11 SoCs In-Reply-To: <20221004112724.31621-2-konrad.dybcio@somainline.org> References: <20221004112724.31621-1-konrad.dybcio@somainline.org> <20221004112724.31621-2-konrad.dybcio@somainline.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: konrad.dybcio@somainline.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, towinchenmi@gmail.com, marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 04 Oct 2022 12:27:24 +0100, Konrad Dybcio wrote: > > Add support for A7-A11 SoCs by if-ing out some features only present > on: > > * A11 & newer (implementation-defined IPI & UNCORE registers) > * A11[1] & newer (fast IPI support). > > UNCORE/UNCORE2 and IPI registers conveniently both first appeared on > A11, so introduce just one check for that. > > Knowing whether the SoC supports the latter is necessary, as they are > written to, even if fast IPI is disabled. This in turn causes a crash > on older platforms, as the implemention-defined registers either do > something else or are not supposed to be touched - definitely not a > NOP though. > > [1] A11 is supposed to use this feature, but it currently doesn't work > for reasons unknown and hence remains disabled. It can easily be enabled > on A11 only, as there is a SoC-specific compatible in the DT with a > fallback to apple,aic. That said, it is not yet necessary, especially > with only one core up, and it has worked a-ok so far. > > Signed-off-by: Konrad Dybcio > --- > Changes since v2: > - has_uncore_regs now also reflects whether the soc has IPI regs (A11+) > - apple,aic is now the default, lowest-common-denominator fallback > compatible (Sven checked it still works on M1) > - fixed an error where "Fast IPI fired. Acking." would be unreachable.. > oops.. > - what used to be apple,aic (yes UNCORE/IPI regs no fast IPI) is now > used for the A11 compatible I asked for it when I reviewed the first revision of this series, and I'm going to ask again: please add a cover letter to your patches. It's not rocket science, and this is the place where you should have the change log. > > drivers/irqchip/irq-apple-aic.c | 60 ++++++++++++++++++++++++--------- > 1 file changed, 45 insertions(+), 15 deletions(-) > > diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c > index 1c2813ad8bbe..239115c64340 100644 > --- a/drivers/irqchip/irq-apple-aic.c > +++ b/drivers/irqchip/irq-apple-aic.c > @@ -230,6 +230,9 @@ > > static DEFINE_STATIC_KEY_TRUE(use_fast_ipi); > > +/* True if UNCORE/UNCORE2 and Sn_... IPI registers are present (A11+) */ > +static DEFINE_STATIC_KEY_TRUE(has_uncore_ipi_regs); > + > struct aic_info { > int version; > > @@ -246,6 +249,7 @@ struct aic_info { > > /* Features */ > bool fast_ipi; > + bool uncore_ipi_regs; > }; > > static const struct aic_info aic1_info = { > @@ -261,18 +265,33 @@ static const struct aic_info aic1_fipi_info = { > .event = AIC_EVENT, > .target_cpu = AIC_TARGET_CPU, > > + .uncore_ipi_regs = true, > .fast_ipi = true, > }; > > +static const struct aic_info aic1_nofipi_info = { It is high time that these structures get marked as __initconst, as we don't need them once the driver is up and running. > + .version = 1, > + > + .event = AIC_EVENT, > + .target_cpu = AIC_TARGET_CPU, > + > + .uncore_ipi_regs = true, > +}; > + > static const struct aic_info aic2_info = { > .version = 2, > > .irq_cfg = AIC2_IRQ_CFG, > > + .uncore_ipi_regs = true, > .fast_ipi = true, Please initialise the fields in the same order as the declaration. > }; > > static const struct of_device_id aic_info_match[] = { This could also benefit from __initconst. > + { > + .compatible = "apple,t8015-aic", > + .data = &aic1_nofipi_info, > + }, > { > .compatible = "apple,t8103-aic", > .data = &aic1_fipi_info, > @@ -524,12 +543,14 @@ static void __exception_irq_entry aic_handle_fiq(struct pt_regs *regs) > * we check for everything here, even things we don't support yet. > */ > > - if (read_sysreg_s(SYS_IMP_APL_IPI_SR_EL1) & IPI_SR_PENDING) { > - if (static_branch_likely(&use_fast_ipi)) { > - aic_handle_ipi(regs); > - } else { > - pr_err_ratelimited("Fast IPI fired. Acking.\n"); > - write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); > + if (static_branch_likely(&has_uncore_ipi_regs)) { > + if (read_sysreg_s(SYS_IMP_APL_IPI_SR_EL1) & IPI_SR_PENDING) { What's wrong with: if (static_branch_likely(&has_uncore_ipi_regs) && (read_sysreg_s(SYS_IMP_APL_IPI_SR_EL1) & IPI_SR_PENDING)) { which limits the churn and avoids the extra indentation? > + if (static_branch_likely(&use_fast_ipi)) { > + aic_handle_ipi(regs); > + } else { > + pr_err_ratelimited("Fast IPI fired. Acking.\n"); > + write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); > + } > } > } > > @@ -566,12 +587,14 @@ static void __exception_irq_entry aic_handle_fiq(struct pt_regs *regs) > AIC_FIQ_HWIRQ(irq)); > } > > - if (FIELD_GET(UPMCR0_IMODE, read_sysreg_s(SYS_IMP_APL_UPMCR0_EL1)) == UPMCR0_IMODE_FIQ && > - (read_sysreg_s(SYS_IMP_APL_UPMSR_EL1) & UPMSR_IACT)) { > - /* Same story with uncore PMCs */ > - pr_err_ratelimited("Uncore PMC FIQ fired. Masking.\n"); > - sysreg_clear_set_s(SYS_IMP_APL_UPMCR0_EL1, UPMCR0_IMODE, > - FIELD_PREP(UPMCR0_IMODE, UPMCR0_IMODE_OFF)); > + if (static_branch_likely(&has_uncore_ipi_regs)) { > + if (FIELD_GET(UPMCR0_IMODE, read_sysreg_s(SYS_IMP_APL_UPMCR0_EL1)) == > + UPMCR0_IMODE_FIQ && (read_sysreg_s(SYS_IMP_APL_UPMSR_EL1) & UPMSR_IACT)) { Same thing. > + /* Same story with uncore PMCs */ > + pr_err_ratelimited("Uncore PMC FIQ fired. Masking.\n"); > + sysreg_clear_set_s(SYS_IMP_APL_UPMCR0_EL1, UPMCR0_IMODE, > + FIELD_PREP(UPMCR0_IMODE, UPMCR0_IMODE_OFF)); > + } > } > } > > @@ -944,7 +967,8 @@ static int aic_init_cpu(unsigned int cpu) > /* Mask all hard-wired per-CPU IRQ/FIQ sources */ > > /* Pending Fast IPI FIQs */ > - write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); > + if (static_branch_likely(&use_fast_ipi)) > + write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); > > /* Timer FIQs */ > sysreg_clear_set(cntp_ctl_el0, 0, ARCH_TIMER_CTRL_IT_MASK); > @@ -965,8 +989,9 @@ static int aic_init_cpu(unsigned int cpu) > FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_OFF)); > > /* Uncore PMC FIQ */ > - sysreg_clear_set_s(SYS_IMP_APL_UPMCR0_EL1, UPMCR0_IMODE, > - FIELD_PREP(UPMCR0_IMODE, UPMCR0_IMODE_OFF)); > + if (static_branch_likely(&has_uncore_ipi_regs)) > + sysreg_clear_set_s(SYS_IMP_APL_UPMCR0_EL1, UPMCR0_IMODE, > + FIELD_PREP(UPMCR0_IMODE, UPMCR0_IMODE_OFF)); > > /* Commit all of the above */ > isb(); > @@ -1125,6 +1150,11 @@ static int __init aic_of_ic_init(struct device_node *node, struct device_node *p > else > static_branch_disable(&use_fast_ipi); > > + if (irqc->info.uncore_ipi_regs) > + static_branch_enable(&has_uncore_ipi_regs); You initialised the static branch to true, so this does very little. > + else > + static_branch_disable(&has_uncore_ipi_regs); > + > irqc->info.die_stride = off - start_off; > > irqc->hw_domain = irq_domain_create_tree(of_node_to_fwnode(node), Thanks, M. -- Without deviation from the norm, progress is not possible.