Skip to content

Commit f3c1948

Browse files
prime-zenggregkh
authored andcommitted
cpu-topology: Don't error on more than CONFIG_NR_CPUS CPUs in device tree
When the kernel is configured with CONFIG_NR_CPUS smaller than the number of CPU nodes in the device tree(DT), all the CPU nodes parsing done to fetch topology information will fail. This is not reasonable as it is legal to have all the physical CPUs in the system in the DT. Let us just skip such CPU DT nodes that are not used in the kernel rather than returning an error. Reviewed-by: Sudeep Holla <[email protected]> Signed-off-by: Zeng Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a37f495 commit f3c1948

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/base/arch_topology.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ core_initcall(free_raw_capacity);
248248
#endif
249249

250250
#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV)
251+
/*
252+
* This function returns the logic cpu number of the node.
253+
* There are basically three kinds of return values:
254+
* (1) logic cpu number which is > 0.
255+
* (2) -ENODEV when the device tree(DT) node is valid and found in the DT but
256+
* there is no possible logical CPU in the kernel to match. This happens
257+
* when CONFIG_NR_CPUS is configure to be smaller than the number of
258+
* CPU nodes in DT. We need to just ignore this case.
259+
* (3) -1 if the node does not exist in the device tree
260+
*/
251261
static int __init get_cpu_for_node(struct device_node *node)
252262
{
253263
struct device_node *cpu_node;
@@ -261,7 +271,8 @@ static int __init get_cpu_for_node(struct device_node *node)
261271
if (cpu >= 0)
262272
topology_parse_cpu_capacity(cpu_node, cpu);
263273
else
264-
pr_crit("Unable to find CPU node for %pOF\n", cpu_node);
274+
pr_info("CPU node for %pOF exist but the possible cpu range is :%*pbl\n",
275+
cpu_node, cpumask_pr_args(cpu_possible_mask));
265276

266277
of_node_put(cpu_node);
267278
return cpu;
@@ -286,9 +297,8 @@ static int __init parse_core(struct device_node *core, int package_id,
286297
cpu_topology[cpu].package_id = package_id;
287298
cpu_topology[cpu].core_id = core_id;
288299
cpu_topology[cpu].thread_id = i;
289-
} else {
290-
pr_err("%pOF: Can't get CPU for thread\n",
291-
t);
300+
} else if (cpu != -ENODEV) {
301+
pr_err("%pOF: Can't get CPU for thread\n", t);
292302
of_node_put(t);
293303
return -EINVAL;
294304
}
@@ -307,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id,
307317

308318
cpu_topology[cpu].package_id = package_id;
309319
cpu_topology[cpu].core_id = core_id;
310-
} else if (leaf) {
320+
} else if (leaf && cpu != -ENODEV) {
311321
pr_err("%pOF: Can't get CPU for leaf core\n", core);
312322
return -EINVAL;
313323
}

0 commit comments

Comments
 (0)