From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD5E4C433F5 for ; Thu, 16 Dec 2021 23:33:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c95GHYBOBDKXRxdzlZ7aTHupPONxJtqVW96XnDaiH+k=; b=4U2lcSGALCd94E IW+jE4C/hE4uND3MI4FfQG8aw0CZxdhoX2i9tdCNEkekZLCvUdT5PpHHEWX0bOXAT6ifaembOK10z f/4/JjkwPHdsxJHptpTmyaBmvdKX6+2yOHyNCsnGSPHIaQMYmXl9qe03pg5ZT+OPvSYJr2FdgFjDW QDquI606zuZZUJmCW8KmPqbj+xQ5shJLSGrymjs4CAVqVlFPxRX3T+PORwA33/do/aQN2LFqenKqo rpl/ZSjKZcc6q5DnQkaC09VQJ5/RyHuRos3uxrm+qMv2TXimMoa4KoSt1VofObbtKL1cePlUzXLKn bx7EFoahuCWYPkHW0dCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1my0E3-007wND-Px; Thu, 16 Dec 2021 23:31:51 +0000 Received: from mail-oi1-f172.google.com ([209.85.167.172]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1my0Di-007wGz-Ne for linux-arm-kernel@lists.infradead.org; Thu, 16 Dec 2021 23:31:32 +0000 Received: by mail-oi1-f172.google.com with SMTP id s139so1086834oie.13 for ; Thu, 16 Dec 2021 15:31:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XJxuQtRLTVfIiHxosQQwj5MJ9jgW00UdvVH4T37a4e0=; b=I7ItZ5nrV2hcnKngbEA4p2AX9UofgBL6IzriMaiq9J7XnAZJm+s32HTkgsDtNb8x9D D0W43K+x5ucKuqS271TIHeg/R5z11XuBz7adHzx+CwvpYnc8+MI9QcgyTR+AOqqiPDTT sdik0OjhqHGRKdprfwD0jWwYkGU51LcsmpspKWvZEpvWUnlYOBnc5G0GJpYlzdsTJOpU G+mZEiN19ARQNWmJ8J7NWKlcVBdvfGS4maP9/EFGI+yxvcmfjcBkdzfhg2YXkIbkuruc ufZhG7pxOz8hQ0hnyIOYArjL5DFumzaeseUVwlCIVDXSjL/ejw0YU3XPcA/TdE3HILiB excA== X-Gm-Message-State: AOAM530iwGBg30EMZoDSJ2dfRbJsUw/QnciVKB3bK3U1TexT0dVsOL0L eKX3dvr6SaQU/DIB3WOLQA== X-Google-Smtp-Source: ABdhPJy3osxEec/uFfDfvEc9vw+RCg25N1CQDsD8MFEWyLn67kai6YEnfUJhllbsJNoUI1R1/4kVtg== X-Received: by 2002:a05:6808:4d2:: with SMTP id a18mr136647oie.99.1639697489825; Thu, 16 Dec 2021 15:31:29 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id n11sm1256646oor.9.2021.12.16.15.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 15:31:29 -0800 (PST) From: Rob Herring To: Greg Kroah-Hartman , James Morse , Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , "Rafael J. Wysocki" , Len Brown , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 2/6] cacheinfo: Set cache 'id' based on DT data Date: Thu, 16 Dec 2021 17:31:21 -0600 Message-Id: <20211216233125.1130793-3-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216233125.1130793-1-robh@kernel.org> References: <20211216233125.1130793-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211216_153130_811936_4E4A03DC X-CRM114-Status: GOOD ( 15.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the minimum CPU h/w id of the CPUs associated with the cache for the cache 'id'. This will provide a stable id value for a given system. As we need to check all possible CPUs, we can't use the shared_cpu_map which is just online CPUs. There's not a cache to CPUs mapping in DT, so we have to walk all CPU nodes and then walk cache levels. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Rob Herring --- v2: - Loop with for_each_possible_cpu instead of for_each_of_cpu_node as we will need the logical cpu numbers. --- drivers/base/cacheinfo.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 66d10bdb863b..21accddf8f5f 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -136,6 +136,36 @@ static bool cache_node_is_unified(struct cacheinfo *this_leaf, return of_property_read_bool(np, "cache-unified"); } +static void cache_of_set_id(struct cacheinfo *this_leaf, struct device_node *np) +{ + int cpu; + unsigned long min_id = ~0UL; + + for_each_possible_cpu(cpu) { + u64 id; + struct device_node *cache_node, *cpu_node; + + cache_node = cpu_node = of_get_cpu_node(cpu, NULL); + id = of_get_cpu_hwid(cpu_node, 0); + while ((cache_node = of_find_next_cache_node(cache_node))) { + if (cache_node == np) { + if (id < min_id) { + min_id = id; + of_node_put(cache_node); + break; + } + } + of_node_put(cache_node); + } + of_node_put(cpu_node); + } + + if (min_id != ~0UL) { + this_leaf->id = min_id; + this_leaf->attributes |= CACHE_ID; + } +} + static void cache_of_set_props(struct cacheinfo *this_leaf, struct device_node *np) { @@ -151,6 +181,7 @@ static void cache_of_set_props(struct cacheinfo *this_leaf, cache_get_line_size(this_leaf, np); cache_nr_sets(this_leaf, np); cache_associativity(this_leaf); + cache_of_set_id(this_leaf, np); } static int cache_setup_of_node(unsigned int cpu) -- 2.32.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel