Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp211322rwe; Fri, 14 Apr 2023 01:18:11 -0700 (PDT) X-Google-Smtp-Source: AKy350ZS9A2q/DkJr/uV0S+6tYNE/oAmXpBu+65wZIXlpT0+qdapkTs06n6iT5fLD5jqXcXuzYQi X-Received: by 2002:a17:902:ceca:b0:1a2:a904:c438 with SMTP id d10-20020a170902ceca00b001a2a904c438mr2088228plg.58.1681460290796; Fri, 14 Apr 2023 01:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681460290; cv=none; d=google.com; s=arc-20160816; b=gkAVwd+PVAg1t4226Xxt61nmgDPkYr/I+pOtFEUp4Hbf7GSC11ClccXC60jqfyb8WL aQWtbc9fvxATizg4PpuzcaJGbHywNTe5smh74Q7EjH9Uv/yLI1eRu/L+7or/wVJer4OL XrneHIebLrxreVhpHRdnOBcCK6zERzrHRdKSIJw0UlOfFHWIqera1sM5qDQk4wsbNmVB Vrncj7UdlVu2x2H0QZaVoa83yTyH/GkhrS1rPmBgOC8iCPBPMhPRPrWpArM72bUkWcLQ tQLgiO5kPPY4I42+k5FXf56el32DHMR3B8grjV72+c13cORsRX1mxrrOGz4rzi1iMhhh iO/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Z1OvbkAQpFDbulKCynZ5bDVYQJMkyU6mwtg+qVtTKZc=; b=Yjiu6erFsz6OpuX0uQnJnPbZ9MiYzSTJLbaZz14bAgxD0wYkxt5z5glGy8mjgI0N2B zh2lhJW8hC+ixvvNXbu4pMlP8TW7PO8HUgRN/OpB4UQXo8QAFeVck6Hl6DUBL8NXddvC cHp4mTDydlTxsNJ51/ruHT63YKt6v8WMUvleoc9bwP6W0Jda9g7Ft2d8sQ6Mg3DBs+Ca io1HWENV3AT9vXdoeitO0JuBA7IlG9BQQOcGN8oyjUyD5i4pq7K8/FwtzWzLV4ZIR5zi hYT8jzJqLd/LxBSB90lBvaAE5gCLdTgkrYdDRm1uf0X4M91RgDfsFBxwDX6AlgA2IvLu 35uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a170902c40500b001a183ade8f7si4610300plk.433.2023.04.14.01.17.56; Fri, 14 Apr 2023 01:18:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbjDNIP7 (ORCPT + 99 others); Fri, 14 Apr 2023 04:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbjDNIPp (ORCPT ); Fri, 14 Apr 2023 04:15:45 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 39C0083F6 for ; Fri, 14 Apr 2023 01:15:40 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5F9B94B3; Fri, 14 Apr 2023 01:16:24 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.19.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 684ED3F6C4; Fri, 14 Apr 2023 01:15:37 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Radu Rendec , Alexandre Ghiti , Conor Dooley , Will Deacon , Florian Fainelli , Pierre Gondois , Sudeep Holla , Greg Kroah-Hartman , "Rafael J. Wysocki" , Palmer Dabbelt , Gavin Shan Subject: [PATCH v4 4/4] cacheinfo: Add use_arch[|_cache]_info field/function Date: Fri, 14 Apr 2023 10:14:52 +0200 Message-Id: <20230414081453.244787-5-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414081453.244787-1-pierre.gondois@arm.com> References: <20230414081453.244787-1-pierre.gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cache information can be extracted from either a Device Tree (DT), the PPTT ACPI table, or arch registers (clidr_el1 for arm64). The clidr_el1 register is used only if DT/ACPI information is not available. It does not states how caches are shared among CPUs. Add a use_arch_cache_info field/function to identify when the DT/ACPI doesn't provide cache information. Use this information to assume L1 caches are privates and L2 and higher are shared among all CPUs. Signed-off-by: Pierre Gondois --- drivers/base/cacheinfo.c | 12 ++++++++++-- include/linux/cacheinfo.h | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index ea8f416852bd..8120ac1ddbe4 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -28,6 +28,9 @@ static DEFINE_PER_CPU(struct cpu_cacheinfo, ci_cpu_cacheinfo); #define per_cpu_cacheinfo_idx(cpu, idx) \ (per_cpu_cacheinfo(cpu) + (idx)) +/* Set if no cache information is found in DT/ACPI. */ +static bool use_arch_info; + struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) { return ci_cacheinfo(cpu); @@ -40,7 +43,8 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, * For non DT/ACPI systems, assume unique level 1 caches, * system-wide shared caches for all other levels. */ - if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI))) + if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI)) || + use_arch_info) return (this_leaf->level != 1) && (sib_leaf->level != 1); if ((sib_leaf->attributes & CACHE_ID) && @@ -343,6 +347,10 @@ static int cache_setup_properties(unsigned int cpu) else if (!acpi_disabled) ret = cache_setup_acpi(cpu); + // Assume there is no cache information available in DT/ACPI from now. + if (ret && use_arch_cache_info()) + use_arch_info = true; + return ret; } @@ -361,7 +369,7 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) * to update the shared cpu_map if the cache attributes were * populated early before all the cpus are brought online */ - if (!last_level_cache_is_valid(cpu)) { + if (!last_level_cache_is_valid(cpu) && !use_arch_info) { ret = cache_setup_properties(cpu); if (ret) return ret; diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index 908e19d17f49..b91cc9991c7c 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -129,4 +129,10 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level) return -1; } +#ifdef CONFIG_ARM64 +#define use_arch_cache_info() (true) +#else +#define use_arch_cache_info() (false) +#endif + #endif /* _LINUX_CACHEINFO_H */ -- 2.25.1