Messages in this thread Patch in this message | | | From | Leo Yan <> | Subject | [PATCH v1 2/3] arch_topology: Handle inconsistent binding of CPU raw capacity | Date | Sun, 13 Mar 2022 13:55:11 +0800 |
| |
There have a corner case is if we use below DT binding:
cpu0: cpu@0 { compatible = "arm,cortex-a53"; device_type = "cpu"; reg = <0x0 0x0>; enable-method = "psci"; };
cpu1: cpu@1 { compatible = "arm,cortex-a53"; device_type = "cpu"; reg = <0x0 0x1>; enable-method = "psci"; capacity-dmips-mhz = <1024>; };
In this case, CPU0 node misses to bind "capacity-dmips-mhz" property, and CPU1 node binds the property, this means the CPU raw capacity binding is inconsistent across all CPUs.
This patch introduces an extra flag 'cap_property_miss' to indicate that any previous CPU nodes miss binding for "capacity-dmips-mhz" property, and any new CPU node contains the property, it detects the inconsistent binding, and sets 'cap_parsing_failed' to true and frees raw capacity array.
Signed-off-by: Leo Yan <leo.yan@linaro.org> --- drivers/base/arch_topology.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index b81777ae6425..0687576e880b 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -294,6 +294,7 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) struct clk *cpu_clk; int ret; u32 cpu_capacity; + static bool cap_property_miss; if (cap_parsing_failed) return false; @@ -301,6 +302,20 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz", &cpu_capacity); if (!ret) { + /* + * A previous CPU node misses binding for CPU raw capacity and + * current CPU node finds its property "capacity-dmips-mhz", + * thus the DT binding for "capacity-dmips-mhz" is inconsistent + * across all CPUs. Set 'cap_parsing_failed' flag and drop the + * CPU raw capacity values. + */ + if (cap_property_miss) { + pr_err("cpu_capacity: binding %pOF raw capacity\n", + cpu_node); + pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n"); + goto parsing_failure; + } + if (!raw_capacity) { raw_capacity = kcalloc(num_possible_cpus(), sizeof(*raw_capacity), @@ -331,12 +346,18 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) pr_err("cpu_capacity: missing %pOF raw capacity\n", cpu_node); pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n"); - cap_parsing_failed = true; - free_raw_capacity(); + goto parsing_failure; + } else { + cap_property_miss = true; } } return !ret; + +parsing_failure: + cap_parsing_failed = true; + free_raw_capacity(); + return !ret; } #ifdef CONFIG_CPU_FREQ -- 2.25.1
| |