Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp11617imw; Mon, 4 Jul 2022 04:25:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sw92LP9qjka/Yy0VIcyKYjhNffMoZGGc6ZFLx7vu8SmvPNZZ6yWvaS+6VR5xjMX3ESci/W X-Received: by 2002:a17:90a:bc95:b0:1ef:8b48:fa0b with SMTP id x21-20020a17090abc9500b001ef8b48fa0bmr3595940pjr.189.1656933941125; Mon, 04 Jul 2022 04:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656933941; cv=none; d=google.com; s=arc-20160816; b=Cm3kW5sYYN4F93xKE/+7nSMGUXC5zhD2Lw1MwLMbtZe8/FbXPB+KgSQfREfh54DUus rTgZmo9SyjN/cdMNqMG3abIHELaEJRPdAL44VQTvLFBKsGeQfPLGOJ6umflUqjdA5OA8 Sj6Wj5Xiu7hXIOt8Uxq1BTYCHKvV6DpePAXBzKYbvr06+RFRe5picPz6q4Wg9HalgcQk C2WVR9NHSusLGmtnY7peglTI+yyi8Mg5Prit0SArBwuR6WbWkhQb0JvKSBJV/Ueh6UAB p9YhZSdXjCPL7XPgnEKp/Eo0v7jlI3gYv6EQKfuYXU2JAecWQPoVXeKrGrrT4k4/K0T8 BZcw== 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=MpN75UTNm1zkwsyNfPLynbhxsHb/donU+5PTCQi4Cgs=; b=dPf0fvBV0CXW9QA8a2m79MmB1AWUdHYEtM1Z8NUbMoeq1x5HpZQ4dKvBfaoX3cTMHy adAEAbMMHQ8z1bUAUYc42ZGhbOiQjq0SVHV+q8/oEat6ON6kq9uj6wiibvspzVCLqWum 5dQwBs2ntNHIh1TQKY9GBCx/o5Mwu0k8KetkaPWjtPb2Q0a03bwcIdOwK3LStv2TNfZh HlKactmIkvrZfzVUVKXJmDiVM9IW4S4Lfqd2EgmP58HAt+7K+n78iUjP3GWkPnf9Ej5U liBWYgrFGfDJ6fIsVn4/MTJlevdgSUaSeaLO+tbbdoOS2phUPDYDFSvy84xSvRF7n29D mYng== 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 j24-20020a635518000000b004124c1fb619si3522382pgb.639.2022.07.04.04.25.29; Mon, 04 Jul 2022 04:25:41 -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 S234189AbiGDKRV (ORCPT + 99 others); Mon, 4 Jul 2022 06:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234097AbiGDKQa (ORCPT ); Mon, 4 Jul 2022 06:16:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E3DB0DFA4 for ; Mon, 4 Jul 2022 03:16:29 -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 033C6D6E; Mon, 4 Jul 2022 03:16:30 -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 E6AF63F792; Mon, 4 Jul 2022 03:16:27 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Cc: Sudeep Holla , conor.dooley@microchip.com, valentina.fernandezalanis@microchip.com, 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 v6 07/21] cacheinfo: Use cache identifiers to check if the caches are shared if available Date: Mon, 4 Jul 2022 11:15:51 +0100 Message-Id: <20220704101605.1318280-8-sudeep.holla@arm.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220704101605.1318280-1-sudeep.holla@arm.com> References: <20220704101605.1318280-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. 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 4d21a1022fa9..e331b399adeb 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.37.0