0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #include <linux/interrupt.h>
0029 #include <linux/nodemask.h>
0030 #include <linux/export.h>
0031 #include <linux/mmzone.h>
0032 #include <linux/init.h>
0033 #include <linux/smp.h>
0034 #include <linux/irq.h>
0035 #include <asm/io_apic.h>
0036 #include <asm/cpu.h>
0037
0038 static DEFINE_PER_CPU(struct x86_cpu, cpu_devices);
0039
0040 #ifdef CONFIG_HOTPLUG_CPU
0041
0042 #ifdef CONFIG_BOOTPARAM_HOTPLUG_CPU0
0043 static int cpu0_hotpluggable = 1;
0044 #else
0045 static int cpu0_hotpluggable;
0046 static int __init enable_cpu0_hotplug(char *str)
0047 {
0048 cpu0_hotpluggable = 1;
0049 return 1;
0050 }
0051
0052 __setup("cpu0_hotplug", enable_cpu0_hotplug);
0053 #endif
0054
0055 #ifdef CONFIG_DEBUG_HOTPLUG_CPU0
0056
0057
0058
0059
0060
0061
0062 int _debug_hotplug_cpu(int cpu, int action)
0063 {
0064 int ret;
0065
0066 if (!cpu_is_hotpluggable(cpu))
0067 return -EINVAL;
0068
0069 switch (action) {
0070 case 0:
0071 ret = remove_cpu(cpu);
0072 if (!ret)
0073 pr_info("DEBUG_HOTPLUG_CPU0: CPU %u is now offline\n", cpu);
0074 else
0075 pr_debug("Can't offline CPU%d.\n", cpu);
0076 break;
0077 case 1:
0078 ret = add_cpu(cpu);
0079 if (ret)
0080 pr_debug("Can't online CPU%d.\n", cpu);
0081
0082 break;
0083 default:
0084 ret = -EINVAL;
0085 }
0086
0087 return ret;
0088 }
0089
0090 static int __init debug_hotplug_cpu(void)
0091 {
0092 _debug_hotplug_cpu(0, 0);
0093 return 0;
0094 }
0095
0096 late_initcall_sync(debug_hotplug_cpu);
0097 #endif
0098
0099 int arch_register_cpu(int num)
0100 {
0101 struct cpuinfo_x86 *c = &cpu_data(num);
0102
0103
0104
0105
0106
0107
0108 if (c->x86_vendor != X86_VENDOR_INTEL ||
0109 boot_cpu_has(X86_FEATURE_XENPV))
0110 cpu0_hotpluggable = 0;
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 if (num == 0 && cpu0_hotpluggable) {
0121 unsigned int irq;
0122
0123
0124
0125
0126 for_each_active_irq(irq) {
0127 if (!IO_APIC_IRQ(irq) && irq_has_action(irq)) {
0128 cpu0_hotpluggable = 0;
0129 break;
0130 }
0131 }
0132 }
0133 if (num || cpu0_hotpluggable)
0134 per_cpu(cpu_devices, num).cpu.hotpluggable = 1;
0135
0136 return register_cpu(&per_cpu(cpu_devices, num).cpu, num);
0137 }
0138 EXPORT_SYMBOL(arch_register_cpu);
0139
0140 void arch_unregister_cpu(int num)
0141 {
0142 unregister_cpu(&per_cpu(cpu_devices, num).cpu);
0143 }
0144 EXPORT_SYMBOL(arch_unregister_cpu);
0145 #else
0146
0147 static int __init arch_register_cpu(int num)
0148 {
0149 return register_cpu(&per_cpu(cpu_devices, num).cpu, num);
0150 }
0151 #endif
0152
0153 static int __init topology_init(void)
0154 {
0155 int i;
0156
0157 for_each_present_cpu(i)
0158 arch_register_cpu(i);
0159
0160 return 0;
0161 }
0162 subsys_initcall(topology_init);