From patchwork Thu Aug 29 09:03:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13782904 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 1A3E2C71135 for ; Thu, 29 Aug 2024 09:40:11 +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=/eGSx27JcX0pDUTDyQY+9iXqRUjb43ZGaILimNXE8xk=; b=hyrJQ6jxvmUut8ngEU6MgVMBew cKjWkjQvQYwK0/y2WDrHIJom+8bCIPOrPMCagE9t5NYulgkshiTrZw6rF0ZERzOXqxTFq4ubvVTCt sqqIDA/Bzh1xDH+pycfFRKCBOE/6dsFXcJ2su8qSkmsp6F9MG75ME2QOkQVW/LdknA5CqVmmlFvza qApwtlBRih8ACCTmyem7e4StcqB8Qt9kl1UOvh5CzSqVNWMB6wB6WcQDlXu0HZRaY9oSq0evde8SJ 76a7h7krZzOgmg3z/XBO527JAGSViLdnG1L74K4/mkWS2lCw4vgwG70noCwouLKTbRxK6fyFx/zrM En4+nWug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjbcX-00000001OiJ-12I6; Thu, 29 Aug 2024 09:39:13 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjbR3-00000001M1N-1g5f for linux-arm-kernel@lists.infradead.org; Thu, 29 Aug 2024 09:27:22 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2020ac89cabso4339085ad.1 for ; Thu, 29 Aug 2024 02:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724923640; x=1725528440; 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=/eGSx27JcX0pDUTDyQY+9iXqRUjb43ZGaILimNXE8xk=; b=UsQDQNw1G3cURjnwebqgkzkeWXZDQsYIp8spOjYQVeogmtW+nz0/7GQePzzu1MMrDC 6lpK53t/4bnivODWIQ2NC+iu98dwpma02kJjEYwlfjeP7AWlleXE1TJnULWKsd3h90G8 dMBzTJ3t8nWo647iBaPNCGCNwNvdb9d5ZXo9pp49lp58nJIVItzQCJM2Aki9olQxF4Ai KRHK9ZE06v5jVPp9nv2uOfYPZj/N+1Iwf/BSlDqqH4yYw2pWgmXPBHY+lSqTcjK7hZZv 9Px6F4f3/TkxeqCjIS4ad6cjNeojAbojnpSTFxQ4NtrOEgmjoIq+X8ZWVsS3oIW6VzOK ehhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724923640; x=1725528440; 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=/eGSx27JcX0pDUTDyQY+9iXqRUjb43ZGaILimNXE8xk=; b=nxO2oz/wkXaD26ls4fQAUyGoBVy9iNXWnTWjByiCbzmgZ0/lXertow8bP6vpXmOCQS 44VjhgtPTTAQcj0s71v2ZeCM5V9S/pR4ozhkPavMECjF5YTOOrtIRhQ1rpy1/aKH03M5 A0hAlz5aPqbUCV+FF2HOQChsbKvtjhmuJUXdQMX9OdpdvGKvjWsaFDspuEPei+Oa59hO tD8xXi92tgmjjbaahMhfjxEuJ81h25ar7pk8gHB3mo3uV/elymlF8rkRZ5RA9uyxrojc mugyRDndqRtttKfO9SjIOiF87Tol/BePozJZosk/lIzw+eB2ySAVuu3K8U57tJFfAAGq NtWQ== X-Forwarded-Encrypted: i=1; AJvYcCVnis8O6MZrawt1Ycxjpf/OrTxplMguMlAK16v6Rank2n0ou84wGoMFDiOfItiDFx3NXxHYEbGb9B0KhjDqRzMg@lists.infradead.org X-Gm-Message-State: AOJu0YyU7shrsz9t09I0RHcB7i/ng3+0PbCjhjMgJHYCSbIfwo0jJOl1 xqkggcVdzD+xjlfjxyeKDPf3sHYZPEt099Zq7CXECyh3VXx1ynjP X-Google-Smtp-Source: AGHT+IEKUoxDuqT/4bjh7520aySEhnZ1arjlxKlqJuEFhxlHhQmG4atig6hIsfRUrkQ+FFxR+vzDFQ== X-Received: by 2002:a17:902:ccc7:b0:202:11ab:ccf4 with SMTP id d9443c01a7336-2050c215845mr22583185ad.6.1724923640331; Thu, 29 Aug 2024 02:27:20 -0700 (PDT) Received: from localhost.localdomain ([59.188.211.160]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-20515552b6dsm7469245ad.249.2024.08.29.02.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 02:27:20 -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, Nick Chan , Konrad Dybcio Subject: [PATCH 2/3] irqchip/apple-aic: Only access IPI sysregs when use_fast_ipi is true Date: Thu, 29 Aug 2024 17:03:12 +0800 Message-ID: <20240829092610.89731-3-towinchenmi@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829092610.89731-1-towinchenmi@gmail.com> References: <20240829092610.89731-1-towinchenmi@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_022721_467364_5C0A4502 X-CRM114-Status: GOOD ( 16.66 ) 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 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. While at it, remove the IPI-always-ack path on aic_handle_fiq. If we are able to reach there, we are on an IPI-capable system and should be using one of the IPI-capable compatibles, anyway. Signed-off-by: Konrad Dybcio Signed-off-by: Nick Chan --- drivers/irqchip/irq-apple-aic.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 5c534d9fd2b0..626aaeafa96c 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); struct aic_info { @@ -532,13 +533,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))) @@ -574,8 +571,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, @@ -811,7 +809,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); @@ -832,8 +831,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();