Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp311701iob; Wed, 18 May 2022 02:45:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3b0x29IGeKIRiLNG9dK1MvhznhXY3N6/QzIGC2tR+85f6dBFeNKlds3OwAb9tzmwovA55 X-Received: by 2002:a17:903:240c:b0:153:c452:f282 with SMTP id e12-20020a170903240c00b00153c452f282mr26200075plo.88.1652867132700; Wed, 18 May 2022 02:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652867132; cv=none; d=google.com; s=arc-20160816; b=PVPld+QjfM1w4wMxBcgA+JEltYP2qRWMu02Mgv/VBCpL/W1K5bpXaheSPfdAw2NcH2 WE/UKxxq7SVjKsq2b+zpbiKADbO8otNzktwy/I0tJSXesz73jCGYR8zX3K2zZNPnHmGH zaFLk/2WVgkYsgT/dACMv7kAjhCU3XCMBQmb2FXsaa+KSNoOovtZWPQqiTbL5JfPQjQn OfCuOml8bEKv6ULmcO12uZ4cw6+CFRiGw+5FdVoWEkBaMfhneXZuzP5EbTcXWeOjQWUm 1bcgfTHpUKv4KlQvxfMz3iRGxGytYnp9SMX1WK5Gsp1IEB8c9quAPSLYbU59KHqJgcTz r/MQ== 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=GmaqDcya1KLi+00A83yz1j0NW3O6gtIk81cVgUJMqUk=; b=xcWP09g7zai9WcEgwu2gC5k3yxsUkYe42YDfADb1f4z5YVLFLvqayrOQmgWilWeTdC EuoBrKXUAN9VS1Sx0eK6eOLOVkly2jxu8yeSA6LqLiLzdgf4gbamW81czDwjObCLixm1 GhWkOiS1/PJ3Nn86QZx1CVEdHbyndE1E32wsnN17uVex87XKReoQ3/LCQsp6sOXPNHd4 4vSgPymsUcaGBs7LCvdpvtvLU8qu53gZwn20VXcHHyS/ApaZHUUa1ASWDD5mAJ3OzjGl Hy0is2RvjAWYktZsgbirSId5w0EsEt+AO2lsc/jvS94XySzHdFENNr6QJB8nQHQ2X5Kf bY3w== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u15-20020a170902e5cf00b00153b2d16596si2278714plf.414.2022.05.18.02.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 02:45:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ABCD390CF3; Wed, 18 May 2022 02:35:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234393AbiERJeh (ORCPT + 99 others); Wed, 18 May 2022 05:34:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234357AbiERJeL (ORCPT ); Wed, 18 May 2022 05:34:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0AF5CB042C for ; Wed, 18 May 2022 02:34:06 -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 90D0C1063; Wed, 18 May 2022 02:34:06 -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 DDDBB3F66F; Wed, 18 May 2022 02:34:04 -0700 (PDT) From: Sudeep Holla To: Atish Patra , linux-kernel@vger.kernel.org Cc: Sudeep Holla , Atish Patra , Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Qing Wang , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Rob Herring Subject: [PATCH v2 7/8] of: base: add support to get the device node for the CPU's last level cache Date: Wed, 18 May 2022 10:33:24 +0100 Message-Id: <20220518093325.2070336-8-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220518093325.2070336-1-sudeep.holla@arm.com> References: <20220518093325.2070336-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 It is useful to have helper function just to get the pointer to the device node of the last level cache for a given logical cpu. It can be used as unique firmware identifier for the last level cache. This is useful to obtain the cpumask/cpumap of all the CPUs sharing the last level cache using the device node pointer as unique identifier for the last level cache. Cc: Rob Herring Signed-off-by: Sudeep Holla --- drivers/of/base.c | 33 +++++++++++++++++++++++++-------- include/linux/of.h | 1 + 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index d4f98c8469ed..0b6a8c3f9a85 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2072,17 +2072,17 @@ struct device_node *of_find_next_cache_node(const struct device_node *np) } /** - * of_find_last_cache_level - Find the level at which the last cache is - * present for the given logical cpu + * of_find_last_level_cache_node - Find the device node at which the last + * cache is present for the given logical cpu * - * @cpu: cpu number(logical index) for which the last cache level is needed + * @cpu: cpu number(logical index) for which the last cache level's device + * node is needed * - * Return: The the level at which the last cache is present. It is exactly - * same as the total number of cache levels for the given logical cpu. + * Return: The device node corresponding to the last cache for the given + * logical cpu */ -int of_find_last_cache_level(unsigned int cpu) +struct device_node *of_find_last_level_cache_node(unsigned int cpu) { - u32 cache_level = 0; struct device_node *prev = NULL, *np = of_cpu_device_node_get(cpu); while (np) { @@ -2091,7 +2091,24 @@ int of_find_last_cache_level(unsigned int cpu) np = of_find_next_cache_node(np); } - of_property_read_u32(prev, "cache-level", &cache_level); + return prev; +} + +/** + * of_find_last_cache_level - Find the level at which the last cache is + * present for the given logical cpu + * + * @cpu: cpu number(logical index) for which the last cache level is needed + * + * Return: The level at which the last cache is present. It is exactly + * same as the total number of cache levels for the given logical cpu. + */ +int of_find_last_cache_level(unsigned int cpu) +{ + u32 cache_level = 0; + struct device_node *np = of_find_last_level_cache_node(cpu); + + of_property_read_u32(np, "cache-level", &cache_level); return cache_level; } diff --git a/include/linux/of.h b/include/linux/of.h index 04971e85fbc9..ca0384cf08a3 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -297,6 +297,7 @@ extern struct device_node *of_get_child_by_name(const struct device_node *node, /* cache lookup */ extern struct device_node *of_find_next_cache_node(const struct device_node *); +extern struct device_node *of_find_last_level_cache_node(unsigned int cpu); extern int of_find_last_cache_level(unsigned int cpu); extern struct device_node *of_find_node_with_property( struct device_node *from, const char *prop_name); -- 2.36.1