Merge commit 'upstream/master'
[pandora-kernel.git] / arch / powerpc / kernel / sysfs.c
1 #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>
15 #include <asm/firmware.h>
16 #include <asm/hvcall.h>
17 #include <asm/prom.h>
18 #include <asm/paca.h>
19 #include <asm/lppaca.h>
20 #include <asm/machdep.h>
21 #include <asm/smp.h>
22
23 static DEFINE_PER_CPU(struct cpu, cpu_devices);
24
25 /* SMT stuff */
26
27 #ifdef CONFIG_PPC_MULTIPLATFORM
28 /* Time in microseconds we delay before sleeping in the idle loop */
29 DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
30
31 static ssize_t store_smt_snooze_delay(struct sys_device *dev,
32                                       struct sysdev_attribute *attr,
33                                       const char *buf,
34                                       size_t count)
35 {
36         struct cpu *cpu = container_of(dev, struct cpu, sysdev);
37         ssize_t ret;
38         unsigned long snooze;
39
40         ret = sscanf(buf, "%lu", &snooze);
41         if (ret != 1)
42                 return -EINVAL;
43
44         per_cpu(smt_snooze_delay, cpu->sysdev.id) = snooze;
45
46         return count;
47 }
48
49 static ssize_t show_smt_snooze_delay(struct sys_device *dev,
50                                      struct sysdev_attribute *attr,
51                                      char *buf)
52 {
53         struct cpu *cpu = container_of(dev, struct cpu, sysdev);
54
55         return sprintf(buf, "%lu\n", per_cpu(smt_snooze_delay, cpu->sysdev.id));
56 }
57
58 static SYSDEV_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
59                    store_smt_snooze_delay);
60
61 /* Only parse OF options if the matching cmdline option was not specified */
62 static int smt_snooze_cmdline;
63
64 static int __init smt_setup(void)
65 {
66         struct device_node *options;
67         const unsigned int *val;
68         unsigned int cpu;
69
70         if (!cpu_has_feature(CPU_FTR_SMT))
71                 return -ENODEV;
72
73         options = of_find_node_by_path("/options");
74         if (!options)
75                 return -ENODEV;
76
77         val = of_get_property(options, "ibm,smt-snooze-delay", NULL);
78         if (!smt_snooze_cmdline && val) {
79                 for_each_possible_cpu(cpu)
80                         per_cpu(smt_snooze_delay, cpu) = *val;
81         }
82
83         of_node_put(options);
84         return 0;
85 }
86 __initcall(smt_setup);
87
88 static int __init setup_smt_snooze_delay(char *str)
89 {
90         unsigned int cpu;
91         int snooze;
92
93         if (!cpu_has_feature(CPU_FTR_SMT))
94                 return 1;
95
96         smt_snooze_cmdline = 1;
97
98         if (get_option(&str, &snooze)) {
99                 for_each_possible_cpu(cpu)
100                         per_cpu(smt_snooze_delay, cpu) = snooze;
101         }
102
103         return 1;
104 }
105 __setup("smt-snooze-delay=", setup_smt_snooze_delay);
106
107 #endif /* CONFIG_PPC_MULTIPLATFORM */
108
109 /*
110  * Enabling PMCs will slow partition context switch times so we only do
111  * it the first time we write to the PMCs.
112  */
113
114 static DEFINE_PER_CPU(char, pmcs_enabled);
115
116 void ppc64_enable_pmcs(void)
117 {
118         /* Only need to enable them once */
119         if (__get_cpu_var(pmcs_enabled))
120                 return;
121
122         __get_cpu_var(pmcs_enabled) = 1;
123
124         if (ppc_md.enable_pmcs)
125                 ppc_md.enable_pmcs();
126 }
127 EXPORT_SYMBOL(ppc64_enable_pmcs);
128
129 /* XXX convert to rusty's on_one_cpu */
130 static unsigned long run_on_cpu(unsigned long cpu,
131                                 unsigned long (*func)(unsigned long),
132                                 unsigned long arg)
133 {
134         cpumask_t old_affinity = current->cpus_allowed;
135         unsigned long ret;
136
137         /* should return -EINVAL to userspace */
138         if (set_cpus_allowed(current, cpumask_of_cpu(cpu)))
139                 return 0;
140
141         ret = func(arg);
142
143         set_cpus_allowed(current, old_affinity);
144
145         return ret;
146 }
147
148 #define SYSFS_PMCSETUP(NAME, ADDRESS) \
149 static unsigned long read_##NAME(unsigned long junk) \
150 { \
151         return mfspr(ADDRESS); \
152 } \
153 static unsigned long write_##NAME(unsigned long val) \
154 { \
155         ppc64_enable_pmcs(); \
156         mtspr(ADDRESS, val); \
157         return 0; \
158 } \
159 static ssize_t show_##NAME(struct sys_device *dev, \
160                         struct sysdev_attribute *attr, \
161                         char *buf) \
162 { \
163         struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
164         unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
165         return sprintf(buf, "%lx\n", val); \
166 } \
167 static ssize_t __used \
168         store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \
169                         const char *buf, size_t count) \
170 { \
171         struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
172         unsigned long val; \
173         int ret = sscanf(buf, "%lx", &val); \
174         if (ret != 1) \
175                 return -EINVAL; \
176         run_on_cpu(cpu->sysdev.id, write_##NAME, val); \
177         return count; \
178 }
179
180
181 /* Let's define all possible registers, we'll only hook up the ones
182  * that are implemented on the current processor
183  */
184
185 SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0);
186 SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1);
187 SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
188 SYSFS_PMCSETUP(pmc1, SPRN_PMC1);
189 SYSFS_PMCSETUP(pmc2, SPRN_PMC2);
190 SYSFS_PMCSETUP(pmc3, SPRN_PMC3);
191 SYSFS_PMCSETUP(pmc4, SPRN_PMC4);
192 SYSFS_PMCSETUP(pmc5, SPRN_PMC5);
193 SYSFS_PMCSETUP(pmc6, SPRN_PMC6);
194 SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
195 SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
196 SYSFS_PMCSETUP(purr, SPRN_PURR);
197 SYSFS_PMCSETUP(spurr, SPRN_SPURR);
198 SYSFS_PMCSETUP(dscr, SPRN_DSCR);
199
200 SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
201 SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
202 SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
203 SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
204 SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
205 SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
206
207 #ifdef CONFIG_DEBUG_KERNEL
208 SYSFS_PMCSETUP(hid0, SPRN_HID0);
209 SYSFS_PMCSETUP(hid1, SPRN_HID1);
210 SYSFS_PMCSETUP(hid4, SPRN_HID4);
211 SYSFS_PMCSETUP(hid5, SPRN_HID5);
212 SYSFS_PMCSETUP(ima0, SPRN_PA6T_IMA0);
213 SYSFS_PMCSETUP(ima1, SPRN_PA6T_IMA1);
214 SYSFS_PMCSETUP(ima2, SPRN_PA6T_IMA2);
215 SYSFS_PMCSETUP(ima3, SPRN_PA6T_IMA3);
216 SYSFS_PMCSETUP(ima4, SPRN_PA6T_IMA4);
217 SYSFS_PMCSETUP(ima5, SPRN_PA6T_IMA5);
218 SYSFS_PMCSETUP(ima6, SPRN_PA6T_IMA6);
219 SYSFS_PMCSETUP(ima7, SPRN_PA6T_IMA7);
220 SYSFS_PMCSETUP(ima8, SPRN_PA6T_IMA8);
221 SYSFS_PMCSETUP(ima9, SPRN_PA6T_IMA9);
222 SYSFS_PMCSETUP(imaat, SPRN_PA6T_IMAAT);
223 SYSFS_PMCSETUP(btcr, SPRN_PA6T_BTCR);
224 SYSFS_PMCSETUP(pccr, SPRN_PA6T_PCCR);
225 SYSFS_PMCSETUP(rpccr, SPRN_PA6T_RPCCR);
226 SYSFS_PMCSETUP(der, SPRN_PA6T_DER);
227 SYSFS_PMCSETUP(mer, SPRN_PA6T_MER);
228 SYSFS_PMCSETUP(ber, SPRN_PA6T_BER);
229 SYSFS_PMCSETUP(ier, SPRN_PA6T_IER);
230 SYSFS_PMCSETUP(sier, SPRN_PA6T_SIER);
231 SYSFS_PMCSETUP(siar, SPRN_PA6T_SIAR);
232 SYSFS_PMCSETUP(tsr0, SPRN_PA6T_TSR0);
233 SYSFS_PMCSETUP(tsr1, SPRN_PA6T_TSR1);
234 SYSFS_PMCSETUP(tsr2, SPRN_PA6T_TSR2);
235 SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3);
236 #endif /* CONFIG_DEBUG_KERNEL */
237
238 static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
239 static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
240 static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
241 static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
242
243 static struct sysdev_attribute ibm_common_attrs[] = {
244         _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
245         _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
246 };
247
248 static struct sysdev_attribute ibm_pmc_attrs[] = {
249         _SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1),
250         _SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2),
251         _SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3),
252         _SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4),
253         _SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5),
254         _SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6),
255         _SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7),
256         _SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8),
257 };
258
259 static struct sysdev_attribute pa6t_attrs[] = {
260         _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
261         _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
262         _SYSDEV_ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0),
263         _SYSDEV_ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1),
264         _SYSDEV_ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2),
265         _SYSDEV_ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3),
266         _SYSDEV_ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4),
267         _SYSDEV_ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5),
268 #ifdef CONFIG_DEBUG_KERNEL
269         _SYSDEV_ATTR(hid0, 0600, show_hid0, store_hid0),
270         _SYSDEV_ATTR(hid1, 0600, show_hid1, store_hid1),
271         _SYSDEV_ATTR(hid4, 0600, show_hid4, store_hid4),
272         _SYSDEV_ATTR(hid5, 0600, show_hid5, store_hid5),
273         _SYSDEV_ATTR(ima0, 0600, show_ima0, store_ima0),
274         _SYSDEV_ATTR(ima1, 0600, show_ima1, store_ima1),
275         _SYSDEV_ATTR(ima2, 0600, show_ima2, store_ima2),
276         _SYSDEV_ATTR(ima3, 0600, show_ima3, store_ima3),
277         _SYSDEV_ATTR(ima4, 0600, show_ima4, store_ima4),
278         _SYSDEV_ATTR(ima5, 0600, show_ima5, store_ima5),
279         _SYSDEV_ATTR(ima6, 0600, show_ima6, store_ima6),
280         _SYSDEV_ATTR(ima7, 0600, show_ima7, store_ima7),
281         _SYSDEV_ATTR(ima8, 0600, show_ima8, store_ima8),
282         _SYSDEV_ATTR(ima9, 0600, show_ima9, store_ima9),
283         _SYSDEV_ATTR(imaat, 0600, show_imaat, store_imaat),
284         _SYSDEV_ATTR(btcr, 0600, show_btcr, store_btcr),
285         _SYSDEV_ATTR(pccr, 0600, show_pccr, store_pccr),
286         _SYSDEV_ATTR(rpccr, 0600, show_rpccr, store_rpccr),
287         _SYSDEV_ATTR(der, 0600, show_der, store_der),
288         _SYSDEV_ATTR(mer, 0600, show_mer, store_mer),
289         _SYSDEV_ATTR(ber, 0600, show_ber, store_ber),
290         _SYSDEV_ATTR(ier, 0600, show_ier, store_ier),
291         _SYSDEV_ATTR(sier, 0600, show_sier, store_sier),
292         _SYSDEV_ATTR(siar, 0600, show_siar, store_siar),
293         _SYSDEV_ATTR(tsr0, 0600, show_tsr0, store_tsr0),
294         _SYSDEV_ATTR(tsr1, 0600, show_tsr1, store_tsr1),
295         _SYSDEV_ATTR(tsr2, 0600, show_tsr2, store_tsr2),
296         _SYSDEV_ATTR(tsr3, 0600, show_tsr3, store_tsr3),
297 #endif /* CONFIG_DEBUG_KERNEL */
298 };
299
300
301 static void register_cpu_online(unsigned int cpu)
302 {
303         struct cpu *c = &per_cpu(cpu_devices, cpu);
304         struct sys_device *s = &c->sysdev;
305         struct sysdev_attribute *attrs, *pmc_attrs;
306         int i, nattrs;
307
308         if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
309                         cpu_has_feature(CPU_FTR_SMT))
310                 sysdev_create_file(s, &attr_smt_snooze_delay);
311
312         /* PMC stuff */
313         switch (cur_cpu_spec->pmc_type) {
314         case PPC_PMC_IBM:
315                 attrs = ibm_common_attrs;
316                 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
317                 pmc_attrs = ibm_pmc_attrs;
318                 break;
319         case PPC_PMC_PA6T:
320                 /* PA Semi starts counting at PMC0 */
321                 attrs = pa6t_attrs;
322                 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
323                 pmc_attrs = NULL;
324                 break;
325         default:
326                 attrs = NULL;
327                 nattrs = 0;
328                 pmc_attrs = NULL;
329         }
330
331         for (i = 0; i < nattrs; i++)
332                 sysdev_create_file(s, &attrs[i]);
333
334         if (pmc_attrs)
335                 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
336                         sysdev_create_file(s, &pmc_attrs[i]);
337
338         if (cpu_has_feature(CPU_FTR_MMCRA))
339                 sysdev_create_file(s, &attr_mmcra);
340
341         if (cpu_has_feature(CPU_FTR_PURR))
342                 sysdev_create_file(s, &attr_purr);
343
344         if (cpu_has_feature(CPU_FTR_SPURR))
345                 sysdev_create_file(s, &attr_spurr);
346
347         if (cpu_has_feature(CPU_FTR_DSCR))
348                 sysdev_create_file(s, &attr_dscr);
349 }
350
351 #ifdef CONFIG_HOTPLUG_CPU
352 static void unregister_cpu_online(unsigned int cpu)
353 {
354         struct cpu *c = &per_cpu(cpu_devices, cpu);
355         struct sys_device *s = &c->sysdev;
356         struct sysdev_attribute *attrs, *pmc_attrs;
357         int i, nattrs;
358
359         BUG_ON(!c->hotpluggable);
360
361         if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
362                         cpu_has_feature(CPU_FTR_SMT))
363                 sysdev_remove_file(s, &attr_smt_snooze_delay);
364
365         /* PMC stuff */
366         switch (cur_cpu_spec->pmc_type) {
367         case PPC_PMC_IBM:
368                 attrs = ibm_common_attrs;
369                 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
370                 pmc_attrs = ibm_pmc_attrs;
371                 break;
372         case PPC_PMC_PA6T:
373                 /* PA Semi starts counting at PMC0 */
374                 attrs = pa6t_attrs;
375                 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
376                 pmc_attrs = NULL;
377                 break;
378         default:
379                 attrs = NULL;
380                 nattrs = 0;
381                 pmc_attrs = NULL;
382         }
383
384         for (i = 0; i < nattrs; i++)
385                 sysdev_remove_file(s, &attrs[i]);
386
387         if (pmc_attrs)
388                 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
389                         sysdev_remove_file(s, &pmc_attrs[i]);
390
391         if (cpu_has_feature(CPU_FTR_MMCRA))
392                 sysdev_remove_file(s, &attr_mmcra);
393
394         if (cpu_has_feature(CPU_FTR_PURR))
395                 sysdev_remove_file(s, &attr_purr);
396
397         if (cpu_has_feature(CPU_FTR_SPURR))
398                 sysdev_remove_file(s, &attr_spurr);
399
400         if (cpu_has_feature(CPU_FTR_DSCR))
401                 sysdev_remove_file(s, &attr_dscr);
402 }
403 #endif /* CONFIG_HOTPLUG_CPU */
404
405 static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
406                                       unsigned long action, void *hcpu)
407 {
408         unsigned int cpu = (unsigned int)(long)hcpu;
409
410         switch (action) {
411         case CPU_ONLINE:
412         case CPU_ONLINE_FROZEN:
413                 register_cpu_online(cpu);
414                 break;
415 #ifdef CONFIG_HOTPLUG_CPU
416         case CPU_DEAD:
417         case CPU_DEAD_FROZEN:
418                 unregister_cpu_online(cpu);
419                 break;
420 #endif
421         }
422         return NOTIFY_OK;
423 }
424
425 static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
426         .notifier_call  = sysfs_cpu_notify,
427 };
428
429 static DEFINE_MUTEX(cpu_mutex);
430
431 int cpu_add_sysdev_attr(struct sysdev_attribute *attr)
432 {
433         int cpu;
434
435         mutex_lock(&cpu_mutex);
436
437         for_each_possible_cpu(cpu) {
438                 sysdev_create_file(get_cpu_sysdev(cpu), attr);
439         }
440
441         mutex_unlock(&cpu_mutex);
442         return 0;
443 }
444 EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr);
445
446 int cpu_add_sysdev_attr_group(struct attribute_group *attrs)
447 {
448         int cpu;
449         struct sys_device *sysdev;
450         int ret;
451
452         mutex_lock(&cpu_mutex);
453
454         for_each_possible_cpu(cpu) {
455                 sysdev = get_cpu_sysdev(cpu);
456                 ret = sysfs_create_group(&sysdev->kobj, attrs);
457                 WARN_ON(ret != 0);
458         }
459
460         mutex_unlock(&cpu_mutex);
461         return 0;
462 }
463 EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
464
465
466 void cpu_remove_sysdev_attr(struct sysdev_attribute *attr)
467 {
468         int cpu;
469
470         mutex_lock(&cpu_mutex);
471
472         for_each_possible_cpu(cpu) {
473                 sysdev_remove_file(get_cpu_sysdev(cpu), attr);
474         }
475
476         mutex_unlock(&cpu_mutex);
477 }
478 EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr);
479
480 void cpu_remove_sysdev_attr_group(struct attribute_group *attrs)
481 {
482         int cpu;
483         struct sys_device *sysdev;
484
485         mutex_lock(&cpu_mutex);
486
487         for_each_possible_cpu(cpu) {
488                 sysdev = get_cpu_sysdev(cpu);
489                 sysfs_remove_group(&sysdev->kobj, attrs);
490         }
491
492         mutex_unlock(&cpu_mutex);
493 }
494 EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr_group);
495
496
497 /* NUMA stuff */
498
499 #ifdef CONFIG_NUMA
500 static void register_nodes(void)
501 {
502         int i;
503
504         for (i = 0; i < MAX_NUMNODES; i++)
505                 register_one_node(i);
506 }
507
508 int sysfs_add_device_to_node(struct sys_device *dev, int nid)
509 {
510         struct node *node = &node_devices[nid];
511         return sysfs_create_link(&node->sysdev.kobj, &dev->kobj,
512                         kobject_name(&dev->kobj));
513 }
514 EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
515
516 void sysfs_remove_device_from_node(struct sys_device *dev, int nid)
517 {
518         struct node *node = &node_devices[nid];
519         sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj));
520 }
521 EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node);
522
523 #else
524 static void register_nodes(void)
525 {
526         return;
527 }
528
529 #endif
530
531 /* Only valid if CPU is present. */
532 static ssize_t show_physical_id(struct sys_device *dev,
533                                 struct sysdev_attribute *attr, char *buf)
534 {
535         struct cpu *cpu = container_of(dev, struct cpu, sysdev);
536
537         return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->sysdev.id));
538 }
539 static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
540
541 static int __init topology_init(void)
542 {
543         int cpu;
544
545         register_nodes();
546         register_cpu_notifier(&sysfs_cpu_nb);
547
548         for_each_possible_cpu(cpu) {
549                 struct cpu *c = &per_cpu(cpu_devices, cpu);
550
551                 /*
552                  * For now, we just see if the system supports making
553                  * the RTAS calls for CPU hotplug.  But, there may be a
554                  * more comprehensive way to do this for an individual
555                  * CPU.  For instance, the boot cpu might never be valid
556                  * for hotplugging.
557                  */
558                 if (ppc_md.cpu_die)
559                         c->hotpluggable = 1;
560
561                 if (cpu_online(cpu) || c->hotpluggable) {
562                         register_cpu(c, cpu);
563
564                         sysdev_create_file(&c->sysdev, &attr_physical_id);
565                 }
566
567                 if (cpu_online(cpu))
568                         register_cpu_online(cpu);
569         }
570
571         return 0;
572 }
573 subsys_initcall(topology_init);