xref: /openbmc/linux/arch/loongarch/kernel/topology.c (revision 18afb028)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/acpi.h>
3 #include <linux/cpu.h>
4 #include <linux/cpumask.h>
5 #include <linux/init.h>
6 #include <linux/node.h>
7 #include <linux/nodemask.h>
8 #include <linux/percpu.h>
9 #include <asm/bootinfo.h>
10 
11 #include <acpi/processor.h>
12 
13 static DEFINE_PER_CPU(struct cpu, cpu_devices);
14 
15 #ifdef CONFIG_HOTPLUG_CPU
16 int arch_register_cpu(int cpu)
17 {
18 	int ret;
19 	struct cpu *c = &per_cpu(cpu_devices, cpu);
20 
21 	c->hotpluggable = 1;
22 	ret = register_cpu(c, cpu);
23 	if (ret < 0)
24 		pr_warn("register_cpu %d failed (%d)\n", cpu, ret);
25 
26 	return ret;
27 }
28 EXPORT_SYMBOL(arch_register_cpu);
29 
30 void arch_unregister_cpu(int cpu)
31 {
32 	struct cpu *c = &per_cpu(cpu_devices, cpu);
33 
34 	c->hotpluggable = 0;
35 	unregister_cpu(c);
36 }
37 EXPORT_SYMBOL(arch_unregister_cpu);
38 #endif
39 
40 static int __init topology_init(void)
41 {
42 	int i, ret;
43 
44 	for_each_present_cpu(i) {
45 		struct cpu *c = &per_cpu(cpu_devices, i);
46 
47 		c->hotpluggable = !io_master(i);
48 		ret = register_cpu(c, i);
49 		if (ret < 0)
50 			pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret);
51 	}
52 
53 	return 0;
54 }
55 
56 subsys_initcall(topology_init);
57