From patchwork Thu Aug 30 18:04:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582507 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 1DA145A4 for ; Thu, 30 Aug 2018 18:07:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D3E428581 for ; Thu, 30 Aug 2018 18:07:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F387F2C384; Thu, 30 Aug 2018 18:07:16 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 5B67828581 for ; Thu, 30 Aug 2018 18:07:16 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=OYwt36g+nbvzR4WnAvsIiTL9v+7FcBfL8kpE7Lknl9s=; b=JjIENPcEhX9OejPXGbgF0xDoAP IsUAxvMZwwLtEXLYJ3D9xLNVzyOn4qyvN0cJGJkojvYHIPMM+j/MUAwSUvP5giYQEaHBFeEhVpjMY DDE2siM0JoPlcJZx3Jb/jDb5bOTHZ3dMLx+4qCjjDyH/jI59u4JXbu6YbYNs1wBM7/ex5P68jpkTw DIO0K8bvX6jvGpfv+b21S2PTzex59X07bHjV9RncC+z9v7FEv//BGenmCXtKFptpJF3/PAzDPAS9e e8NeXPp8Gj0RzeuOzCOyU8POXMlmt/o/0zQBGOkQD5GFNgd0F7/f3mhmpOB247zCHrbpT9RgiBAxd eLA8f3hA==; 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 1fvRLU-0000iJ-Cb; Thu, 30 Aug 2018 18:07:04 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK2-0008Tt-FM for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:37 +0000 Received: by mail-lf1-x142.google.com with SMTP id g6-v6so7891350lfb.11 for ; Thu, 30 Aug 2018 11:05:24 -0700 (PDT) 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; bh=JvSO0dczpNLWTzHOOBaNzPUDUqa2BMj87UWzjeeshg0=; b=JhFtXVj2j4o8LMl2qgBvT9Z8dT812PGiK3s5tu243KhPWIlbK7bzO8vzuoX7xEmoZb jO/7evKIfqGNIro8kSGyVpJRQO2drQOEcL9RYGy/sQi/50HWjwLFz8R94HOtF4RZ3uR+ AeImLlqlhg8rBJ8b8K1o2zqPhpUn/4V4S3ooal7rJjmBa88gqwi0S4Oe0MwnZw498zuN bIYv+dB0frEJj3itoQ9aYYZSwq6yFld4mVu5IMLQqI74BvwTQ7RVSs5mKanCYL86kMF8 kUM4jAcrFppFbSdFPTYl5o6zt4nV71KiC3/wNHjdrJGbkHDlz9R4vhOBPFz6nLD87gZP MaSg== 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; bh=JvSO0dczpNLWTzHOOBaNzPUDUqa2BMj87UWzjeeshg0=; b=GHV9K5q4n40GQO+PPfxcZDAtms+EVoJvE08F/jkyO/3ZLFqbauJ2/48A+mXGL/AB5U j8TavbVv2ZsmMOqc4LU2FrUY45R4bE9MCm2w4nMbr58xsrzSVpqAz90Qgi6ug7SpWuTD xoH2axR9cSVgE3ZcIuddVp1hGnK4O5VHlKHs6csprVoLSfifud3JME7GFsqYv6/HEBv1 L1mj7kjF0+mWwBH2pMUhi2LUTft/znCh+B2xK6Et5sHvBBQ1rxpMYbo8cLs5avstfdEY MrHQ6keHQJT2HzyA8qK/ffnQyhkcsxcBhtVd5ymMJLU1QcW7+NJg44vGFqx6yc9B4kU3 ptdA== X-Gm-Message-State: APzg51CjgTi6D+Yk+IwfJStteRKBlyOkX6Pvppv8YctbEijm4jAp/wze CiLAiKcMDLISfGiKm5Aui3Nppy5p X-Google-Smtp-Source: ANB0Vdb/m5Rdj9LgsSQAYgyq+EsfiZDKo8eZeD36wlslUlZH9TxcBplZT7cU7CHpBkw0KxOfQMQ8hQ== X-Received: by 2002:a19:2a91:: with SMTP id q17-v6mr8574174lfq.74.1535652322600; Thu, 30 Aug 2018 11:05:22 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:22 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 1/8] ARM: trusted_foundations: Implement L2 cache initialization callback Date: Thu, 30 Aug 2018 21:04:14 +0300 Message-Id: <20180830180421.6415-2-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110534_550571_237F816C X-CRM114-Status: GOOD ( 14.48 ) 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 MIME-Version: 1.0 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 in boot in order to setup the required outer cache driver callbacks. 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 Thu Aug 30 18:04:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582509 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 764665A4 for ; Thu, 30 Aug 2018 18:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBE692B356 for ; Thu, 30 Aug 2018 18:07:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC5B02B3F9; Thu, 30 Aug 2018 18:07: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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 026782B356 for ; Thu, 30 Aug 2018 18:07: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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=zsCgXhBwM/XaQEJ8wVORQ/DVxJ6YSPIwFF856+0c6/Q=; b=CMto14eRLW85CCWRYnWtRw/Akx advyjG31PfuAROYAhQxEBPOCdy+wLnJK/QJhX+KCZJQwLqvYrT56qNMAxIhOKhYbh5UdILeVfmnd1 z+r6wuUsNcLg4JFMsgLLPekWwDlvMTtrMnlyznN44OxqUirs60AwJiq4LpP6rDCUSYhO5Ms6upEwG Ag7VvVlAmDGTvW8Pb5Uy+AsNzSVh0HWQYqca8pcQjoQVAT41EQ8mv2KiOIlsgNceqhWyI8XaDvA8W i45qD6UzdDEcYujLTCG3u1ZYvwBfZJEb5k/0dXH9CPCiRmZK4qdSCFC1quE5ez8A7bB9z/1y7FIA0 aC/NWMeA==; 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 1fvRMB-0000yp-Gm; Thu, 30 Aug 2018 18:07:47 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK3-0008Tu-E0 for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:38 +0000 Received: by mail-lf1-x141.google.com with SMTP id q13-v6so7935840lfc.2 for ; Thu, 30 Aug 2018 11:05:24 -0700 (PDT) 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; bh=9v+w8nN/A6Frgkr+jrAIaiXhOfG+TiNL1K224zqxYZk=; b=pIi3+AiK9ewAMIkJqZDYucNokk/Gosab5ntB4JxFFMDbapjyBEbYhzYiqCT/Xx3EKs bywZGjBt+PLz8Rggd4mblS7XdyMi0kwi1FQF9l8xn5nib0WTVeiuVmR3Bo6cK+mTvsFo qOP2eSsH/gfE+eKaC3Ku7T4w9nw5btVhV6x2xOk3Qw48OvKzFuogRBPZX3U5iFJnHDxG PjA2PnQuJDzsgrLUAg5grqWClzD0kz82R7pf8CobYY76xqvyA2w8ZPLJY2z1ifX+cEOt oaoUtRhk5tWjS1b9pRiW1SFvZFZpNQdXCyuab/cBhervpCg5Xy23LuW4mIwsoX1TGc87 CSNg== 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; bh=9v+w8nN/A6Frgkr+jrAIaiXhOfG+TiNL1K224zqxYZk=; b=Qy2n7bPvoe94xPW5StKIuijR2XXOYQxtuUOC6vgjx81r+1r4rHwpZmBFlBTKC470MR AUFjUiCHbrn/Y+bv33lnMrECtAtn0WXKRQ9qKZ7YDbFlsp7dPrQSQPkpB8/eeX+LrKcv kATgQwvslqUAIJdMWeAVpL3VO1ZoP4gUB2xA4sag9JegD2YZoMWJBAEW8ACjKLXexecG nUryCw4mqk453hjMdMf26v3boK5X/VC3gj3Nc9ABLuaKJA4LA1vSm4daHUt58BYOjkWw 5utjTzwElAjDKEqPSh20Pyb4bTXQFCruUB2xNVYqimLfQq7TYn/ejWuTAi3RF3TB829k D6dg== X-Gm-Message-State: APzg51AK1bzoYjQ6vqmJTMLEdThUzhoseaHuXmxCwiXtK/kXy82O1jf1 vbEVOjxKa8WhBoz3f7dVgeY= X-Google-Smtp-Source: ANB0VdYyx2OSmgt+FtCUWSuqL4zUjelsB5aZ2FSWO5Vsp3ebXatJ1n8cNVxBDa2fElgvgNkrHSdFgw== X-Received: by 2002:a19:9bcc:: with SMTP id d195-v6mr8679683lfe.123.1535652323520; Thu, 30 Aug 2018 11:05:23 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:23 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 2/8] ARM: trusted_foundations: Make prepare_idle call to take mode argument Date: Thu, 30 Aug 2018 21:04:15 +0300 Message-Id: <20180830180421.6415-3-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110535_491753_2AC2DFC3 X-CRM114-Status: GOOD ( 16.21 ) 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 MIME-Version: 1.0 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 Thu Aug 30 18:04:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582513 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 92DBE174A for ; Thu, 30 Aug 2018 18:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84CF02C1B7 for ; Thu, 30 Aug 2018 18:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78E2D2C1BE; Thu, 30 Aug 2018 18:09:15 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 129F42C1B7 for ; Thu, 30 Aug 2018 18:09:15 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=jm5Y0eHNZiVFJKkuC0/9WkfQOrcm2Rwrb7nGydoGjdk=; b=Qn2IQZffoSAexJCvdixW13oY6u frXon7K3r2vGLMIyVIT1cStYi8L/h9j7gTRPMB6ZF764a2COJVOvxw4NELaV1cem75NrhpM1g4+bO g775IKvnbO4erPKR9+69AJtLKydQ9PHW+QL5zA4aU6tkzU214jQ/Z9ZWtuuXdJsBmS2XggvPAZhad p1Kxsw6ZFKQps7W7sHrSWQiFMhrg/3J7DxGDCJjr6A5JjaNXU1pYQG9bP48+5WIDT6WGwdq1SDo6R wPz+twfFEVlbpPItCXcU0TOkUf3N0CzJTluvbfRSUbN0rZCiW6Ky5gYrh0CosCqk06JwddGNt1P9k gcnWSTJA==; 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 1fvRNW-0001XP-Rb; Thu, 30 Aug 2018 18:09:10 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK4-0008Tw-9Q for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:38 +0000 Received: by mail-lj1-x242.google.com with SMTP id f1-v6so8027068ljc.9 for ; Thu, 30 Aug 2018 11:05:25 -0700 (PDT) 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; bh=jiYxzZYlLxYwiCUBX9+009bBH7xfhIzJMM0X4EjQePU=; b=eN5QeZqH0c30fW+dqI1cVGjL5h3cen2L7BX5R/YdiX9e6CjDPp56zIMrBr5vgIUfTE DXKc3smXef3p1HFW5VBOJwhVv9qvgSKNuaI92apbJEXa+wLS09JEvRwD09zTqzY4Sk35 v8ljY+1WmR0/ABtUBzul/e6279l5uU2g/CkPlDpDn6Nt11hBku3eAc8UuZxMOc+B17cd izfQAbVZjl1xRzfC+hM28H/49PSoW6HBMeeB5z2iQacRqQjtaWwPICDOIYJNuND2bHKw BHY1DP3FPKb4i/1PYVzuhirkO+dVOflNytZwd7SUrX5AaAaeD9g3K0A7kDRpVqa8yih4 XyPQ== 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; bh=jiYxzZYlLxYwiCUBX9+009bBH7xfhIzJMM0X4EjQePU=; b=LXar585MpnwX3Af9A+PI/XIVyOpDS4T2vmRarauPS+9NXiwz5nueJ735dsNOqoWmHQ mALPEbTqPrGZR4BONs2uiBZgbYe09TNPatKqwQ/4D16cygyz+d8O+soxbW6eFH0Jkmvr H/ueYo78WVrkuBRyisQ3aBMGMN+W9TOW0W4JGuArziwUbyXx6p1k3aDq/WnntHshJAWT SMeMPhVyvLV41LiJgE4ZLEVfJ7RQ3mTE6kWhGutIQX9apgi13MWVHXGzBvE04X/v2YBy xVHWwaUgPKB6pFqv0LtG5Mqj4j0vADbOHX/tBirJrpCmdBgHs4TVsbU6g4Hqommesiw+ Amtw== X-Gm-Message-State: APzg51A7E8qT1Nj9OQ6KRqBS4iUyfiWonDN6KyiMh8LZ8j7fk9q48EXG vzxjIZa/R5L1VnP8E8dHi3PRazho X-Google-Smtp-Source: ANB0VdYhPafGlqOEdbXy1bmb80xp5zicWVfD2Unzt2ol5lSahKedAC18SzHXQTGtjCbtre2bq5FQUw== X-Received: by 2002:a2e:9198:: with SMTP id f24-v6mr7728460ljg.64.1535652324441; Thu, 30 Aug 2018 11:05:24 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:23 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 3/8] ARM: trusted_foundations: Provide information about whether firmware is registered Date: Thu, 30 Aug 2018 21:04:16 +0300 Message-Id: <20180830180421.6415-4-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110536_365238_FA2AB4DA X-CRM114-Status: GOOD ( 12.87 ) 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 MIME-Version: 1.0 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 Thu Aug 30 18:04:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582505 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 8C344174A for ; Thu, 30 Aug 2018 18:06:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E4A328581 for ; Thu, 30 Aug 2018 18:06:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7198D2C384; Thu, 30 Aug 2018 18:06:35 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 7753A28581 for ; Thu, 30 Aug 2018 18:06:34 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=msEZoY2kyePTjw7/sxA9FGYh3hlR38YLW+6dOeX+c1c=; b=eYuT8hi+mlhDhjsq1HpXdGdM5f AkQe0JCxXu324iUmkWm8INkkchAWnDnbsbMnwGSCEOqc1l5G7Dym6yYIhIUUBinf54nplhwUACPgs MRgCv8Na1WYb71QsPILF8immRr2S7dqzRQ7svOaVJ3lAMa6ZyDCIN+NmXuVQIcJHw0aVV5RFjatA0 x4F/TmmED2ZGBRlDII6syBfvPfXlVhcsA72IfatJBglVt64Ou8vDhajoZ8xA6eWwK8yd0CFPDTz1W unoksaNY8HUfy7+MoC2qGO46uYhmpEmpshbhOa8uTF4jpZrsXmI8KOvZNC4mKtWdm75Z6IIWDF4+R KOLYsZQA==; 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 1fvRKm-0000Op-LW; Thu, 30 Aug 2018 18:06:20 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK2-0008Tx-1H for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:35 +0000 Received: by mail-lj1-x244.google.com with SMTP id j19-v6so8009527ljc.7 for ; Thu, 30 Aug 2018 11:05:26 -0700 (PDT) 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; bh=bqXBzGttmLbwA1tWVcC4ztFYtQ17JkPgOJF7TeCjrQM=; b=M44SoKfTQYxXncRXe+sQpbpCcP6pB/OL8hJhMfpeIkPLnG7cMvIJkNOM3KpfbP2Koj sGsNxr7iIgyeBaaCHE3MSuhUu24lBDY+9T3DU0nRSiIVsN1X8lc8lOKVZV1kWXEGfZ39 O/462rzfb66PswKqggEJDr4L8+p4W0U5kU31haTIUJBX8Is05loSZOAcxMqyHXKkY+BM +7jzPXmMwM0uvUxpV/GAeXFJRrx5DbWlAsYRV+qvkb2joqab0gvdWK5OIcwWOQW15JCo UgbulB/EmgR3PF/dpYzj9YSdpCTQLcQiAhjfVm7LATQImbZuLqHLJd4kJOyiDu6/9r3r mtLA== 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; bh=bqXBzGttmLbwA1tWVcC4ztFYtQ17JkPgOJF7TeCjrQM=; b=I5tuAHyPhf3StCviGZGzqbot5ZW+d6qfR8nZGXM1uZLqL2ZS9V42S3idO3neVPJJiY Qv6yJE9TduZO2B/V0XJQ5RibIoJO9ldLLQLo5QxtUzzNbEvc7o5f1lD+4kNMx+N9+HQK qutv3TzHOLih1jdHo8UcEMx6PLC5q6Dxbv1BC1v7QrUJVJqJhO3y//MvilK9g2Fzru+/ hW6qpce2odmlZeK2MgEqW8qeX+BNaBUuDKALzgG5pCGuv0L3+pzTBNHtQoNYIxx+KRVb Cn9ez1StXPuLiCXY0rPy0Fmsa6jqD44p1ywyh2p3eUYxGdAd3j9Rqtq3GadpSfVp3Rls imUw== X-Gm-Message-State: APzg51CqJR4osvd6U0QwAC2kbaxd2q7uGef6S9XRlDx9JZCTP+z80wnL hFmPo4pvs0X6SMBZ5W4A17E= X-Google-Smtp-Source: ANB0VdbxonLX3/tHfylXGtFG76UKRY87tiyShDKVhxYJyauhL0lsJJ3vB2b1tqj3CTwHtyBLN/rknQ== X-Received: by 2002:a2e:990b:: with SMTP id v11-v6mr7955986lji.87.1535652325589; Thu, 30 Aug 2018 11:05:25 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:24 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 4/8] ARM: tegra: Setup L2 cache using Trusted Foundations firmware Date: Thu, 30 Aug 2018 21:04:17 +0300 Message-Id: <20180830180421.6415-5-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110534_092539_4340B78E X-CRM114-Status: GOOD ( 13.96 ) 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 MIME-Version: 1.0 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 setup the outer-cache callbacks in early 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 Thu Aug 30 18:04:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582515 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 5B2B15A4 for ; Thu, 30 Aug 2018 18:10:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CFAB2C397 for ; Thu, 30 Aug 2018 18:10:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B04E2C301; Thu, 30 Aug 2018 18:10:06 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 81CC42C2E0 for ; Thu, 30 Aug 2018 18:10:05 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=iws1fUPNG1QUHCyYD9/iMVs8dBqtoCDgrJQ/jLMppnE=; b=B1lGH5Gw5leoZ4YsFKR6LGFh5l NTqVRLCzSw2TGwBfOPtUZAsA3pjwtENzwUCLm5mRdAIVLTvP5s2PLjBhaPJjHDS+XdLXdKHaZGWAD UhUCpESNm9b+pvVl4Xo3ScTFhQgGW1vJhTslnGMnyt2zeC85YQW/U9OQ7wus5dhmT+kZ4pcUd1k92 qHkbyacNJ/qWjXYmxQK5bn+I32NYLshDIgB9NbJ8fBNkKCn4Y2XMEg1sXiscGBP02ZLqW9rkJHTr6 0Nnj53N+b9m6AtDwF6m+kjynr8bMUPzePskXRpws9ZabLlhI6sGyKXoRvIRIJieH70l0e4lh+rud2 EAZp9AsA==; 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 1fvROC-0001pc-8c; Thu, 30 Aug 2018 18:09:52 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK6-0008U0-FX for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:40 +0000 Received: by mail-lj1-x243.google.com with SMTP id q127-v6so8003828ljq.11 for ; Thu, 30 Aug 2018 11:05:28 -0700 (PDT) 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; bh=wxnbvPyqV9MwtYpRFTERECdapTydYiOKIVc11OZOZ1g=; b=TZFuR7FaQcOV/na0BmDQRYbWwKbmhq2PMpeO/OOVSdvqtVCtgCI7HGUS8wGgOTqpTG xiGoecj/+SEZStzrteI9Bta2afXRe6dGC2MD9xhLudDe11c7cDHrWWAjtaVWDvsMlJF0 DUDsw+28zG4rV0Bzb2sJoHf1jvRHZLoK33fRGaOBjyLIUDVglPEyAbamk9rhaysNoZus q+9iBg/lQlcBiBKWtPXBpV4eJag3PwraT56iHNxKakPB2/H4WJ84l6woLPyGke/+bnug r0/ZH/RW9wNmktfjI6AKeoCeDnPrJLnHdo/0GJkVCgkUPCZGkxJKuQJ8EMIeSncS/TP4 lQpw== 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; bh=wxnbvPyqV9MwtYpRFTERECdapTydYiOKIVc11OZOZ1g=; b=oTNnleURkFRGVdlbUuXGrwVz3jwmZ96wgg/SpMeaLHsup32jvi6V5cSdrTAIoZUdCv Y/aD8cyOZLUYMhi502wiYim9Hd2psTVvxiIlDC567OZy1dSxO6T/yNhTEq3RypNP433w ZIVJcVkWm2awB9htJpz1M9XtLypjj6y7zE/qYcgnLzFHT8xEXBYK7Zx9fpJtm/modTWQ q84EKcMPwHBhYXOuJeJ2DDAPX4ZB2OIoEArVpcy8IjWLFb9EbltKJCAa6W4mZ7VEYqNy qfebfXH45qeqfiLRkzlWl+MAfW1htjNhcM7Hn45mejRhL2xM+Ums57gIk+rffITpP0Af LAYw== X-Gm-Message-State: APzg51C7xjXpkZiAdelBK7AMCMzfUBYjn+2bnYS9xxdCaVasel9bL9rf GhfkjIRKH+3cNEeLVri74nyrsUIF X-Google-Smtp-Source: ANB0Vdb8b97qS7fwtXan4rU2YGPlpcWmk56YL4hQGawOliBBQp1+rozAC8yfsFKESFnQ/P953m2M1A== X-Received: by 2002:a2e:6a04:: with SMTP id f4-v6mr8472532ljc.109.1535652326528; Thu, 30 Aug 2018 11:05:26 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:26 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 5/8] ARM: tegra: Don't apply CPU erratas in insecure mode Date: Thu, 30 Aug 2018 21:04:18 +0300 Message-Id: <20180830180421.6415-6-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110538_646782_5F398803 X-CRM114-Status: GOOD ( 14.67 ) 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 MIME-Version: 1.0 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. 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 5c8e638ee51a..11f423e4a263 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 @@ -54,6 +55,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 Thu Aug 30 18:04:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582519 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 A64CD5A4 for ; Thu, 30 Aug 2018 18:11:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 973C22C40D for ; Thu, 30 Aug 2018 18:11:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9490E2C408; Thu, 30 Aug 2018 18:11:08 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 21FEC2C1DD for ; Thu, 30 Aug 2018 18:11:08 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=UzxVdOhuZvEj8s1yRrK6JVYBvfXGx/ZKujPqoZWm6L4=; b=ahsiGWD03dofCPpiqOJG7J1fHd a9lDIa3FUId+YJcmYeN5JyYtyB8QNuG/nHSfX/gtKd2FJbJ8cwbErVFDEbuEfxxMJreBVPMCV1scO dExGPLKYMZOiK+3/2py2Njz9rn8/eY2BO78kW9YIOPXiaxlH3OqNaTXsygvcV0Jp0iH5csXSRwnAO EFq5EUAucW5QDMh/lStM1FN1gEqv9mFrVglrZcdOtGfNuIwvk7RfYB3x2e0EpqNYoV6napKqpXQE/ mt9rI8mx7lkEu2dgiDdyN2LAngI4AGNglm5LSBm31saxt9K7qyH7Gmc4jFm0AiraTTu3n6Y0BDnGF /7VsuTuw==; 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 1fvRPF-0003Vl-8Y; Thu, 30 Aug 2018 18:10:57 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK7-0008UL-IZ for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:42 +0000 Received: by mail-lf1-x143.google.com with SMTP id j8-v6so7927113lfb.4 for ; Thu, 30 Aug 2018 11:05:29 -0700 (PDT) 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; bh=tcKFedpKwPfw1JlfTbqpZJDN1CaZbc+G2vd2PvtCtNc=; b=EbqdchwX8jfqttxqyoqz3SvSqTfR6ixXhWKIzVJajiFsakwjg3L1rVqw21GaVokSb6 xbdiw2TD14a6R6gibFyD9R6lmApJA+KYGx29F2Q7zfxkcv9CJ9SLdBTQ82PIqCIrLqs0 GIQvgo5wvStudDFYkAIi40lsjEN9VOwKUm6IX4sKYf9T0K+NOboGd1CLBmj+YSOXG6pi llnwGHLL7mFZOc7lb2894+kjgkYzjaMODbZvuG61IYIsMbDbe+c6fEo3Kma9tgxBe9I7 /sUyvRok4O0h7qhGxfDM4LrXPR/YKS6A3kpPheNodqEfdLwS0nkYwreqGcs3SimRIIWG Psqg== 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; bh=tcKFedpKwPfw1JlfTbqpZJDN1CaZbc+G2vd2PvtCtNc=; b=p5PxVHysR36XWj6bGjt7OA66oOSGjcKer5PZlSEtO5olXQHoEHfYywktzQ0Baja2Z7 H4rFiOy6R7CxbLAF77+ZdORGVRrVO//+3RJoNMiB8xluF4pVhFSSNu6UXT1SlACGu6KQ zi8ls/aOpzzvyZ7QrEZvM1SyH77LwkzQ5Cj7TvQu7D3z7taa2ewG3fXJ5kN25odeDGA+ x28r3BWCKYCyfOsOLXLf6YN4cCEw0iMApAKgBQyAFs6rRwJwYcrrcSR2+zuXKnnW7wPM bO1v+TrMKLG836U6c8SugNrEFg1Z80bB4N0WAPSAPUhsDa/uvksArYmzrNBhlBgWW2hl m9kA== X-Gm-Message-State: APzg51BX8waxGkbV0sH93w37r5Szoi+NvnoeZk0B1dQI63VRAhTK/Gqv X9RbngKTNOzX5gcJWEJ0EG+xs8Te X-Google-Smtp-Source: ANB0Vdbxv7aZL4XC/1eeroHssT9Nml9X/ny3YSGiEX30upk8nCv5jMSNUHEVN4pIdrpbNeELdmF46g== X-Received: by 2002:a19:c38b:: with SMTP id t133-v6mr8527066lff.7.1535652327705; Thu, 30 Aug 2018 11:05:27 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:27 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 6/8] ARM: tegra: Always boot CPU in ARM-mode Date: Thu, 30 Aug 2018 21:04:19 +0300 Message-Id: <20180830180421.6415-7-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110539_659200_3008883C X-CRM114-Status: GOOD ( 14.68 ) 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 MIME-Version: 1.0 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 to support. 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 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index a9f13230da2f..555c652f5a07 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 @@ -112,10 +113,20 @@ 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) + /* + * Tegra30 ignores first bit of the reset vector and always jumps + * into kernel in .ARM mode from the firmware, hence force the mode + * switch if kernel is compiled in Thumb-2. + */ + THUMB( badr r0, 1f ) + THUMB( bx r0 ) + THUMB( .thumb ) + THUMB( 1: ) + cpsid aif, 0x13 @ SVC mode, interrupts disabled tegra_get_soc_id TEGRA_APB_MISC_BASE, r6 @@ -215,7 +226,7 @@ __no_cpu0_chk: ldr lr, [r12, #RESET_DATA(STARTUP_SECONDARY)] cmp lr, #0 bleq __die @ no secondary startup handler - bx lr + ret lr #endif /* From patchwork Thu Aug 30 18:04:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582511 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 B5E8A5A4 for ; Thu, 30 Aug 2018 18:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A785D2C1B6 for ; Thu, 30 Aug 2018 18:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B51A2C1BA; Thu, 30 Aug 2018 18:08:42 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 B6F892C1B6 for ; Thu, 30 Aug 2018 18:08:41 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=j/W/OigOcpZWz/1BxjYqfU9G1msepZXRut9zGumWqkw=; b=JWbxf/cKVmfKWe6fvJ55jMeQk/ Je8RLxl67IzhzRViC4SIXMFv/NvB40BmCTQX5qLPXqw2uXXBu/zXGJBtNfWaO036gS+jYY4nS0CLz s8LCOleM+stKojYBqI6thLMtimU6q2pW6Rz5n/2WWNkVCLlQz+MWtCfrc47pP7W0LjCEzAp0N576c JZSkKbH3ppcbMmNg3Nl8aiYTiEA/YzZ6jH/V9JpaCG9UaOnBgX5vJc+fyIy/DRiTHbHqLbHR+da5d SpNETCEwVv5omhbgldQUw2drQ6Tw1qkCQL0gOekJuyxNT23mteBVvrpHuWYi6+Q0NJG6jmgTdl7zo HnZwmHqg==; 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 1fvRMq-0001GH-3S; Thu, 30 Aug 2018 18:08:28 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK3-0008Ui-Dx for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:38 +0000 Received: by mail-lf1-x141.google.com with SMTP id z11-v6so7916076lff.9 for ; Thu, 30 Aug 2018 11:05:30 -0700 (PDT) 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; bh=gzoUL224jX0LdcQuHl3QNpfOd2p4daBp/oJP6u+IJQI=; b=jsABhjJl5ipsNtvgdx0BajWqOKPpYsM/a6XaMVYu+7hd6M3jsaVqy7ZIXZHzBJUW4j UgafmTy9YBHe9eP0jGlnOhnnqVc2ywZi3zuKZNlpqaf8dxsowZF5gNuC7C5SmNQwmEvh 5qY7iGDflaLNk+iyj2zf/jy4XetQnQf5oSqtU3DLQ6ChjQ29Nm20TpyWUlTWJWNYapAi fMh4Oz80TULiArj+jbk6Skzsrb16OL0W93RGHgRQRZbPxw7TBcgtx0CD7TZjR7XxtnZC mQnjE1mUZY7M+JgDVC/sHwMHIbTKYPfgo6viLYf9A/niX3bcYbz9QnShnSdx6gDWLD+B OOrQ== 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; bh=gzoUL224jX0LdcQuHl3QNpfOd2p4daBp/oJP6u+IJQI=; b=VvBZUbdVCy/JRDZMprUecthh37Qm8E6SFTx5sJfEH0IshS6O4/DijItjM8RnQ3hkiM B23VnYn5ZfehZsEyOBnbbiKTFqboKfNtHr+77LwLuQ+nNi7cjIjNDjjtYhLV0U8rWlB2 sWS9U+w9KX9xck0ibc70q9G2VRlellRr+ZLjrn6R6OGe0foIVuMNyFS5Jo7wu/IxOgTn pTkJoGRea5OjhTjy+zfik0KB/izo8aTQfW7nU08Vi/eHiA7QwjhKnsHoE5Cjs6khv4F1 dW2Q7Oip8LJCptL8kWifxBZz/51eGp1u+ufbAGgilmDQLrHR5K41YG+cqZUq26gurE// 72/w== X-Gm-Message-State: APzg51BjciHmVzbX13f4Ysn7AUAKzAAK6J8l2GaX8bbBcFhkTI40LxDe wCbEc+vuDaCeUHH/6dZz2CQ= X-Google-Smtp-Source: ANB0VdaNiDWWi1NIzkr9GyFQ71be5Vr5ImkYyEJcF4crdGGp3fnfunSq3K9kNy8Z4NZ3PIX0jhQT4g== X-Received: by 2002:a19:a345:: with SMTP id m66-v6mr2280499lfe.23.1535652328614; Thu, 30 Aug 2018 11:05:28 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:28 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 7/8] ARM: tegra: Support L2 cache maintenance done via firmware Date: Thu, 30 Aug 2018 21:04:20 +0300 Message-Id: <20180830180421.6415-8-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110535_472236_FF10CA83 X-CRM114-Status: GOOD ( 16.14 ) 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 MIME-Version: 1.0 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/reset-handler.S | 8 ++----- arch/arm/mach-tegra/sleep.S | 4 ++++ 3 files changed, 42 insertions(+), 6 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/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 555c652f5a07..4973ea053bd7 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -69,7 +69,7 @@ ENTRY(tegra_resume) mov32 r9, 0xc09 cmp r8, r9 - bne end_ca9_scu_l2_resume + bne end_ca9_scu_resume #ifdef CONFIG_HAVE_ARM_SCU /* enable SCU */ mov32 r0, TEGRA_ARM_PERIF_BASE @@ -78,11 +78,7 @@ ENTRY(tegra_resume) str r1, [r0] #endif -#ifdef CONFIG_CACHE_L2X0 - /* L2 cache resume & re-enable */ - bl l2c310_early_resume -#endif -end_ca9_scu_l2_resume: +end_ca9_scu_resume: mov32 r9, 0xc0f cmp r8, r9 bleq tegra_init_l2_for_a15 diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S index 5e3496753df1..b96126fe5dc5 100644 --- a/arch/arm/mach-tegra/sleep.S +++ b/arch/arm/mach-tegra/sleep.S @@ -132,8 +132,12 @@ ENTRY(tegra_shut_off_mmu) #ifdef CONFIG_CACHE_L2X0 /* Disable L2 cache */ check_cpu_part_num 0xc09, r9, r10 + retne r0 + movweq r2, #:lower16:(TEGRA_ARM_PERIF_BASE + 0x3000) movteq r2, #:upper16:(TEGRA_ARM_PERIF_BASE + 0x3000) + ldr r3, [r2, #L2X0_CTRL] + cmp r3, #1 moveq r3, #0 streq r3, [r2, #L2X0_CTRL] #endif From patchwork Thu Aug 30 18:04:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582521 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 7257D174A for ; Thu, 30 Aug 2018 18:11:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6264F2C1DD for ; Thu, 30 Aug 2018 18:11:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 564892C1FB; Thu, 30 Aug 2018 18:11:54 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 A17722C1DD for ; Thu, 30 Aug 2018 18:11:53 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=hqvv07ggEpJ5YOg1A1blG8t2uTZgMACAy4tpiBWLA2E=; b=AIxhd7tNt7Gq27LWwxAzjLojUn dAg7xXxjEWCkbIz6QcQIyOKjHi+fiPkDaPZNKsivK5dpy6zNvbWLsIOieyqucIsvjyF5k/HXDOSWT rLZhK29ohcLGCr+F0jb+t77LMpIE+4xHsC4UZlNBZv03OkICemM+c1RlMWpGt/uVV75RYrd7/T5za kBofFc8uCKyKK0ltgDrb5sKgjI8+VGhRNm58wmVimHugnTiByjyyEokaZvw5twQsOE18Ev7qwcWii JYEUOlvskgcHR2u9bdF5N7jUM/IRexnh0LUXOtkgYMRMNYrmJJ/7lTPt12wE0ns3MiML3P0bDLQ8Q DXlFftmg==; 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 1fvRPv-0003ns-57; Thu, 30 Aug 2018 18:11:39 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK9-0008Ul-LZ for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:43 +0000 Received: by mail-lj1-x241.google.com with SMTP id q127-v6so8003945ljq.11 for ; Thu, 30 Aug 2018 11:05:31 -0700 (PDT) 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; bh=8oMFGxXF6QUlJj5F31ofFC/byB4gOQFq079DGk4vXTU=; b=WVF+g8T56Wa5yvSO7+HtBo/1wWJw2I+/Gt1i4ISB6wcx6pPaYrW5Mk5YrslapLh1XV RoyXYDloAFZb4EYqwmDJV4M9Ui7vvFW4LKb1oSO031/VQq8XnI0vkKc3JjXOW+rDCoG0 GRehMi0xhBYoBo2jet0h/k5GwJnak7lPjYSa8IQgPwQgWh2YDuIFmGQ96colrthjlnzO GdSNp5ZkszVDbqJYTsUr2yl+iGb5uwyHrTeY6ILIbxWsWnQu15oOzG3OEh5F2rk4iKoX yXTZJPGfzsfFhxAFS8D1PLzYbiJvh2KBz9TLr5Ug7OqXo2idlqv9fS/uX+hLWKlt/fpd R/Zw== 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; bh=8oMFGxXF6QUlJj5F31ofFC/byB4gOQFq079DGk4vXTU=; b=MSBku+2qxXt8zn+WnWLWxw0uT1m8SpuvD1Jr0daf5JYJ8qLkinLnpyfp2qc+noBMkd +itRLGR+DP5k1ozxD6jXnZ8m72G5KqbCnnUD7iZysRzBbWdl1MGt18qsPi+y/156JDR0 TqzMghGpszrqJvqD3F3cPIj903GngZU2fKoSW2ULDyCsVoMkulrMYKIFfFwmlGIop85w BCUIEwaYRQQHT62CAnvSyQCCvgG+hLHOHEWLSt+WQxzoZk5zquxocLjbxTDrEFcd9Uez RWCeMFXi9I/MVtoujtyPWQy7k23bicNKpvvM0Rd0rVJBQAhCbfPD8noOG04tlP+EkVSm Nxqw== X-Gm-Message-State: APzg51BgnKYhpP49r3lWf64mLfPR5LaKEWyWoKzJ6FYRRA/RDpTeUh3M VjmI0rHwQNtBmfrCzUwAHpE= X-Google-Smtp-Source: ANB0VdbuSB/JaEZO4HXFI+IdiQJOsLmtRkKAAAwzNcz8e2DHekyQh9V3BpF4V53XDh+4HW8SBgCNaw== X-Received: by 2002:a2e:85d5:: with SMTP id h21-v6mr7864981ljj.103.1535652329646; Thu, 30 Aug 2018 11:05:29 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:29 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 8/8] ARM: tegra: Add firmware calls required for suspend-resume Date: Thu, 30 Aug 2018 21:04:21 +0300 Message-Id: <20180830180421.6415-9-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110541_781862_4DBE2DB0 X-CRM114-Status: GOOD ( 14.73 ) 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 MIME-Version: 1.0 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 | 7 ++++++ arch/arm/mach-tegra/reset-handler.S | 33 +++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 66c8cd63dd86..12341ffabb99 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 @@ -150,6 +151,10 @@ bool tegra_set_cpu_in_lp2(void) tegra20_cpu_set_resettable_soon(); spin_unlock(&tegra_lp2_lock); + + if (last_cpu) + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + return last_cpu; } @@ -316,6 +321,8 @@ static void tegra_suspend_enter_lp1(void) tegra_lp1_iram.start_addr, iram_save_size); *((u32 *)tegra_cpu_lp1_mask) = 1; + + call_firmware_op(prepare_idle, TF_PM_MODE_LP1); } static void tegra_suspend_exit_lp1(void) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 4973ea053bd7..0e208b2e246e 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -69,7 +69,7 @@ ENTRY(tegra_resume) mov32 r9, 0xc09 cmp r8, r9 - bne end_ca9_scu_resume + bne end_ca9_scu_l2_resume #ifdef CONFIG_HAVE_ARM_SCU /* enable SCU */ mov32 r0, TEGRA_ARM_PERIF_BASE @@ -77,14 +77,43 @@ ENTRY(tegra_resume) orr r1, r1, #1 str r1, [r0] #endif + bl tegra_resume_trusted_foundations -end_ca9_scu_resume: +#ifdef CONFIG_CACHE_L2X0 + /* L2 cache resume & re-enable */ + bleq l2c310_early_resume @ No, resume cache early +#endif +end_ca9_scu_l2_resume: mov32 r9, 0xc0f cmp r8, r9 bleq tegra_init_l2_for_a15 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