@@ -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;
}
@@ -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);
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(-)