From patchwork Fri Mar 17 16:22:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Liu X-Patchwork-Id: 664557 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp491499wrv; Fri, 17 Mar 2023 09:23:38 -0700 (PDT) X-Google-Smtp-Source: AK7set+Nd5mPAihZev6lz9K/K9pvM+pM53vIRwsTlLvGrk08G9n77LxA4zltcuOVZcNHF6wz9iK4 X-Received: by 2002:a05:6214:cc3:b0:56e:b5a1:b521 with SMTP id 3-20020a0562140cc300b0056eb5a1b521mr47625851qvx.51.1679070217972; Fri, 17 Mar 2023 09:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679070217; cv=none; d=google.com; s=arc-20160816; b=fv3ukcKW3pRhYFmFnC8Ma+gc6ij74uHSxKblRExlZ124J1xN2gGn3pXiOEOzLeEPzV UYztgoXxoJSgodb550GhqUstOVu7tUEYfqZsMLSwz7zntc1Nkt8z3KFc8HFYsvHdT3js em0ooufAbMipuMC/+cszXnRfKZQcIfY6SHXBdO01yB7kLucWw8qNFeg9lEArORzfLJt5 Fq4FXaVoKfNfsaSZdzJuV2OkujriMQDSXQKIEOJ6LDbOmgl4BAgpayqA14X9qQLIa9Gw K+wbTuzSGBFBDe3Tu5W6Yqm+4vA+kt1f1zY+g3fE+iCU8Rp3ezx90VBlKqX46NMoQObl dIKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f/yZdXq0tXoVn+UnXN86SQR2lNQJiQzEBQB393JaLjk=; b=T3qxQWCMh4gg8TZSleRPbBAFaNCUS3ZwvkFXTGDzwnM3MidzziGdusisL5x32AgWKC URQ/p1EN6QvX0+kEOQ2dA74inoxmTT7ezZltyP6DESD66ewg1z5xtQ9LYi/VLB26FC8f F+RjJWEfD7nlscPDmh0UD+Nb5r0lL9j3Rlw+gpF/byfvbz8PSVHR8Btxv2MdC5EOgBXc U3gIfxzUH7xYTGzQHj7+Q1KTAKcdAM/CFwsGOD7sBOMl3f4DyrywZTa6QL/fXJl7ST85 HrTOGqLhYDq/1S7kSKeEEnCiQ+J8La6nYm7d7t6xo9/S+xGGzAUcpAD/N8zXgCXqyKh/ MtEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tLf0a7r5; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id r27-20020ae9d61b000000b0074655908f6esi1209836qkk.417.2023.03.17.09.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 09:23:37 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tLf0a7r5; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4546685A07; Fri, 17 Mar 2023 17:23:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tLf0a7r5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D3BC8598A; Fri, 17 Mar 2023 17:23:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2866C85925 for ; Fri, 17 Mar 2023 17:23:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=paul.liu@linaro.org Received: by mail-pj1-x102a.google.com with SMTP id h12-20020a17090aea8c00b0023d1311fab3so5761631pjz.1 for ; Fri, 17 Mar 2023 09:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679070182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f/yZdXq0tXoVn+UnXN86SQR2lNQJiQzEBQB393JaLjk=; b=tLf0a7r5edv11y0fbxFoJWTTcojrRjHvT7sM8nkcUZtyuXQgcbKMdr5JJ1Jtf1LEMA ncJvt8TnYxS3QF0xOdtwXwQ4zUGHzx6bdubMElQvpNTHDmyvA5+O6DOXYgNc/+9Ptm0J vNqiu54qHXPC+wB6H/HcnabNlmVLizvI+7MCZuDp/b8j3LxkhLdzq3GKKTHFkNpUFKb/ YB3FoSMYKuqmiOHbTcXrCbvOdLiICMFJ+KmwB33zR//A4UOCmh10ksMkfh4ohaAItCj6 Qx7mPKmuqXy3V9ke5yw8xa9HGRJJPs5ZWMGQRw37aOnqqwpqBHaIPI+tUu6oF73TgSAX 4QBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679070182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f/yZdXq0tXoVn+UnXN86SQR2lNQJiQzEBQB393JaLjk=; b=xteuFb8ebI1Uj+sFqj2gNU1PyyVhgx54xXEtAdsp/hLtblQ9yWwyHGcurmZ+ny5/07 cKgBMWzhsjcf1kzSC/Rl/2tzsW1UTrhtlMv739nukINdtlgFVJ1mgUOibysF8dSHw4g6 XS+Omyb/Lx48zn4/BHDqb37IbetiKBd6U9IGWWFXWcHbpvoFPJNAC4xQmCw5I+TVSL+t p8wG60/ry1k9NKyuQZCwnoID0YJZ/p5GorfC8RvizH9yF9EsO7PMpvCpfzi3MxGV16FN N8a2b8yuqdN6xd382CyteqioteP6YQrjfGlNzNWW0MOCN3QDa2cgnsNNgZWxkBE+mFjH 774Q== X-Gm-Message-State: AO0yUKX3SMwrJVEuniMEVBMKHJIy+bhrHeSdZwupl66bJv+PqR3FlV4X tRP+SZn1TPEbj9UunKCv5mhzoRdZc993D2RbfOI= X-Received: by 2002:a17:902:d0d1:b0:1a0:70e5:280a with SMTP id n17-20020a170902d0d100b001a070e5280amr5835847pln.60.1679070182195; Fri, 17 Mar 2023 09:23:02 -0700 (PDT) Received: from localhost ([111.184.129.17]) by smtp.gmail.com with ESMTPSA id g12-20020a170902c38c00b001990028c0c9sm1767544plg.68.2023.03.17.09.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 09:23:01 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: Marc Zyngier , Ying-Chun Liu , Tom Rini Subject: [PATCH 2/3] arm64: Use level-2 for largest block mappings when FEAT_HAFDBS is present Date: Sat, 18 Mar 2023 00:22:52 +0800 Message-Id: <20230317162253.1049446-3-paul.liu@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317162253.1049446-1-paul.liu@linaro.org> References: <20230317162253.1049446-1-paul.liu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Marc Zyngier In order to make invalidation by VA more efficient, set the largest block mapping to 2MB, mapping it onto level-2. This has no material impact on u-boot's runtime performance, and allows a huge speedup when cleaning the cache. Signed-off-by: Marc Zyngier [ Paul: pick from the Android tree. Rebase to the upstream ] Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Tom Rini Link: https://android.googlesource.com/platform/external/u-boot/+/417a73581a72ff6d6ee4b0938117b8a23e32f7e8 --- arch/arm/cpu/armv8/cache_v8.c | 14 ++++++++++---- arch/arm/include/asm/global_data.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c index 4760064ee1..4c6a1b1d6c 100644 --- a/arch/arm/cpu/armv8/cache_v8.c +++ b/arch/arm/cpu/armv8/cache_v8.c @@ -314,7 +314,7 @@ static void map_range(u64 virt, u64 phys, u64 size, int level, for (i = idx; size; i++) { u64 next_size, *next_table; - if (level >= 1 && + if (level >= gd->arch.first_block_level && size >= map_size && !(virt & (map_size - 1))) { if (level == 3) table[i] = phys | attrs | PTE_TYPE_PAGE; @@ -353,6 +353,9 @@ static void add_map(struct mm_region *map) if (va_bits < 39) level = 1; + if (!gd->arch.first_block_level) + gd->arch.first_block_level = 1; + if (gd->arch.has_hafdbs) attrs |= PTE_DBM | PTE_RDONLY; @@ -369,7 +372,7 @@ static void count_range(u64 virt, u64 size, int level, int *cntp) for (i = idx; size; i++) { u64 next_size; - if (level >= 1 && + if (level >= gd->arch.first_block_level && size >= map_size && !(virt & (map_size - 1))) { virt += map_size; size -= map_size; @@ -410,10 +413,13 @@ __weak u64 get_page_table_size(void) u64 size, mmfr1; asm volatile("mrs %0, id_aa64mmfr1_el1" : "=r" (mmfr1)); - if ((mmfr1 & 0xf) == 2) + if ((mmfr1 & 0xf) == 2) { gd->arch.has_hafdbs = true; - else + gd->arch.first_block_level = 2; + } else { gd->arch.has_hafdbs = false; + gd->arch.first_block_level = 1; + } /* Account for all page tables we would need to cover our memory map */ size = one_pt * count_ranges(); diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h index eda99b5b41..9d94cbe665 100644 --- a/arch/arm/include/asm/global_data.h +++ b/arch/arm/include/asm/global_data.h @@ -52,6 +52,7 @@ struct arch_global_data { #if defined(CONFIG_ARM64) unsigned long tlb_fillptr; unsigned long tlb_emerg; + unsigned int first_block_level; bool has_hafdbs; #endif #endif