From patchwork Thu Feb 28 14:59:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1049560 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qSu5eghi"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Nm4rQPwI"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449G2L65SRz9s71 for ; Fri, 1 Mar 2019 02:00:42 +1100 (AEDT) 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=lf0Fl0VJ5epKWPL5uXU3zshMVEbGvQd3xsTh0CK5vjo=; b=qSu5eghi1oIb7K MWGM69AzKDlvhWED9WgLfk0bE0ITZHMdXIpSWwPd8WAI812yQJsAeJ28MVhbjagc3znini6/eP23g cF7NagDP2GC10wFIAND3vC4QBAqYYRplx4S/a/zWr8ieTbB0GCX9GIk7s+EUPtK9a9dXSW8r5vtUi Z/UlM115LuPyLtmRAwCgmHISUaalhSH1VkJfPe71JUQ6bqSUNkBOm1yfrT9+HHUhCyUUQZzNcwgEC uXxxqzWaAjBMf20ejbpBGDLK79jk9dui9QX8ddyWEY4gmkWmK/J59gzXKg3u/9POML0B2Rb3/qJgB 1tYFpa8iOQ8mekAJLpiQ==; 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 1gzNAp-0005bH-Js; Thu, 28 Feb 2019 15:00:35 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzNAC-0003dY-U8 for linux-arm-kernel@lists.infradead.org; Thu, 28 Feb 2019 14:59:59 +0000 Received: by mail-lf1-x143.google.com with SMTP id x206so7464864lff.3 for ; Thu, 28 Feb 2019 06:59:56 -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=OUbFGCkTlGqhFrgKpP67ocSrAhCVcyTzIpRgjYYzmlY=; b=Nm4rQPwID/9qjpwD9gXHmcQqNg5O9haWteRwKy6cSPs5T/O3gfp8Y+Cp36miuvYYGs Sno4ncvsRmzE1Rlm2os0nld/JQukOslvE+6kp3eeuZj0eTGPkaf4H3M7+56GKkRjOhQq g1gkrNh99hx9t3leTWgG1NIoTM4JnXiIO9R23Huwu89sBf7SAwkfqIgh4yrpOgUPj93e xrbNXynXjQo6puIZFzdx/j99AgAUF6A7QGH2T+29plLdv1KfRtOS3I8gGJiHz7dMThFV 8/iInqoGX44r928jXwvXYzVSO/Abr5Fmh+2FNZSp1tX2/dnK9gtD7695iQRsLYekQPwT LnsQ== 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=OUbFGCkTlGqhFrgKpP67ocSrAhCVcyTzIpRgjYYzmlY=; b=ByBmhcLj2vo6ZwpjfCIhmhaXRdOptJ7NAaBhWRWE6l1cg+Q1241iPOC/0Kk1thRYUO aNNJEf9mHU0KhI17uC/jVEqRg1EbZHqoR14jrzXLe2q6D870wt7X1d0cv0S328I0LS3M n8Tg/1h8dV/3VvvfiUqTQUzXhROhGk4/qxn/z2VrsxrSHOkTAJ1mjA8vSJHuE58WFQ1d O3DcxQktT09E94oitrKv6bc9M7dCHs2XyXlT/J3Axp2DyqAJmbA1Rwxr0KJ8X4hsoYAs Ak3Qmle7LqDh5+JI0DK/miFZ6wO5RYRvYYjUAho2U6jQuRQYfICZ8iVM9XYwM0lh36QV 41yg== X-Gm-Message-State: AHQUAubZVemalZVtXc4vKRQMH7pSu8ff4S7MikhOg7miYXCoIBm2Liez o9yTtb4Jns/xYKm6hmIaFhI= X-Google-Smtp-Source: AHgI3IZ3xD1oLK6FWxPWrtoHeM5XRP9iIJFoEzkCDvFv/SgcqG28srWBZjSjQyc5x2iOuPRVayHI1g== X-Received: by 2002:a19:760d:: with SMTP id c13mr3821793lff.102.1551365994766; Thu, 28 Feb 2019 06:59:54 -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 z20sm4728309lff.87.2019.02.28.06.59.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 06:59:54 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v8 1/7] ARM: trusted_foundations: Support L2 cache maintenance Date: Thu, 28 Feb 2019 17:59:31 +0300 Message-Id: <20190228145937.27725-2-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190228145937.27725-1-digetx@gmail.com> References: <20190228145937.27725-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_065956_981390_5BE8EFCE X-CRM114-Status: GOOD ( 15.79 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:143 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (digetx[at]gmail.com) -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list 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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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..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