From patchwork Sun Mar 3 17:12:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10837123 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 49484139A for ; Sun, 3 Mar 2019 17:13:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C44C29D55 for ; Sun, 3 Mar 2019 17:13:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EA6929D66; Sun, 3 Mar 2019 17:13:39 +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 8234D29D55 for ; Sun, 3 Mar 2019 17:13:38 +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=Q1aWbfonEf6s/lucNfCBWo7F+kxMnzLQOntrXLK+ab8=; b=IVdC11gTyBbDWD Otp8vxQ4DNalXSlLeuOLTDnvXeuOAJIKq9WUQXmtaLmobF5+s4rZ5Hcx6wCAO8X3/BvuZOuTtCXw5 vJK09Chh8rq4SNX5t1xmohiJDhnJwecc8CKPLkQvOLhcdEIpJmH4pPI6h/wG+o4g5wfpLSOl5GBTg Ffv8AmYr4azpygapzBU5C0hbWdJd0qVnmc8kBR2ONKI5rPCCF4p4ly7dcIDQAt9Ajd074iQS8w6PO AWRYxNrUWMUkXczPvANQ+EWO2SkV71PSCAwJEfeLHzmJ51yTN3zIoZsnNuWJtpD7xQS6z023uwjHX fmBMlVDjxsd+rWpjarKQ==; 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 1h0UgD-0000eU-17; Sun, 03 Mar 2019 17:13:37 +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 1h0Ug8-0000X9-7X for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:13:35 +0000 Received: by mail-pg1-x544.google.com with SMTP id l11so1340505pgq.10 for ; Sun, 03 Mar 2019 09:13:32 -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=xRPWdDzEgjoLvgNLlDqRYxDvr6EyPAugVognUJGP4To=; b=GX66dTWenzmhQlN/6AF7yMeSO+8lEdUWk3OCpxejXPDUIViLmNao/iQN2OXXJ8dJvw QhGQpNA6WahNSHIAaoUF3HxcP/NfK7/KFTzohiWFAtrRjh8MtOapZ5QdhMnsn22ilHBf 8Q/lJ773NqYxwM/dejIWQ8ImZOC1u1bpUd9Ks0Pl3hv0y4NGWLlNDJcxI2+il/ltKNGQ ZJbgeTWaEajaGFEnLzzxa/g42lEcg00QLt5xwEGgSj5RG3LkPzD3Fi97knSgclYyntf7 mPE84fmCNDl3idzCTpo/zbYH2WQX2oP0ldi1RAzHcDTTo1EU1HEoeQZ9IcNBiBcJACUC vlVQ== 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=xRPWdDzEgjoLvgNLlDqRYxDvr6EyPAugVognUJGP4To=; b=UK/ImCUqrDuaTMg8W9myg07nVAglF4aCV4GafdJU7C6csXaMB1F/mTH70Q6Zwhi86l UnSv6w4qzEjmAlENegfcseRXJqLlY1xf6TnZ2TFRhLZCi36xRik9z6XARgNp2XhOXHUK 72h9vNiQVUuZficpv42nRB+JKIiVqBJyk3Hva0uVS+pfoUDojtO0/WBfVu3Rwck6kBYx YPzIMajnuRdqyyL6UprgdQwXUF5TBd20VBCD9cJqqERemss57+vUpfcmLtgPUAA5ASq9 5zEJdOvQV4ra8B5ShXRqW+M0d+FoucqvhfsrQ3Q0agP/5oWGQoL5+cMRtOPPflewuShD 7NSw== X-Gm-Message-State: APjAAAWealIxQbpz7n53VrhM567CvdwClPM+WF9gUDgunmG0k77wzwSE +loPqz8c8HUZiNYucoTglx8= X-Google-Smtp-Source: APXvYqxo0avGDODD2Ng7ahsZcZsdIAE0WSZBf83j2wK0402ss5WHfCLwakvdJMgd9pnTnpTuLTx9jg== X-Received: by 2002:a65:4384:: with SMTP id m4mr14493823pgp.375.1551633211778; Sun, 03 Mar 2019 09:13:31 -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 e22sm5349412pfi.126.2019.03.03.09.13.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:13:31 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v9 1/7] ARM: trusted_foundations: Support L2 cache maintenance Date: Sun, 3 Mar 2019 20:12:08 +0300 Message-Id: <20190303171214.24821-2-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190303171214.24821-1-digetx@gmail.com> References: <20190303171214.24821-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_091332_569099_EF76C1FE X-CRM114-Status: GOOD ( 15.60 ) 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 and add the callback required for L2X0 maintenance. Partially based on work done by Michał Mirosław [1]. [1] https://www.spinics.net/lists/arm-kernel/msg594765.html Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c | 41 ++++++++++++++++++++++ arch/arm/include/asm/trusted_foundations.h | 12 +++++++ 2 files changed, 53 insertions(+) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 689e6565abfc..d7ac05103a52 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,43 @@ static int tf_prepare_idle(void) return 0; } +#ifdef CONFIG_CACHE_L2X0 +static void tf_cache_write_sec(unsigned long val, unsigned int reg) +{ + u32 l2x0_way_mask = 0xff; + + switch (reg) { + case L2X0_CTRL: + if (l2x0_saved_regs.aux_ctrl & L310_AUX_CTRL_ASSOCIATIVITY_16) + l2x0_way_mask = 0xffff; + + if (val == L2X0_CTRL_EN) + tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_ENABLE, + l2x0_saved_regs.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) diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index 00748350cf72..d5d1b7efa02e 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -32,6 +32,9 @@ #include #include +#include +#include + struct trusted_foundations_platform_data { unsigned int version_major; unsigned int version_minor; @@ -43,6 +46,11 @@ void register_trusted_foundations(struct trusted_foundations_platform_data *pd); void of_register_trusted_foundations(void); #else /* CONFIG_TRUSTED_FOUNDATIONS */ +static inline void tf_dummy_write_sec(unsigned long val, unsigned int reg) +{ + if (reg == L2X0_CTRL && val == L2X0_CTRL_EN) + pr_err("Trusted Foundations unavailable, ignoring request to enable L2C\n"); +} static inline void register_trusted_foundations( struct trusted_foundations_platform_data *pd) @@ -53,6 +61,10 @@ static inline void register_trusted_foundations( */ pr_err("No support for Trusted Foundations, continuing in degraded mode.\n"); pr_err("Secondary processors as well as CPU PM will be disabled.\n"); +#if IS_ENABLED(CONFIG_CACHE_L2X0) + pr_err("L2X0 cache will be disabled.\n"); + outer_cache.write_sec = tf_dummy_write_sec; +#endif #if IS_ENABLED(CONFIG_SMP) setup_max_cpus = 0; #endif From patchwork Sun Mar 3 17:12:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10837125 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 42DE514DE for ; Sun, 3 Mar 2019 17:13:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26C9F29D55 for ; Sun, 3 Mar 2019 17:13:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1ABF029D66; Sun, 3 Mar 2019 17:13: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 9B1AC29D55 for ; Sun, 3 Mar 2019 17:13: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=ADugp3RUjpjtRv3/nk1QRsmuoKTlKrcoxn/CeLSbrx4=; b=DKIMU5TWV6jzqW DUaqrzVvuF0KEXE74+w6lBu2qY/sWd2JT7NMhLjyp1lvvD+X0PPWtoCn5d8pa1wVhv29E+WQFX03e HuIQY/tekFbx+oOJ1IzuV56EuyOsIldL40ojCBj0XBO1NVYPP2gihZC4+LQemmWhoGoYoPbiedwRg mlK+UMOlaoS3RBJ02XmGNcJYo8IEQkHSKpkfIXaR60umwK0f9AZNO8DnJBj7PJlZMxZJpWWWmuzrS lkZlg9Av8TaDAMTnDmeCOCPcMlWb53bJRAlm2oofF+dXj7tEp/9mNsKv8MyHq/uplXjSNWPC4cpX7 WWboX/qyePsaoVcxjZWQ==; 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 1h0UgO-0000wp-Qc; Sun, 03 Mar 2019 17:13:48 +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 1h0UgF-0000iX-Qu for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:13:44 +0000 Received: by mail-pg1-x542.google.com with SMTP id 196so1335888pgf.13 for ; Sun, 03 Mar 2019 09:13: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=Nazjdaxsj9lmT9Vl6H8Rm89SYIfCC9VqRFy4LFo9W5w=; b=ett46jcBrstaPoGr+OcvcNG3g5Nqx3vsgVaTU45463dLWKaiPXYfxffSCLbACTusVx PS05tflZftj9Q5WBja0o29O4sYLfpeHjxGFIFwGyqm+VCHCwKcQno5Xge5L6f1s4Hb5T N5n4/yQWvKNQ9oa2lCfkIIBonYJ5fc39XvKwIRExFeiXeRwJxTyXsOByimLsxWJniVPh sPaL6DX06o+VHjxHD/7EzpWGi9iJGsj+AsL0CZWenBD5+9KLqAlza2iPXm/g5a1XxZCX Ll2BtVPm6Z1Ci1BtZeaTSkSTRYEONL+fdHQAJ4Q3pcbjg/jZhjT9tybii+cssFeW2yHW ZSLw== 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=Nazjdaxsj9lmT9Vl6H8Rm89SYIfCC9VqRFy4LFo9W5w=; b=e4v+Tpli919v3mhYH4caFu8vV04ixFuSC+ulfK0LoLXDYHhyC/uU2umKE8Kb7ysssW frozoQilPSAOjEOyuHwEHMbKsuiTg4yOWUIve4hApqD+9QxlXvHJ38i6CTIQXkfqZFNa HOte4OaD64LNqDUZDtJtynz8hAQbYvaCksBMXytSBw+1tpxqp6HQQc1d0184N9eFGjto 1plydqrFlR8kqSrd2C67EY2McBdSglCl3wsXrobDxCvDSY6XSiy6tmRtQ26zECL48d0o BArlyPdNrdTymQI7AfgEpXcRhnsxWrFns4OOSILi4xfM8FL8pvdHuZjN9huYIcsWKhoX GvhA== X-Gm-Message-State: APjAAAXdA56so2/zuu5O4eY6zVomcDFjnMiMrA6kkTBDdPE7BviEHQxl n1TZ5HEqDK7TVEOz+JDKNjI= X-Google-Smtp-Source: APXvYqxUgeWZMbINYs2QBq007Og5WRVCUI9Pm32mGYmR6jbN5jXkWaCvP1QqAXU8UWEfQ6RZSUKeAw== X-Received: by 2002:a63:4c18:: with SMTP id z24mr14761857pga.62.1551633219084; Sun, 03 Mar 2019 09:13:39 -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 e22sm5349412pfi.126.2019.03.03.09.13.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:13:37 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v9 2/7] ARM: trusted_foundations: Make prepare_idle call to take mode argument Date: Sun, 3 Mar 2019 20:12:09 +0300 Message-Id: <20190303171214.24821-3-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190303171214.24821-1-digetx@gmail.com> References: <20190303171214.24821-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_091340_319437_1629C177 X-CRM114-Status: GOOD ( 16.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 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. Tested-by: Robert Yang Tested-by: Michał Mirosław 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 d7ac05103a52..720904a43c00 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 d5d1b7efa02e..40445389ffe7 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -35,6 +35,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 Sun Mar 3 17:12:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10837127 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 B578614DE for ; Sun, 3 Mar 2019 17:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 974B42848F for ; Sun, 3 Mar 2019 17:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 871822855D; Sun, 3 Mar 2019 17:14:07 +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 EF9652848F for ; Sun, 3 Mar 2019 17:14:06 +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=PRdIkd9VR08+eB5HWFIcZ/6VkZBYqELEtom11bzpZJY=; b=PKO3u9XDREsxgi Ufi5vJamQgidQ76xE1Mgr2WsqwIwDObE23QJWEcp5ys2OPaP4uZSKVmrAt7CftlJl/m46WGs20+AB 3dPHUY/wZCj+omAcyi6fx6bvXrfnlSK4b/rgwUjEohcvY3PT5U2Q7uA84Wmoev2jtGSNuAoPhTeBV o3BMO3bkn7nXVsftY+U0zUZqMvZgzEvjSVO1JN1f2D98n4xNisMLVL1pJ2FvouLGJUHbV7RsWA7yD dIJmh2Pntrz+p9PxCaLX5f5/waAes2TBItC1fIQ/Nj5/rigZvo+95SlHdABugHvCOTsPEDikrZ3FJ MiIzXc/62+ROzffg73XQ==; 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 1h0Ugb-0001E1-ER; Sun, 03 Mar 2019 17:14:01 +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 1h0UgM-0000s4-8j for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:13:59 +0000 Received: by mail-pg1-x543.google.com with SMTP id h8so1347655pgp.6 for ; Sun, 03 Mar 2019 09:13: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=09wpTThfZ2pWFmgypLfEoMbwgOxZpXVNvgWK6RajSSA=; b=H3t9RiyhiqIXJPkJEx2r0D5Tx/5itCDkr/LcUSgOZxExrsgdWJtCtaX6VFjYTxSSTk IvfwO/N6d/6+pd9PGPnyshsRKD34EvPAPW1YuQR3q706DEOqf0UEsR2isUH9wqtrPddY FZZpbGwLYqok97YPrSpWyL94doqyDx1fD77bGmh27nT0dC+K8E7u0l6uUVQFQGGdX5NF QToo2R25uP3qntnnMBOmDqfm47hDjWn4eaAmSHErL7oZ8CJr3WrqZbdNlU5Rn9SpjNUT n3hTQeQVqZt0ac6EsXx4RKMhHQoIEIk1L7SrYU/dE94k7d3s/Aw3fqrc549fa1Sq2zRS 3rog== 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=09wpTThfZ2pWFmgypLfEoMbwgOxZpXVNvgWK6RajSSA=; b=FawUiOB5q2cSALOUs7JFfyxRgte7TS4AwuXxBf+Jof30Mai81ExJdjCHojKrTSsvve QSeLujiGav6uLxSXNnvtd09OgI6/bjFUk4K7+Rlgh8b8AGSFB7kHzVInR0OPjQ7ZLsiU qrE5Cdr+JPS6kvHz5hc8vqjIJzwV0z+uQvPEL/TbhLtotH+8gh+wDiLpeCUA2hviSlV6 Oq0zhVDdHH8otn7wpCVBh1jU1C0LgBnvZeaWKZDPtUKXNRAsxmyhpEB8nODwSYqyffG9 OzIVaVLf9MCQL0+lFfyO9kJ36eVFWUFqvsXXE4U3DrhAXz9wHwoSa64Qiv5Kz0AuIGCP XJlQ== X-Gm-Message-State: APjAAAUpAs7ty8PTgjge87hvDGwID/E18SqSaWBVYTvMwGEDGesANnwz YMJph4aeTlm2AA4CKVLzyjHkNqny X-Google-Smtp-Source: APXvYqzlCnIK9lYswSG3Ccr3eckFrqZMrtpwoVwbTTNd+gLesvEy8vQiBSmKMOTrWT9PGSsqLu4qQA== X-Received: by 2002:a63:440d:: with SMTP id r13mr14553203pga.5.1551633225256; Sun, 03 Mar 2019 09:13: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 e22sm5349412pfi.126.2019.03.03.09.13.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:13:44 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v9 3/7] ARM: trusted_foundations: Provide information about whether firmware is registered Date: Sun, 3 Mar 2019 20:12:10 +0300 Message-Id: <20190303171214.24821-4-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190303171214.24821-1-digetx@gmail.com> References: <20190303171214.24821-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_091346_817501_9CA95BF2 X-CRM114-Status: GOOD ( 12.16 ) 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. Tested-by: Robert Yang Tested-by: Michał Mirosław 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 720904a43c00..bb2ee73d9e02 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -167,3 +167,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 40445389ffe7..253747789958 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 #include #include @@ -50,6 +51,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 */ static inline void tf_dummy_write_sec(unsigned long val, unsigned int reg) @@ -86,6 +88,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 Sun Mar 3 17:12:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10837129 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 5AF51139A for ; Sun, 3 Mar 2019 17:14:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B332848F for ; Sun, 3 Mar 2019 17:14:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 323EF2855D; Sun, 3 Mar 2019 17:14:22 +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 D6B362848F for ; Sun, 3 Mar 2019 17:14:21 +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=j03uu/r8o4qsWT2LZI1uqljkx7JfjwgH7YBvOdahonE=; b=eATSyYXqaDYLPS 5wLjQodenq46vr8uhX4e9fDTVzbUcQKgyjJNyBE6zfUsrzK9e5DOBqcaJLTJvgMnz8/lSzrLUXbJn 7NtTK5Cww5c4DdHQA1k/FCMlXB657pqyku8gFU4sVD7500fH7F2gRLBTqTgoVBDgr2R1XoYy/Lw1p JLwEtITUBIjIpO4ui4MyVxO0N0RJ6GcIESX5MgvTacgmKxmsFpwzZ7ingTbQZ2DcDqXc4sZrK7E4n 08YNKrikOsBUazfCVw+6FjhiKXtFwX8c2R0ipChDgRyblNadWZEQQ40t1j2zB4tTQ4JjbpDV3WG9p bguBwxBeQMc72tpkuoaA==; 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 1h0Ugp-0001X8-Sn; Sun, 03 Mar 2019 17:14:15 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0UgR-00011N-T2 for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:14:11 +0000 Received: by mail-pl1-x641.google.com with SMTP id k2so1358881plt.3 for ; Sun, 03 Mar 2019 09:13: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=yq5wxwSzSOiQKae/Fl8cjis8j+TFJgO/dAYMPjapJ44=; b=MtD7TBbXLyW6fjethOzFExYZI8piXlJEpV2qEZKIYUw42knJE9ItuU5wuzL6Ign6Sq VF0KfgM79UEJNfn+oQ4S/e5QtgXk/5UwNLdW/6tdFh2BI+PQMgcNMeig8XaIQrm/FpCC a/BU+Owy9YzpICcSwliPiU9NYFSMpSU4pGmXeUXOUEYl0AUz9Ux1HLWsGAOPBAjQgp5v bW0+ZV9SWPUz/A4c0b7/2E6ejxVY3Pc2o/JGv8IzOPBygQVYiuRLD+S49/WekIttte0+ Wo/fj8OMKyf0bgVJ9Ju4oY0ykw4uaZyJ8jCusKEJ4bd9RC4Tmx0clVkqRfue9khM9bxa 3rZw== 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=yq5wxwSzSOiQKae/Fl8cjis8j+TFJgO/dAYMPjapJ44=; b=NUdsQB6kxG4OWJpfPcJazYxcEKWt/dWBZmxlTs6fQ4fX7Pka2FymB15SjN3IqkT6HY zf0lAgfnGMKjHXjBAvPDeGkW5WzgZTfbSoykvbS8fOPx00K+2ImGO6zHPtfsol1JeLBX atXrhOLF0bpnVG6X2G+qPujxNXk1ck80riV12bXfVPBoxOdFoAqENcJVmB6D5Eo6Bvz3 dcN/mVlnExSPq5owoRy5w19f0A0524tddInAZcaDvDt34w2h9nbpPSu3HItT3H7OJ1Ns BxxjQO7TLCq2fIeehZIpE0xVju2sZgcWOI7AD1IncPDuAuDk9iM1FTc2T7KyP2jzhhJ1 IrFg== X-Gm-Message-State: APjAAAWdlPFc+U7QrjpbQBG+A5OV4917nYb/puM5bP/WycZmstgDj0Fo GcFcuD//WW2KJSijqWY6DCk= X-Google-Smtp-Source: APXvYqysRSIMaTkF2jEZg2EV10D31KYgs37WSSrRrIQwB1hI5QxwgHTB/mbyIiwICzZXKvuEzHTqkA== X-Received: by 2002:a17:902:33c1:: with SMTP id b59mr15885023plc.220.1551633231506; Sun, 03 Mar 2019 09:13: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 e22sm5349412pfi.126.2019.03.03.09.13.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:13:51 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v9 4/7] ARM: tegra: Set up L2 cache using Trusted Foundations firmware Date: Sun, 3 Mar 2019 20:12:11 +0300 Message-Id: <20190303171214.24821-5-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190303171214.24821-1-digetx@gmail.com> References: <20190303171214.24821-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_091352_439852_D90083AE X-CRM114-Status: GOOD ( 13.18 ) 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. Set up the required outer-cache write_sec() callback early during boot using the firmware API, it is always a NO-OP on T114+ and is NO-OP on T20/30 if Trusted Foundations firmware node isn't present in device-tree. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/tegra.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index f9587be48235..1e89cfefbf68 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 @@ -74,6 +75,7 @@ static void __init tegra_init_early(void) { of_register_trusted_foundations(); tegra_cpu_reset_handler_init(); + call_firmware_op(l2x0_init); } static void __init tegra_dt_init_irq(void) From patchwork Sun Mar 3 17:12:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10837187 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 7FE5214DE for ; Sun, 3 Mar 2019 18:10:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 656FD29BA7 for ; Sun, 3 Mar 2019 18:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5640129BB0; Sun, 3 Mar 2019 18:10: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=-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 3440B29BA7 for ; Sun, 3 Mar 2019 18:10: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: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=YZbHIbyTnhvBLJ1/cyAVcl8amvKCmycwiwrtnWitQio=; b=f4Y6GRa0zU9+gj hNade3ql1Ow71psk8qywNtEdpR63lLYq8+EbaLgYd+MuzkbgsCW5OfwcYWxPzLc93xFT8qSwe8xwn n5dReiLkvdNO/PYwbC37XUZp4WnE/rbpzn5+vGyoLXaZJcB929yUipaUzFqNykZMAB4Zu6VYhifUN R+gu8CwlQ3f63/GZO9xkWvI2eu/LgE5N8X+pfm9ZiHxC9oShH1yAE0NbwiNzS/IUa/XGourHBQWV4 S/C9roVPR58rVzBU7qnJ/VnA0pfH9hnkbVyRl6Biici5DOvPvsFq2fgc9LXGi+v3aD5vwaaPugehq 2zbVauv3procSjS6H3Ng==; 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 1h0VZW-0000yS-Gx; Sun, 03 Mar 2019 18:10:46 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0VZU-0000yG-AN for linux-arm-kernel@bombadil.infradead.org; Sun, 03 Mar 2019 18:10:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=buciGHsipdLQFuQo4BFBFhcyxYei+3vIbC+6BJ6jYFQ=; b=TE82O7NW6qq2QOpW0gTXiCk5v2 reiwKpNygC9k4Cdpi/E3ixiPcByqvIvygXMU8SCot19P3QG6DQ7Ysb233zm2m+y1C60GhsfQR9EZs /n4jVEvt6d8Rvd1vdGFr1kHx/H6j3aTbz2Uvrdbf9uLfycrvdOA5SGZz1WN0r1OwDfV8i06vSf7TN tf8K1QkK9u5kMYxMDcmHAWArXaemA5dOnigpiYxlccLG+0G+LBDDTeeT9ni5vdXEvemNsQSc180v4 qxm8WJONSZZqySzVCHM8GIer5l3+2lTgFnsNEiD2OkgbWxf4S5pYETAWbjspDNoSd/gjniHq1HBdJ oKO5qTQQ==; Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0Ugf-0007dA-4O for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:14:06 +0000 Received: by mail-pl1-x642.google.com with SMTP id y5so1348212plk.8 for ; Sun, 03 Mar 2019 09:14:00 -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=buciGHsipdLQFuQo4BFBFhcyxYei+3vIbC+6BJ6jYFQ=; b=Taj43xsj5ircTOgqnLYTo21UaXCH5rYpbmC2ssYt31/Q90ds5shENkdEyDMl3oRPs+ ar2h0QnFUPLLGgTs0vRC0uQ4UrAdbMf3MOC/wBhy/uxuJU7xQrTMgSZEAqgObriqswJO fsKYqMW/noIAGaY9hz0cTUY6r8tbn6Ucf2ZsnP2IMDSW17eoOKR5YZnSF4c7/sGfdMoD q4wzNePj6TUJgsOYcqkVx0yWTefwgwU6bewpZZ6/mqUjMLRGLs/huA3xudyXAktyYh7n WmNQSmTy7hqdOtyce74/Ub+OXEVV5R35CQSKCZj1Jrt6U0oQahPItFvFKLfY98g+qy3o YeDg== 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=buciGHsipdLQFuQo4BFBFhcyxYei+3vIbC+6BJ6jYFQ=; b=J1nRtfd74aujh7D+widw12UsgLg693g1/BXOzQAecpVcQlzHUuSg9uwoyWBGAt3YJC eRqY/iyUp+hml+5u81GahUnfqASBgz88G8fy3NClAt+hb+S8qoMnq+8m0T+6e2xz43Z2 p+FuWHx/ju0m6utuk+LiXJVILZWVqJOSvYcYH62zP4utWR7MZfQRUAh4SvZDTyxlOFIZ Hb1QYLbc6anWvdDNKmoNNDd98KnJzy/4ZzTHW9acYG5PEEkOHEYkVqV1eGI8560J60hR S+yI73sHQ7f+oBteAYWt9fq1d51R6kUWbrl912xUCUNpF02y/UQhXQzukOc1EdA18gKx R0zw== X-Gm-Message-State: APjAAAXrkBqUCz4ohsWh4pHAAPnmf+plOjOUelUTIWzbiT3PkE+A16Yn aG5a4mN0CkXj9k40XcX5Ek4= X-Google-Smtp-Source: APXvYqxdhTjL2GUEPl23GkRtn+9EX4/9c7cliAA2PV7vhrfUNc/v+j1DrdHHCuYlZkfyup+kwuz9KQ== X-Received: by 2002:a17:902:45:: with SMTP id 63mr16286052pla.281.1551633237659; Sun, 03 Mar 2019 09:13: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 e22sm5349412pfi.126.2019.03.03.09.13.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:13:57 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v9 5/7] ARM: tegra: Don't apply CPU erratas in insecure mode Date: Sun, 3 Mar 2019 20:12:12 +0300 Message-Id: <20190303171214.24821-6-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190303171214.24821-1-digetx@gmail.com> References: <20190303171214.24821-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_121405_199973_09303AFA X-CRM114-Status: GOOD ( 16.25 ) 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 Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/reset-handler.S | 23 ++++++++++++----------- 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(+), 13 deletions(-) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index e22ccf87eded..809fbc200cef 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 - strbne r0, [r5, #__tegra20_cpu1_resettable_status_offset] + strbne r0, [r12, #RESET_DATA(RESETTABLE_STATUS)] 1: #endif @@ -277,14 +279,13 @@ 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 Sun Mar 3 17:12:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10837131 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 026C1139A for ; Sun, 3 Mar 2019 17:14:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D892429D98 for ; Sun, 3 Mar 2019 17:14:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA37A29DCC; Sun, 3 Mar 2019 17:14: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=-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 7591729D98 for ; Sun, 3 Mar 2019 17:14: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=tmEIy4ix8y1V6gB/wy7dkqMMlPJlhpNVeXVLLV2eswE=; b=koCrIkWWJVCTxE V2/VpmhasT7XdRKst+VlHpW4vcfifZBUCYNaBpGct21YY1bIe9AaB87w2uVBOm8Y8zLC/ui30R63x A6Sy7YrP1O2nm6qWx24XVQfrSls5IR1rHEa0XNEOaI2t3cagPsIA8tv1TpHJXOVTrGQzNuq5E/2cZ vbKKaBCQHhSqDW3rDJdNQRAtsD0pSaztZ7l7grAnFHstxyA/Yf5iN4/3qIHJVqejp18kqY/3lzZ2W fOgCq05/YzPC+N7xckZqwuFYhEUF60KRWEL86fKnWoNGoZj71cHolY4zUBPopUpU2cFICdabSY73d areNHTChm80mvUDbIfew==; 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 1h0Uh5-0001pP-OQ; Sun, 03 Mar 2019 17:14:31 +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 1h0Uge-0001HY-JB for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:14:28 +0000 Received: by mail-pg1-x541.google.com with SMTP id u9so1346039pgo.7 for ; Sun, 03 Mar 2019 09:14:04 -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=JuH8Ap/N0CCqMGuBFEsBfvavZHslxZuq0RCbP2Dsuc4=; b=GVN0WZ1ccz4yXnERhF3aF4XTdfhZOFD5UTa9Gh1U05Xzr3VKrZ27x9IFApDU/gL3p2 Fm6uRDwZsrKxlpjQX6Kaas0xGkHOkhpjrDDCR7JuMpAtzewy5GTGjjcXm2NNPYhTliTG Y1uo40O5E33d4vd6PLZakHaYDk6keeQo9m4lJffR9ZDCRXLoM0DvezWjjm2kljcnaFve Ch0p67BJwrzpwOx/VzB4GC7P8d9nmqKh9jM/2s+zKHbR5Btc+7zo/mbSBYp813PKSUFs m+3PDhqkFzPQ5zsRovZP+nuPJe9YpS3SEu26c2jQMLHtZx33L1J0O3bJFSlrozIGgZXz t0ZQ== 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=JuH8Ap/N0CCqMGuBFEsBfvavZHslxZuq0RCbP2Dsuc4=; b=AKHRJM9nMGwwrMDSE2cF6khu/hEDSmpxlG4aS8/U8DhBNzGOfL4NF6U8US5X26td5v u+dAe3JkIlJfT5TPJSp72XS1KeC8hfDoAF0kjTQa6GbeXNvp6R0o3afiH32zemdg7R4l DGNAsnzdoVfqN98TLxd7m42dzDe4Jg68Zn+UiLKwJ4BeUOxK6MNBDkLTOeGEdtU9+dfe wDz2ABJfjt4Bs4M5CmsEPpcU0doTsB7nfvCF6V7ORNxIBpdHvB7u3TCqvU9hgsAs5BAr 98lo0mHD/r8W6Kuhd5d7usG89jbRdkuLPAcYxq2CSyk+1akGlj52rfgnfFUzVW88thnv yapw== X-Gm-Message-State: APjAAAUUHz6SjYxe26L8zbgBSpiqk8nj5GlbZgZ15NGbwwPPBPBwMma2 fmm3Rx7XNsqCeG/ulsMACfE= X-Google-Smtp-Source: APXvYqzbLlxWyEhg2eojea5F2ZLAM3FNNjHl1s50wR70kAVK5vJ98/a7OtAFTLrsCDN5nS1pIxnvNw== X-Received: by 2002:a62:39c5:: with SMTP id u66mr15648749pfj.245.1551633243840; Sun, 03 Mar 2019 09:14:03 -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 e22sm5349412pfi.126.2019.03.03.09.13.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:14:03 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v9 6/7] ARM: tegra: Always boot CPU in ARM-mode Date: Sun, 3 Mar 2019 20:12:13 +0300 Message-Id: <20190303171214.24821-7-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190303171214.24821-1-digetx@gmail.com> References: <20190303171214.24821-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_091405_156321_A123D5DC X-CRM114-Status: GOOD ( 12.51 ) 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. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/reset-handler.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 809fbc200cef..31fb53f9ce13 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -113,6 +113,7 @@ ENTRY(__tegra_cpu_reset_handler_start) * must be position-independent. */ + .arm .align L1_CACHE_SHIFT ENTRY(__tegra_cpu_reset_handler) From patchwork Sun Mar 3 17:12:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10837189 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 E7DD014DE for ; Sun, 3 Mar 2019 18:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D487729BA7 for ; Sun, 3 Mar 2019 18:10:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C528F29BB0; Sun, 3 Mar 2019 18:10:57 +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 3054B29BA7 for ; Sun, 3 Mar 2019 18:10:57 +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=LmHBasSi9YET2EX15rSRr/6CEDqfFgjNNLI6kGolkg0=; b=bAIRjMBQfCqv1Y MAEhTsmrTEPPQVt8aj/quD9JnyPAP42ptnA62qLwPK4RiEqQ716OkmynMgoZR1300mRHo2aYfAHwy WYgflJ2BgBQgk+npyJExs/Y5+ofQqip2nSPmfsjX3RBud07U/IhiQYXATHFYTEAQlmty3071isPHF 0KMZry/ok23jju5ouVofU6voscsSsYC380IwgDJGhF/29ouDNP9EjQLL/tzpFKheViod0W20JMGbO ShPNwKhpmW2X2w1/RltQXdLSqjOM95KnbDJ4w2C2E0Fmw3is8NxrwZgq8a+JeMDMOu7PaMMnCiCLL ZpDTYS5w4SgSv4oYhP7A==; 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 1h0VZc-00015O-GX; Sun, 03 Mar 2019 18:10:52 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0VZV-0000yG-Vo for linux-arm-kernel@bombadil.infradead.org; Sun, 03 Mar 2019 18:10:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=S/ZyEhorrdTBL7u6Ya1Op9P6A1v1DuFjJTJQoxPu4VY=; b=XglI4BCxHEu0DEMGujMeeQS1Vk 9Ofvlox7fWEizOvTByTpiq8rNmAcBREfu75p/ZQeIKKQ4VjkyJfWKX9EHQrnpF7wDwpcPbGx6PNHl 1W3kQZCn+CkBHuZiEv+3GZTuG8z7TB1B5k4Y1+ppQ0Q+B+YIHk7w9x3zpMgTQpg1UZdYcuq5GrSyl 4jmmfcBjDVoH9z1Fe4Hu7t8+xwOnAqsOurl+gkO+1Lzwzm1c8t+5YZ7o78o7AFN1/YEzr/3bsRz79 fOvpxOalyUo59PIIjR3bn1xGZtMT9YhVCw6t3Br5GASV8IXG5V/epSoi/FQ2C1xcHmXeUNmiuMuUA pdiarufQ==; Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0Ugn-0007df-RY for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:14:15 +0000 Received: by mail-pg1-x544.google.com with SMTP id k11so365704pgb.8 for ; Sun, 03 Mar 2019 09:14:12 -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=S/ZyEhorrdTBL7u6Ya1Op9P6A1v1DuFjJTJQoxPu4VY=; b=s8ZuZV2/I3zwZe/kEfY/j0eXq+/h3U63yAwipL4Q2dB5hrlOhAw1eXik/Ldl2LGqUN Hi7aUatMPx7iUaTBQ/MrX89hc3L5gxmLnm3lPIIQLz4ZCjwRWzxQqlJdHyD3TJwskRTI iHe+S2oP/xYlQeJwEiOapE6gnOSrP1XMp/404RAePQS8UKUDIjrY5xOMGDkFGWtE1kvF L2jpV24u81Z/1ETwSq402YHgAbSyYArH4RiLOYB9qNmZdyJ/5AD/CmLZ4i95IImsE22J KuwIsC4qbrL4CLC1yhPiHV+vkhN2q7v1nHzoY/7Mi+PGz8dhL69vSKhatyeSMb7lDPfo 7Z1g== 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=S/ZyEhorrdTBL7u6Ya1Op9P6A1v1DuFjJTJQoxPu4VY=; b=ulxHvkgNk+8SslXvIb6cjAVA5vVMs7XpzMUWbj3N/Tc0Ozik44E75cM+kBxy91beig 5DV33EmS4gpXvkPlI71XYu12DqQp02Ggc+46cBd1uloUNuX+n+Vw5LepSLDSCUQMvcxd CjIEhu8STX5OToEFcZEJs5XRgcOoYGo/kdspT7dwdLeWSIcOG0+BcYhohOCXOwdWtkKr 6kPqWOHTcFPBjmNHH4d7mHlqES7ptWLLWeXXp7VHtRhFf6n+mu+zq0vn9Yx3YOnmoJ1a V9xrsGFzAImxm6sAHhUKippyd7hq0AoGe9/wACoPNi7w9+ldoKZB9DTJXVfQFkjTJviW 8yUQ== X-Gm-Message-State: APjAAAVPVAM0IRJY9DpEPxYKDGX8FV5jD3P2B0MRsdYjibwDOEu/lZW9 ETXE+2Q6LlRG/dL5vsm5334= X-Google-Smtp-Source: APXvYqxfLsmRAPRznfkOu8fnFfnK/wUWohnVxn/0K8ORSBztGGzCLcypK9JtpiFfz6FPWuVpZFC/aw== X-Received: by 2002:a63:d49:: with SMTP id 9mr14576916pgn.27.1551633250262; Sun, 03 Mar 2019 09:14: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 e22sm5349412pfi.126.2019.03.03.09.14.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:14:09 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v9 7/7] ARM: tegra: Add firmware calls required for suspend-resume on Tegra30 Date: Sun, 3 Mar 2019 20:12:14 +0300 Message-Id: <20190303171214.24821-8-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190303171214.24821-1-digetx@gmail.com> References: <20190303171214.24821-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_121413_932172_8D37B14F X-CRM114-Status: GOOD ( 20.27 ) 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 suspend-resume CPU with Trusted Foundations firmware being present on Tegra30, the LP1/LP2 boot vectors and CPU caches need to be set up using the firmware calls and then suspend code shall avoid re-disabling parts that were disabled by the firmware. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/pm.c | 49 +++++++++++++++++++++++++++++ arch/arm/mach-tegra/reset-handler.S | 26 +++++++++++++++ arch/arm/mach-tegra/sleep.S | 14 ++++++--- 3 files changed, 84 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 1ad5719779b0..abf5f88778f4 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -33,11 +33,13 @@ #include #include +#include #include #include #include #include #include +#include #include "iomap.h" #include "pm.h" @@ -159,6 +161,28 @@ int tegra_cpu_do_idle(void) static int tegra_sleep_cpu(unsigned long v2p) { + /* + * L2 cache disabling using kernel API only allowed when all + * secondary CPU's are offline. Cache have to be disabled with + * MMU-on 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-idle + * code-path only for Tegra20/30. + */ + if (trusted_foundations_registered()) + outer_disable(); + + /* + * Note that besides of setting up CPU reset vector this firmware + * call may also do the following, depending on the FW version: + * 1) Disable L2. But this doesn't matter since we already + * disabled the L2. + * 2) Disable D-cache. This need to be taken into account in + * particular by the tegra_disable_clean_inv_dcache() which + * shall avoid the re-disable. + */ + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + setup_mm_for_reboot(); tegra_sleep_cpu_finish(v2p); @@ -197,6 +221,14 @@ void tegra_idle_lp2_last(void) 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. This is always a no-op on Tegra114+. + */ + outer_resume(); + restore_cpu_complex(); cpu_cluster_pm_exit(); } @@ -215,6 +247,15 @@ enum tegra_suspend_mode tegra_pm_validate_suspend_mode( static int tegra_sleep_core(unsigned long v2p) { + /* + * Cache have to be disabled with MMU-on if cache maintenance is done + * via Trusted Foundations firmware. This is a no-op on Tegra114+. + */ + if (trusted_foundations_registered()) + outer_disable(); + + call_firmware_op(prepare_idle, TF_PM_MODE_LP1); + setup_mm_for_reboot(); tegra_sleep_core_finish(v2p); @@ -342,6 +383,14 @@ static int tegra_suspend_enter(suspend_state_t state) 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 31fb53f9ce13..cd94d7c41fc0 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 diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S index 5e3496753df1..1735ded5a812 100644 --- a/arch/arm/mach-tegra/sleep.S +++ b/arch/arm/mach-tegra/sleep.S @@ -49,8 +49,9 @@ ENTRY(tegra_disable_clean_inv_dcache) /* Disable the D-cache */ mrc p15, 0, r2, c1, c0, 0 + tst r2, #CR_C @ see tegra_sleep_cpu() bic r2, r2, #CR_C - mcr p15, 0, r2, c1, c0, 0 + mcrne p15, 0, r2, c1, c0, 0 isb /* Flush the D-cache */ @@ -132,10 +133,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] + tst r3, #L2X0_CTRL_EN @ see tegra_sleep_cpu() + mov r3, #0 + strne r3, [r2, #L2X0_CTRL] #endif ret r0 ENDPROC(tegra_shut_off_mmu)