From patchwork Mon Feb 18 00:17:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817247 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 5B1E51399 for ; Mon, 18 Feb 2019 00:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4663229EF4 for ; Mon, 18 Feb 2019 00:19:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3669E29EFE; Mon, 18 Feb 2019 00:19:55 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 8A9C929EF4 for ; Mon, 18 Feb 2019 00:19:54 +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: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=FatyJJmGQZO1i9dvN+dnWT3eWFTgH755QezZJrlCb+Y=; b=j8O+e6+ZxY/Tg8 geCkVC1Y3Z9ek4WazCPxdfSbClhRPU0OkGWrWICiGb+CqFJa4cZAOPeWiQQBv2JUwBEwMUYuQK+u4 j4usmLqHC7hNqIHpSPdFytYhwjU+bMuvpDvbbA5ghwPfj0XlJx/Gajc1DlndynmdqZ9ExPr/f+3S7 73biuOvWD9RSFNnTushPi+bGzCkzc3g8YXvFQaC6R/A+aOeYeFvKJ4uFEdH8HuGqZLuqYOFm4+aML cAiAxE3tA0vHbiHilDiucirIowebIdF3snulUGO14j08E4fxNBN4X0VcpTqhZQhfc/nTC+egx9o7c ZC630+KQJOcQtrKntzxw==; 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 1gvWey-0001oH-1S; Mon, 18 Feb 2019 00:19:48 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWec-0001Iu-LJ for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:19:28 +0000 Received: by mail-pl1-x642.google.com with SMTP id r14so7805758pls.12 for ; Sun, 17 Feb 2019 16:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ef/pjs0sC4GxqdxxxUgy0sbHhpRnX1Oqj7kTNWdGqgw=; b=c8/B3ioT16kwbIY57ldLRWsLeuksRs6DL7eObvDSD7CIYQDr4mo1jA7eC5a5IYos3J CK0e+wFmVeDzvYhZK7uh6rbtvbTJacNO7x6DTfNaKUWFNTAfPGbgM0t53hhtwG7ZMy/G 46RNrn08ANjrWs4C5f7snzDtFGMG9Wo9mJnuUCWv87EDlD3EjDquDVKR9+z9I+ONElHP eoO1lrEja2TA4omz13wup+lnnHi5QYNoZjxOw53v35otFUdlidKkpuBmS4RdcDLQDspA gMms3I5BrWgB0rEwsahmHQu/TKGsNqIa/YtFVVMPAO9mwXQOL5fWzdjW2qXXybvyfh0D 9EKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ef/pjs0sC4GxqdxxxUgy0sbHhpRnX1Oqj7kTNWdGqgw=; b=NtmZvZen3QXzueIo7IiFyDXrSj19Dq/w33iHkMrt7nUgj/gzl3qoFbiBshmQX3K2y6 r7T9pDLCwLKnAc9fvoTQG7l/fS1Pshddui4r0+NvCHMwPddP3BqpFPM2GTnM7CuKdR81 +9Tf5ySalV3/+W7EotKMndzLKlOn0xnq1rpkpYB+AavTq4pj2AjNU/deDyiKQps680T+ wCo0OuWyE00w3RiZ/O2MkNcXvvjuB5pT27GCDc4paLEESUJAGgkLA9kU7B0RcLrB+Bg4 4dukkSTht9LyXrbkimkrfmloMkG4B+aF++5tWBR87GIwVmP/soa/ZQzzbzeTN8zacCMp 3E8Q== X-Gm-Message-State: AHQUAuagO6W1F3ZAN2HPUpeizpyYNRaIYfNa5kGwgF6x1oazcwOX9otM DIAQTUVY0VaKE+x8GA1glAw= X-Google-Smtp-Source: AHgI3IavcXNoo+tvv02/VjCX7nswKHG9gUmWMgJhu/m3mD9L83zn/gjNjqRlZOm/3F0YEj2sNtbjDw== X-Received: by 2002:a17:902:29ab:: with SMTP id h40mr22405596plb.238.1550449166237; Sun, 17 Feb 2019 16:19:26 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.19.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:19:25 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 1/8] ARM: trusted_foundations: Implement L2 cache initialization callback Date: Mon, 18 Feb 2019 03:17:19 +0300 Message-Id: <20190218001726.16785-2-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_161926_700443_5CE601E0 X-CRM114-Status: GOOD ( 14.93 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Implement L2 cache initialization firmware callback that should be invoked early during boot in order to set up the required outer cache driver's callbacks. Partially based on work done by Michał Mirosław [1]. [1] https://www.spinics.net/lists/arm-kernel/msg594765.html Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 689e6565abfc..3bf61a5933b9 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -18,8 +18,15 @@ #include #include #include +#include +#include #include +#define TF_CACHE_MAINT 0xfffff100 + +#define TF_CACHE_ENABLE 1 +#define TF_CACHE_DISABLE 2 + #define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200 #define TF_CPU_PM 0xfffffffc @@ -67,9 +74,48 @@ static int tf_prepare_idle(void) return 0; } +#ifdef CONFIG_CACHE_L2X0 +static void tf_cache_write_sec(unsigned long val, unsigned int reg) +{ + static u32 l2x0_way_mask = 0xff; + static u32 l2x0_aux_ctrl = 0; + + switch (reg) { + case L2X0_AUX_CTRL: + l2x0_aux_ctrl = val; + + if (l2x0_aux_ctrl & BIT(16)) + l2x0_way_mask = 0xffff; + break; + + case L2X0_CTRL: + if (val == L2X0_CTRL_EN) + tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_ENABLE, + l2x0_aux_ctrl); + else + tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_DISABLE, + l2x0_way_mask); + break; + + default: + break; + } +} + +static int tf_init_cache(void) +{ + outer_cache.write_sec = tf_cache_write_sec; + + return 0; +} +#endif /* CONFIG_CACHE_L2X0 */ + static const struct firmware_ops trusted_foundations_ops = { .set_cpu_boot_addr = tf_set_cpu_boot_addr, .prepare_idle = tf_prepare_idle, +#ifdef CONFIG_CACHE_L2X0 + .l2x0_init = tf_init_cache, +#endif }; void register_trusted_foundations(struct trusted_foundations_platform_data *pd) From patchwork Mon Feb 18 00:17:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817249 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 EBF55180E for ; Mon, 18 Feb 2019 00:19:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71EE29EF4 for ; Mon, 18 Feb 2019 00:19:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBA9129EFE; Mon, 18 Feb 2019 00:19:58 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 457A729EF4 for ; Mon, 18 Feb 2019 00:19:58 +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: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=MaSs8fPvzvDTYT6H+jAzeSShLPMyp9jNa/p76Fuqfsc=; b=CnxlzYVJhxmREy hGV/YN39sCI0WiGk5K8tWYTGwMQ1IA6Jy0xLgKP0VagXNbkFBaPfx896qNGOtFD9obkLmHtZe9wNL 5MCeXdzQ9Jy/QVA5Gj0NvL44WaS1lM7tCEjZ6yGsk3EjnS2yeCvZdRxovuLCOXQg42EYEdGnc5AVv KEl8IAbGT6qJnLQCsRuNWAunR5jJLKoipZwV/1uJ4LHD+Pznna7JSaEWIn7c/TzyLrgltW5m/pRta BTaCxyNMFVZ0XkBteC4Bz2GJk/z6XvEjtSN43Ubr6AsvBNL+qLUscCJyRcrkP7gO/7+irQuHXus0O uViNwixEziYfB8ALHAAw==; 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 1gvWf6-000215-RR; Mon, 18 Feb 2019 00:19:56 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWej-0001RD-DO for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:19:41 +0000 Received: by mail-pg1-x542.google.com with SMTP id r11so7513891pgp.6 for ; Sun, 17 Feb 2019 16:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FgOYxchHGlJHFmyyLBfbI94R8PKLM3DDEZqKom9TK2g=; b=NS5UQLQLQLnVdisz184ynUBPb5jurc2gGJ46g1wTWkq4XXVfHiP7dbzoRj+Yss+iSD hDWE5WKgP36YGvs8FcEd2NRQVWCERfX2iL7OXUyJovTDzhcIgtPJD6MMV7CFsUKPIUpE YpiK2h9YF4/akO34hglLcEVt2Wb2qAmwmaByQuNW3cP8qyOw6Ru1bReg/++yvsmnI0EA 0TXZ/MD7G1VV020FYg/uJl1U3gO+zDhVq6FLoM1tW75isRuDPIPj8hGvBbKp0ti5yj3f d3bsQoxkH71R3f7U5TFWOcugPiHJ+qsHwj4z5vUBxt27udtYRcz9IDmiqnaHpvyrtaBM oBrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FgOYxchHGlJHFmyyLBfbI94R8PKLM3DDEZqKom9TK2g=; b=B3haY/6ZKuB/oNjAxm4VdS1h60rpxEjgFJu2FhnV+6A1ymP4ce4A1/VnBuLpkmrah1 CKl2eBobS2bF7GQc7kZbFzuIGmYRl95de8+2gD32JYUXJIZV5LZnq7LY7AwOi8ob15Lk JAWNwwrQKMxHhd7wqV2KJ/M7dM5eKGWEgX3MaoBuqLKlyX6h1be3aDoKNFqs4XSyL0gr HJoJpbQT84OINhudMcfJWoz0u5Si9yE6F/DTBnmWiXCIzFVSNquKui6RN3SnH18hIiPT cbSpeRoYoHgZefsEE4CXQVjWm6zex/DwEuJHdXT+m186+ZI9YczurhJgohmp2lFe1Ytd oshQ== X-Gm-Message-State: AHQUAua++iwKgr5FS/PBMf2z3YGyRs61AWu+3hsOm4Dz1AY1hnKW5Pcv R+GwD9BcdFEi3RSH8+bDSPY= X-Google-Smtp-Source: AHgI3IZQ6O64Nq7/2GBz/Y3eRYdRdWVu8yS3s0nflN81yZpH/5ZgUXWZY5xdo39MBHm1qrLPsTMPRA== X-Received: by 2002:a63:a11:: with SMTP id 17mr16168904pgk.310.1550449172622; Sun, 17 Feb 2019 16:19:32 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.19.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:19:32 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 2/8] ARM: trusted_foundations: Make prepare_idle call to take mode argument Date: Mon, 18 Feb 2019 03:17:20 +0300 Message-Id: <20190218001726.16785-3-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_161933_959982_F436C220 X-CRM114-Status: GOOD ( 16.02 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 The Trusted Foundations firmware call varies depending on the required suspend-mode. Make the firmware API to take the mode argument in order to expose all of the modes to firmware user. Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c | 29 ++++++++++++++++++++-- arch/arm/include/asm/firmware.h | 2 +- arch/arm/include/asm/trusted_foundations.h | 6 +++++ arch/arm/mach-tegra/cpuidle-tegra114.c | 3 ++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 3bf61a5933b9..c496f4cc49cb 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -67,9 +67,34 @@ static int tf_set_cpu_boot_addr(int cpu, unsigned long boot_addr) return 0; } -static int tf_prepare_idle(void) +static int tf_prepare_idle(unsigned long mode) { - tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2, cpu_boot_addr); + switch (mode) { + case TF_PM_MODE_LP0: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S3, cpu_boot_addr); + break; + + case TF_PM_MODE_LP1: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2, cpu_boot_addr); + break; + + case TF_PM_MODE_LP1_NO_MC_CLK: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2_NO_MC_CLK, + cpu_boot_addr); + break; + + case TF_PM_MODE_LP2: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1, cpu_boot_addr); + break; + + case TF_PM_MODE_LP2_NOFLUSH_L2: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2, + cpu_boot_addr); + break; + + default: + return -EINVAL; + } return 0; } diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h index 34c1d96ef46d..6698272bbcbf 100644 --- a/arch/arm/include/asm/firmware.h +++ b/arch/arm/include/asm/firmware.h @@ -24,7 +24,7 @@ struct firmware_ops { /* * Inform the firmware we intend to enter CPU idle mode */ - int (*prepare_idle)(void); + int (*prepare_idle)(unsigned long mode); /* * Enters CPU idle mode */ diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index 00748350cf72..cdd48ab7d191 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -32,6 +32,12 @@ #include #include +#define TF_PM_MODE_LP0 0 +#define TF_PM_MODE_LP1 1 +#define TF_PM_MODE_LP1_NO_MC_CLK 2 +#define TF_PM_MODE_LP2 3 +#define TF_PM_MODE_LP2_NOFLUSH_L2 4 + struct trusted_foundations_platform_data { unsigned int version_major; unsigned int version_minor; diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c index e3fbcfedf845..3b9af4766cdf 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra114.c +++ b/arch/arm/mach-tegra/cpuidle-tegra114.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "cpuidle.h" @@ -46,7 +47,7 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev, tegra_set_cpu_in_lp2(); cpu_pm_enter(); - call_firmware_op(prepare_idle); + call_firmware_op(prepare_idle, TF_PM_MODE_LP2_NOFLUSH_L2); /* Do suspend by ourselves if the firmware does not implement it */ if (call_firmware_op(do_idle, 0) == -ENOSYS) From patchwork Mon Feb 18 00:17:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817251 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 4B2BC13B5 for ; Mon, 18 Feb 2019 00:20:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3124C2A147 for ; Mon, 18 Feb 2019 00:20:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EA7E2A14A; Mon, 18 Feb 2019 00:20:31 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 B4D6B2A147 for ; Mon, 18 Feb 2019 00:20:30 +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: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=gG7mJYauJTsz2rOJUaTYAv2PsG1tEEvtMyZ7v/Mwi4g=; b=Li1au+xTwq0/ed tKbz26K8Cp/GA/4SuaDpKF6LfJsKOAHRJbrzGnPMYHVBPvYhguOQVdQrHlNPAr6NzY7xWb6M1RzkJ /zn3kOV3PDTBkLpTVjBBgwledS54/cmo37uXlNobiv5qsYdrqIMJw/SprGuSPRquxr54pF97UiiTP tpbj6TH+17YDLhqJYi9Ju6nzc+M6NzBQmS4cm4GLAs1PiB3g4qv52eZI6aBSXubJultqQ12t8+6OB S4HTG7pOXS+jQdReuIQMIGvnHosEzwpWpE2lSQdp3hv+z4u3u2yRDxgihxQe1odlRVaAkyDIvujD7 SlLpQqwR0rvN3hL2J+Cg==; 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 1gvWfY-0003aa-DQ; Mon, 18 Feb 2019 00:20:24 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWep-0001Zf-OU for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:19:47 +0000 Received: by mail-pg1-x541.google.com with SMTP id u9so3990056pgo.7 for ; Sun, 17 Feb 2019 16:19:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7AXM5gfuoADBg0BFzphcMP4lLAjmgxuvX7FX0op9rJ8=; b=WzEL4kWCx33847OA62oJO2Wr9cM2nJ70TgNnaqK8kNY8pt5dl6BwVdjYoffp2DEfLM XT9um9KQ782bFnUcUBez6Azds+lfhwXa11qb6R1DJ7hMIl6aAunvy4FlFCnt7p48UETQ dhEkEwt4EE3YJUExN0fP0J5sM/ezttnJE+8BvH3H8SMNAARvXDChNsQksp4KtcC7yR1Q 14p2faN0pVd7wGQChe3awiNYPgyHU2N0TEz8GJEZBJJwTXIrD5WnYHOj5/EOB+MyLTuq at8e+Gh8yyAxV2ygRGUuhY88sXvkqbyNCRjjm8H1g7v5Lar1jkoW8WlvEYP6jS/UbJvi lE0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7AXM5gfuoADBg0BFzphcMP4lLAjmgxuvX7FX0op9rJ8=; b=EabcwEEt0H5V9U9lc3YJ2twe47+mQtt4GwIV9QLvgu+JyHs2W7HLQbsPdF3Nk4Nc45 0mblBqS47u6mHpcgtXGXaLs/JzFCGc/f16NfqnSkY6i+UzjdO/lattgI+QKkwF9yikBm DyH9L3UN3ieqV7t+id76jJ+EQMVLWVwcFO8WXYTj0A4ecDFqf2G/0AcR8mubSyHPJXuW ICKa6zdrl7jVn2cIgGNP+Va0WxEvIeGAWn9Al+d872Ur7jZdAv7ijcbVAPIYrK64jq6T 2gzUt2Xn38gCDjQmNcrbYxyZ9RKo7SjjOwC3qiO1ZqZ+kfhlAXHqb2yFKTee4s0AzVKg zR6A== X-Gm-Message-State: AHQUAuZD/N8wZ8aad7miHVm51MCfX/axPXnUFGAj2JuQxC22lZ5ufmLW 63yn4U2H4t9PU4+glldN8L51kAsb X-Google-Smtp-Source: AHgI3IbFVYQxk+UFZWL1I+XcGnUftENqMcDIkh5oC5TY5Lbla+3d4kjnIpLE+JKYOIQkawf+o4YdUQ== X-Received: by 2002:a62:d281:: with SMTP id c123mr17106376pfg.210.1550449178969; Sun, 17 Feb 2019 16:19:38 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.19.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:19:38 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 3/8] ARM: trusted_foundations: Provide information about whether firmware is registered Date: Mon, 18 Feb 2019 03:17:21 +0300 Message-Id: <20190218001726.16785-4-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_161940_189736_22BB0AC6 X-CRM114-Status: GOOD ( 12.65 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Add a helper that provides information about whether Trusted Foundations firmware operations have been registered. Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c | 5 +++++ arch/arm/include/asm/trusted_foundations.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index c496f4cc49cb..d795ed83a3cd 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -172,3 +172,8 @@ void of_register_trusted_foundations(void) panic("Trusted Foundation: missing version-minor property\n"); register_trusted_foundations(&pdata); } + +bool trusted_foundations_registered(void) +{ + return firmware_ops == &trusted_foundations_ops; +} diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index cdd48ab7d191..3f23fa493db6 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -31,6 +31,7 @@ #include #include #include +#include #define TF_PM_MODE_LP0 0 #define TF_PM_MODE_LP1 1 @@ -47,6 +48,7 @@ struct trusted_foundations_platform_data { void register_trusted_foundations(struct trusted_foundations_platform_data *pd); void of_register_trusted_foundations(void); +bool trusted_foundations_registered(void); #else /* CONFIG_TRUSTED_FOUNDATIONS */ @@ -74,6 +76,11 @@ static inline void of_register_trusted_foundations(void) if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations")) register_trusted_foundations(NULL); } + +static inline bool trusted_foundations_registered(void) +{ + return false; +} #endif /* CONFIG_TRUSTED_FOUNDATIONS */ #endif From patchwork Mon Feb 18 00:17:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817253 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 4B5D41575 for ; Mon, 18 Feb 2019 00:20:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37EA82A147 for ; Mon, 18 Feb 2019 00:20:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BFB92A14A; Mon, 18 Feb 2019 00:20:36 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 D601E2A147 for ; Mon, 18 Feb 2019 00:20:35 +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: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=7WPvb8eTWBGVkUpINCwVjNSoRGFiesrw1+lu4TIgLxU=; b=SukD6jZyabzZWc 38H7NR2kg1CDy4SGsSgyeYqWyzL9TySNujZvimfvsikt0JX6D/5/e0f3NVmqwXZWLB8Cv2TJEHQ1w fm9FkPVNpIFxyDyUqkSZktjobQDKdBtMAarZbhz9hcBo6d0I3jVFW8EWGI43LJ4QtFPttS6hYFhuT BhZHF9q8M+/aNzZUCOjewo7KIi3oMx3+WdZvmQaeRvowgNCmyQuu1a2hRPmCBfrt9etQkae3CmEeR mq6l4qJ4i1NfTC/eLl9N7mrW8B67TqadM2fnG5D/mG2pi7Zd2AuWXlcAqghC9/MkQOOWC5I/jdLIj t/GSMpDv0FTtaP0Pks2w==; 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 1gvWfg-0003k2-JW; Mon, 18 Feb 2019 00:20:32 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWev-0001io-LI for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:19:49 +0000 Received: by mail-pg1-x542.google.com with SMTP id y4so7509224pgc.12 for ; Sun, 17 Feb 2019 16:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AfjyKjJ4BPDlX5QQ+sFj1fRVuO9lVs7F3NH6shrTHtY=; b=cLDsfNsx13o5jVbpfVJM1rGKKUV/63W8NmOQz/8GkyEPs8GYLjJarohBh8aVUh5J+s qYaKYdoDeAymcZqFK7Y2dulSPWNelR3dY4eFhyXHpuWH+aSiaqP60pcyGK2DdCNEoe0R L6fb153r6bLrAUThs5k0InFu+iTYQPUwjffXXTIeZZJKSUqrrWPRsEfYYNvEuI/HBGFk 020PIrw/pRWhdmcz51jjErVI7JZ640M5LPgWyvUQkeyFH4hre7sQm/EMNdhPixoeYh/l HO94JHYUQbAcnZhW40fwFiQmgym35S6ynrmeuLGf2d3pvs7IUxNb1YuHgnA3vCPyd56v W6CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AfjyKjJ4BPDlX5QQ+sFj1fRVuO9lVs7F3NH6shrTHtY=; b=kEuTW7tWBfdAHAhVmNtYrrobgfqKu6i0aQPVZjgOhMsYlonDebYz6rxEqvc+ig9FeF mUeXUn5jvGHTESwUPRCLdTpKk9b13432+alM9otCGJG5eKGQ+aeX9EF9NI6hYmvq6ERJ Ixjz+gzrRj/FhZVXzAiRg1No1YjwfSqGxMPMs+luSh230E7RLOz2jBdEV3KW+iA5BQ4B eZdGcNx3zASFZwRS/u/MZB+GyNMECfiOUKqtW2Y+xsQADQPgSCVVpYwbJbbpX6mGQH5b sx7U56YYXEZC9gg3mFhqgFl9i4Ds/qNVyYQL9ktpA3pX0aruw9HyAOkQJd4JDbCPhb/U mOgA== X-Gm-Message-State: AHQUAubYFDdJU+QKDTkqVSsYpxGu+lCo5H+6NUNki2V0WRHoFCOxGdww avmK5Wvy+ffnCE+5YTHQlog= X-Google-Smtp-Source: AHgI3IZaCtIC5CyA4/pgD49BKesPmkzS/NPioMK8YCwl06w0fhCsm3mqwWP81/cedYiGA1P3nOfozw== X-Received: by 2002:a63:8441:: with SMTP id k62mr15388177pgd.219.1550449185279; Sun, 17 Feb 2019 16:19:45 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.19.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:19:44 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 4/8] ARM: tegra: Set up L2 cache using Trusted Foundations firmware Date: Mon, 18 Feb 2019 03:17:22 +0300 Message-Id: <20190218001726.16785-5-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_161945_770613_1E654191 X-CRM114-Status: GOOD ( 14.30 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 On Tegra30 L2 cache should be initialized using firmware call if CPU is running in insecure mode. Initialize L2 cache and set up the outer-cache callbacks early during boot using the firmware API. Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/tegra.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index f9587be48235..67d8ae60ac67 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -70,9 +71,18 @@ u32 tegra_uart_config[3] = { 0, }; +static void __init tegra_trusted_foundations_l2x0_cache_init(void) +{ + if (IS_ENABLED(CONFIG_CACHE_L2X0) && + IS_ENABLED(CONFIG_ARCH_TEGRA_3x_SOC) && + of_machine_is_compatible("nvidia,tegra30")) + call_firmware_op(l2x0_init); +} + static void __init tegra_init_early(void) { of_register_trusted_foundations(); + tegra_trusted_foundations_l2x0_cache_init(); tegra_cpu_reset_handler_init(); } From patchwork Mon Feb 18 00:17:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817255 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 CF6F714E1 for ; Mon, 18 Feb 2019 00:20:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDBD42A147 for ; Mon, 18 Feb 2019 00:20:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1BCD2A14A; Mon, 18 Feb 2019 00:20:50 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 3A5952A147 for ; Mon, 18 Feb 2019 00:20:50 +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: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=GSanIPqHPSKuowYdV4oy7cPtWSC/8xqH8OS+BCxfNDI=; b=f6+JYu07Rqas1P 3A4t7pwu3aWGw4JK2/fc2CXh7K7td1LRYbgnXMn0x3zyvNiuo6mdRsB6fJfN20b+0XA5YaRXPhs7w t57SODiFGL/rfU4tv2V1wOiYwp32OSZMxZKqSzsLeL+Mf0XDJqL6ViQV6fEpXD5yLjuYoNHL0oAXM C4MSGzvjaFUSHyVxNj+fFyr++8P6XYar2sX2K0KVPGCR4BvT5byg8DJu+jsAFdf0vl09n19c2BU9y RK8E79ezLZzlU4wc3MtQDpspk0wbs4gH/mvFw92kGS9fN2Wr8NjA68TjIH+9TyzZUP6+rx9EILGIv YkR58/kx33h6KBJ96FcQ==; 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 1gvWfr-0003yq-4S; Mon, 18 Feb 2019 00:20:43 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWf2-0001uY-0S for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:20:16 +0000 Received: by mail-pg1-x542.google.com with SMTP id v28so7510645pgk.10 for ; Sun, 17 Feb 2019 16:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2F+WQtD7UmaE6gs1Qx5/njELVxXcgMmUvzMAMx63pSc=; b=gB9bMMFSzwZ9meu2aeUtRAv9eaagO4RP/PZXideuQH11PlskQYAV0/0AI1p0mN1vls cQBn7XJCpgM9BKufliY1Aob2SAFS/VWCSjtvdyPOBShuEnznafNwrWblOsnTbs352gYt BL9rN/kDdZKieUh6kIUO3rwnchKqFlZ2TWQJ2lENfS0y8EpisD/vSJf/4X4ruPebebiP X1/HmJ2qSPpey3azelAgTK5eW6AvpYZrHCskIwXYW65quJdLtBvyrzdHQ8+CVpgHMien 1g6S3vQfbXzaFvVhmsCGsdBiEie6fM3ALnYNbkt0O1VLJSqyB4zbOQF9J8SajPVujZJl psdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2F+WQtD7UmaE6gs1Qx5/njELVxXcgMmUvzMAMx63pSc=; b=mrxfoRkB4vyoqLzcS2MQjbaMjWvpjgvEZ2trlPEYdG8lObgx4Kpyt9DqP4EYiOIxTH SWLE02VnAWy7VJjQ3CbM0Lvr48Oh7jJHXbnhx3/H/NYB/MO1kydEGnl6iJBdbxf/KYFP fuIduPBDERn03VjtpYeWPtI/CPaQJtMsFH//ZHeB7M40U9beV7rSEvsEEsIEqc7ennbo TkJ4np+cp58JtMLMxeilygXAz4g6T3pbLjgApm22TMKEQrtJZ8kz3zlvhkwymEwRu5Ib hZhAoKr7alQyCyVCMBsLTJAFrVIl3175uO9AQ5zDlZz0jFJcKEnM3UI8x+AGzarnFBMk +HWw== X-Gm-Message-State: AHQUAuZXE6app+svAEYqC/yTeCDAhV9NFAwbWhVGJiDdeIls9EtFZ0RI uY1mIVaVm3poQi2da1LNABU= X-Google-Smtp-Source: AHgI3IZXQewZkIHo+DfcVSHmKaZuYEfvh/PFGdQgSBCWv2Io+bWsBLaObZg45pfP04lAgsTNuQPINg== X-Received: by 2002:a63:1c42:: with SMTP id c2mr16100598pgm.265.1550449191560; Sun, 17 Feb 2019 16:19:51 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.19.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:19:51 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 5/8] ARM: tegra: Don't apply CPU erratas in insecure mode Date: Mon, 18 Feb 2019 03:17:23 +0300 Message-Id: <20190218001726.16785-6-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_161952_419314_6BE119E0 X-CRM114-Status: GOOD ( 14.98 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 CPU isn't allowed to touch secure registers while running under secure monitor. Hence skip applying of CPU erratas in the reset handler if Trusted Foundations firmware presents. Partially based on work done by Michał Mirosław [1]. [1] https://www.spinics.net/lists/arm-kernel/msg594768.html Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/reset-handler.S | 24 ++++++++++++------------ arch/arm/mach-tegra/reset.c | 3 +++ arch/arm/mach-tegra/reset.h | 9 +++++++-- arch/arm/mach-tegra/sleep-tegra20.S | 4 ++++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 805f306fa6f7..a9f13230da2f 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -29,8 +29,6 @@ #define PMC_SCRATCH41 0x140 -#define RESET_DATA(x) ((TEGRA_RESET_##x)*4) - #ifdef CONFIG_PM_SLEEP /* * tegra_resume @@ -121,6 +119,12 @@ ENTRY(__tegra_cpu_reset_handler) cpsid aif, 0x13 @ SVC mode, interrupts disabled tegra_get_soc_id TEGRA_APB_MISC_BASE, r6 + + adr r12, __tegra_cpu_reset_handler_data + ldr r5, [r12, #RESET_DATA(TF_PRESENT)] + cmp r5, #0 + bne after_errata + #ifdef CONFIG_ARCH_TEGRA_2x_SOC t20_check: cmp r6, #TEGRA20 @@ -155,7 +159,6 @@ after_errata: and r10, r10, #0x3 @ R10 = CPU number mov r11, #1 mov r11, r11, lsl r10 @ R11 = CPU mask - adr r12, __tegra_cpu_reset_handler_data #ifdef CONFIG_SMP /* Does the OS know about this CPU? */ @@ -169,10 +172,9 @@ after_errata: cmp r6, #TEGRA20 bne 1f /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */ - mov32 r5, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET mov r0, #CPU_NOT_RESETTABLE cmp r10, #0 - strneb r0, [r5, #__tegra20_cpu1_resettable_status_offset] + strneb r0, [r12, #RESET_DATA(RESETTABLE_STATUS)] 1: #endif @@ -277,14 +279,12 @@ ENDPROC(__tegra_cpu_reset_handler) .align L1_CACHE_SHIFT .type __tegra_cpu_reset_handler_data, %object .globl __tegra_cpu_reset_handler_data + .globl __tegra_cpu_reset_handler_data_offset + .equ __tegra_cpu_reset_handler_data_offset, \ + . - __tegra_cpu_reset_handler_start __tegra_cpu_reset_handler_data: - .rept TEGRA_RESET_DATA_SIZE - .long 0 + .rept TEGRA_RESET_DATA_SIZE + .long 0 .endr - .globl __tegra20_cpu1_resettable_status_offset - .equ __tegra20_cpu1_resettable_status_offset, \ - . - __tegra_cpu_reset_handler_start - .byte 0 .align L1_CACHE_SHIFT - ENTRY(__tegra_cpu_reset_handler_end) diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c index dc558892753c..b02ae7699842 100644 --- a/arch/arm/mach-tegra/reset.c +++ b/arch/arm/mach-tegra/reset.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "iomap.h" #include "irammap.h" @@ -89,6 +90,8 @@ static void __init tegra_cpu_reset_handler_enable(void) void __init tegra_cpu_reset_handler_init(void) { + __tegra_cpu_reset_handler_data[TEGRA_RESET_TF_PRESENT] = + trusted_foundations_registered(); #ifdef CONFIG_SMP __tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] = diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h index 9c479c7925b8..db0e6b3097ab 100644 --- a/arch/arm/mach-tegra/reset.h +++ b/arch/arm/mach-tegra/reset.h @@ -25,7 +25,11 @@ #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_RESETTABLE_STATUS 6 +#define TEGRA_RESET_TF_PRESENT 7 +#define TEGRA_RESET_DATA_SIZE 8 + +#define RESET_DATA(x) ((TEGRA_RESET_##x)*4) #ifndef __ASSEMBLY__ @@ -49,7 +53,8 @@ void __tegra_cpu_reset_handler_end(void); (u32)__tegra_cpu_reset_handler_start))) #define tegra20_cpu1_resettable_status \ (IO_ADDRESS(TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + \ - (u32)__tegra20_cpu1_resettable_status_offset)) + ((u32)&__tegra_cpu_reset_handler_data[TEGRA_RESET_RESETTABLE_STATUS] - \ + (u32)__tegra_cpu_reset_handler_start))) #endif #define tegra_cpu_reset_handler_offset \ diff --git a/arch/arm/mach-tegra/sleep-tegra20.S b/arch/arm/mach-tegra/sleep-tegra20.S index dedeebfccc55..50d51d3465f6 100644 --- a/arch/arm/mach-tegra/sleep-tegra20.S +++ b/arch/arm/mach-tegra/sleep-tegra20.S @@ -28,6 +28,7 @@ #include #include "irammap.h" +#include "reset.h" #include "sleep.h" #define EMC_CFG 0xc @@ -53,6 +54,9 @@ #define APB_MISC_XM2CFGCPADCTRL2 0x8e4 #define APB_MISC_XM2CFGDPADCTRL2 0x8e8 +#define __tegra20_cpu1_resettable_status_offset \ + (__tegra_cpu_reset_handler_data_offset + RESET_DATA(RESETTABLE_STATUS)) + .macro pll_enable, rd, r_car_base, pll_base ldr \rd, [\r_car_base, #\pll_base] tst \rd, #(1 << 30) From patchwork Mon Feb 18 00:17:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817257 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 00FDD17D5 for ; Mon, 18 Feb 2019 00:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD34F2A147 for ; Mon, 18 Feb 2019 00:20:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D179C2A14A; Mon, 18 Feb 2019 00:20:55 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 881DD2A147 for ; Mon, 18 Feb 2019 00:20:55 +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: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=BkmMu9s7o3aOUo2HhPyropgaslV84f8Loi0dhnnvy0I=; b=lR0sGZKB4dZA31 BH6QvUJQeQsGrKt84Ggls40DCPwXs0ni46qHtd4ESkLy8PsyLib8xF7WXxpvokMcqBdHDXub8vfBp fI7PVJ8Ao15HFqOVnfA4mbWB2O1EFNz2tK8O4KrvYEdUZvd9A+jX9sIpDysv9L45V5mptddJ/TND8 zdQ9dJntsbEF1OJ5RVfRE2Glzl10wtMPO0txsaYloQrgL++jrbcHPj+DAUtQZE73lGG7vi0wccXUi Nw97c6lD3y5+rBmFLJeOBx4V3Cs77CklSwITxYUgOw+goI31QwmjWOOfqcsEkk8wQzPLqZHd+GZQl 0HXOgRdWVHm6hUs2mzkg==; 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 1gvWg1-0004Fk-78; Mon, 18 Feb 2019 00:20:53 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWf8-00023X-DJ for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:20:19 +0000 Received: by mail-pg1-x544.google.com with SMTP id q206so7528334pgq.4 for ; Sun, 17 Feb 2019 16:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EoaCOkUk5gTo3YGBlv0mXfCaFcXwFz99tNXwoGoos+Q=; b=CUF0VKILEd6e5TC6U/Lk5nkkqDiX0VIWU9IgUFZ0ZfyXaueXbEzZeuCCaXO9tpa9Q4 I8kHcc7SmVIrzdHiDayDq8QvKu4uxVe9gQVPuQuaIJ9+1vJ14bGcim8gMUvVX0MHGNzl GtjM/DGj27oZ3U5QVJwyXdYxdq21B3yo7Jdj12x56ffl5eboITDSRjrbLmhBFPPvmbDH 3hZ4WkqE5nUdKUAKT3Uwbh/x6KYP4V9rGz68rnKD5ZmOWu1V+DvcFbhyuW62pIBXShrc NaCyWyTXM9e+6isJJTm8aq6aFiz5nHepCVopinJSUqgk6M5DOoszn5LXdumiimzXUq1A 5jOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EoaCOkUk5gTo3YGBlv0mXfCaFcXwFz99tNXwoGoos+Q=; b=SwK31SDUeDz2R+sHKZbWPoyjEhhdwAch+kEUfPqdjwDNQv1phQmlmFSCN1JtWs/pUG oGTBB2fcdNFjpX++AjKJdUr6QxC3+75WoSjTpZLdDX1Fo9z4DTsoWacmzfT3cW8qm9Xv 4ptEC3WYyD1Hz3UDT8U6Ib5/pi0SRLwZxQJ+cq5YYJa5OyHxEswNIDzT1b6jnS3ppwVI GO2NSN9C5LEsohY8j78GPUgy+1t/4CmE9dBjEujiIXadoJnRzRcbqWUjM7MUcCsMqvm5 aKlRjst1LWdWKrw68sh/v0y+gLVgDHTT+eQoGFzAj2Rxde184TJwrO+SOC7LaTtNt8X6 3yZQ== X-Gm-Message-State: AHQUAuadwbZkfI613D3LO5hMefXGxUEN0gszF0kh2DmvI8ER7tI+XorO geaRlxOP0ehpJs0iCIThwj8= X-Google-Smtp-Source: AHgI3IY26M/PoAW6QKgiAoUGCwB26eIUUKSsASUJvxvJcrOiGbH+GGYwoscq7O/Hmqh5WqIKoSHuVQ== X-Received: by 2002:a63:2312:: with SMTP id j18mr16365991pgj.344.1550449197904; Sun, 17 Feb 2019 16:19:57 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.19.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:19:57 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 6/8] ARM: tegra: Always boot CPU in ARM-mode Date: Mon, 18 Feb 2019 03:17:24 +0300 Message-Id: <20190218001726.16785-7-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_161959_333436_890502A5 X-CRM114-Status: GOOD ( 14.00 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 CPU always jumps into reset handler in ARM-mode from the Trusted Foundations firmware, hence let's make CPU to always jump into kernel in ARM-mode regardless of the firmware presence. This is required to make Thumb-2 kernel working with the Trusted Foundations firmware on Tegra30. Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/reset-handler.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index a9f13230da2f..c827b185d281 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -112,7 +112,7 @@ ENTRY(__tegra_cpu_reset_handler_start) * NOTE: This code is copied to IRAM. All code and data accesses * must be position-independent. */ - + .arm .align L1_CACHE_SHIFT ENTRY(__tegra_cpu_reset_handler) From patchwork Mon Feb 18 00:17:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817261 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 48A3213A4 for ; Mon, 18 Feb 2019 00:35:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3444829AB7 for ; Mon, 18 Feb 2019 00:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28C9B2A03A; Mon, 18 Feb 2019 00:35:53 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 B4B9F29AB7 for ; Mon, 18 Feb 2019 00:35:52 +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: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=8la6RfnjHOQlWLHh80YGHbRnZY7pVgDCUFvldra3TT4=; b=Xw55ge1ciNHPOB nUKsuIPobzVb7pzBDfNC1Dx2dLoYHxm3yH70CcD15HfqbFJXe2gHfEIpoEdZ4lrA9gGvCBlsuB78U KRVSlogp3dHMcm4/LVQOTV9H1XbZsjKOw1KJpgJphLp7McG2/mhPe50SUvILu/zmBvQDCovKJQK83 IQVEi4/5HV1oLgluEguWlytS3bsIZQ48+CmtOg4rXWXlXpy50nbej+AKBYkSnMml/LGZPtou7zEpX Y+rinMGd05tGJw22PkwfQn3LgWr2YpiqNjZRYf8HAvElOhgCI/XTXe3TV6dkovyasMyEiFIp05RXl P+Egd11uB0Y+udway6rQ==; 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 1gvWuW-0000x1-4C; Mon, 18 Feb 2019 00:35:52 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWuV-0000m6-AH for linux-arm-kernel@bombadil.infradead.org; Mon, 18 Feb 2019 00:35:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type: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=9FtVEGiGy9Eakv2EeSbS97SgOgiiipvDTd5Smr8Hxk8=; b=UidRx6HsKLwMEDxdvJv0pxQF7P ebDp3vdxfjePIMjrh5+l1A1twdzBf+myhNZW/gYcblalNasSqZohH9zyb7q7XXWW+HzbPpg/J+zDW i4AkQqT4dgv5O7VuCYy+4woJzCiTYun9f+i6VAnuFuHoSPufk2O0NH7E8xpwwd7BKoAYcoCIlSqk/ xGM4Oo9pK3mJIsbWYW3SqqpnJGhTf4O2EX5FyKsgmafKNw2Og0+q4vQUvCZeGTJOOXs8Yx3TwW3nY lQ7n36geEkUCuDVgfbNBNi4AN5If11priPGZBAX6zlXECFjy0FjhxGQrXSI6TLDg4ydEhFbIYJaxV mtAMuWbA==; Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWfH-0002PW-1d for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:20:09 +0000 Received: by mail-pl1-x644.google.com with SMTP id p8so7831706plo.2 for ; Sun, 17 Feb 2019 16:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9FtVEGiGy9Eakv2EeSbS97SgOgiiipvDTd5Smr8Hxk8=; b=ZiFYjd/DceJ32azEOGg3cEeCfivgoHOn5pSsHhx6DOzudxTGZgsSdpN91KqrwkcBoj JE8F+vmR/wGEYqfBK5hlpgRzxkouMwDbbQM5dwg6yIW0TbTsAy0zyTBGqRcWPHI5bzvP J+fSm2HPUAEfqtMHbagvT4XTvcCzN7p0jKLCXqm+N9kbvcgmHlv7EbDvl342ov6wbdQX bRul/abgCPNwWLohKJJEZKkEzVhJthIKSszAxtG2cyxiztZvcZm1Moc+n8kXY4KL5k1j lalO2xETJno5ZoqgKjRTHoqiPDjYBHfrl+XH55pGccOaElQduEsGfAcmuJSVA1KZzb9J eFUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9FtVEGiGy9Eakv2EeSbS97SgOgiiipvDTd5Smr8Hxk8=; b=Dm6HDIGjb/zhGDtTGBHv01E0ZOgmBIEsIu5odz7uhQsWrrUqXiYKFoZ8pIdaNMKEvS LS8yEejENi952Zsz5ZwWeTtyDKW6OahNmtX649wL4K9nRp9AYiOUyvWHa/XAzcdtyh+o 3DSASV4uhuyjRKJlxc9OHVfOSU+Ig4hWbXp7ekznWs/30/mIT+jXKavRPR1vtm6VFXBk fYzIvgyXUTMl/yg4OBtk72xIqOAlNs8V3pKRdMq+fKYFVGAdrl/ou9fSafiIpskPEJDV Il1pJGltsRvOdwmPzrWBuCPPx24vY1Y+La+2LkGsBlynIW1ARZRwgD3SH0OucFoXKBoj YPQw== X-Gm-Message-State: AHQUAua4goaEw0PnGMfxyyqcl9yvLM7I2eBmahruWDoTad294r3WKOxv mu1A9r3s7G8mUuzal2v1FpZ9axUi X-Google-Smtp-Source: AHgI3IYQ/SwO5F6rcNdfHclFv8bc9xGYpjbYXVBHjrn4VC4UNvGShKHQnUALs/pzHyCq3Fc5mml44Q== X-Received: by 2002:a17:902:9306:: with SMTP id bc6mr2982099plb.59.1550449204193; Sun, 17 Feb 2019 16:20:04 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.19.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:20:03 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 7/8] ARM: tegra: Support L2 cache maintenance done via firmware Date: Mon, 18 Feb 2019 03:17:25 +0300 Message-Id: <20190218001726.16785-8-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190218_002007_431694_53E9F729 X-CRM114-Status: GOOD ( 17.57 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Trusted Foundations firmware require MMU to be enabled for L2 cache maintenance on Tegra30, hence perform the maintenance early/late on suspend-resume respectively. Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/pm.c | 36 ++++++++++++++++++++++++++++++++++++ arch/arm/mach-tegra/sleep.S | 11 +++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 1ad5719779b0..66c8cd63dd86 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "iomap.h" #include "pm.h" @@ -195,8 +196,27 @@ void tegra_idle_lp2_last(void) cpu_cluster_pm_enter(); suspend_cpu_complex(); + /* + * L2 cache disabling using kernel API only allowed when all + * secondary CPU's are offline. Cache have to be disabled early + * if cache maintenance is done via Trusted Foundations firmware. + * Note that CPUIDLE won't ever enter powergate on Tegra30 if any + * of secondary CPU's is online and this is the LP2 codepath only + * for Tegra20/30. + */ + if (trusted_foundations_registered()) + outer_disable(); + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); + /* + * Resume L2 cache if it wasn't re-enabled early during resume, + * which is the case for Tegra30 that has to re-enable the cache + * via firmware call. In other cases cache is already enabled and + * hence re-enabling is a no-op. + */ + outer_resume(); + restore_cpu_complex(); cpu_cluster_pm_exit(); } @@ -340,8 +360,24 @@ static int tegra_suspend_enter(suspend_state_t state) break; } + /* + * Cache have to be disabled early if cache maintenance is done + * via Trusted Foundations firmware. Otherwise this is a no-op, + * like on Tegra114+. + */ + if (trusted_foundations_registered()) + outer_disable(); + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, tegra_sleep_func); + /* + * Resume L2 cache if it wasn't re-enabled early during resume, + * which is the case for Tegra30 that has to re-enable the cache + * via firmware call. In other cases cache is already enabled and + * hence re-enabling is a no-op. + */ + outer_resume(); + switch (mode) { case TEGRA_SUSPEND_LP1: tegra_suspend_exit_lp1(); diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S index 5e3496753df1..0a8086d5a47a 100644 --- a/arch/arm/mach-tegra/sleep.S +++ b/arch/arm/mach-tegra/sleep.S @@ -132,10 +132,13 @@ ENTRY(tegra_shut_off_mmu) #ifdef CONFIG_CACHE_L2X0 /* Disable L2 cache */ check_cpu_part_num 0xc09, r9, r10 - movweq r2, #:lower16:(TEGRA_ARM_PERIF_BASE + 0x3000) - movteq r2, #:upper16:(TEGRA_ARM_PERIF_BASE + 0x3000) - moveq r3, #0 - streq r3, [r2, #L2X0_CTRL] + retne r0 + + mov32 r2, TEGRA_ARM_PERIF_BASE + 0x3000 + ldr r3, [r2, #L2X0_CTRL] + mov r9, #0 + tst r3, #1 + strne r9, [r2, #L2X0_CTRL] #endif ret r0 ENDPROC(tegra_shut_off_mmu) From patchwork Mon Feb 18 00:17:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817259 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 7B91314E1 for ; Mon, 18 Feb 2019 00:21:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 665672A147 for ; Mon, 18 Feb 2019 00:21:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58E0D2A14A; Mon, 18 Feb 2019 00:21:11 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 024322A147 for ; Mon, 18 Feb 2019 00:21:11 +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: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=vDTA7fazmetm61ArX44RTlL7z3VP5ZyUw7OHwsZqaII=; b=GgoIEMEv6DMkAj 3y6fznswwpwty2+pb3LvPB5d3YzB1+ieLjK3rvCFgRZY2g1psaPqSWxEW3vmOvtF07tz2GwgXzM1S zpwvUy/PR2W1ourZp/oH6DYRnDy3i1mjGpfN4yxacpEKdnorpYge68BalmIUOl4ybDvDIlQZcGWm9 OaaQX0sPW5pXlqYdChJW4QzNmz5gvNzYIbRgXFCAEuaFqvu6rXTjviL/8SorHjW5Qo+4HJLTdxn08 zGQEUL+3rv5uLsIWhJDIX0aJ/UaA4CtRPdhqY6PhQtaJuXwldUg1BNumUC8JGxiIixvQfz6lz3anD ImMM4r5QYhVOONTpxgaA==; 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 1gvWgF-0004ae-Ku; Mon, 18 Feb 2019 00:21:07 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWfL-0002ot-4y for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:20:24 +0000 Received: by mail-pg1-x543.google.com with SMTP id r124so7526102pgr.3 for ; Sun, 17 Feb 2019 16:20:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BvZ9oj3/sW8iZFxRIUh2GML421I70F1BQFHxs/lpvMg=; b=TjfT5Ardm+nWAMMGW/qXxaRrMgEVjhMs3IxlxLDThMh5A1u4aKAzu91599vKGBccIR AClzIhZOJNcFOZecAGT+EAJ1sjbXh3giEmE9DvtZB4aQ1bWgVX4YlkT6u33X84/kBus4 BGl7F6Hyv7Vwu89H9bxGaYGijfZx8xXy3i3qYszLObQgazidbdtOX33PYgnUGR0Qdl5I BtxDRfhQwUNSwFjhcc7xkp5W9zjszbhDwM/SVXrzN4XUsGuavFlNnC0V6PtrfRxo+INj m4vm+Zpytzvu6W1bRIIoPZejTIboTNq9z3A0OScm7Gl9jpa2IefBPzmo6BP7/VVCK0pt IulQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BvZ9oj3/sW8iZFxRIUh2GML421I70F1BQFHxs/lpvMg=; b=q96zdMoJyr/wJ9bTc1UaJA7X0K2D73KsgBBm5rPfXvddkOHk6V9EG5vmY0L6vVf+6a YiyLi7ekYJq2bbBltzenFvtGSbdfsQubRvQbxtRx3KojEPElGTqRaWqsDEMJt6KZCp6t sIW6BAac3buq1bSMTl2PzRdt4ispcZ3VQ49ao6umE+Qzo8x0cEiiGsl4lZMmxJwxGNp+ No8snMpx3QEFDoA51RTZCrxIjX+KZzwGKBGW6TS3tT42zv+ULd71ubwOLoBb4oU2sEWP 67USUbGN+tK6NugEkDyXllrBrecFB6QHaojjjscj/JzD0I8D+zlSHwEBXbYbOYv6QC2v /vyg== X-Gm-Message-State: AHQUAuYIQznQ5Isz61XmHZ5JAsz/GPhn4b4WQJO1UYhLHawrQeprGG5e dQt3QhPPhK6V5+6aTdRG29w= X-Google-Smtp-Source: AHgI3IZFxXD8vvprhu2l4e5vhlmtcR4sxejpGHTL3Fp9T2bq/p4Yol+XqQX+5E8wjDFWzQJvtQWsSw== X-Received: by 2002:a63:2a96:: with SMTP id q144mr16028847pgq.338.1550449210513; Sun, 17 Feb 2019 16:20:10 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:20:10 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 8/8] ARM: tegra: Add firmware calls required for suspend-resume Date: Mon, 18 Feb 2019 03:17:26 +0300 Message-Id: <20190218001726.16785-9-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_162011_831560_D055BA44 X-CRM114-Status: GOOD ( 12.91 ) 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: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 In order to resume CPU from suspend via trusted Foundations firmware, the LP1/LP2 boot vectors shall be specified using the firmware calls. Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/pm.c | 14 ++++++++++++++ arch/arm/mach-tegra/reset-handler.S | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 66c8cd63dd86..97bdfffc244e 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -207,6 +208,8 @@ void tegra_idle_lp2_last(void) if (trusted_foundations_registered()) outer_disable(); + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); /* @@ -368,6 +371,17 @@ static int tegra_suspend_enter(suspend_state_t state) if (trusted_foundations_registered()) outer_disable(); + switch (mode) { + case TEGRA_SUSPEND_LP1: + call_firmware_op(prepare_idle, TF_PM_MODE_LP1); + break; + case TEGRA_SUSPEND_LP2: + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + break; + default: + break; + } + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, tegra_sleep_func); /* diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index c827b185d281..24fb375e11a9 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -76,6 +77,7 @@ ENTRY(tegra_resume) orr r1, r1, #1 str r1, [r0] #endif + bl tegra_resume_trusted_foundations #ifdef CONFIG_CACHE_L2X0 /* L2 cache resume & re-enable */ @@ -88,6 +90,30 @@ end_ca9_scu_l2_resume: b cpu_resume ENDPROC(tegra_resume) + +/* + * tegra_resume_trusted_foundations + * + * Trusted Foundations firmware initialization. + * + * Doesn't return if firmware presents. + * Corrupted registers: r1, r2 + */ +ENTRY(tegra_resume_trusted_foundations) + /* Check whether Trusted Foundations firmware presents. */ + mov32 r2, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + ldr r1, =__tegra_cpu_reset_handler_data_offset + \ + RESET_DATA(TF_PRESENT) + ldr r1, [r2, r1] + cmp r1, #0 + reteq lr + + .arch_extension sec + /* First call after suspend wakes firmware. No arguments required. */ + smc #0 + + b cpu_resume +ENDPROC(tegra_resume_trusted_foundations) #endif .align L1_CACHE_SHIFT