blob: 933e214c33e8a835ed1614afa399b37b9506ceda [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/sysdev.h>
2#include <linux/cpu.h>
3#include <linux/smp.h>
4#include <linux/percpu.h>
5#include <linux/init.h>
6#include <linux/sched.h>
7#include <linux/module.h>
8#include <linux/nodemask.h>
9#include <linux/cpumask.h>
10#include <linux/notifier.h>
11
12#include <asm/current.h>
13#include <asm/processor.h>
14#include <asm/cputable.h>
Stephen Rothwell1ababe12005-08-03 14:35:25 +100015#include <asm/firmware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/hvcall.h>
17#include <asm/prom.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/paca.h>
19#include <asm/lppaca.h>
20#include <asm/machdep.h>
Paul Mackerras2249ca92005-11-07 13:18:13 +110021#include <asm/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23static DEFINE_PER_CPU(struct cpu, cpu_devices);
24
25/* SMT stuff */
26
27#ifdef CONFIG_PPC_MULTIPLATFORM
Anton Blanchard0ddd3e72006-09-22 20:30:14 +100028/* Time in microseconds we delay before sleeping in the idle loop */
29DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf,
32 size_t count)
33{
34 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
35 ssize_t ret;
36 unsigned long snooze;
37
38 ret = sscanf(buf, "%lu", &snooze);
39 if (ret != 1)
40 return -EINVAL;
41
42 per_cpu(smt_snooze_delay, cpu->sysdev.id) = snooze;
43
44 return count;
45}
46
47static ssize_t show_smt_snooze_delay(struct sys_device *dev, char *buf)
48{
49 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
50
51 return sprintf(buf, "%lu\n", per_cpu(smt_snooze_delay, cpu->sysdev.id));
52}
53
54static SYSDEV_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
55 store_smt_snooze_delay);
56
57/* Only parse OF options if the matching cmdline option was not specified */
58static int smt_snooze_cmdline;
59
60static int __init smt_setup(void)
61{
62 struct device_node *options;
Jeremy Kerra7f67bd2006-07-12 15:35:54 +100063 const unsigned int *val;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 unsigned int cpu;
65
66 if (!cpu_has_feature(CPU_FTR_SMT))
Anton Blanchard69ed3322006-03-28 14:08:39 +110067 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Stephen Rothwell8c8dc322007-04-24 13:50:55 +100069 options = of_find_node_by_path("/options");
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 if (!options)
Anton Blanchard69ed3322006-03-28 14:08:39 +110071 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Stephen Rothwelle2eb6392007-04-03 22:26:41 +100073 val = of_get_property(options, "ibm,smt-snooze-delay", NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 if (!smt_snooze_cmdline && val) {
KAMEZAWA Hiroyuki0e551952006-03-28 14:50:51 -080075 for_each_possible_cpu(cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 per_cpu(smt_snooze_delay, cpu) = *val;
77 }
78
Stephen Rothwell8c8dc322007-04-24 13:50:55 +100079 of_node_put(options);
Anton Blanchard69ed3322006-03-28 14:08:39 +110080 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82__initcall(smt_setup);
83
84static int __init setup_smt_snooze_delay(char *str)
85{
86 unsigned int cpu;
87 int snooze;
88
89 if (!cpu_has_feature(CPU_FTR_SMT))
90 return 1;
91
92 smt_snooze_cmdline = 1;
93
94 if (get_option(&str, &snooze)) {
KAMEZAWA Hiroyuki0e551952006-03-28 14:50:51 -080095 for_each_possible_cpu(cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 per_cpu(smt_snooze_delay, cpu) = snooze;
97 }
98
99 return 1;
100}
101__setup("smt-snooze-delay=", setup_smt_snooze_delay);
102
Michael Ellerman180a3362005-08-09 11:13:36 +1000103#endif /* CONFIG_PPC_MULTIPLATFORM */
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105/*
106 * Enabling PMCs will slow partition context switch times so we only do
107 * it the first time we write to the PMCs.
108 */
109
110static DEFINE_PER_CPU(char, pmcs_enabled);
111
112void ppc64_enable_pmcs(void)
113{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 /* Only need to enable them once */
115 if (__get_cpu_var(pmcs_enabled))
116 return;
117
118 __get_cpu_var(pmcs_enabled) = 1;
119
Michael Ellerman180a3362005-08-09 11:13:36 +1000120 if (ppc_md.enable_pmcs)
121 ppc_md.enable_pmcs();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123EXPORT_SYMBOL(ppc64_enable_pmcs);
124
125/* XXX convert to rusty's on_one_cpu */
126static unsigned long run_on_cpu(unsigned long cpu,
127 unsigned long (*func)(unsigned long),
128 unsigned long arg)
129{
130 cpumask_t old_affinity = current->cpus_allowed;
131 unsigned long ret;
132
133 /* should return -EINVAL to userspace */
134 if (set_cpus_allowed(current, cpumask_of_cpu(cpu)))
135 return 0;
136
137 ret = func(arg);
138
139 set_cpus_allowed(current, old_affinity);
140
141 return ret;
142}
143
144#define SYSFS_PMCSETUP(NAME, ADDRESS) \
145static unsigned long read_##NAME(unsigned long junk) \
146{ \
147 return mfspr(ADDRESS); \
148} \
149static unsigned long write_##NAME(unsigned long val) \
150{ \
151 ppc64_enable_pmcs(); \
152 mtspr(ADDRESS, val); \
153 return 0; \
154} \
155static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
156{ \
157 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
158 unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
159 return sprintf(buf, "%lx\n", val); \
160} \
161static ssize_t __attribute_used__ \
162 store_##NAME(struct sys_device *dev, const char *buf, size_t count) \
163{ \
164 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
165 unsigned long val; \
166 int ret = sscanf(buf, "%lx", &val); \
167 if (ret != 1) \
168 return -EINVAL; \
169 run_on_cpu(cpu->sysdev.id, write_##NAME, val); \
170 return count; \
171}
172
Olof Johansson6529c132007-01-28 21:25:57 -0600173
174/* Let's define all possible registers, we'll only hook up the ones
175 * that are implemented on the current processor
176 */
177
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0);
179SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1);
180SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
181SYSFS_PMCSETUP(pmc1, SPRN_PMC1);
182SYSFS_PMCSETUP(pmc2, SPRN_PMC2);
183SYSFS_PMCSETUP(pmc3, SPRN_PMC3);
184SYSFS_PMCSETUP(pmc4, SPRN_PMC4);
185SYSFS_PMCSETUP(pmc5, SPRN_PMC5);
186SYSFS_PMCSETUP(pmc6, SPRN_PMC6);
187SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
188SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
189SYSFS_PMCSETUP(purr, SPRN_PURR);
Anton Blanchardf0509822006-12-08 17:51:13 +1100190SYSFS_PMCSETUP(spurr, SPRN_SPURR);
Anton Blanchard4c1985572006-12-08 17:46:58 +1100191SYSFS_PMCSETUP(dscr, SPRN_DSCR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
Olof Johansson25fc5302007-04-18 16:38:21 +1000193SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
194SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
195SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
196SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
197SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
198SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
Olof Johansson6529c132007-01-28 21:25:57 -0600199
200
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
Anton Blanchardf0509822006-12-08 17:51:13 +1100202static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
Anton Blanchard4c1985572006-12-08 17:46:58 +1100203static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
Olof Johansson6529c132007-01-28 21:25:57 -0600204static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
205
206static struct sysdev_attribute ibm_common_attrs[] = {
207 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
208 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
209};
210
211static struct sysdev_attribute ibm_pmc_attrs[] = {
212 _SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1),
213 _SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2),
214 _SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3),
215 _SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4),
216 _SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5),
217 _SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6),
218 _SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7),
219 _SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8),
220};
221
222static struct sysdev_attribute pa6t_attrs[] = {
223 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
224 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
225 _SYSDEV_ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0),
226 _SYSDEV_ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1),
227 _SYSDEV_ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2),
228 _SYSDEV_ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3),
229 _SYSDEV_ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4),
230 _SYSDEV_ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5),
231};
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234static void register_cpu_online(unsigned int cpu)
235{
236 struct cpu *c = &per_cpu(cpu_devices, cpu);
237 struct sys_device *s = &c->sysdev;
Olof Johansson6529c132007-01-28 21:25:57 -0600238 struct sysdev_attribute *attrs, *pmc_attrs;
239 int i, nattrs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Stephen Rothwellad5cb172006-11-13 14:46:04 +1100241 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
242 cpu_has_feature(CPU_FTR_SMT))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 sysdev_create_file(s, &attr_smt_snooze_delay);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
245 /* PMC stuff */
Olof Johansson6529c132007-01-28 21:25:57 -0600246 switch (cur_cpu_spec->pmc_type) {
247 case PPC_PMC_IBM:
248 attrs = ibm_common_attrs;
249 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
250 pmc_attrs = ibm_pmc_attrs;
251 break;
252 case PPC_PMC_PA6T:
253 /* PA Semi starts counting at PMC0 */
254 attrs = pa6t_attrs;
255 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
256 pmc_attrs = NULL;
257 break;
258 default:
259 attrs = NULL;
260 nattrs = 0;
261 pmc_attrs = NULL;
262 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Olof Johansson6529c132007-01-28 21:25:57 -0600264 for (i = 0; i < nattrs; i++)
265 sysdev_create_file(s, &attrs[i]);
266
267 if (pmc_attrs)
268 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
269 sysdev_create_file(s, &pmc_attrs[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271 if (cpu_has_feature(CPU_FTR_MMCRA))
272 sysdev_create_file(s, &attr_mmcra);
273
Michael Neulingafd05422006-07-28 13:58:37 +1000274 if (cpu_has_feature(CPU_FTR_PURR))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 sysdev_create_file(s, &attr_purr);
Anton Blanchard4c1985572006-12-08 17:46:58 +1100276
Anton Blanchardf0509822006-12-08 17:51:13 +1100277 if (cpu_has_feature(CPU_FTR_SPURR))
278 sysdev_create_file(s, &attr_spurr);
279
Anton Blanchard4c1985572006-12-08 17:46:58 +1100280 if (cpu_has_feature(CPU_FTR_DSCR))
281 sysdev_create_file(s, &attr_dscr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282}
283
284#ifdef CONFIG_HOTPLUG_CPU
285static void unregister_cpu_online(unsigned int cpu)
286{
287 struct cpu *c = &per_cpu(cpu_devices, cpu);
288 struct sys_device *s = &c->sysdev;
Olof Johansson6529c132007-01-28 21:25:57 -0600289 struct sysdev_attribute *attrs, *pmc_attrs;
290 int i, nattrs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
Siddha, Suresh B72486f12006-12-07 02:14:10 +0100292 BUG_ON(!c->hotpluggable);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293
Stephen Rothwellad5cb172006-11-13 14:46:04 +1100294 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
295 cpu_has_feature(CPU_FTR_SMT))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 sysdev_remove_file(s, &attr_smt_snooze_delay);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
298 /* PMC stuff */
Olof Johansson6529c132007-01-28 21:25:57 -0600299 switch (cur_cpu_spec->pmc_type) {
300 case PPC_PMC_IBM:
301 attrs = ibm_common_attrs;
302 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
303 pmc_attrs = ibm_pmc_attrs;
304 break;
305 case PPC_PMC_PA6T:
306 /* PA Semi starts counting at PMC0 */
307 attrs = pa6t_attrs;
308 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
309 pmc_attrs = NULL;
310 break;
311 default:
312 attrs = NULL;
313 nattrs = 0;
314 pmc_attrs = NULL;
315 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
Olof Johansson6529c132007-01-28 21:25:57 -0600317 for (i = 0; i < nattrs; i++)
318 sysdev_remove_file(s, &attrs[i]);
319
320 if (pmc_attrs)
321 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
322 sysdev_remove_file(s, &pmc_attrs[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324 if (cpu_has_feature(CPU_FTR_MMCRA))
325 sysdev_remove_file(s, &attr_mmcra);
326
Michael Neulingafd05422006-07-28 13:58:37 +1000327 if (cpu_has_feature(CPU_FTR_PURR))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 sysdev_remove_file(s, &attr_purr);
Anton Blanchard4c1985572006-12-08 17:46:58 +1100329
Anton Blanchardf0509822006-12-08 17:51:13 +1100330 if (cpu_has_feature(CPU_FTR_SPURR))
331 sysdev_remove_file(s, &attr_spurr);
332
Anton Blanchard4c1985572006-12-08 17:46:58 +1100333 if (cpu_has_feature(CPU_FTR_DSCR))
334 sysdev_remove_file(s, &attr_dscr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336#endif /* CONFIG_HOTPLUG_CPU */
337
Chandra Seetharaman8c78f302006-07-30 03:03:35 -0700338static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 unsigned long action, void *hcpu)
340{
341 unsigned int cpu = (unsigned int)(long)hcpu;
342
343 switch (action) {
344 case CPU_ONLINE:
345 register_cpu_online(cpu);
346 break;
347#ifdef CONFIG_HOTPLUG_CPU
348 case CPU_DEAD:
349 unregister_cpu_online(cpu);
350 break;
351#endif
352 }
353 return NOTIFY_OK;
354}
355
Chandra Seetharaman8c78f302006-07-30 03:03:35 -0700356static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 .notifier_call = sysfs_cpu_notify,
358};
359
Christian Krafft0344c6c2006-10-24 18:31:24 +0200360static DEFINE_MUTEX(cpu_mutex);
361
362int cpu_add_sysdev_attr(struct sysdev_attribute *attr)
363{
364 int cpu;
365
366 mutex_lock(&cpu_mutex);
367
368 for_each_possible_cpu(cpu) {
369 sysdev_create_file(get_cpu_sysdev(cpu), attr);
370 }
371
372 mutex_unlock(&cpu_mutex);
373 return 0;
374}
375EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr);
376
377int cpu_add_sysdev_attr_group(struct attribute_group *attrs)
378{
379 int cpu;
380 struct sys_device *sysdev;
381
382 mutex_lock(&cpu_mutex);
383
384 for_each_possible_cpu(cpu) {
385 sysdev = get_cpu_sysdev(cpu);
386 sysfs_create_group(&sysdev->kobj, attrs);
387 }
388
389 mutex_unlock(&cpu_mutex);
390 return 0;
391}
392EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
393
394
395void cpu_remove_sysdev_attr(struct sysdev_attribute *attr)
396{
397 int cpu;
398
399 mutex_lock(&cpu_mutex);
400
401 for_each_possible_cpu(cpu) {
402 sysdev_remove_file(get_cpu_sysdev(cpu), attr);
403 }
404
405 mutex_unlock(&cpu_mutex);
406}
407EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr);
408
409void cpu_remove_sysdev_attr_group(struct attribute_group *attrs)
410{
411 int cpu;
412 struct sys_device *sysdev;
413
414 mutex_lock(&cpu_mutex);
415
416 for_each_possible_cpu(cpu) {
417 sysdev = get_cpu_sysdev(cpu);
418 sysfs_remove_group(&sysdev->kobj, attrs);
419 }
420
421 mutex_unlock(&cpu_mutex);
422}
423EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr_group);
424
425
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426/* NUMA stuff */
427
428#ifdef CONFIG_NUMA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429static void register_nodes(void)
430{
431 int i;
432
Yasunori Goto0fc44152006-06-27 02:53:38 -0700433 for (i = 0; i < MAX_NUMNODES; i++)
434 register_one_node(i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435}
Jeremy Kerr953039c2006-05-01 12:16:12 -0700436
437int sysfs_add_device_to_node(struct sys_device *dev, int nid)
438{
439 struct node *node = &node_devices[nid];
440 return sysfs_create_link(&node->sysdev.kobj, &dev->kobj,
441 kobject_name(&dev->kobj));
442}
443
444void sysfs_remove_device_from_node(struct sys_device *dev, int nid)
445{
446 struct node *node = &node_devices[nid];
447 sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj));
448}
449
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450#else
451static void register_nodes(void)
452{
453 return;
454}
Jeremy Kerr953039c2006-05-01 12:16:12 -0700455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456#endif
457
Jeremy Kerr953039c2006-05-01 12:16:12 -0700458EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
459EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node);
460
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461/* Only valid if CPU is present. */
462static ssize_t show_physical_id(struct sys_device *dev, char *buf)
463{
464 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
465
466 return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->sysdev.id));
467}
468static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
469
470static int __init topology_init(void)
471{
472 int cpu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
474 register_nodes();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 register_cpu_notifier(&sysfs_cpu_nb);
476
KAMEZAWA Hiroyuki0e551952006-03-28 14:50:51 -0800477 for_each_possible_cpu(cpu) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 struct cpu *c = &per_cpu(cpu_devices, cpu);
479
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 /*
481 * For now, we just see if the system supports making
482 * the RTAS calls for CPU hotplug. But, there may be a
483 * more comprehensive way to do this for an individual
484 * CPU. For instance, the boot cpu might never be valid
485 * for hotplugging.
486 */
Siddha, Suresh B72486f12006-12-07 02:14:10 +0100487 if (ppc_md.cpu_die)
488 c->hotpluggable = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
Siddha, Suresh B72486f12006-12-07 02:14:10 +0100490 if (cpu_online(cpu) || c->hotpluggable) {
KAMEZAWA Hiroyuki76b67ed2006-06-27 02:53:41 -0700491 register_cpu(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492
493 sysdev_create_file(&c->sysdev, &attr_physical_id);
494 }
495
496 if (cpu_online(cpu))
497 register_cpu_online(cpu);
498 }
499
500 return 0;
501}
502__initcall(topology_init);