Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3137560iog; Mon, 27 Jun 2022 09:54:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ujCQGiIlhiEKeaNk7YF3yWgeSbNnr0zpdj3azmIhXQFxYA5VlKZkm5dIS4iMC2yBx757bN X-Received: by 2002:a17:906:149:b0:712:c9:7981 with SMTP id 9-20020a170906014900b0071200c97981mr13483470ejh.218.1656348858154; Mon, 27 Jun 2022 09:54:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656348858; cv=none; d=google.com; s=arc-20160816; b=tOdv2ioWaIIFUpU+jGDZ5FUohb0mwV5jeH9bfEQA9UY5bRZJ22qHzfTAutDRkWIytJ 0NiOF0PZyVSttoGttOuoIsD78tWz60w70aF/DBA5vH6vS15siAxSqmZnR/KE+9gqzxjV EnnIFj4kU49KsomPN4rnytCBCpfQPf8ZV8auypHu1P1osCHP92j4WghheBsVAgMRfux7 Qgke1/HOlxrEWJ0vTESm4ypFtP27pHwOVw+gf8wt4owsT93AfWwGbbsXZtFEnVRJVg/g obKQ7qwy2nXfxGPiIy59uIYAmGTwVjj+Dd5taykxPXHaqSBI6GsERJ0SreZlxYMu7fPU HOGg== 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=YoafvvOmCHPbnfpdI0Tg2ObQ4s/Wjsw+LGobGqbBvoM=; b=BLS2E2w/BZA2btmwM12IcfDcXveQIouiJAnY4HAXeYR4muTaS74dXLoHIIddNgpYfT Oaicvjycm2qNZrE/txpeh3yAhVBRPoo4WuG/V7F8YMyzOg2DnwVp4D/iSwfcIyJbxYdL S7b02l/8biAUx60XoXKwdJCf0rgm4OORzDMN0lrKxHbcCql/d3+Cx7jx8bJ6qOUWzEcj 1u64hBZ3sNYCH3l2ALyASoDd0OWNze/aCzDWL88Iz5TgUsS1zVKRaMXQ+SAOoPWASw42 doTSOSSQk5CrovO03/6wzP2U52XArJoYKKXNVcmPH+QdtYuFG2oPfHk/tyt7jAdnnHBc yJqA== 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 go7-20020a1709070d8700b006ff0f87f566si13166012ejc.563.2022.06.27.09.53.51; Mon, 27 Jun 2022 09:54:18 -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 S239572AbiF0Qvc (ORCPT + 99 others); Mon, 27 Jun 2022 12:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239436AbiF0QvU (ORCPT ); Mon, 27 Jun 2022 12:51:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B71A313CF7 for ; Mon, 27 Jun 2022 09:51:11 -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 BB0BD1758; Mon, 27 Jun 2022 09:51:11 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D85803F792; Mon, 27 Jun 2022 09:51:09 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Atish Patra , Atish Patra , Vincent Guittot , Dietmar Eggemann , Qing Wang , Rob Herring , "Rafael J . Wysocki" , Ionela Voinescu , Pierre Gondois , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Subject: [PATCH v5 07/19] cacheinfo: Use cache identifiers to check if the caches are shared if available Date: Mon, 27 Jun 2022 17:50:35 +0100 Message-Id: <20220627165047.336669-8-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627165047.336669-1-sudeep.holla@arm.com> References: <20220627165047.336669-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, 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 identifiers is an optional property on most of the platforms. The presence of one must be indicated by the CACHE_ID valid bit in the attributes. We can use the cache identifiers provided by the firmware to check if any two cpus share the same cache instead of relying on the fw_token generated and set in the OS. Link: https://lore.kernel.org/r/20220621192034.3332546-8-sudeep.holla@arm.com Tested-by: Ionela Voinescu Signed-off-by: Sudeep Holla --- drivers/base/cacheinfo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 2aa9e8e341b7..167abfa6f37d 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -44,6 +44,10 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI))) return !(this_leaf->level == 1); + if ((sib_leaf->attributes & CACHE_ID) && + (this_leaf->attributes & CACHE_ID)) + return sib_leaf->id == this_leaf->id; + return sib_leaf->fw_token == this_leaf->fw_token; } @@ -56,7 +60,8 @@ bool last_level_cache_is_valid(unsigned int cpu) llc = per_cpu_cacheinfo_idx(cpu, cache_leaves(cpu) - 1); - return !!llc->fw_token; + return (llc->attributes & CACHE_ID) || !!llc->fw_token; + } bool last_level_cache_is_shared(unsigned int cpu_x, unsigned int cpu_y) -- 2.36.1