From patchwork Thu Aug 30 18:04:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5E8A5A4 for ; Thu, 30 Aug 2018 18:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A785D2C1B6 for ; Thu, 30 Aug 2018 18:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B51A2C1BA; Thu, 30 Aug 2018 18:08:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B6F892C1B6 for ; Thu, 30 Aug 2018 18:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=j/W/OigOcpZWz/1BxjYqfU9G1msepZXRut9zGumWqkw=; b=JWbxf/cKVmfKWe6fvJ55jMeQk/ Je8RLxl67IzhzRViC4SIXMFv/NvB40BmCTQX5qLPXqw2uXXBu/zXGJBtNfWaO036gS+jYY4nS0CLz s8LCOleM+stKojYBqI6thLMtimU6q2pW6Rz5n/2WWNkVCLlQz+MWtCfrc47pP7W0LjCEzAp0N576c JZSkKbH3ppcbMmNg3Nl8aiYTiEA/YzZ6jH/V9JpaCG9UaOnBgX5vJc+fyIy/DRiTHbHqLbHR+da5d SpNETCEwVv5omhbgldQUw2drQ6Tw1qkCQL0gOekJuyxNT23mteBVvrpHuWYi6+Q0NJG6jmgTdl7zo HnZwmHqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRMq-0001GH-3S; Thu, 30 Aug 2018 18:08:28 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK3-0008Ui-Dx for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:38 +0000 Received: by mail-lf1-x141.google.com with SMTP id z11-v6so7916076lff.9 for ; Thu, 30 Aug 2018 11:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gzoUL224jX0LdcQuHl3QNpfOd2p4daBp/oJP6u+IJQI=; b=jsABhjJl5ipsNtvgdx0BajWqOKPpYsM/a6XaMVYu+7hd6M3jsaVqy7ZIXZHzBJUW4j UgafmTy9YBHe9eP0jGlnOhnnqVc2ywZi3zuKZNlpqaf8dxsowZF5gNuC7C5SmNQwmEvh 5qY7iGDflaLNk+iyj2zf/jy4XetQnQf5oSqtU3DLQ6ChjQ29Nm20TpyWUlTWJWNYapAi fMh4Oz80TULiArj+jbk6Skzsrb16OL0W93RGHgRQRZbPxw7TBcgtx0CD7TZjR7XxtnZC mQnjE1mUZY7M+JgDVC/sHwMHIbTKYPfgo6viLYf9A/niX3bcYbz9QnShnSdx6gDWLD+B OOrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gzoUL224jX0LdcQuHl3QNpfOd2p4daBp/oJP6u+IJQI=; b=VvBZUbdVCy/JRDZMprUecthh37Qm8E6SFTx5sJfEH0IshS6O4/DijItjM8RnQ3hkiM B23VnYn5ZfehZsEyOBnbbiKTFqboKfNtHr+77LwLuQ+nNi7cjIjNDjjtYhLV0U8rWlB2 sWS9U+w9KX9xck0ibc70q9G2VRlellRr+ZLjrn6R6OGe0foIVuMNyFS5Jo7wu/IxOgTn pTkJoGRea5OjhTjy+zfik0KB/izo8aTQfW7nU08Vi/eHiA7QwjhKnsHoE5Cjs6khv4F1 dW2Q7Oip8LJCptL8kWifxBZz/51eGp1u+ufbAGgilmDQLrHR5K41YG+cqZUq26gurE// 72/w== X-Gm-Message-State: APzg51BjciHmVzbX13f4Ysn7AUAKzAAK6J8l2GaX8bbBcFhkTI40LxDe wCbEc+vuDaCeUHH/6dZz2CQ= X-Google-Smtp-Source: ANB0VdaNiDWWi1NIzkr9GyFQ71be5Vr5ImkYyEJcF4crdGGp3fnfunSq3K9kNy8Z4NZ3PIX0jhQT4g== X-Received: by 2002:a19:a345:: with SMTP id m66-v6mr2280499lfe.23.1535652328614; Thu, 30 Aug 2018 11:05:28 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:28 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 7/8] ARM: tegra: Support L2 cache maintenance done via firmware Date: Thu, 30 Aug 2018 21:04:20 +0300 Message-Id: <20180830180421.6415-8-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110535_472236_FF10CA83 X-CRM114-Status: GOOD ( 16.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Trusted Foundations firmware require MMU to be enabled for L2 cache maintenance on Tegra30, hence perform the maintenance early-late on suspend-resume respectively. Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/pm.c | 36 +++++++++++++++++++++++++++++ arch/arm/mach-tegra/reset-handler.S | 8 ++----- arch/arm/mach-tegra/sleep.S | 4 ++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 1ad5719779b0..66c8cd63dd86 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "iomap.h" #include "pm.h" @@ -195,8 +196,27 @@ void tegra_idle_lp2_last(void) cpu_cluster_pm_enter(); suspend_cpu_complex(); + /* + * L2 cache disabling using kernel API only allowed when all + * secondary CPU's are offline. Cache have to be disabled early + * if cache maintenance is done via Trusted Foundations firmware. + * Note that CPUIDLE won't ever enter powergate on Tegra30 if any + * of secondary CPU's is online and this is the LP2 codepath only + * for Tegra20/30. + */ + if (trusted_foundations_registered()) + outer_disable(); + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); + /* + * Resume L2 cache if it wasn't re-enabled early during resume, + * which is the case for Tegra30 that has to re-enable the cache + * via firmware call. In other cases cache is already enabled and + * hence re-enabling is a no-op. + */ + outer_resume(); + restore_cpu_complex(); cpu_cluster_pm_exit(); } @@ -340,8 +360,24 @@ static int tegra_suspend_enter(suspend_state_t state) break; } + /* + * Cache have to be disabled early if cache maintenance is done + * via Trusted Foundations firmware. Otherwise this is a no-op, + * like on Tegra114+. + */ + if (trusted_foundations_registered()) + outer_disable(); + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, tegra_sleep_func); + /* + * Resume L2 cache if it wasn't re-enabled early during resume, + * which is the case for Tegra30 that has to re-enable the cache + * via firmware call. In other cases cache is already enabled and + * hence re-enabling is a no-op. + */ + outer_resume(); + switch (mode) { case TEGRA_SUSPEND_LP1: tegra_suspend_exit_lp1(); diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 555c652f5a07..4973ea053bd7 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -69,7 +69,7 @@ ENTRY(tegra_resume) mov32 r9, 0xc09 cmp r8, r9 - bne end_ca9_scu_l2_resume + bne end_ca9_scu_resume #ifdef CONFIG_HAVE_ARM_SCU /* enable SCU */ mov32 r0, TEGRA_ARM_PERIF_BASE @@ -78,11 +78,7 @@ ENTRY(tegra_resume) str r1, [r0] #endif -#ifdef CONFIG_CACHE_L2X0 - /* L2 cache resume & re-enable */ - bl l2c310_early_resume -#endif -end_ca9_scu_l2_resume: +end_ca9_scu_resume: mov32 r9, 0xc0f cmp r8, r9 bleq tegra_init_l2_for_a15 diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S index 5e3496753df1..b96126fe5dc5 100644 --- a/arch/arm/mach-tegra/sleep.S +++ b/arch/arm/mach-tegra/sleep.S @@ -132,8 +132,12 @@ ENTRY(tegra_shut_off_mmu) #ifdef CONFIG_CACHE_L2X0 /* Disable L2 cache */ check_cpu_part_num 0xc09, r9, r10 + retne r0 + movweq r2, #:lower16:(TEGRA_ARM_PERIF_BASE + 0x3000) movteq r2, #:upper16:(TEGRA_ARM_PERIF_BASE + 0x3000) + ldr r3, [r2, #L2X0_CTRL] + cmp r3, #1 moveq r3, #0 streq r3, [r2, #L2X0_CTRL] #endif