From patchwork Sun Sep 1 03:40:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13786248 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 677BACA101E for ; Sun, 1 Sep 2024 03:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9Jlw7myxYxrx+WOkTkEU/GjLvfU58jir7qbTQIyRSl8=; b=GK5Hbzu0UKY6kLHrB8iGMtQxL7 Xj13h89wTkEu4ZtFTFkqGbn+SikK1HNk3Nq2KN9600DYvgbi7osn2ACiv3TsPh8mP8BCAmH/Qljw/ 8h54whP6zpRheUB9ojnG+dIN3Rp3I0PeW5jTI00ED6p6ilDFQQyKCRnXvM3jbk/ZNyxIVR2Nt+QwC cKYd3qv9wUjHkRJgaufIGBPwZ7yGmmiR5tHx6SfkDUoNon1SgSvnvrw5/bsmQD4ZuOGTImMoUEpt1 iBsu1V1h7F4h8BNNibtzE+HKYonsQf4rToBH+Ms6zv1OpESkdoYFqO5QrhaYCwXgGtE3tDUwGW+dL 7XKKctaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skbY2-0000000Al2K-1HBs; Sun, 01 Sep 2024 03:46:42 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skbUL-0000000AkS1-3hu6 for linux-arm-kernel@lists.infradead.org; Sun, 01 Sep 2024 03:42:55 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-715cdc7a153so2242233b3a.0 for ; Sat, 31 Aug 2024 20:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725162173; x=1725766973; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9Jlw7myxYxrx+WOkTkEU/GjLvfU58jir7qbTQIyRSl8=; b=eNHR9HqNdeof2cSBF1YXOIHbA+nCqZgahcLDo8e+B1ZBVEHs0accXiXCB9kQhNtqRf eD4gCb2m7Xghqw1rZPHtIq2+1rwJU8lG+6ndVDURoUplZMiKUTMYQS2CaaMcn0/6Im+z XOGuT2mGuUyXJg71q+xT9CU5Tzc+KRbUAvVSb7X53Pj6d3ALDeUZvAkFFbWQ0IC/poA2 53uiS7CY+9G9lkXrd8iPJ+WSRWib09DsGkS+pc2dDctkdlqdZJLlcWoxET4sfFjmBtMl 3P0K0We29xr+X/sgxj8/Bf6jcgXZHQrexjifPQX1qPqperwpI53Ci/Mf+2NncLgpIJoQ ieaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725162173; x=1725766973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Jlw7myxYxrx+WOkTkEU/GjLvfU58jir7qbTQIyRSl8=; b=GImHrvvhTgQND/H0eq7ENds3ruW1eXUBskjssYoCNZe4gHvWeNm17o5bWX1WwikBkX KIL4ndTNMGnscJoORb1tzg0Q4sT50UmR7lp5eWzpCiH1nprpHJVjUo0aClDO2/IYplMB gu2VPwtvsP0SoahCN59CIn2c0njlt35zSLpUqLVbP1/23S/+VTCvy71e+1SwSXBUH6Z/ NKyAopOgbt1S7oaodtBu24GYgnAqE9I2CkVYEZiE9BEaI6SpKgkebQ4ghPsbofZHARqK oA73SVEYrw1ApszOQGwgS6dqqAR7kvnG/gJStyq/JP1jBnqpdP3dbpGZJFFWnZ8lKj6C 6qhA== X-Forwarded-Encrypted: i=1; AJvYcCVN9M6NqTr+IaX2AKsqvXOHH3t+I/aepXGQjgi+PRkY6+pRVKM6ttA5cWZ/qvAzQQziO5K54/cbRO3S8C2JDuQy@lists.infradead.org X-Gm-Message-State: AOJu0YxejeINefuFblJxJe+Z7d6K643dsJ7zxkILvUJMaRk1K7V/5jMH pFGbQjPi4oT557MX5VZavgV5zqyr5dsN/uhuBXlJnwYisS98VlDP X-Google-Smtp-Source: AGHT+IHc5YknrxzXlFuucuStWx3gBFqQRQQwKvn1lhHqX/o6iunywxLlE/ficJuzfPbWPY8NggTDHA== X-Received: by 2002:a05:6a00:1905:b0:712:7512:add9 with SMTP id d2e1a72fcca58-7170a85ab58mr10551336b3a.13.1725162172772; Sat, 31 Aug 2024 20:42:52 -0700 (PDT) Received: from localhost.localdomain ([49.130.72.113]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-715e55771ccsm4826767b3a.43.2024.08.31.20.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Aug 2024 20:42:52 -0700 (PDT) From: Nick Chan To: Hector Martin , Sven Peter , Alyssa Rosenzweig , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, konrad.dybcio@somainline.org, Nick Chan Subject: [PATCH v3 4/4] irqchip/apple-aic: Only access system registers on SoCs which provide them Date: Sun, 1 Sep 2024 11:40:07 +0800 Message-ID: <20240901034143.12731-5-towinchenmi@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901034143.12731-1-towinchenmi@gmail.com> References: <20240901034143.12731-1-towinchenmi@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240831_204253_948093_4A066499 X-CRM114-Status: GOOD ( 14.88 ) 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 From: Konrad Dybcio Starting from the A11 (T8015) SoC, Apple introuced system registers for fast IPI and UNCORE PMC control. These sysregs do not exist on earlier A7-A10 SoCs and trying to access them results in an instant crash. Restrict sysreg access within the AIC driver to configurations where use_fast_ipi is true to allow AIC to function properly on A7-A10 SoCs. Reviewed-by: Sven Peter Signed-off-by: Konrad Dybcio Co-developed-by: Nick Chan Signed-off-by: Nick Chan --- drivers/irqchip/irq-apple-aic.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 01a3c79054f5..a6d812afb10d 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -234,6 +234,7 @@ enum fiq_hwirq { AIC_NR_FIQ }; +/* True if UNCORE/UNCORE2 and Sn_... IPI registers are present and used (A11+) */ static DEFINE_STATIC_KEY_TRUE(use_fast_ipi); /* True if SYS_IMP_APL_IPI_RR_LOCAL_EL1 exists for local fast IPIs (M1+) */ static DEFINE_STATIC_KEY_TRUE(use_local_fast_ipi); @@ -550,14 +551,9 @@ 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(&use_fast_ipi) && + (read_sysreg_s(SYS_IMP_APL_IPI_SR_EL1) & IPI_SR_PENDING)) + aic_handle_ipi(regs); if (TIMER_FIRING(read_sysreg(cntp_ctl_el0))) generic_handle_domain_irq(aic_irqc->hw_domain, @@ -592,8 +588,9 @@ 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)) { + if (static_branch_likely(&use_fast_ipi) && + (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, @@ -830,7 +827,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); @@ -851,8 +849,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(&use_fast_ipi)) + sysreg_clear_set_s(SYS_IMP_APL_UPMCR0_EL1, UPMCR0_IMODE, + FIELD_PREP(UPMCR0_IMODE, UPMCR0_IMODE_OFF)); /* Commit all of the above */ isb();