From: Sudeep Holla <sudeep.holla@arm.com>
To: Atish Patra <atishp@atishpatra.org>, linux-kernel@vger.kernel.org
Cc: Sudeep Holla <sudeep.holla@arm.com>,
Atish Patra <atishp@rivosinc.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Qing Wang <wangqing@vivo.com>,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org, Rob Herring <robh+dt@kernel.org>
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 [thread overview]
Message-ID: <20220518093325.2070336-8-sudeep.holla@arm.com> (raw)
In-Reply-To: <20220518093325.2070336-1-sudeep.holla@arm.com>
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 <robh+dt@kernel.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-05-18 9:37 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-18 9:33 [PATCH v2 0/8] arch_topology: Updates to add socket support and fix cluster ids Sudeep Holla
2022-05-18 9:33 ` [PATCH v2 1/8] arch_topology: Don't set cluster identifier as physical package identifier Sudeep Holla
2022-05-20 12:31 ` Dietmar Eggemann
2022-05-20 13:13 ` Sudeep Holla
2022-05-18 9:33 ` [PATCH v2 2/8] arch_topology: Set thread sibling cpumask only within the cluster Sudeep Holla
2022-05-20 12:32 ` Dietmar Eggemann
2022-05-20 13:20 ` Sudeep Holla
2022-05-18 9:33 ` [PATCH v2 3/8] arch_topology: Set cluster identifier in each core/thread from /cpu-map Sudeep Holla
2022-05-19 16:55 ` Ionela Voinescu
2022-05-20 12:33 ` Dietmar Eggemann
2022-05-20 13:54 ` Sudeep Holla
2022-05-20 15:27 ` Sudeep Holla
2022-05-18 9:33 ` [PATCH v2 4/8] arch_topology: Add support for parsing sockets in /cpu-map Sudeep Holla
2022-05-18 9:33 ` [PATCH v2 5/8] arch_topology: Check for non-negative value rather than -1 for IDs validity Sudeep Holla
2022-05-18 9:33 ` [PATCH v2 6/8] arch_topology: Avoid parsing through all the CPUs once a outlier CPU is found Sudeep Holla
2022-05-18 9:33 ` Sudeep Holla [this message]
2022-05-18 9:33 ` [PATCH v2 8/8] arch_topology: Add support to build llc_sibling on DT platforms Sudeep Holla
2022-05-19 18:10 ` Rob Herring
2022-05-20 12:59 ` Sudeep Holla
2022-05-20 14:36 ` Rob Herring
2022-05-20 15:06 ` Sudeep Holla
2022-05-20 12:33 ` Dietmar Eggemann
2022-05-20 14:56 ` Sudeep Holla
2022-05-19 16:32 ` [PATCH v2 0/8] arch_topology: Updates to add socket support and fix cluster ids Ionela Voinescu
2022-05-20 15:33 ` Sudeep Holla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220518093325.2070336-8-sudeep.holla@arm.com \
--to=sudeep.holla@arm.com \
--cc=atishp@atishpatra.org \
--cc=atishp@rivosinc.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=morten.rasmussen@arm.com \
--cc=robh+dt@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=wangqing@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox