From patchwork Sun Mar 17 22:52:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10856647 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 D2C421669 for ; Sun, 17 Mar 2019 22:55:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE74129211 for ; Sun, 17 Mar 2019 22:55:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B118B29250; Sun, 17 Mar 2019 22:55:51 +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 065D129211 for ; Sun, 17 Mar 2019 22:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KtoVNA+NVY4PsYVIOC1p2tzeGKX6IYAJfB8na5jGZMk=; b=SREV5y7vKuBL4z It1Idnoor8ppnNqRuskqV5mji71cY6rZNq3z1LZFIslmcE8rN54Cfl11c7CnfZI8/DeXt0F9HoB2X KbXIj3lQts8z5cXUDZJJJdprujX5rv/zFmq9RSV1zY4Gjqicz1exrCMGd2og9WIb3dDSIH3IewijT xFabLQwUbbhG1IxjGZBFiMYtMhOl4XJ7g/lCGdlMTCramFf+sZHgunAxdbUCbEed74GSmawsYq7ME 8tvlOSA1H3zGtr6BAv8/6PInV5b/1xixELuMrXFfE56JDLn63jfooBv6t3IWKFmd5yuCGxfOmIJPG Skt2wPgkxcUirP9mkcGQ==; 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 1h5eh3-0006zE-8B; Sun, 17 Mar 2019 22:55:49 +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 1h5egs-0006ps-Va for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:55:42 +0000 Received: by mail-pg1-x542.google.com with SMTP id r124so10045134pgr.3 for ; Sun, 17 Mar 2019 15:55:36 -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 :mime-version:content-transfer-encoding; bh=HSikdKeOgVMUbPdUvSpI1vxVe2RfmJf1h+7n9WQeyU8=; b=PEi36b5zpTEJmpsUOoisFLOi8d0Q0wXGJL03axzsB31v6fjwhnROUduUsTzUDN2VpB gdU0L3pNl8GVgRy6yvobK7eIMSxSRgXn4jx9PQw2Yo+zbjqohE2vQKoy7Jm6uYV1jo9S wdotEepLqUf4MPxOJPrb5dcs/Mm4Mc1tMd9zyIiZRk13wBSSBTYnfNDG50igZstmMsaX 5YWRmFDIHrLNoIxSIdRiaWvuoFaZ/zKuGhx55wWjIgVZgo5I+OahEOdF1QZHnVywEXsn /7E07VUQBssgr0tIrT4GjqKOqQghkBNFwQbDGV/VoljyQ1px4irDTtjb2eXobN9W1Xzq TvpQ== 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=HSikdKeOgVMUbPdUvSpI1vxVe2RfmJf1h+7n9WQeyU8=; b=kXcjFVYgIWE6FEy0bBlqTuXLRQWheDDtjDJEIUKV8J6Bb+gy7u7JLF+JUwt8+lvmR/ OlHCTb4vj5H2BqVavEKo3SnONPxqXzJS5gluwGXbecopTBwasbiNQRnglCIRTsCQj8NG h8xbTyOPhIuI6nDE9mV9IK893sNOdtlOdDpQB+8ImzExnRxI2TauoFCMqBLxM9FrmAYp D7b+Q7oGzs1uWM1QroDi25AAOHoEVjNeH9xtSud9Sfnvat/lDwmKPPVe9k7kPI+mlky5 jcLKvZ9kGT08a/LQD5P246FmeTIg7Yx8B/cIibuXEd3e+PC2bu5EKJv4cF6KtJejfPQF WULQ== X-Gm-Message-State: APjAAAUCVc5Tyl0VvcKYWXbLU2I4/ZD1UdfO2Zab72J04bJ0PSsaO/+k EWxlH0y8ewH7gabjGbm9s8Q= X-Google-Smtp-Source: APXvYqyHAAmmuTYlCvbEWrpAnISBYqSZKxjOQsd5C8tcZzyRaWynTw9dZDqIz6Oll/Xt9t5tQfTRFw== X-Received: by 2002:a65:6559:: with SMTP id a25mr13688586pgw.99.1552863336090; Sun, 17 Mar 2019 15:55:36 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.55.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:55:35 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 1/7] ARM: trusted_foundations: Support L2 cache maintenance Date: Mon, 18 Mar 2019 01:52:04 +0300 Message-Id: <20190317225211.23091-2-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155539_162983_610982AF X-CRM114-Status: GOOD ( 14.88 ) 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 | 10 ++++++ 2 files changed, 51 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..9e6a41e9215e 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,9 @@ 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) +{ +} static inline void register_trusted_foundations( struct trusted_foundations_platform_data *pd) @@ -53,6 +59,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 kept 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 17 22:52:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10856649 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 007321390 for ; Sun, 17 Mar 2019 22:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFC1329211 for ; Sun, 17 Mar 2019 22:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3FB529250; Sun, 17 Mar 2019 22:56:05 +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 5A3BE29211 for ; Sun, 17 Mar 2019 22:56: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: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=mrmWjHEJsJRB5SXaFX5f3yp7ahMG/bAeMvZz8IH3lEA=; b=JthoxV5udI6rTC UWoMJ/NrcKNfytOjwlyVQEL+0md3dbS4TmR90J5DpnVhKd/r5kLzI2SOYKcq/8RLHwNF2m9vLsf5i eUGBWKDoNzFU96sbcnyu3e1dj6/WVeBYBI4OJVQfX0p3aUtikD4XOn+R4+Qpri+pfv9/b7poabb+x SLfe9UeNdBSUM0R2gYh40cuiiE4Pp9Q3sqzfkPIHFn1XNd4TmbOq2/07t1E+dEvcl8tGvbwVTQjGH Ww09nTAbzWCmYjurKntxanmPIYPG+x1G4dAkCshXAW275A3PZfwEd1WyKbqoOb6jcmJe1IPzhWe3n HREhvS53sGijBiDogRIA==; 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 1h5ehH-0007J0-Ql; Sun, 17 Mar 2019 22:56:03 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5egx-0006vh-0H for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:55:45 +0000 Received: by mail-pf1-x442.google.com with SMTP id c8so3275601pfd.10 for ; Sun, 17 Mar 2019 15:55:42 -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 :mime-version:content-transfer-encoding; bh=GW0CJWrCEGpuTDu8JaGzJeC7YDvChX9uFBrKnKEZVBA=; b=sv+rK1y5xzW9mhrWvbgSjlJEXgHP20APMLfab+9HoNTt53IOXTXU2LpTsgzocI8r38 4f6H3BvW+B9BBfLrhZorTU6EiUjuDozASo9sdNH/cvKqQjRDRZPBFzL8xBQTAlMUCXLF TiyPz5zOt/iPgfA1Onz7vR4BAdpfTDRhrs9FydZsUuR2jnUvR3AdtDd2rAsdXNXPlOV9 4D6fjxwWlAg5rBAtMoZamrpCkWaMn8kASvyBsLmgi5sfzaCf8KUkdTPwBzr7MVfj4M1v vD0hzAx3Jkt8KkkHpfeToXStUzTbbzhmP0GQBps1LFpnDJS9xFgM5Os2CmRAA8RBNiAO Wpog== 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=GW0CJWrCEGpuTDu8JaGzJeC7YDvChX9uFBrKnKEZVBA=; b=ZJY92//7Taae24G2BL9T6lQ0befJkovDihZCUtIfkiPDdslqBKmJRulaK3MY4FwpXv R2cq4ZbDX2CWMH2uwr+L6jUlq4ji3P0e/5pgEymNi4htFWJuEmgW7JN3tMH3NSjryR3h SZoLQMPjRuLBeDcvpNZUHG3HEvVrsR2ayUuLzAs3Ab1SwsMWPDtF5xs1Dtcf0OOI58kF 6P8HAun0PZ1xPhcIsfI/79lyvhbs7xl6NYfVGwl1a7NEIAzMAIAInBn4FBdVc1jg1wVA pGKLWZ0oGb+TTYudoPi2bP8xeI7mXrYlJ39TBHwbG0Knoh/lT+iB2YID79Y1WKyvQKq7 cdtQ== X-Gm-Message-State: APjAAAU4UqwjgLOuJR7GftGK6UbhMWzv0/yOBbkyEp4BfddtezAr26ts CnaREOQ9ZST61xkONcfzS8A= X-Google-Smtp-Source: APXvYqzqktU5qj7d4vKKC7/iiSYG/lgW+0X+5nLieaLzGJ8atcp2XBicOQfYf9eDAZg4LSnzcgly1Q== X-Received: by 2002:a17:902:bd87:: with SMTP id q7mr16420755pls.227.1552863342532; Sun, 17 Mar 2019 15:55:42 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.55.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:55:41 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 2/7] ARM: trusted_foundations: Make prepare_idle call to take mode argument Date: Mon, 18 Mar 2019 01:52:05 +0300 Message-Id: <20190317225211.23091-3-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155543_260537_75213793 X-CRM114-Status: GOOD ( 15.11 ) 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 9e6a41e9215e..201ceb259e71 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 17 22:52:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10856651 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 C7F7E1390 for ; Sun, 17 Mar 2019 22:56:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B375E29211 for ; Sun, 17 Mar 2019 22:56:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A79CB29250; Sun, 17 Mar 2019 22:56:21 +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 4F73F29211 for ; Sun, 17 Mar 2019 22:56: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=YF7vAZujZYyRl/HW7Zm4B7bOLoJ3AtNlbImBXOkBi9Y=; b=kbf3LKU7F0Jfjh rMQvMr9/lL0VKrKYZ2AnabTSL4jLtLIoRPU3mKRIN92h4P9IwtQAQ5+m6B1Wn383eFVv5lxJ7Jaf5 ANqBA/2ilOo80RxYgDSvilw1FBgQZY85l43OdCeoKcLyg98GSg1UvlOheb26HIBgp2kZAjo84lzTv o9mBD5ATZP4FMk7OhwynAT2hi0sV2WMCHAGIKENMofU3r0ltnnE8rh9Yc7HCNXaOgjk+TnQXBOPge vFY24zH1UYYw+Fi1vbKruhbAkNVP4S0s72UijcWdpGT1J5C2+GIt/ryKAnZcfExcjIFUxnH7JrDwI OVwP+f+CrJ8GgAkhLIsQ==; 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 1h5ehW-0007aa-05; Sun, 17 Mar 2019 22:56:18 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5eh3-000742-D2 for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:55:51 +0000 Received: by mail-pf1-x444.google.com with SMTP id c207so936960pfc.7 for ; Sun, 17 Mar 2019 15:55:49 -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 :mime-version:content-transfer-encoding; bh=wNzJGGyEOize1LzTO0+y1Kgh6PGMJqQwtkfpH9Pt58o=; b=KS/HPJoCizQS/MGEIiwJMWEe55oqGw+mflnBa/9xG+7mjBVs6x+v3qYAUIXOalW1fW RJvQAFUTBDry4mmHZ1meEYtTZuSUUjphqLiXje1IrRRsLJazt3A26MrMcj755njP8XZF JXvmMoW8nWThkHRw1JwTfHm9qDXkGm8kKl2bPfcC8QEjVGItEwoeCgsJo+ViGMpzozll qmGG/1RTouaymqGSg/V7qlPVsOAtRHn2CD+mnH076g2fr9PJfGH4fiSftTHvszPkPlqF HxQe6cT9FmzPj7k7k5ccXMHqzSjtuiScme0EIgQmwI9sv3VWqo+ntVAmQ6d8OZb3O5Pg JqGw== 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=wNzJGGyEOize1LzTO0+y1Kgh6PGMJqQwtkfpH9Pt58o=; b=JfzTOlAQywTjI8MpDDWdlSnH7kRyZ21gVEWICpU0kJxbOfMO/gbHxtXRM1qxBkzGl8 4cyjrmCQYIplEvP1bPnGYXJt44gOjJpTh8oUwkSGpuzUjfnpNf/PNSfOYA30tnASUt44 GIx0Y1/p0kcCQ49PjWqE1lZ7Nv2YiRqubCr23HH4VeCfzxRmQ8+osgyrRrsBDquHmCz/ 1uZN7oUE57RCXr1OxPBmqlM1a9mSV/j6a1lwRGfg9z4ByV4ewItCw5EeXDJ7JQQuAxc8 lXkCp24E0e6lcXRVn7lxTKRVp7snmd30HluIiNui+zToriHS1FYA0gHF3Xzn+IW18DgE 9GsQ== X-Gm-Message-State: APjAAAW+5ke8B4heFjZVY81t/iNdl5Ic8JsACymjXk+hYJSXpiloQkVM fkJnP/RcFnri/AiXAreaVTQ= X-Google-Smtp-Source: APXvYqxcTo0Wcwu7bj5yIzZO1FtGxruGm26JpgvnPbswyc6Ya5LV5ZdYzM83DkpdMWOd8mh7xXJuWg== X-Received: by 2002:a65:62c2:: with SMTP id m2mr14666478pgv.348.1552863348757; Sun, 17 Mar 2019 15:55:48 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.55.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:55:48 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 3/7] ARM: trusted_foundations: Provide information about whether firmware is registered Date: Mon, 18 Mar 2019 01:52:06 +0300 Message-Id: <20190317225211.23091-4-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155549_864470_A3EAE208 X-CRM114-Status: GOOD ( 11.54 ) 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 201ceb259e71..54513c533811 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) @@ -84,6 +86,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 17 22:52:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10856653 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 A448F1390 for ; Sun, 17 Mar 2019 22:56:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9008C29211 for ; Sun, 17 Mar 2019 22:56:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82A7029250; Sun, 17 Mar 2019 22:56: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 6C85A29211 for ; Sun, 17 Mar 2019 22:56: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=j03uu/r8o4qsWT2LZI1uqljkx7JfjwgH7YBvOdahonE=; b=QCsm1Kco2PyKHa Qc2F9WSSHMGHrn3QMY50lb/QnYkVsM+E3fXECOoNim4jp9jRMGiMV2T408CNdJ8J2TnCQ3sQVlq5y 38iA8RV4gWKnqEmnNlFWrZgH2Kgs7Us/RPHlGSNPlTWyPAP1XE9nQzJnaaDoA+83kPFLR3pJ/TIr0 QXa0IE/gMpoH/8ke/pQHtScQ2+WDoT1xgyr1Vwv69kb2L5lW3SI80QIlOZ5bXbBsCSLyukcA218GC 6Xn6kJ6Ze4zH7uSy0WHcx34Vw4CNWoqcMeWA3wMNmsXhHHTBxsnOlxUEtcCiyDbTrzkO2nvKze72q 5XP4JEC823zNm3rrPeuA==; 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 1h5ehk-0007rz-5e; Sun, 17 Mar 2019 22:56:32 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5eh9-0007C7-Dx for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:55:57 +0000 Received: by mail-pf1-x442.google.com with SMTP id r15so7172622pfn.9 for ; Sun, 17 Mar 2019 15:55:55 -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 :mime-version:content-transfer-encoding; bh=yq5wxwSzSOiQKae/Fl8cjis8j+TFJgO/dAYMPjapJ44=; b=sDq82OY4NHq+gWmXsU0zF/TyBXvRvQE89Ccg1fWIqHxltD2U5zgX3D/IsdwogTJfLc atB3UZ5TJCF9933+Ha1vhBfqCOVnZoXFRUx0TvQcHKs/kyX00Tdlppp4+8S24CCf2RG1 S+7KdclKfsd11lWm8z1slHNYGNuREULU5JTB4foy2DLZ0oDDqZ9Oib/uzuyw4avux8JE r6hJhVF2Ewicj2ta5O2W7kWIgspV7mdOSOD7aKBPHGpaT4WHLyLVynRisteAcHh4SaBp Rx7yr82DceGTD4eVlQTLe4n6DP/nTE5Ve5FvB1bBQgtlGekRtRpFNa1hYp8bsnkwhz0o nXzQ== 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=CdsaNIY+nj1sDwQfW6oNpmzdo8sIPuDFEWruNn2tqnBP7aam873bW7JntL+Hufb9kX x0VqzLUYtyN+pXdmO+3QKaqCWDYKxtZ5CQgV/gq5tSzBDr4XPBq6VjC7enh2IJ61aPLB tWkRQ+d6cKvY5h8DeR/cxCCLZ9y3nVLFdOw6Np/lfX4m/IsNPMCAO75XjZag0RCGNGLf E6xoOG1/QijBpYhUVLnJ6d0KkF8CVYu1K6YlYIaV74pid8JE+hfKAmi4/Ickvm2OIolH cWrD0vUsvOBlgBmqdpmyslXwGA8ebD9MZ+oznWLqpZvzK1gDJZ647vr2GEp2VBkcVB6/ FOnA== X-Gm-Message-State: APjAAAXlmKUJsACuttIoJHgkhjkj9R7qEeofeiVGn/cfG/D7eUgYuxI9 yD6JCXD5sOQ0DsPNFE2/6uw= X-Google-Smtp-Source: APXvYqxFiScNA8yf0lov+46e0AgC7VJxPldRn92Ro7qqB4qo5NE1wtdvXtzl7YI3ipSWiz2LwD0rUg== X-Received: by 2002:a65:47cb:: with SMTP id f11mr14875231pgs.18.1552863355027; Sun, 17 Mar 2019 15:55:55 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.55.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:55:54 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 4/7] ARM: tegra: Set up L2 cache using Trusted Foundations firmware Date: Mon, 18 Mar 2019 01:52:07 +0300 Message-Id: <20190317225211.23091-5-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155555_665245_2557A320 X-CRM114-Status: GOOD ( 12.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 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 17 22:52: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: 10856655 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 8324517E6 for ; Sun, 17 Mar 2019 22:56:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C6E429211 for ; Sun, 17 Mar 2019 22:56:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6081229250; Sun, 17 Mar 2019 22:56: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 D760B29211 for ; Sun, 17 Mar 2019 22:56: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=ARf7CTd5jA5hfM 5gnApD22l7v1NOGkJo5DB3l3E/DComxPuDBUj+YXPEe8G3oGUIVgXlDV4XnExQyPHPKBWekt7ORQX a/5bUlERnGlaEks5z1EXGoC7WObaSXlt74BjPsTi732y4vc+O+cJn8DiNFGtK8UDmILv1S4AsQP+U qx1cXHKTUb40xNfFUoDAXxreWqy8BCm2mr0NRfstLSx27P8lgK0wYxzFvEptdeFJIg5C7osmpqF3V DlOo54hYeU/3LxG7FjQxXNUjdqvR1AUOwC0Av18IA2pDPvbjEBPJR5cQBLQ25Blrgs1nfA26Y03Tz 1Pc55Yeqheixl1pCnkKQ==; 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 1h5ei3-0008Aj-H6; Sun, 17 Mar 2019 22:56:51 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5ehG-0007K4-97 for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:56:06 +0000 Received: by mail-pf1-x441.google.com with SMTP id c8so3275927pfd.10 for ; Sun, 17 Mar 2019 15:56:01 -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 :mime-version:content-transfer-encoding; bh=buciGHsipdLQFuQo4BFBFhcyxYei+3vIbC+6BJ6jYFQ=; b=KhLTcFHxt1/bq8V2UlkofdYbF5vQFNo0O8inSDasT1QHmwNR9+DSzMmltjjKnXgxqp +cGnPMJpgPCz0c0hZ/YMLNfGF2gXPbtsryoZccYo7s74LYLZk9PsYiYkOJbVqaDedQDJ UVcnSeBFm8I/ZQIl00MYOpZ5XQdp5vzPtRKGyYQV0J8U3a/vlib/sgOhRTVJXGCvy3mJ RaG9UNv2EmBUo5N+Xdr4sPp5dj4VG0UmH3FMYcyhZaapjx/LAGT/y5vYVzTHdNU9huCZ D9/O0KnIoSCqFW9wq15vhOKdXNvHwtE9MynpNbdioDHrhEledf0fXEIFVY4zCE/Ady1C gm4Q== 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=p7Ss2Hb+pFdqpcnxJ2PGepO6snXWaz4nV7DKD1ipZlNjnFjJMFGHQcYOAT5QzWLnf5 MF+LFxQNvW4XaW1zsVa5k2Yv7CtrqDorfJ34qZxocLg8SVxGkYLnuTfoe47sTeCqnK/0 QQKfP3ZDUCVUhsVzAJfrzFxWv34ggRVy2Nyw7yo1DDR6wQQel87Y7LM9vg3WuYU80NZe RLlHYq3j1AKU2N+wXsdNKtp7MGXa1U5lpksRirmnYiuXdJaZFvw0lxrKpRyxB68gINrc 184w2mG9m6B29e50zGoVA5i4lhguwqeLxMOqAWmP/1dOrOjhhs2Nly1ir7SWnLZod2Ns plEg== X-Gm-Message-State: APjAAAX77vVQX9TU/QfoFk9q3RmeYmDYMeK5fCmCvYTrwWkz2ukS5LVK 4cfVWoflhUfF6e6GaKOMXH4= X-Google-Smtp-Source: APXvYqw3JVSRYsUquhaC3kKn7dRl8p1UxF3fFIAevB/w7fPz518wLH4e4bn9R3ENsTEBZFEPTMJykQ== X-Received: by 2002:a17:902:b618:: with SMTP id b24mr16016681pls.73.1552863361273; Sun, 17 Mar 2019 15:56:01 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.55.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:56:00 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 5/7] ARM: tegra: Don't apply CPU erratas in insecure mode Date: Mon, 18 Mar 2019 01:52:08 +0300 Message-Id: <20190317225211.23091-6-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155602_969587_E11CEBDE X-CRM114-Status: GOOD ( 13.88 ) 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 17 22:52: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: 10856657 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 33D3D17E6 for ; Sun, 17 Mar 2019 22:57:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DF7929211 for ; Sun, 17 Mar 2019 22:57:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E8EA29250; Sun, 17 Mar 2019 22:57: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=-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 0302D29211 for ; Sun, 17 Mar 2019 22:57: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: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=b8tORH4ZoGGNvX FeHMXBI1LQOQ9/9z01aNTbAgzHnXByt6XlhfnEtMZPhip95s6tWaZeXLssDJaBgNstRQX6EDmxK/x A4UuGQZJfDxnSVhnLDmAvIrAXhu/k7vQphV5/mE5/3jEO57QldaeHO5yPXElSC8/XsvCBlfJwcHUi 1FHhBXrjFqtpOneyxlJhEAESjjSo5R/oa4TYNdAFHpic8CVUu6YtVnePYWbprMxSWOd3qak4RdNez WVDxoyTvgCJHFdF7YHJpUAFdPqYpub40yYtOxzTLRC5fRCgdQqESgZRaaC7S7tmCN/KvOvGAEtr8c W9EB6ZYno8nwXCksNANA==; 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 1h5eiF-0008RA-L0; Sun, 17 Mar 2019 22:57:03 +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 1h5ehO-0007S7-6y for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:56:22 +0000 Received: by mail-pg1-x543.google.com with SMTP id v1so5320537pgi.5 for ; Sun, 17 Mar 2019 15:56:08 -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 :mime-version:content-transfer-encoding; bh=JuH8Ap/N0CCqMGuBFEsBfvavZHslxZuq0RCbP2Dsuc4=; b=iOcwJLtJQnDLJiglzaTS+waJniGYwLA83xMREpG+k375gPYY4JP1CpdKaH0WW48J9D HwazE2Mt8U3/qVi2y6EMOSTYjfggq1G/pwXKubuc5/evx3RFBc6/FSKIYqTXRR1csoJc c62xnwSrCuuwwKZYRr96bKCym0IaUAXUfpf7dK9reOecNqCs2d+WeL2qB7YWMXXEih9j vwL+awOaTcP1q6tXXCB6B9tIhD0qCkGXJDvJEgkZJ/SZX2EAb1iTr4GWQLV+EHeRom5z dyuEXEoYtN+bYpsd6aQr1Z5H03UxwSrbh+W0ZONh85lBu2BGibrue6qMqiscTT1CwHOP gFjA== 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=ovRSYW9dgwhUCRB6qaAg563DDFxuLL+19UcljImU46Fgz2MBjfoE4ij4+6Xo6taOjA zJtboNLsPvKeR09jeM88THOxXgXb1FN3K9Ww6+yLmukLqmOdECOt1LDIOfBXpl/Ctjx3 UzFChosp7YZ6Eql2vDNYhS7QQ6U0A2HsWYi6rW8GMyn7ERr0h1oVnYCAkNxRI9QSz6IY HJjCPhQkRmSeM/nIUJN3AJKq8XXWVnW0GeIAVOyjjkspoVbmhjCEczLNkJTMMz5aICh9 ztVV0KnVaWd5iEkIRdFM6Eo9UWz0Rhaqn1UUldmTCBSpv3c6E9QLKZbsBH9PxHzT5Cul 0klQ== X-Gm-Message-State: APjAAAXLT40lomAAOwmWmaT1a7fTDeeyqfAVZ0rAWKE2GQ6z+s064P6I EQ3f/NhfhCR3jDysjGbV4wnOMEpY X-Google-Smtp-Source: APXvYqyZ9bjwZ3mO6XQE939//EtDOS9s43r7bv6jyV1ZA4rVpiUwoovnt0DAlggb/V2H5hxYhqU+8g== X-Received: by 2002:aa7:8b12:: with SMTP id f18mr16501979pfd.240.1552863367692; Sun, 17 Mar 2019 15:56:07 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:56:07 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 6/7] ARM: tegra: Always boot CPU in ARM-mode Date: Mon, 18 Mar 2019 01:52:09 +0300 Message-Id: <20190317225211.23091-7-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155610_574371_C366A669 X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 17 22:52: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: 10856659 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 F1D161390 for ; Sun, 17 Mar 2019 22:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBFF229211 for ; Sun, 17 Mar 2019 22:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D054E29250; Sun, 17 Mar 2019 22:57: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 3A76F29211 for ; Sun, 17 Mar 2019 22:57:22 +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=AZJ1qxXGKzHeqp U4Dsn6r9CfEiZYrs0UyM0fCtfbnED94DPZsm1cYBgIajArcEodNVkyq/0GWMpx+Wgs9eygcQNcmje hWjiCbxZpXcTu0dvzOjXC2nY6v0CGaUuZ2CtiNUTVjBa9wiYrTW8lPj77l2DhT4FkHNsVkIx/YOJg /sgni97O34EZ6Fh0srCrFtQ3X0qqLWeb+G9fq+n3PX8kYzVOTEjAFmar1QsbJbla6MnwVa+/pSUiq D7vJmLgt9UcZ1sr94Vvb2dGDuvF8h6daHt5RrRYv8kRzZPRKyj4H4GvKxsEownICD44qdBxezdWJa EUmNXAia6c0Qtlz5CHjQ==; 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 1h5eiV-0000FR-Mm; Sun, 17 Mar 2019 22:57:19 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5ehS-0007YO-Gd for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:56:25 +0000 Received: by mail-pf1-x444.google.com with SMTP id p10so3119956pff.3 for ; Sun, 17 Mar 2019 15:56:14 -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 :mime-version:content-transfer-encoding; bh=S/ZyEhorrdTBL7u6Ya1Op9P6A1v1DuFjJTJQoxPu4VY=; b=MolOMgiLIqn0Zzod22JLytqh3LSjhHxcL3OvBhnYcojMOikknOVBEYd24Mdee5T9mp YvJIK5agvLU5mj+UNOgC+cnO7Xz0R5iLX+cxyOs+thjEFBK2aAT/yC8eEdlfULXd1J20 7W8/rDDQ3NcICYZRySdM/7qDBjlLGfii5a4r/wm5j1AR8ecAQy3MaquMyuSc30HQDB8c cxGuJxt8eIGOai6Fj0FcyliDxjtPcznZDxmuepnLT9Gn/wELQvm8V1l0m57HkmeenGF3 5YTwyww7xljXV1QRZxM8G1WvXGF6NY/7SPDBOYk21CAVLhxcxBWHL4vknXKACCe+ffNO uOvw== 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=kWFRmqePmM8uoCMx8hZzz/woWUPDEJNVvhViKHcpeIaAMQRrOX3WJWKclzCEduy+kk v7RhDwkVyt3Zng6NNh7Jp0kr+Ngqm+JFJaks8VvaFj0eu8m9Xiln3KX3fg6yY6VvzKs9 SsdNVRdBgItbtp8hGYLUuP45gqVkDQjK3T/THbhe15L3KaT/79a8HlDGQdHljsRytJ99 RgmTKJWTKrnQGGuFg+myAHIZqt+1upB1ITEH5nHYAviZVWShf7CkndDvrB3BbcnB3H6q IRZhEPVfmnRkgw0rZ3fzhErI0I6pA58uX1cV6wHol1MkzkHqbqxPbTx4PaHZhzZXvY3a ZREQ== X-Gm-Message-State: APjAAAVic88Q8HvMCoOKVNW4ayDd0qUJYMv75AOTob/VTRhqDdraBDVM f+KvIH74DD0H41WCgYQnUOw= X-Google-Smtp-Source: APXvYqxAvoy3u6Y7NzZ1q41nEoP5wDlRHUo52KnQX74sRaXEq9ReZ10ZYA5j3+HVtbsSwjd0ZUWTIw== X-Received: by 2002:a63:c06:: with SMTP id b6mr3267034pgl.440.1552863373957; Sun, 17 Mar 2019 15:56:13 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.56.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:56:13 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 7/7] ARM: tegra: Add firmware calls required for suspend-resume on Tegra30 Date: Mon, 18 Mar 2019 01:52:10 +0300 Message-Id: <20190317225211.23091-8-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155614_784220_77830D27 X-CRM114-Status: GOOD ( 17.80 ) 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)