From patchwork Sat Nov 10 21:18:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 10677445 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AB7714E2 for ; Sat, 10 Nov 2018 21:18:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4943A2957B for ; Sat, 10 Nov 2018 21:18:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D5B32BE4A; Sat, 10 Nov 2018 21:18:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A9B92957B for ; Sat, 10 Nov 2018 21:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:References :In-Reply-To:Message-Id:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n+BwMTwMGaLlbzydGa6kPllq9mZmLwBYnmGxHbuqzpI=; b=uIf+wWOKNI0tqi hmdEc4ejTUu5MIUkN6pWTtXd8XSWCwHIMmgWnnpQo4lpXFqnwIh9c9LfIV0l8hawjj7OLsvXICh0W o6VkkI+t9nJ2q5bWRQShz9YlIBTVCNjxETJJBVTIx+ifMU+eUTgH6jYR6aGXtc03rzgp+g9oEnF77 XjN9PJkzL+bdb5GZbPfRPkWyNC1T1FxxCrsIeqA9Hd2j1Zkjml4LPXa85y/KUBFVcrcIXGoBF5+wj CYbQTuoS436h3PD4DHAMlVlgasNmHgansXHNUecYQpXC6ZEDC3qfZ0CYPnuPADHiLAkygZ4z/m/fK FrhQYJyaM/aieskHlMkw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLaeR-0000nT-Je; Sat, 10 Nov 2018 21:18:43 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLae8-0000Jt-Bw for linux-arm-kernel@bombadil.infradead.org; Sat, 10 Nov 2018 21:18:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Cc:To:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:From:References:In-Reply-To:Message-Id:Date :Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=H737vrmIgP6tmoMRj4Ur7/jm5PDfGW/Gz8mb3BNHMvk=; b=qElOymKETC4zJmR3aYLK1IQncX aW+Bzl7lDmD5L67D1+RjDR0drSlIlGlYioooi5QXjBBG4VOPeHEqwRGOPEGmKk8XxEnC0n4oS+YH1 lbdjpYgvFcKS5fwSiwZa+wiU0MTo7zvI5ll6Amki4zGNqgZlMcmttEhYmhTQl38Di6qXUW72pOKdC MVcn9L3/Gd3YF5bPchr5Okht0SloB/n1Rz79IbbcWZswbv9RGrKluGvysZxus9ZiFWIwmVwuEyvTm /VYr00+8DaxV9ndBZ4seU7fIS/Fk3B33nqQ//sPbPUy2O91LBk3KVbCYYcolhldNoYzrYBatDGdq8 akWThjDg==; Received: from rere.qmqm.pl ([91.227.64.183]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLae4-00008P-PP for linux-arm-kernel@lists.infradead.org; Sat, 10 Nov 2018 21:18:22 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 42sqbV04przSL; Sat, 10 Nov 2018 22:17:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1541884630; bh=DL6I1MfuXEZqznzYms6TSoripGrakVcX11od+kvwaUI=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=U4sctqTx8wrvVQNC95VFFTeGJ2M/SSJS6DLmzYcjQqRpoga6uoCxxRH7SsE2UgL5j DgyydkRpwMX8Y7UFsaO1ZqdA0eLb+9COjdtIuuOhBecKQSQj1PWkFpK3cFVFmBVtOI 5gLTzxnIZ7Bpp1F0xBL0f5rIwmRer/C7m2Hm3/JXqR9OgcbNUAhBWjyfz4qS4+glXL OS4RWq4RRFmtCI4TFib/a+6dXxev6YDg3R3TAzxXAeQPiCSxybLZcQXyewYNTNTmGK sqM/RUj/+X7OkYA/MNh0iuu7fLvWEKx4FrSfcq3qwUl7UXog1ZCtMngXCd3khsJ6tV XQaqLNDVW33kw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Sat, 10 Nov 2018 22:18:09 +0100 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 1/2] ARM: tegra: enable cache via TF MIME-Version: 1.0 To: linux-tegra@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181110_161821_171467_D33FE0C7 X-CRM114-Status: GOOD ( 17.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Osipenko , Thierry Reding , Russell King , linux-arm-kernel@lists.infradead.org, Jonathan Hunter Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Cache enable needs to go via firmware call with TF running. This version is based on code proposed by Dmitry Osipenko that uses run-time TF-presence instead of hardcoded in Kconfig. Signed-off-by: Michał Mirosław --- arch/arm/firmware/trusted_foundations.c | 6 ++++-- arch/arm/include/asm/trusted_foundations.h | 6 ++++-- arch/arm/mach-tegra/reset-handler.S | 20 +++++++++++++++++++- arch/arm/mach-tegra/reset.c | 5 ++++- arch/arm/mach-tegra/reset.h | 5 +++-- arch/arm/mach-tegra/tegra.c | 6 ++++-- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index e59f44fcda35..148d890da0b6 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -141,7 +141,7 @@ void register_trusted_foundations(struct trusted_foundations_platform_data *pd) register_firmware_ops(&trusted_foundations_ops); } -void of_register_trusted_foundations(void) +int of_register_trusted_foundations(void) { struct device_node *node; struct trusted_foundations_platform_data pdata; @@ -149,7 +149,7 @@ void of_register_trusted_foundations(void) node = of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations"); if (!node) - return; + return -ENOENT; err = of_property_read_u32(node, "tlm,version-major", &pdata.version_major); @@ -161,4 +161,6 @@ void of_register_trusted_foundations(void) panic("Trusted Foundation: missing version-minor property\n"); register_trusted_foundations(&pdata); + + return 0; } diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index 00748350cf72..80104a4e8476 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -40,7 +40,7 @@ struct trusted_foundations_platform_data { #if IS_ENABLED(CONFIG_TRUSTED_FOUNDATIONS) void register_trusted_foundations(struct trusted_foundations_platform_data *pd); -void of_register_trusted_foundations(void); +int of_register_trusted_foundations(void); #else /* CONFIG_TRUSTED_FOUNDATIONS */ @@ -59,7 +59,7 @@ static inline void register_trusted_foundations( cpu_idle_poll_ctrl(true); } -static inline void of_register_trusted_foundations(void) +static inline int of_register_trusted_foundations(void) { /* * If we find the target should enable TF but does not support it, @@ -67,6 +67,8 @@ static inline void of_register_trusted_foundations(void) */ if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations")) register_trusted_foundations(NULL); + + return -ENOENT; } #endif /* CONFIG_TRUSTED_FOUNDATIONS */ diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 805f306fa6f7..fe4c568aeace 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -78,8 +78,26 @@ ENTRY(tegra_resume) orr r1, r1, #1 str r1, [r0] #endif - #ifdef CONFIG_CACHE_L2X0 +#ifdef CONFIG_TRUSTED_FOUNDATIONS + adr r3, __tegra_cpu_reset_handler_data + ldr r0, [r3, #RESET_DATA(TF_PRESENT)] + cmp r0, #0 + beq ca9_scu_l2_resume + + push {r8} /* TF call might corrupt r4-r12 */ + + mov r0, #3 // local wake + mov r3, #0 + mov r4, #0 + dsb + .arch_extension sec + smc #0 + + pop {r8} + b end_ca9_scu_l2_resume +ca9_scu_l2_resume: +#endif /* L2 cache resume & re-enable */ bl l2c310_early_resume #endif diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c index dc558892753c..1c3cb62255fe 100644 --- a/arch/arm/mach-tegra/reset.c +++ b/arch/arm/mach-tegra/reset.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -87,7 +88,7 @@ static void __init tegra_cpu_reset_handler_enable(void) } } -void __init tegra_cpu_reset_handler_init(void) +void __init tegra_cpu_reset_handler_init(bool tf_present) { #ifdef CONFIG_SMP @@ -104,5 +105,7 @@ void __init tegra_cpu_reset_handler_init(void) __pa_symbol((void *)tegra_resume); #endif + __tegra_cpu_reset_handler_data[TEGRA_RESET_TF_PRESENT] = tf_present; + tegra_cpu_reset_handler_enable(); } diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h index 9c479c7925b8..5e42dd1e9841 100644 --- a/arch/arm/mach-tegra/reset.h +++ b/arch/arm/mach-tegra/reset.h @@ -25,7 +25,8 @@ #define TEGRA_RESET_STARTUP_SECONDARY 3 #define TEGRA_RESET_STARTUP_LP2 4 #define TEGRA_RESET_STARTUP_LP1 5 -#define TEGRA_RESET_DATA_SIZE 6 +#define TEGRA_RESET_TF_PRESENT 6 +#define TEGRA_RESET_DATA_SIZE 7 #ifndef __ASSEMBLY__ @@ -60,7 +61,7 @@ void __tegra_cpu_reset_handler_end(void); (__tegra_cpu_reset_handler_end - \ __tegra_cpu_reset_handler_start) -void __init tegra_cpu_reset_handler_init(void); +void __init tegra_cpu_reset_handler_init(bool tf_present); #endif #endif diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index f9587be48235..0281de82387e 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c @@ -72,8 +72,10 @@ u32 tegra_uart_config[3] = { static void __init tegra_init_early(void) { - of_register_trusted_foundations(); - tegra_cpu_reset_handler_init(); + bool tf_present; + + tf_present = of_register_trusted_foundations() == 0; + tegra_cpu_reset_handler_init(tf_present); } static void __init tegra_dt_init_irq(void)