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