lkml.org 
[lkml]   [2022]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] arm: topology: Consider clock-frequency property from parent /cpus node
Date
If the clock-frequency property is not set in the cpu node but in the
parent /cpus node, the following warning is emitted:

/cpus/cpu@X missing clock-frequency property

The devicetree specification in section 3.8 however specifies that
"properties that have identical values across cpu nodes may be placed in
the /cpus node instead. A client program must first examine a specific cpu
node, but if an expected property is not found then it should look at the
parent /cpus node."

Signed-off-by: Stefan Wiehler <stefan.wiehler@nokia.com>
---
- Refactored /cpus node lookup
- Add missing node refcount decrement via of_node_put(); of_get_property() does
not need it
---
arch/arm/kernel/topology.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index ef0058de432b..773c46c07a1c 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -90,10 +90,18 @@ static void __init parse_dt_topology(void)
unsigned long max_capacity = 0;
unsigned long capacity = 0;
int cpu = 0;
+ const __be32 *common_rate;
+ int common_rate_len;

__cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity),
GFP_NOWAIT);

+ cn = of_find_node_by_path("/cpus");
+ if (!cn)
+ pr_err("missing CPU root device node\n");
+ common_rate = of_get_property(cn, "clock-frequency", &common_rate_len);
+ of_node_put(cn);
+
for_each_possible_cpu(cpu) {
const __be32 *rate;
int len;
@@ -121,8 +129,12 @@ static void __init parse_dt_topology(void)

rate = of_get_property(cn, "clock-frequency", &len);
if (!rate || len != 4) {
- pr_err("%pOF missing clock-frequency property\n", cn);
- continue;
+ if (common_rate && common_rate_len == 4) {
+ rate = common_rate;
+ } else {
+ pr_err("%pOF missing clock-frequency property\n", cn);
+ continue;
+ }
}

capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
--
2.31.0
\
 
 \ /
  Last update: 2023-03-26 23:17    [W:0.023 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site