From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74479C433E0 for ; Wed, 20 Jan 2021 13:32:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E56F923340 for ; Wed, 20 Jan 2021 13:32:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E56F923340 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=caramail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/mqkWYUXtjyX2Smp4LnIMaMGx7p+eQvJX7mlPZ8ikZI=; b=g/kIvZD8WmlaCTMqSpCnGZ8VY GTSvOU32+5czKS08/t0Vxtbx+35ENmloizP2x7PXzYNaKS4BZVv7vcF1++z/xi70VFDetr4pwDPYC fPYcw6TBKYaSvnvBjAFQXtfh+Kccr0yinsRUS7tnnzOfLyoQ5BnLvj9fZH4uYzDVDs7OIlO/isUcF OwWzrRVVqH+x9lqi+8/Ig8G2FNpwCpUsz7hIm4wpF1zcQ/jSl2YOyctJuvm4+Ltk4d6xQoX6vagAZ 1lxQDdSQArFe3f9vozAYiv1eclsb9Vg4DQIiqm/lQyk1IUYpyIoUJnurxMBrYU+8epR8ba/j3UjkY 7EOEclmzA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2DYO-0005JS-FW; Wed, 20 Jan 2021 13:29:44 +0000 Received: from mout.gmx.net ([212.227.15.19]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2DWY-0004fq-5q for linux-arm-kernel@lists.infradead.org; Wed, 20 Jan 2021 13:28:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1611149253; bh=Qa9Di41LcN0RuLnAp68u5mMaALrY7xnIGO1WB315kuo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=akLBpE10xmN+SQNDTySZETF5P6JMvSSXEEqfrLQ8sbKMcz0aSw6iNRmK/TPMs7+Cr BMD1KfWBWlOcf/0uhYIDqnme+60U+SjD2fTa7zS71kXdWCtzueZ1L23LYAypvFp1YO QqdGA9NwL2upvnFeaZQDj08MTtcCjeVr7uuUexmc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([83.204.192.78]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MIwzA-1lIDwF2YO2-00KTG9; Wed, 20 Jan 2021 14:27:33 +0100 From: Mohamed Mediouni To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 2/7] arm64: kernel: Add a WFI hook. Date: Wed, 20 Jan 2021 14:27:12 +0100 Message-Id: <20210120132717.395873-3-mohamed.mediouni@caramail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210120132717.395873-1-mohamed.mediouni@caramail.com> References: <20210120132717.395873-1-mohamed.mediouni@caramail.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:VFpxDb1Pw2xeOZRr7mOJYZKYKFdz9uqWWjqerljkCcZ9LCRlKdN Q5uAw7cv2cLU3r24bGFbFQNqNzTMXIg6nBOdfRDMUyr5RIq0GQVT/xFBaYTO65TMYcvHSBb i839SCKlA6H2az5y/0KNi3nRucCFPMzEe544c0albOKkKGS7nWwImD/LPbJCHj0poBrDyb7 c9bubmzDe876bkTyY9v8Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:lptcHETjPWI=:H8zJtTpVUX88hOd4CmTUwM eXCTnZIzj8MEsPy1fz1MiLFlq1mocVd4sID0CDXoIOzaMK+xDCXO8rBzm5+7tipzqd9TKfXTA ZzDXAuX5AS7v64qWbVMzM2nQM2p2jM0wmLX60hWqNPakY0joMKwRf7hgGjnogY6xcI3293CtU ZrVsQzJv7RoIKRDO2ZIDz+oe7SCj9BDumcmQN+q4mhday4hDjh2MLuU9kTw8uP3oba6vzAYIa vvvmPcA0QzM+9DyPxPSi2QIfHY3xuoCYywME/Xu8Hatubcc+c30T9tYEIYk72HaUIFOHXodPl Bt7qK7FSyg+SedxovJ0bs+wqpQA0s2ecXQFkBTsAptEg0qAgR4UfAniyp7+8oqbjGJr/fxd/0 Q89A7v0CRIAazZqW9KD449VmnGYc8OOwU7TWu4lJOaP+fhXVRPKjXkufjRAeMw8mRx2nirp6c 05X0VcYEmHmP27sfLtgWVWcBprFOxocENJeVgVwazranfdzyu1Vk2O1uMVHIV8ajOK0MD0VtC IMUT+4xinygpxTCV2ACoOQhAm1JWbB600HlZx7CYq76MQnkMwdizmWGmDyiBvJv2MSZkRj4tq 6gFJmURf7sbcsyJiA3SpFg2/9S2nyE1qJFSR6/XbhuD9WfCTlcOpPP1W0pbbKLAgJ8EP1Y4rZ 17s20BB1IO4/Vw0fWx2dYwzGoG3F8GgBBBSfwRyP45AunuDWw1MpcI/T3Pu8s0nfb3Pv7G+Ob d4XFRv5u01iNK/2wXtRPpfQAKBtpp2twxgYR7LCwzA8XAZDlxTGqrhsaPqlXVmbwcu0l6KtQZ tR0MoJG+haX4ui5HGVRnjnPPbAiitF5/TKzDPu/L9QGCL8i0aapSC/knWSI5xA0OAA5HBAGUL 2TbISFds5qsTmJ5rTsok6nxcJ4A3UkL9dXNJcvlng= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210120_082750_461174_90C8C009 X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , Hector Martin , linux-kernel@vger.kernel.org, Marc Zyngier , Mohamed Mediouni , Will Deacon , Stan Skowronek Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stan Skowronek WFI drops register state on Apple Silicon for SMP systems. This hook will be used for a hardware workaround in the Apple CPU start driver. Signed-off-by: Stan Skowronek Signed-off-by: Mohamed Mediouni --- arch/arm64/include/asm/cpu_ops.h | 2 ++ arch/arm64/kernel/cpu_ops.c | 6 ++++++ arch/arm64/kernel/process.c | 11 +++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index e95c4df83911..4be0fc5bcaf9 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -23,6 +23,7 @@ * @cpu_boot: Boots a cpu into the kernel. * @cpu_postboot: Optionally, perform any post-boot cleanup or necessary * synchronisation. Called from the cpu being booted. + * @cpu_wfi: Optionally, replace calls to WFI in default idle with this. * @cpu_can_disable: Determines whether a CPU can be disabled based on * mechanism-specific information. * @cpu_disable: Prepares a cpu to die. May fail for some mechanism-specific @@ -43,6 +44,7 @@ struct cpu_operations { int (*cpu_prepare)(unsigned int); int (*cpu_boot)(unsigned int); void (*cpu_postboot)(void); + void (*cpu_wfi)(void); #ifdef CONFIG_HOTPLUG_CPU bool (*cpu_can_disable)(unsigned int cpu); int (*cpu_disable)(unsigned int cpu); diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index e133011f64b5..6979fc4490b2 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -19,12 +19,18 @@ extern const struct cpu_operations smp_spin_table_ops; extern const struct cpu_operations acpi_parking_protocol_ops; #endif extern const struct cpu_operations cpu_psci_ops; +#ifdef CONFIG_ARCH_APPLE +extern const struct cpu_operations cpu_apple_start_ops; +#endif static const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; static const struct cpu_operations *const dt_supported_cpu_ops[] __initconst = { &smp_spin_table_ops, &cpu_psci_ops, +#ifdef CONFIG_ARCH_APPLE + &cpu_apple_start_ops, +#endif NULL, }; diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 34ec400288d0..611c639e20be 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -57,6 +57,7 @@ #include #include #include +#include #if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_STACKPROTECTOR_PER_TASK) #include @@ -74,8 +75,14 @@ void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd); static void noinstr __cpu_do_idle(void) { - dsb(sy); - wfi(); + const struct cpu_operations *ops = get_cpu_ops(task_cpu(current)); + + if (ops->cpu_wfi) { + ops->cpu_wfi(); + } else { + dsb(sy); + wfi(); + } } static void noinstr __cpu_do_idle_irqprio(void) -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel