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 <sudeep.holla@arm.com>
Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
Link: https://lore.kernel.org/r/1579225973-32423-1-git-send-email-prime.zeng@hisilicon.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Zeng Tao 2020-01-17 09:52:52 +08:00 committed by Greg Kroah-Hartman
parent a37f4958f7
commit f3c1948182

View File

@ -248,6 +248,16 @@ core_initcall(free_raw_capacity);
#endif #endif
#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) #if defined(CONFIG_ARM64) || defined(CONFIG_RISCV)
/*
* This function returns the logic cpu number of the node.
* There are basically three kinds of return values:
* (1) logic cpu number which is > 0.
* (2) -ENODEV when the device tree(DT) node is valid and found in the DT but
* there is no possible logical CPU in the kernel to match. This happens
* when CONFIG_NR_CPUS is configure to be smaller than the number of
* CPU nodes in DT. We need to just ignore this case.
* (3) -1 if the node does not exist in the device tree
*/
static int __init get_cpu_for_node(struct device_node *node) static int __init get_cpu_for_node(struct device_node *node)
{ {
struct device_node *cpu_node; struct device_node *cpu_node;
@ -261,7 +271,8 @@ static int __init get_cpu_for_node(struct device_node *node)
if (cpu >= 0) if (cpu >= 0)
topology_parse_cpu_capacity(cpu_node, cpu); topology_parse_cpu_capacity(cpu_node, cpu);
else else
pr_crit("Unable to find CPU node for %pOF\n", cpu_node); pr_info("CPU node for %pOF exist but the possible cpu range is :%*pbl\n",
cpu_node, cpumask_pr_args(cpu_possible_mask));
of_node_put(cpu_node); of_node_put(cpu_node);
return cpu; return cpu;
@ -286,9 +297,8 @@ static int __init parse_core(struct device_node *core, int package_id,
cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].package_id = package_id;
cpu_topology[cpu].core_id = core_id; cpu_topology[cpu].core_id = core_id;
cpu_topology[cpu].thread_id = i; cpu_topology[cpu].thread_id = i;
} else { } else if (cpu != -ENODEV) {
pr_err("%pOF: Can't get CPU for thread\n", pr_err("%pOF: Can't get CPU for thread\n", t);
t);
of_node_put(t); of_node_put(t);
return -EINVAL; return -EINVAL;
} }
@ -307,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id,
cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].package_id = package_id;
cpu_topology[cpu].core_id = core_id; cpu_topology[cpu].core_id = core_id;
} else if (leaf) { } else if (leaf && cpu != -ENODEV) {
pr_err("%pOF: Can't get CPU for leaf core\n", core); pr_err("%pOF: Can't get CPU for leaf core\n", core);
return -EINVAL; return -EINVAL;
} }