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