From patchwork Fri Oct 7 20:00:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13001435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57681C4332F for ; Fri, 7 Oct 2022 20:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FuhxCg5mpGSBoHMXtzb9Ax5F56lRzWNChcTw27l9VPE=; b=1ifvlXw5VPflU9 r++JLqFL1yCmkkAHpVUWuSY7bZBk9UKAatRTd46U7FNllmMU2SuG4IeEt14wdCyo0xzUJipaTkUN/ 1pFB4Ce/pLYEOJz0OC0y4ecA99Mz/muW1LiWXJFTG+XdUhTEFgmawJoH6m395nQlntw4T4Kmk9o8L vPEcfE+0Z3G2rPhpgPwvYUQlhfE9pCAh6ae8CP9EdWa/JiUMT+AtG5Om00wpIO1wt7q6mXeT+/x7L kCCV2uSUxr4+IpOiUL+hSExYii62uJ3cBdbH7jrLUW11u2Uoc0PV72wkJxamv6T8tIAxJVkyJ0ZNB LeyP5WFpfSKyuesNpi1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogtWl-00AIMA-VX; Fri, 07 Oct 2022 20:01:00 +0000 Received: from relay05.th.seeweb.it ([2001:4b7a:2000:18::166]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogtWi-00AID2-M6 for linux-arm-kernel@lists.infradead.org; Fri, 07 Oct 2022 20:00:58 +0000 Received: from localhost.localdomain (95.49.30.201.neoplus.adsl.tpnet.pl [95.49.30.201]) by m-r2.th.seeweb.it (Postfix) with ESMTPA id 7D0E13F359; Fri, 7 Oct 2022 22:00:45 +0200 (CEST) From: Konrad Dybcio To: ~postmarketos/upstreaming@lists.sr.ht, asahi@lists.linux.dev, Hector Martin , Sven Peter , Alyssa Rosenzweig Cc: martin.botka@somainline.org, angelogioacchino.delregno@somainline.org, marijn.suijten@somainline.org, jamipkettunen@somainline.org, Konrad Dybcio , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 1/2] dt-bindings: apple,aic: Document A7-A11 compatibles Date: Fri, 7 Oct 2022 22:00:21 +0200 Message-Id: <20221007200022.22844-2-konrad.dybcio@somainline.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007200022.22844-1-konrad.dybcio@somainline.org> References: <20221007200022.22844-1-konrad.dybcio@somainline.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221007_130056_907322_F2C630C9 X-CRM114-Status: UNSURE ( 8.04 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Document the compatibles for Apple A7-A11 SoCs. Signed-off-by: Konrad Dybcio --- Changes since v3: - Bindings: A7-A10+M1 only get SoC compat and generic fallback, A11 gets M1 fallback and generic fallback (removed A11 compatible) - Drop Rob's A-b as this is essentially yet another rewrite.. .../bindings/interrupt-controller/apple,aic.yaml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml b/Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml index e18107eafe7c..1427ea9b04a2 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml +++ b/Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml @@ -36,9 +36,19 @@ allOf: properties: compatible: - items: - - const: apple,t8103-aic - - const: apple,aic + oneOf: + - items: + - enum: + - apple,s5l8960x-aic + - apple,s8000-aic + - apple,t7000-aic + - apple,t8010-aic + - apple,t8103-aic + - const: apple,aic + - items: + - const: apple,t8015-aic + - const: apple,t8103-aic + - const: apple,aic interrupt-controller: true From patchwork Fri Oct 7 20:00:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13001436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7481DC43217 for ; Fri, 7 Oct 2022 20:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t/gHe+t3og085RxjWQ6q62f1uwPs+aGnJJd0r2PnON0=; b=hjEOTcHOBgTMrk KDG08un2QTdD/QCTPpLtMKwjmz9ZdHBTFFIQx3fqaQhtlZExS5pPwxNia/hnPUP7OBE2Q8e0K+Gjn 4r2tLNnLbhQH9R4u2UMdJdJA8xFRvoY7E/o8aYqRJNvm5nT+5v+zM0BeAYBXpy5dNPcKSvctuy5C4 8ern6m6QsbX9iIDE2XVpKO4DP08JSrqqqQkjgJKJLgsUZSCWTBLpVTO8DMiJijlzOTkeHV0vfp1WF 0twsb847zdoG/OtFD1oQa6LZFFmCwo2i7mos3lsmVdb0ek294PpsTmm/ayUL1wHsGEBmYwlmPmt2o fq2pJMwsh2cR66rK0YwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogtWt-00AINT-Nk; Fri, 07 Oct 2022 20:01:07 +0000 Received: from m-r2.th.seeweb.it ([5.144.164.171]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogtWj-00AID1-Ga for linux-arm-kernel@lists.infradead.org; Fri, 07 Oct 2022 20:00:59 +0000 Received: from localhost.localdomain (95.49.30.201.neoplus.adsl.tpnet.pl [95.49.30.201]) by m-r2.th.seeweb.it (Postfix) with ESMTPA id 0FB6F3F36F; Fri, 7 Oct 2022 22:00:47 +0200 (CEST) From: Konrad Dybcio To: ~postmarketos/upstreaming@lists.sr.ht, asahi@lists.linux.dev, Hector Martin , Sven Peter , Alyssa Rosenzweig Cc: martin.botka@somainline.org, angelogioacchino.delregno@somainline.org, marijn.suijten@somainline.org, jamipkettunen@somainline.org, Konrad Dybcio , Thomas Gleixner , Marc Zyngier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/2] irqchip/apple-aic: Add support for A7-A11 SoCs Date: Fri, 7 Oct 2022 22:00:22 +0200 Message-Id: <20221007200022.22844-3-konrad.dybcio@somainline.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007200022.22844-1-konrad.dybcio@somainline.org> References: <20221007200022.22844-1-konrad.dybcio@somainline.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221007_130057_899396_D60F3E9E X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for A7-A11 SoCs by if-ing out some features only present on A11 & newer (implementation-defined IPI & UNCORE registers). Also, annotate IPI regs support in the aic struct so that the driver can tell whether the SoC supports these, 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. Signed-off-by: Konrad Dybcio --- Changes since v3: - Replace use_fast_ipi with has_uncore_ipi_regs in aic_init_cpu (logic error, this was written to regardless of FIPI usage before, but touching Sn_... regs on SoCs that don't explicitly use them for IPIs makes them sepuku..) - Drop A11 compatible drivers/irqchip/irq-apple-aic.c | 47 ++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 1c2813ad8bbe..2609d6b60487 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,6 +265,7 @@ static const struct aic_info aic1_fipi_info = { .event = AIC_EVENT, .target_cpu = AIC_TARGET_CPU, + .uncore_ipi_regs = true, .fast_ipi = true, }; @@ -269,6 +274,7 @@ static const struct aic_info aic2_info = { .irq_cfg = AIC2_IRQ_CFG, + .uncore_ipi_regs = true, .fast_ipi = true, }; @@ -524,12 +530,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) { + 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 +574,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 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 +954,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(&has_uncore_ipi_regs)) + 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 +976,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 +1137,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); + 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),