Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp576924rwl; Wed, 12 Apr 2023 00:39:33 -0700 (PDT) X-Google-Smtp-Source: AKy350Y7cHvFkjW88hcSWDEpC2C49XhuHhiN2KogkIIIKuYWKqRsAlUkhgQHHLHnp6fZ7IbKE28l X-Received: by 2002:a17:902:f543:b0:1a6:71b1:a0bd with SMTP id h3-20020a170902f54300b001a671b1a0bdmr893507plf.35.1681285173134; Wed, 12 Apr 2023 00:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681285173; cv=none; d=google.com; s=arc-20160816; b=kyprRgGKcfx/xuOtZlRavGyxFsuYRKWMB/79gdEz2Wj9QaHKtc3jOclSQBUn7T5unb uy4r1J9qCmXYKtX4VcfAFS9+iTlRBOYpgKh+GZA2mW8rs8SziZjc4OnLQYIMp7u2phN5 DrRwpjy0af6d+/imiI3r4EM37uLQpqgNH7sVvqoK9rfqNC03ciJWlbbTML/Dvb3vsMfn hqoIDFX23HMMaU5c5yEY4d/tZbJWqM1a+f9fa5fmi8L+QFEDyMC34onvaj0a38zZcoTu y6taFlmjfeoCNwDDyx1RPF48++m/tK10WstmI//xqVmzoUSIQBYYjD59dRHsgmiXUOH0 BKig== 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=zlVSvDYf6BLpgTAnN0lfpY+0ncZ878aK5IE1Djry/2g=; b=EwrYNeBnbCvKrY2W8cqyP8rm1XJPbIUqebzREdBcifQ0Tu/5ecebH5++tXrmu+BsZ5 MrbyKyNFMiZ1oJX/SRGHGeHzsJ+YucIrhlWsiiB7o2RwIT/SltmxWuRgbhHDX7ZV3IO0 x7XArEzSdUB6ihea2PbFe8X8e37TYl+9qIsFGxiBmeEQk+4uiDBBzc/SPOCwu+uQTI0s nC+zJUL+zVWQ997xskUqaG60IoF+Ye2RONV89pxUDitPuooj8fdf9hizRmLg9QRGEtkv pZIscTQZtKVJXV9ny7S3M0yF88PCjUprsMd5p9sLwYMoLAdc44tGuQHRgFkZOG97eO3m nkYw== 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 c1-20020a170902848100b00177568a0e53si15301555plo.252.2023.04.12.00.39.21; Wed, 12 Apr 2023 00:39:33 -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 S229757AbjDLHSf (ORCPT + 99 others); Wed, 12 Apr 2023 03:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjDLHSd (ORCPT ); Wed, 12 Apr 2023 03:18:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 313951731 for ; Wed, 12 Apr 2023 00:18:31 -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 4B5C31684; Wed, 12 Apr 2023 00:19:15 -0700 (PDT) Received: from pierre123.nice.arm.com (pierre123.nice.arm.com [10.34.100.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 18C563F73F; Wed, 12 Apr 2023 00:18:28 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Radu Rendec , Alexandre Ghiti , Conor Dooley , Will Deacon , Pierre Gondois , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , Palmer Dabbelt , Gavin Shan , Jeremy Linton Subject: [PATCH v2 1/3] cacheinfo: Check sib_leaf in cache_leaves_are_shared() Date: Wed, 12 Apr 2023 09:18:04 +0200 Message-Id: <20230412071809.12670-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230412071809.12670-1-pierre.gondois@arm.com> References: <20230412071809.12670-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 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 If 'this_leaf' is a L2 cache (or higher) and 'sib_leaf' is a L1 cache, the caches are detected as shared. Indeed, cache_leaves_are_shared() only checks the cache level of 'this_leaf' when 'sib_leaf''s cache level should also be checked. Check 'sib_leaf->level'. Also update the comment as the function is called when populating 'shared_cpu_map'. Fixes: f16d1becf96f ("cacheinfo: Use cache identifiers to check if the caches are shared if available") Signed-off-by: Pierre Gondois --- drivers/base/cacheinfo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index f3903d002819..e7ad6aba5f97 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -38,11 +38,10 @@ 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. This will be used - * only if arch specific code has not populated shared_cpu_map + * system-wide shared caches for all other levels. */ if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI))) - return !(this_leaf->level == 1); + return (this_leaf->level != 1) || (sib_leaf->level != 1); if ((sib_leaf->attributes & CACHE_ID) && (this_leaf->attributes & CACHE_ID)) -- 2.25.1