From patchwork Thu Feb 28 13:17:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10833019 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 6B4AF17E9 for ; Thu, 28 Feb 2019 13:19:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BE9B2EC7F for ; Thu, 28 Feb 2019 13:19:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CF2E29080; Thu, 28 Feb 2019 13:19:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 C7AC22EC7F for ; Thu, 28 Feb 2019 13:19:07 +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=/MePI9pw02mkRRFxer5rMdEmTTYFve+XhJfx4uIRfPA=; b=NWboeKC3R4wjNo ub93kXfv3RfN3NtfwCX5o9+fOJBP+swaDHyNS/eWs5o3dRcStKP9+UmwUBvG08smBaowJM/BaHL91 djzwz66Lo9K3JEx69JNg65fJGmUNXcqlpRBhfq2F27kgbvc4AF98ZJuUgMjak42e30131g27/ebq2 Zb/YesXFq7OjWmdFsl2WSet0kSJWlJXjdeq1R7HSll47w4lDZNXA6HHlI+eCTtwpE2+s2s6oYtwAX Z9gk9VFXkt/2sabchuKgvMdoUa6brphzA+GbmjuEi/7iIDc6lniE9HLJJ1TCkfe9P5vFAky2vR4XN sRoso6mzOmMCjs2np7WQ==; 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 1gzLaa-0004US-B1; Thu, 28 Feb 2019 13:19:04 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzLaI-0004CK-AP for linux-arm-kernel@lists.infradead.org; Thu, 28 Feb 2019 13:18:48 +0000 Received: by mail-lj1-x243.google.com with SMTP id d14so17065898ljl.9 for ; Thu, 28 Feb 2019 05:18: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=yAub7ZN7TB3C9m6Jjn4lIV9KKAuyGf3mG5EO+qiXK7g=; b=X88mHS2aPJyQxDRk1zfz0iJtFQNRomWUXrlYh1C8GQEXe7dWsioRcl/EtDeNRQSEdl 3TjYRC1jW79JIxCQbdYvw1+OXJ3npD8fQz6PWLIhdmCsEKB1KBzv94N0KpJOsBC+XewR 2HoORB92YCR9yBfddICdOlr/R2exPt3Vak3tkn0iTdMxlSwCMf2niKYVOITHGPRLHP4p iXG0dAfj+Gr+ns6lHSPoaEIB1B/qI1OjYyPk3WFl36zxt5AimcrAExRy/zr0sJXodjwK 32YvQyyKa9QXe1rFVweX+r4bPu0kj+WlwefYTWfV1z88yW2D0VRAEjSDwXOWLnyJIed0 ORsw== 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=yAub7ZN7TB3C9m6Jjn4lIV9KKAuyGf3mG5EO+qiXK7g=; b=sNlXeP9ftvlERhbl4GDh3PdoltL3CAcMDnzaPxo3W622g26rfQUWwRICpl9306W/8L u01MgOERp0l4LtO/TqGFPWKwDJJ8/z9lY9vqhibjD/behxdhF1VO3fQAVC45/J8HK1CF KDKlXDoQ8xcjXH0OfgMJlDCBI/PRiUQlL19AVhPK4UaMH2q02ODwbwAS88XuR8+XQL6q C8Kr3NV5ai456kb+vEO++WpYWoF4BOq2f+lw/vDZDXLNZTG/DqXhmWhCvL80xcqH7a29 gEHZ67jZjuwf4ouHjtM06ZQ2RYpTS7+g53skDzkAe083iZLIluZAM1CpVedgZ7PMk1kE M9lQ== X-Gm-Message-State: AHQUAuaDLFnlYajK3llwVOnpJ6EEzwHfsAPc5YZ1t+xZl/Xwuz3WjPID 7QtziBr9Uo4RxLLbNOMIxWs= X-Google-Smtp-Source: AHgI3Iay8ez0a1RQCFomOJDUMhoHpogz5BNBDfxXHCGhS2T/imLnSJwyv6jNxG0dMULdd8ONusesjw== X-Received: by 2002:a2e:131a:: with SMTP id 26-v6mr4612778ljt.107.1551359923994; Thu, 28 Feb 2019 05:18:43 -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 l26sm4600069lfc.37.2019.02.28.05.18.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 05:18:43 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v7 1/7] ARM: trusted_foundations: Support L2 cache maintenance Date: Thu, 28 Feb 2019 16:17:01 +0300 Message-Id: <20190228131707.2592-2-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190228131707.2592-1-digetx@gmail.com> References: <20190228131707.2592-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190228_051846_356789_047A3CE1 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 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..4028104cf7b2 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 & BIT(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..07183ca43b25 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 L2C enable-request\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