Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4140974iog; Tue, 21 Jun 2022 12:57:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8/2zeYDgJt2NUOefUdruEok6cfWWtX8BtFaP9b0teczxwPIbTMycgU6BdHt0hOnfwmqDg X-Received: by 2002:a05:6402:3988:b0:434:e2a8:8459 with SMTP id fk8-20020a056402398800b00434e2a88459mr37208355edb.253.1655841429414; Tue, 21 Jun 2022 12:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655841429; cv=none; d=google.com; s=arc-20160816; b=vYrLccSCh7FxFp1NJ51DeH1YIf8air+pnQZMDao1EZM65XiVQwdSyQfEyp8LVFjeqa lyItYpBBpndv/5Ll3/SiZcYHBErhS8mj04pJDv4T3ffS9AX60FAusG/YLHeNIHLWufgj 9zFHa/dn8LXxJ3UYKzT4M2YDiYelgkNy3jZ9PTJUEWkOUuGn+LkztSkuSCatRi9J8MRg 0QRiwsp1+wXIAisipOTvxV4fF16lix8aWyYx20L9u0nL0h5nWwF5E3u34uJ7j8J38Vfr rWLbJK+H3OxhmIGsEt5J1BqHFE26/5ouKQQlYsmdDXKoM30+KbW95n7JLrNOogEZo1aw FY4w== 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=BlOwBoRx2XxyumuT+nAuMWNDglP0RI0qMi/MbGl3tx8=; b=MqPz/9Qwct7V7AN+b+6QFg0wHV0CzM3upn5UF+4yHbNSudSzjork39QW33xzOi5znT 4cigrokGXgcLKRBoo9riNlUa7tsISGIzn7l+ovTjkIIeS/AfKwhmYMcdZ5rsImepmE8g 75GV1hyidjBJJ7ecPFvoIWdaTGw64KUchHdzEzmM+LCv6pPByTDlrv4Bnf1k25ulsl4J pDNK1rq+EdddEr0f/t3XR8HfmHKGPwi9AKnTvhtAz234nbSK3ynp3SBFVpOWMIl7Gl72 hJ3bYuBoEiEarOU5y51eLR1e2UxlPqLGoSnBxVZLv4iN56eaW03Fqwlp2fD9w8LDC46k A86w== 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 e17-20020a170906749100b00711f5c9d6bdsi16786068ejl.284.2022.06.21.12.56.43; Tue, 21 Jun 2022 12:57:09 -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 S1353443AbiFUTVR (ORCPT + 99 others); Tue, 21 Jun 2022 15:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233189AbiFUTVB (ORCPT ); Tue, 21 Jun 2022 15:21:01 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C198F27B for ; Tue, 21 Jun 2022 12:21:00 -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 B878A168F; Tue, 21 Jun 2022 12:21:00 -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 CB7223F792; Tue, 21 Jun 2022 12:20:58 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Greg KH Cc: Sudeep Holla , 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 v4 07/20] cacheinfo: Use cache identifiers to check if the caches are shared if available Date: Tue, 21 Jun 2022 20:20:21 +0100 Message-Id: <20220621192034.3332546-8-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220621192034.3332546-1-sudeep.holla@arm.com> References: <20220621192034.3332546-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. 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