Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1483010rwb; Fri, 7 Oct 2022 13:21:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7es+gPOAYSxVSTgUy2sNg7MyxkG6XWSzIJKmDm2QfRn0+ophy2Jj3QZNgybdhwcFSvQFh2 X-Received: by 2002:a17:902:9306:b0:179:e926:dfc6 with SMTP id bc6-20020a170902930600b00179e926dfc6mr6900463plb.66.1665174097839; Fri, 07 Oct 2022 13:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665174097; cv=none; d=google.com; s=arc-20160816; b=eA6ZscscEIkq+kDZWysevZkJ5IdJFXkljjDs9lreEkMxsKZiUjm3qVNuKCkwAiMp3F dR746G7rg3ZTMr6fZN5dE/0c5s+tmDHXFZgsVrPI31Abn69BOLBF80sSwLjS4ZBD2CvF SaBsyh21TylgWPsxJhPFU6k6Fk+SgS/5ivdjj39cBqHSmIeTpD/j5xMhBUHAIDYt+DTs grOgw2nVzwodRv0PIv/feCPs/qpEMt7+O2MQBDhnLk5gGiHf8SaRieEuqbyVFcYLiZ2r HMzvsqA3cFh9J810Yhn7tsAbYghNaDGtL8zZXfJPIIHPP8OypJAE5eWXTH/jVhCf7MPe 6ADQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Op/bjiDLbzgAjFhBcV8a/U9A3w5UMdD6Jd/xskFDApc=; b=U9pYGBOQnnMZc/XiCYXueLo7XJ6Iv8GVrWFtKSjuTaYJIcWO+o07r8bam64By4oNBP Ihc5Bu29A2jm/HmJzJP5Kgh5c8Zyp/WsYe70lrY9ZtvRjEj010++aocnQqVzGmLx9hCd MuTAh+60rHHwH0YeVSCu5YH55MnZsS1ROQ5PttHc7qHCpJbkQLdJrWL2RMFYfSvSTmG1 Nv456BEVKkpwkUlu7MYziIg6X1RmXzhr6klD8hPvW/p0waknrK7ckSKvOJg8Mv0P55kp wg7XKVWP2RQP8fytObx9+eCYCfjyKuSKvHoUCo/7ISacvr0XYt2Ir3D9fM9fu5KZsZYE McLA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe5-20020a17090b4f8500b0020c79f987f4si423297pjb.131.2022.10.07.13.21.20; Fri, 07 Oct 2022 13:21:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbiJGUAy (ORCPT + 99 others); Fri, 7 Oct 2022 16:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbiJGUAv (ORCPT ); Fri, 7 Oct 2022 16:00:51 -0400 Received: from relay05.th.seeweb.it (relay05.th.seeweb.it [IPv6:2001:4b7a:2000:18::166]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C80B9D73F3 for ; Fri, 7 Oct 2022 13:00:49 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 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), -- 2.37.3