xref: /linux/arch/powerpc/kernel/sysfs.c (revision 8a25a2fd126c621f44f3aeaef80d51f00fc11639)
1*8a25a2fdSKay Sievers #include <linux/device.h>
2d3d2176aSDavid Gibson #include <linux/cpu.h>
3d3d2176aSDavid Gibson #include <linux/smp.h>
4d3d2176aSDavid Gibson #include <linux/percpu.h>
5d3d2176aSDavid Gibson #include <linux/init.h>
6d3d2176aSDavid Gibson #include <linux/sched.h>
74b16f8e2SPaul Gortmaker #include <linux/export.h>
8d3d2176aSDavid Gibson #include <linux/nodemask.h>
9d3d2176aSDavid Gibson #include <linux/cpumask.h>
10d3d2176aSDavid Gibson #include <linux/notifier.h>
11d3d2176aSDavid Gibson 
12d3d2176aSDavid Gibson #include <asm/current.h>
13d3d2176aSDavid Gibson #include <asm/processor.h>
14d3d2176aSDavid Gibson #include <asm/cputable.h>
15d3d2176aSDavid Gibson #include <asm/firmware.h>
16d3d2176aSDavid Gibson #include <asm/hvcall.h>
17d3d2176aSDavid Gibson #include <asm/prom.h>
18d3d2176aSDavid Gibson #include <asm/machdep.h>
19d3d2176aSDavid Gibson #include <asm/smp.h>
20a6dbf93aSPaul Mackerras #include <asm/pmc.h>
21d3d2176aSDavid Gibson 
2293197a36SNathan Lynch #include "cacheinfo.h"
2393197a36SNathan Lynch 
24b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64
25b950bdd0SBenjamin Herrenschmidt #include <asm/paca.h>
26b950bdd0SBenjamin Herrenschmidt #include <asm/lppaca.h>
27b950bdd0SBenjamin Herrenschmidt #endif
28b950bdd0SBenjamin Herrenschmidt 
29d3d2176aSDavid Gibson static DEFINE_PER_CPU(struct cpu, cpu_devices);
30d3d2176aSDavid Gibson 
31b950bdd0SBenjamin Herrenschmidt /*
32b950bdd0SBenjamin Herrenschmidt  * SMT snooze delay stuff, 64-bit only for now
33b950bdd0SBenjamin Herrenschmidt  */
34d3d2176aSDavid Gibson 
35b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64
36b950bdd0SBenjamin Herrenschmidt 
370ddd3e7dSAnton Blanchard /* Time in microseconds we delay before sleeping in the idle loop */
38b878dc00SAnton Blanchard DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 };
39d3d2176aSDavid Gibson 
40*8a25a2fdSKay Sievers static ssize_t store_smt_snooze_delay(struct device *dev,
41*8a25a2fdSKay Sievers 				      struct device_attribute *attr,
424a0b2b4dSAndi Kleen 				      const char *buf,
43d3d2176aSDavid Gibson 				      size_t count)
44d3d2176aSDavid Gibson {
45*8a25a2fdSKay Sievers 	struct cpu *cpu = container_of(dev, struct cpu, dev);
46d3d2176aSDavid Gibson 	ssize_t ret;
47b878dc00SAnton Blanchard 	long snooze;
48d3d2176aSDavid Gibson 
49b878dc00SAnton Blanchard 	ret = sscanf(buf, "%ld", &snooze);
50d3d2176aSDavid Gibson 	if (ret != 1)
51d3d2176aSDavid Gibson 		return -EINVAL;
52d3d2176aSDavid Gibson 
53*8a25a2fdSKay Sievers 	per_cpu(smt_snooze_delay, cpu->dev.id) = snooze;
54d3d2176aSDavid Gibson 
55d3d2176aSDavid Gibson 	return count;
56d3d2176aSDavid Gibson }
57d3d2176aSDavid Gibson 
58*8a25a2fdSKay Sievers static ssize_t show_smt_snooze_delay(struct device *dev,
59*8a25a2fdSKay Sievers 				     struct device_attribute *attr,
604a0b2b4dSAndi Kleen 				     char *buf)
61d3d2176aSDavid Gibson {
62*8a25a2fdSKay Sievers 	struct cpu *cpu = container_of(dev, struct cpu, dev);
63d3d2176aSDavid Gibson 
64*8a25a2fdSKay Sievers 	return sprintf(buf, "%ld\n", per_cpu(smt_snooze_delay, cpu->dev.id));
65d3d2176aSDavid Gibson }
66d3d2176aSDavid Gibson 
67*8a25a2fdSKay Sievers static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
68d3d2176aSDavid Gibson 		   store_smt_snooze_delay);
69d3d2176aSDavid Gibson 
70d3d2176aSDavid Gibson static int __init setup_smt_snooze_delay(char *str)
71d3d2176aSDavid Gibson {
72d3d2176aSDavid Gibson 	unsigned int cpu;
73b878dc00SAnton Blanchard 	long snooze;
74d3d2176aSDavid Gibson 
75d3d2176aSDavid Gibson 	if (!cpu_has_feature(CPU_FTR_SMT))
76d3d2176aSDavid Gibson 		return 1;
77d3d2176aSDavid Gibson 
78b878dc00SAnton Blanchard 	snooze = simple_strtol(str, NULL, 10);
790e551954SKAMEZAWA Hiroyuki 	for_each_possible_cpu(cpu)
80d3d2176aSDavid Gibson 		per_cpu(smt_snooze_delay, cpu) = snooze;
81d3d2176aSDavid Gibson 
82d3d2176aSDavid Gibson 	return 1;
83d3d2176aSDavid Gibson }
84d3d2176aSDavid Gibson __setup("smt-snooze-delay=", setup_smt_snooze_delay);
85d3d2176aSDavid Gibson 
86b950bdd0SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */
87d3d2176aSDavid Gibson 
88d3d2176aSDavid Gibson /*
89d3d2176aSDavid Gibson  * Enabling PMCs will slow partition context switch times so we only do
90d3d2176aSDavid Gibson  * it the first time we write to the PMCs.
91d3d2176aSDavid Gibson  */
92d3d2176aSDavid Gibson 
93d3d2176aSDavid Gibson static DEFINE_PER_CPU(char, pmcs_enabled);
94d3d2176aSDavid Gibson 
95b950bdd0SBenjamin Herrenschmidt void ppc_enable_pmcs(void)
96d3d2176aSDavid Gibson {
97a6dbf93aSPaul Mackerras 	ppc_set_pmu_inuse(1);
98a6dbf93aSPaul Mackerras 
99d3d2176aSDavid Gibson 	/* Only need to enable them once */
100d3d2176aSDavid Gibson 	if (__get_cpu_var(pmcs_enabled))
101d3d2176aSDavid Gibson 		return;
102d3d2176aSDavid Gibson 
103d3d2176aSDavid Gibson 	__get_cpu_var(pmcs_enabled) = 1;
104d3d2176aSDavid Gibson 
105d3d2176aSDavid Gibson 	if (ppc_md.enable_pmcs)
106d3d2176aSDavid Gibson 		ppc_md.enable_pmcs();
107d3d2176aSDavid Gibson }
108b950bdd0SBenjamin Herrenschmidt EXPORT_SYMBOL(ppc_enable_pmcs);
109d3d2176aSDavid Gibson 
110d3d2176aSDavid Gibson #define SYSFS_PMCSETUP(NAME, ADDRESS) \
1119a371934SRusty Russell static void read_##NAME(void *val) \
112d3d2176aSDavid Gibson { \
113ec78c8acSBenjamin Herrenschmidt 	*(unsigned long *)val = mfspr(ADDRESS);	\
114d3d2176aSDavid Gibson } \
115ec78c8acSBenjamin Herrenschmidt static void write_##NAME(void *val) \
116d3d2176aSDavid Gibson { \
117b950bdd0SBenjamin Herrenschmidt 	ppc_enable_pmcs(); \
1189a371934SRusty Russell 	mtspr(ADDRESS, *(unsigned long *)val);	\
119d3d2176aSDavid Gibson } \
120*8a25a2fdSKay Sievers static ssize_t show_##NAME(struct device *dev, \
121*8a25a2fdSKay Sievers 			struct device_attribute *attr, \
1224a0b2b4dSAndi Kleen 			char *buf) \
123d3d2176aSDavid Gibson { \
124*8a25a2fdSKay Sievers 	struct cpu *cpu = container_of(dev, struct cpu, dev); \
1259a371934SRusty Russell 	unsigned long val; \
126*8a25a2fdSKay Sievers 	smp_call_function_single(cpu->dev.id, read_##NAME, &val, 1);	\
127d3d2176aSDavid Gibson 	return sprintf(buf, "%lx\n", val); \
128d3d2176aSDavid Gibson } \
1293ff6eeccSAdrian Bunk static ssize_t __used \
130*8a25a2fdSKay Sievers 	store_##NAME(struct device *dev, struct device_attribute *attr, \
1314a0b2b4dSAndi Kleen 			const char *buf, size_t count) \
132d3d2176aSDavid Gibson { \
133*8a25a2fdSKay Sievers 	struct cpu *cpu = container_of(dev, struct cpu, dev); \
134d3d2176aSDavid Gibson 	unsigned long val; \
135d3d2176aSDavid Gibson 	int ret = sscanf(buf, "%lx", &val); \
136d3d2176aSDavid Gibson 	if (ret != 1) \
137d3d2176aSDavid Gibson 		return -EINVAL; \
138*8a25a2fdSKay Sievers 	smp_call_function_single(cpu->dev.id, write_##NAME, &val, 1); \
139d3d2176aSDavid Gibson 	return count; \
140d3d2176aSDavid Gibson }
141d3d2176aSDavid Gibson 
1426529c13dSOlof Johansson 
1436529c13dSOlof Johansson /* Let's define all possible registers, we'll only hook up the ones
1446529c13dSOlof Johansson  * that are implemented on the current processor
1456529c13dSOlof Johansson  */
1466529c13dSOlof Johansson 
14733a7f122SKumar Gala #if defined(CONFIG_PPC64)
148b950bdd0SBenjamin Herrenschmidt #define HAS_PPC_PMC_CLASSIC	1
149b950bdd0SBenjamin Herrenschmidt #define HAS_PPC_PMC_IBM		1
150b950bdd0SBenjamin Herrenschmidt #define HAS_PPC_PMC_PA6T	1
15133a7f122SKumar Gala #elif defined(CONFIG_6xx)
152b950bdd0SBenjamin Herrenschmidt #define HAS_PPC_PMC_CLASSIC	1
153b950bdd0SBenjamin Herrenschmidt #define HAS_PPC_PMC_IBM		1
154b950bdd0SBenjamin Herrenschmidt #define HAS_PPC_PMC_G4		1
155b950bdd0SBenjamin Herrenschmidt #endif
156b950bdd0SBenjamin Herrenschmidt 
157b950bdd0SBenjamin Herrenschmidt 
158b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_CLASSIC
159d3d2176aSDavid Gibson SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0);
160d3d2176aSDavid Gibson SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1);
161d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc1, SPRN_PMC1);
162d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc2, SPRN_PMC2);
163d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc3, SPRN_PMC3);
164d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc4, SPRN_PMC4);
165d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc5, SPRN_PMC5);
166d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc6, SPRN_PMC6);
167b950bdd0SBenjamin Herrenschmidt 
168b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_G4
169b950bdd0SBenjamin Herrenschmidt SYSFS_PMCSETUP(mmcr2, SPRN_MMCR2);
170b950bdd0SBenjamin Herrenschmidt #endif
171b950bdd0SBenjamin Herrenschmidt 
172b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64
173d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
174d3d2176aSDavid Gibson SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
175b950bdd0SBenjamin Herrenschmidt 
176b950bdd0SBenjamin Herrenschmidt SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
177d3d2176aSDavid Gibson SYSFS_PMCSETUP(purr, SPRN_PURR);
178f050982aSAnton Blanchard SYSFS_PMCSETUP(spurr, SPRN_SPURR);
1794c198557SAnton Blanchard SYSFS_PMCSETUP(dscr, SPRN_DSCR);
180d3d2176aSDavid Gibson 
181*8a25a2fdSKay Sievers static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
182*8a25a2fdSKay Sievers static DEVICE_ATTR(spurr, 0600, show_spurr, NULL);
183*8a25a2fdSKay Sievers static DEVICE_ATTR(dscr, 0600, show_dscr, store_dscr);
184*8a25a2fdSKay Sievers static DEVICE_ATTR(purr, 0600, show_purr, store_purr);
185efcac658SAlexey Kardashevskiy 
186efcac658SAlexey Kardashevskiy unsigned long dscr_default = 0;
187efcac658SAlexey Kardashevskiy EXPORT_SYMBOL(dscr_default);
188efcac658SAlexey Kardashevskiy 
189*8a25a2fdSKay Sievers static ssize_t show_dscr_default(struct device *dev,
190*8a25a2fdSKay Sievers 		struct device_attribute *attr, char *buf)
191efcac658SAlexey Kardashevskiy {
192efcac658SAlexey Kardashevskiy 	return sprintf(buf, "%lx\n", dscr_default);
193efcac658SAlexey Kardashevskiy }
194efcac658SAlexey Kardashevskiy 
195*8a25a2fdSKay Sievers static ssize_t __used store_dscr_default(struct device *dev,
196*8a25a2fdSKay Sievers 		struct device_attribute *attr, const char *buf,
197efcac658SAlexey Kardashevskiy 		size_t count)
198efcac658SAlexey Kardashevskiy {
199efcac658SAlexey Kardashevskiy 	unsigned long val;
200efcac658SAlexey Kardashevskiy 	int ret = 0;
201efcac658SAlexey Kardashevskiy 
202efcac658SAlexey Kardashevskiy 	ret = sscanf(buf, "%lx", &val);
203efcac658SAlexey Kardashevskiy 	if (ret != 1)
204efcac658SAlexey Kardashevskiy 		return -EINVAL;
205efcac658SAlexey Kardashevskiy 	dscr_default = val;
206efcac658SAlexey Kardashevskiy 
207efcac658SAlexey Kardashevskiy 	return count;
208efcac658SAlexey Kardashevskiy }
209efcac658SAlexey Kardashevskiy 
210*8a25a2fdSKay Sievers static DEVICE_ATTR(dscr_default, 0600,
211efcac658SAlexey Kardashevskiy 		show_dscr_default, store_dscr_default);
212efcac658SAlexey Kardashevskiy 
213efcac658SAlexey Kardashevskiy static void sysfs_create_dscr_default(void)
214efcac658SAlexey Kardashevskiy {
215efcac658SAlexey Kardashevskiy 	int err = 0;
216efcac658SAlexey Kardashevskiy 	if (cpu_has_feature(CPU_FTR_DSCR))
217*8a25a2fdSKay Sievers 		err = device_create_file(cpu_subsys.dev_root, &dev_attr_dscr_default);
218efcac658SAlexey Kardashevskiy }
219b950bdd0SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */
220b950bdd0SBenjamin Herrenschmidt 
221b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T
22225fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
22325fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
22425fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
22525fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
22625fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
22725fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
2282e1957fdSOlof Johansson #ifdef CONFIG_DEBUG_KERNEL
2292e1957fdSOlof Johansson SYSFS_PMCSETUP(hid0, SPRN_HID0);
2302e1957fdSOlof Johansson SYSFS_PMCSETUP(hid1, SPRN_HID1);
2312e1957fdSOlof Johansson SYSFS_PMCSETUP(hid4, SPRN_HID4);
2322e1957fdSOlof Johansson SYSFS_PMCSETUP(hid5, SPRN_HID5);
2332e1957fdSOlof Johansson SYSFS_PMCSETUP(ima0, SPRN_PA6T_IMA0);
2342e1957fdSOlof Johansson SYSFS_PMCSETUP(ima1, SPRN_PA6T_IMA1);
2352e1957fdSOlof Johansson SYSFS_PMCSETUP(ima2, SPRN_PA6T_IMA2);
2362e1957fdSOlof Johansson SYSFS_PMCSETUP(ima3, SPRN_PA6T_IMA3);
2372e1957fdSOlof Johansson SYSFS_PMCSETUP(ima4, SPRN_PA6T_IMA4);
2382e1957fdSOlof Johansson SYSFS_PMCSETUP(ima5, SPRN_PA6T_IMA5);
2392e1957fdSOlof Johansson SYSFS_PMCSETUP(ima6, SPRN_PA6T_IMA6);
2402e1957fdSOlof Johansson SYSFS_PMCSETUP(ima7, SPRN_PA6T_IMA7);
2412e1957fdSOlof Johansson SYSFS_PMCSETUP(ima8, SPRN_PA6T_IMA8);
2422e1957fdSOlof Johansson SYSFS_PMCSETUP(ima9, SPRN_PA6T_IMA9);
2432e1957fdSOlof Johansson SYSFS_PMCSETUP(imaat, SPRN_PA6T_IMAAT);
2442e1957fdSOlof Johansson SYSFS_PMCSETUP(btcr, SPRN_PA6T_BTCR);
2452e1957fdSOlof Johansson SYSFS_PMCSETUP(pccr, SPRN_PA6T_PCCR);
2462e1957fdSOlof Johansson SYSFS_PMCSETUP(rpccr, SPRN_PA6T_RPCCR);
2472e1957fdSOlof Johansson SYSFS_PMCSETUP(der, SPRN_PA6T_DER);
2482e1957fdSOlof Johansson SYSFS_PMCSETUP(mer, SPRN_PA6T_MER);
2492e1957fdSOlof Johansson SYSFS_PMCSETUP(ber, SPRN_PA6T_BER);
2502e1957fdSOlof Johansson SYSFS_PMCSETUP(ier, SPRN_PA6T_IER);
2512e1957fdSOlof Johansson SYSFS_PMCSETUP(sier, SPRN_PA6T_SIER);
2522e1957fdSOlof Johansson SYSFS_PMCSETUP(siar, SPRN_PA6T_SIAR);
2532e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr0, SPRN_PA6T_TSR0);
2542e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr1, SPRN_PA6T_TSR1);
2552e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr2, SPRN_PA6T_TSR2);
2562e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3);
2572e1957fdSOlof Johansson #endif /* CONFIG_DEBUG_KERNEL */
258b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */
2596529c13dSOlof Johansson 
260b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_IBM
261*8a25a2fdSKay Sievers static struct device_attribute ibm_common_attrs[] = {
262*8a25a2fdSKay Sievers 	__ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
263*8a25a2fdSKay Sievers 	__ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
2646529c13dSOlof Johansson };
265b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */
2666529c13dSOlof Johansson 
267b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_G4
268*8a25a2fdSKay Sievers static struct device_attribute g4_common_attrs[] = {
269*8a25a2fdSKay Sievers 	__ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
270*8a25a2fdSKay Sievers 	__ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
271*8a25a2fdSKay Sievers 	__ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2),
272b950bdd0SBenjamin Herrenschmidt };
273b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */
274b950bdd0SBenjamin Herrenschmidt 
275*8a25a2fdSKay Sievers static struct device_attribute classic_pmc_attrs[] = {
276*8a25a2fdSKay Sievers 	__ATTR(pmc1, 0600, show_pmc1, store_pmc1),
277*8a25a2fdSKay Sievers 	__ATTR(pmc2, 0600, show_pmc2, store_pmc2),
278*8a25a2fdSKay Sievers 	__ATTR(pmc3, 0600, show_pmc3, store_pmc3),
279*8a25a2fdSKay Sievers 	__ATTR(pmc4, 0600, show_pmc4, store_pmc4),
280*8a25a2fdSKay Sievers 	__ATTR(pmc5, 0600, show_pmc5, store_pmc5),
281*8a25a2fdSKay Sievers 	__ATTR(pmc6, 0600, show_pmc6, store_pmc6),
282b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64
283*8a25a2fdSKay Sievers 	__ATTR(pmc7, 0600, show_pmc7, store_pmc7),
284*8a25a2fdSKay Sievers 	__ATTR(pmc8, 0600, show_pmc8, store_pmc8),
285b950bdd0SBenjamin Herrenschmidt #endif
2866529c13dSOlof Johansson };
2876529c13dSOlof Johansson 
288b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T
289*8a25a2fdSKay Sievers static struct device_attribute pa6t_attrs[] = {
290*8a25a2fdSKay Sievers 	__ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
291*8a25a2fdSKay Sievers 	__ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
292*8a25a2fdSKay Sievers 	__ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0),
293*8a25a2fdSKay Sievers 	__ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1),
294*8a25a2fdSKay Sievers 	__ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2),
295*8a25a2fdSKay Sievers 	__ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3),
296*8a25a2fdSKay Sievers 	__ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4),
297*8a25a2fdSKay Sievers 	__ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5),
2982e1957fdSOlof Johansson #ifdef CONFIG_DEBUG_KERNEL
299*8a25a2fdSKay Sievers 	__ATTR(hid0, 0600, show_hid0, store_hid0),
300*8a25a2fdSKay Sievers 	__ATTR(hid1, 0600, show_hid1, store_hid1),
301*8a25a2fdSKay Sievers 	__ATTR(hid4, 0600, show_hid4, store_hid4),
302*8a25a2fdSKay Sievers 	__ATTR(hid5, 0600, show_hid5, store_hid5),
303*8a25a2fdSKay Sievers 	__ATTR(ima0, 0600, show_ima0, store_ima0),
304*8a25a2fdSKay Sievers 	__ATTR(ima1, 0600, show_ima1, store_ima1),
305*8a25a2fdSKay Sievers 	__ATTR(ima2, 0600, show_ima2, store_ima2),
306*8a25a2fdSKay Sievers 	__ATTR(ima3, 0600, show_ima3, store_ima3),
307*8a25a2fdSKay Sievers 	__ATTR(ima4, 0600, show_ima4, store_ima4),
308*8a25a2fdSKay Sievers 	__ATTR(ima5, 0600, show_ima5, store_ima5),
309*8a25a2fdSKay Sievers 	__ATTR(ima6, 0600, show_ima6, store_ima6),
310*8a25a2fdSKay Sievers 	__ATTR(ima7, 0600, show_ima7, store_ima7),
311*8a25a2fdSKay Sievers 	__ATTR(ima8, 0600, show_ima8, store_ima8),
312*8a25a2fdSKay Sievers 	__ATTR(ima9, 0600, show_ima9, store_ima9),
313*8a25a2fdSKay Sievers 	__ATTR(imaat, 0600, show_imaat, store_imaat),
314*8a25a2fdSKay Sievers 	__ATTR(btcr, 0600, show_btcr, store_btcr),
315*8a25a2fdSKay Sievers 	__ATTR(pccr, 0600, show_pccr, store_pccr),
316*8a25a2fdSKay Sievers 	__ATTR(rpccr, 0600, show_rpccr, store_rpccr),
317*8a25a2fdSKay Sievers 	__ATTR(der, 0600, show_der, store_der),
318*8a25a2fdSKay Sievers 	__ATTR(mer, 0600, show_mer, store_mer),
319*8a25a2fdSKay Sievers 	__ATTR(ber, 0600, show_ber, store_ber),
320*8a25a2fdSKay Sievers 	__ATTR(ier, 0600, show_ier, store_ier),
321*8a25a2fdSKay Sievers 	__ATTR(sier, 0600, show_sier, store_sier),
322*8a25a2fdSKay Sievers 	__ATTR(siar, 0600, show_siar, store_siar),
323*8a25a2fdSKay Sievers 	__ATTR(tsr0, 0600, show_tsr0, store_tsr0),
324*8a25a2fdSKay Sievers 	__ATTR(tsr1, 0600, show_tsr1, store_tsr1),
325*8a25a2fdSKay Sievers 	__ATTR(tsr2, 0600, show_tsr2, store_tsr2),
326*8a25a2fdSKay Sievers 	__ATTR(tsr3, 0600, show_tsr3, store_tsr3),
3272e1957fdSOlof Johansson #endif /* CONFIG_DEBUG_KERNEL */
3286529c13dSOlof Johansson };
329b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */
330b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_CLASSIC */
3316529c13dSOlof Johansson 
3329ba1984eSNathan Lynch static void __cpuinit register_cpu_online(unsigned int cpu)
333d3d2176aSDavid Gibson {
334d3d2176aSDavid Gibson 	struct cpu *c = &per_cpu(cpu_devices, cpu);
335*8a25a2fdSKay Sievers 	struct device *s = &c->dev;
336*8a25a2fdSKay Sievers 	struct device_attribute *attrs, *pmc_attrs;
3376529c13dSOlof Johansson 	int i, nattrs;
338d3d2176aSDavid Gibson 
339b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64
340ad5cb17fSStephen Rothwell 	if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
341ad5cb17fSStephen Rothwell 			cpu_has_feature(CPU_FTR_SMT))
342*8a25a2fdSKay Sievers 		device_create_file(s, &dev_attr_smt_snooze_delay);
343b950bdd0SBenjamin Herrenschmidt #endif
344d3d2176aSDavid Gibson 
345d3d2176aSDavid Gibson 	/* PMC stuff */
3466529c13dSOlof Johansson 	switch (cur_cpu_spec->pmc_type) {
347b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_IBM
3486529c13dSOlof Johansson 	case PPC_PMC_IBM:
3496529c13dSOlof Johansson 		attrs = ibm_common_attrs;
350*8a25a2fdSKay Sievers 		nattrs = sizeof(ibm_common_attrs) / sizeof(struct device_attribute);
351b950bdd0SBenjamin Herrenschmidt 		pmc_attrs = classic_pmc_attrs;
3526529c13dSOlof Johansson 		break;
353b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_IBM */
354b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_G4
355b950bdd0SBenjamin Herrenschmidt 	case PPC_PMC_G4:
356b950bdd0SBenjamin Herrenschmidt 		attrs = g4_common_attrs;
357*8a25a2fdSKay Sievers 		nattrs = sizeof(g4_common_attrs) / sizeof(struct device_attribute);
358b950bdd0SBenjamin Herrenschmidt 		pmc_attrs = classic_pmc_attrs;
359b950bdd0SBenjamin Herrenschmidt 		break;
360b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */
361b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T
3626529c13dSOlof Johansson 	case PPC_PMC_PA6T:
3636529c13dSOlof Johansson 		/* PA Semi starts counting at PMC0 */
3646529c13dSOlof Johansson 		attrs = pa6t_attrs;
365*8a25a2fdSKay Sievers 		nattrs = sizeof(pa6t_attrs) / sizeof(struct device_attribute);
3666529c13dSOlof Johansson 		pmc_attrs = NULL;
3676529c13dSOlof Johansson 		break;
368b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */
3696529c13dSOlof Johansson 	default:
3706529c13dSOlof Johansson 		attrs = NULL;
3716529c13dSOlof Johansson 		nattrs = 0;
3726529c13dSOlof Johansson 		pmc_attrs = NULL;
3736529c13dSOlof Johansson 	}
374d3d2176aSDavid Gibson 
3756529c13dSOlof Johansson 	for (i = 0; i < nattrs; i++)
376*8a25a2fdSKay Sievers 		device_create_file(s, &attrs[i]);
3776529c13dSOlof Johansson 
3786529c13dSOlof Johansson 	if (pmc_attrs)
3796529c13dSOlof Johansson 		for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
380*8a25a2fdSKay Sievers 			device_create_file(s, &pmc_attrs[i]);
381d3d2176aSDavid Gibson 
382b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64
383d3d2176aSDavid Gibson 	if (cpu_has_feature(CPU_FTR_MMCRA))
384*8a25a2fdSKay Sievers 		device_create_file(s, &dev_attr_mmcra);
385d3d2176aSDavid Gibson 
386afd05423SMichael Neuling 	if (cpu_has_feature(CPU_FTR_PURR))
387*8a25a2fdSKay Sievers 		device_create_file(s, &dev_attr_purr);
3884c198557SAnton Blanchard 
389f050982aSAnton Blanchard 	if (cpu_has_feature(CPU_FTR_SPURR))
390*8a25a2fdSKay Sievers 		device_create_file(s, &dev_attr_spurr);
391f050982aSAnton Blanchard 
3924c198557SAnton Blanchard 	if (cpu_has_feature(CPU_FTR_DSCR))
393*8a25a2fdSKay Sievers 		device_create_file(s, &dev_attr_dscr);
394b950bdd0SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */
395124c27d3SNathan Lynch 
39693197a36SNathan Lynch 	cacheinfo_cpu_online(cpu);
397d3d2176aSDavid Gibson }
398d3d2176aSDavid Gibson 
399d3d2176aSDavid Gibson #ifdef CONFIG_HOTPLUG_CPU
400d3d2176aSDavid Gibson static void unregister_cpu_online(unsigned int cpu)
401d3d2176aSDavid Gibson {
402d3d2176aSDavid Gibson 	struct cpu *c = &per_cpu(cpu_devices, cpu);
403*8a25a2fdSKay Sievers 	struct device *s = &c->dev;
404*8a25a2fdSKay Sievers 	struct device_attribute *attrs, *pmc_attrs;
4056529c13dSOlof Johansson 	int i, nattrs;
406d3d2176aSDavid Gibson 
40772486f1fSSiddha, Suresh B 	BUG_ON(!c->hotpluggable);
408d3d2176aSDavid Gibson 
409a1e0eb10SMilton Miller #ifdef CONFIG_PPC64
410ad5cb17fSStephen Rothwell 	if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
411ad5cb17fSStephen Rothwell 			cpu_has_feature(CPU_FTR_SMT))
412*8a25a2fdSKay Sievers 		device_remove_file(s, &dev_attr_smt_snooze_delay);
413a1e0eb10SMilton Miller #endif
414d3d2176aSDavid Gibson 
415d3d2176aSDavid Gibson 	/* PMC stuff */
4166529c13dSOlof Johansson 	switch (cur_cpu_spec->pmc_type) {
417b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_IBM
4186529c13dSOlof Johansson 	case PPC_PMC_IBM:
4196529c13dSOlof Johansson 		attrs = ibm_common_attrs;
420*8a25a2fdSKay Sievers 		nattrs = sizeof(ibm_common_attrs) / sizeof(struct device_attribute);
421b950bdd0SBenjamin Herrenschmidt 		pmc_attrs = classic_pmc_attrs;
4226529c13dSOlof Johansson 		break;
423b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_IBM */
424b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_G4
425b950bdd0SBenjamin Herrenschmidt 	case PPC_PMC_G4:
426b950bdd0SBenjamin Herrenschmidt 		attrs = g4_common_attrs;
427*8a25a2fdSKay Sievers 		nattrs = sizeof(g4_common_attrs) / sizeof(struct device_attribute);
428b950bdd0SBenjamin Herrenschmidt 		pmc_attrs = classic_pmc_attrs;
429b950bdd0SBenjamin Herrenschmidt 		break;
430b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */
431b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T
4326529c13dSOlof Johansson 	case PPC_PMC_PA6T:
4336529c13dSOlof Johansson 		/* PA Semi starts counting at PMC0 */
4346529c13dSOlof Johansson 		attrs = pa6t_attrs;
435*8a25a2fdSKay Sievers 		nattrs = sizeof(pa6t_attrs) / sizeof(struct device_attribute);
4366529c13dSOlof Johansson 		pmc_attrs = NULL;
4376529c13dSOlof Johansson 		break;
438b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */
4396529c13dSOlof Johansson 	default:
4406529c13dSOlof Johansson 		attrs = NULL;
4416529c13dSOlof Johansson 		nattrs = 0;
4426529c13dSOlof Johansson 		pmc_attrs = NULL;
4436529c13dSOlof Johansson 	}
444d3d2176aSDavid Gibson 
4456529c13dSOlof Johansson 	for (i = 0; i < nattrs; i++)
446*8a25a2fdSKay Sievers 		device_remove_file(s, &attrs[i]);
4476529c13dSOlof Johansson 
4486529c13dSOlof Johansson 	if (pmc_attrs)
4496529c13dSOlof Johansson 		for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
450*8a25a2fdSKay Sievers 			device_remove_file(s, &pmc_attrs[i]);
451d3d2176aSDavid Gibson 
452b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64
453d3d2176aSDavid Gibson 	if (cpu_has_feature(CPU_FTR_MMCRA))
454*8a25a2fdSKay Sievers 		device_remove_file(s, &dev_attr_mmcra);
455d3d2176aSDavid Gibson 
456afd05423SMichael Neuling 	if (cpu_has_feature(CPU_FTR_PURR))
457*8a25a2fdSKay Sievers 		device_remove_file(s, &dev_attr_purr);
4584c198557SAnton Blanchard 
459f050982aSAnton Blanchard 	if (cpu_has_feature(CPU_FTR_SPURR))
460*8a25a2fdSKay Sievers 		device_remove_file(s, &dev_attr_spurr);
461f050982aSAnton Blanchard 
4624c198557SAnton Blanchard 	if (cpu_has_feature(CPU_FTR_DSCR))
463*8a25a2fdSKay Sievers 		device_remove_file(s, &dev_attr_dscr);
464b950bdd0SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */
465124c27d3SNathan Lynch 
46693197a36SNathan Lynch 	cacheinfo_cpu_offline(cpu);
467d3d2176aSDavid Gibson }
46812633e80SNathan Fontenot 
46912633e80SNathan Fontenot #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
47012633e80SNathan Fontenot ssize_t arch_cpu_probe(const char *buf, size_t count)
47112633e80SNathan Fontenot {
47212633e80SNathan Fontenot 	if (ppc_md.cpu_probe)
47312633e80SNathan Fontenot 		return ppc_md.cpu_probe(buf, count);
47412633e80SNathan Fontenot 
47512633e80SNathan Fontenot 	return -EINVAL;
47612633e80SNathan Fontenot }
47712633e80SNathan Fontenot 
47812633e80SNathan Fontenot ssize_t arch_cpu_release(const char *buf, size_t count)
47912633e80SNathan Fontenot {
48012633e80SNathan Fontenot 	if (ppc_md.cpu_release)
48112633e80SNathan Fontenot 		return ppc_md.cpu_release(buf, count);
48212633e80SNathan Fontenot 
48312633e80SNathan Fontenot 	return -EINVAL;
48412633e80SNathan Fontenot }
48512633e80SNathan Fontenot #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
48612633e80SNathan Fontenot 
487d3d2176aSDavid Gibson #endif /* CONFIG_HOTPLUG_CPU */
488d3d2176aSDavid Gibson 
4898c78f307SChandra Seetharaman static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
490d3d2176aSDavid Gibson 				      unsigned long action, void *hcpu)
491d3d2176aSDavid Gibson {
492d3d2176aSDavid Gibson 	unsigned int cpu = (unsigned int)(long)hcpu;
493d3d2176aSDavid Gibson 
494d3d2176aSDavid Gibson 	switch (action) {
495d3d2176aSDavid Gibson 	case CPU_ONLINE:
4968bb78442SRafael J. Wysocki 	case CPU_ONLINE_FROZEN:
497d3d2176aSDavid Gibson 		register_cpu_online(cpu);
498d3d2176aSDavid Gibson 		break;
499d3d2176aSDavid Gibson #ifdef CONFIG_HOTPLUG_CPU
500d3d2176aSDavid Gibson 	case CPU_DEAD:
5018bb78442SRafael J. Wysocki 	case CPU_DEAD_FROZEN:
502d3d2176aSDavid Gibson 		unregister_cpu_online(cpu);
503d3d2176aSDavid Gibson 		break;
504d3d2176aSDavid Gibson #endif
505d3d2176aSDavid Gibson 	}
506d3d2176aSDavid Gibson 	return NOTIFY_OK;
507d3d2176aSDavid Gibson }
508d3d2176aSDavid Gibson 
5098c78f307SChandra Seetharaman static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
510d3d2176aSDavid Gibson 	.notifier_call	= sysfs_cpu_notify,
511d3d2176aSDavid Gibson };
512d3d2176aSDavid Gibson 
5130344c6c5SChristian Krafft static DEFINE_MUTEX(cpu_mutex);
5140344c6c5SChristian Krafft 
515*8a25a2fdSKay Sievers int cpu_add_dev_attr(struct device_attribute *attr)
5160344c6c5SChristian Krafft {
5170344c6c5SChristian Krafft 	int cpu;
5180344c6c5SChristian Krafft 
5190344c6c5SChristian Krafft 	mutex_lock(&cpu_mutex);
5200344c6c5SChristian Krafft 
5210344c6c5SChristian Krafft 	for_each_possible_cpu(cpu) {
522*8a25a2fdSKay Sievers 		device_create_file(get_cpu_device(cpu), attr);
5230344c6c5SChristian Krafft 	}
5240344c6c5SChristian Krafft 
5250344c6c5SChristian Krafft 	mutex_unlock(&cpu_mutex);
5260344c6c5SChristian Krafft 	return 0;
5270344c6c5SChristian Krafft }
528*8a25a2fdSKay Sievers EXPORT_SYMBOL_GPL(cpu_add_dev_attr);
5290344c6c5SChristian Krafft 
530*8a25a2fdSKay Sievers int cpu_add_dev_attr_group(struct attribute_group *attrs)
5310344c6c5SChristian Krafft {
5320344c6c5SChristian Krafft 	int cpu;
533*8a25a2fdSKay Sievers 	struct device *dev;
5346bcc4c01SOlof Johansson 	int ret;
5350344c6c5SChristian Krafft 
5360344c6c5SChristian Krafft 	mutex_lock(&cpu_mutex);
5370344c6c5SChristian Krafft 
5380344c6c5SChristian Krafft 	for_each_possible_cpu(cpu) {
539*8a25a2fdSKay Sievers 		dev = get_cpu_device(cpu);
540*8a25a2fdSKay Sievers 		ret = sysfs_create_group(&dev->kobj, attrs);
5416bcc4c01SOlof Johansson 		WARN_ON(ret != 0);
5420344c6c5SChristian Krafft 	}
5430344c6c5SChristian Krafft 
5440344c6c5SChristian Krafft 	mutex_unlock(&cpu_mutex);
5450344c6c5SChristian Krafft 	return 0;
5460344c6c5SChristian Krafft }
547*8a25a2fdSKay Sievers EXPORT_SYMBOL_GPL(cpu_add_dev_attr_group);
5480344c6c5SChristian Krafft 
5490344c6c5SChristian Krafft 
550*8a25a2fdSKay Sievers void cpu_remove_dev_attr(struct device_attribute *attr)
5510344c6c5SChristian Krafft {
5520344c6c5SChristian Krafft 	int cpu;
5530344c6c5SChristian Krafft 
5540344c6c5SChristian Krafft 	mutex_lock(&cpu_mutex);
5550344c6c5SChristian Krafft 
5560344c6c5SChristian Krafft 	for_each_possible_cpu(cpu) {
557*8a25a2fdSKay Sievers 		device_remove_file(get_cpu_device(cpu), attr);
5580344c6c5SChristian Krafft 	}
5590344c6c5SChristian Krafft 
5600344c6c5SChristian Krafft 	mutex_unlock(&cpu_mutex);
5610344c6c5SChristian Krafft }
562*8a25a2fdSKay Sievers EXPORT_SYMBOL_GPL(cpu_remove_dev_attr);
5630344c6c5SChristian Krafft 
564*8a25a2fdSKay Sievers void cpu_remove_dev_attr_group(struct attribute_group *attrs)
5650344c6c5SChristian Krafft {
5660344c6c5SChristian Krafft 	int cpu;
567*8a25a2fdSKay Sievers 	struct device *dev;
5680344c6c5SChristian Krafft 
5690344c6c5SChristian Krafft 	mutex_lock(&cpu_mutex);
5700344c6c5SChristian Krafft 
5710344c6c5SChristian Krafft 	for_each_possible_cpu(cpu) {
572*8a25a2fdSKay Sievers 		dev = get_cpu_device(cpu);
573*8a25a2fdSKay Sievers 		sysfs_remove_group(&dev->kobj, attrs);
5740344c6c5SChristian Krafft 	}
5750344c6c5SChristian Krafft 
5760344c6c5SChristian Krafft 	mutex_unlock(&cpu_mutex);
5770344c6c5SChristian Krafft }
578*8a25a2fdSKay Sievers EXPORT_SYMBOL_GPL(cpu_remove_dev_attr_group);
5790344c6c5SChristian Krafft 
5800344c6c5SChristian Krafft 
581d3d2176aSDavid Gibson /* NUMA stuff */
582d3d2176aSDavid Gibson 
583d3d2176aSDavid Gibson #ifdef CONFIG_NUMA
584d3d2176aSDavid Gibson static void register_nodes(void)
585d3d2176aSDavid Gibson {
586d3d2176aSDavid Gibson 	int i;
587d3d2176aSDavid Gibson 
5880fc44159SYasunori Goto 	for (i = 0; i < MAX_NUMNODES; i++)
5890fc44159SYasunori Goto 		register_one_node(i);
590d3d2176aSDavid Gibson }
591953039c8SJeremy Kerr 
592*8a25a2fdSKay Sievers int sysfs_add_device_to_node(struct device *dev, int nid)
593953039c8SJeremy Kerr {
594953039c8SJeremy Kerr 	struct node *node = &node_devices[nid];
595953039c8SJeremy Kerr 	return sysfs_create_link(&node->sysdev.kobj, &dev->kobj,
596953039c8SJeremy Kerr 			kobject_name(&dev->kobj));
597953039c8SJeremy Kerr }
59812654f77SJohannes Berg EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
599953039c8SJeremy Kerr 
600*8a25a2fdSKay Sievers void sysfs_remove_device_from_node(struct device *dev, int nid)
601953039c8SJeremy Kerr {
602953039c8SJeremy Kerr 	struct node *node = &node_devices[nid];
603953039c8SJeremy Kerr 	sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj));
604953039c8SJeremy Kerr }
60512654f77SJohannes Berg EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node);
606953039c8SJeremy Kerr 
607d3d2176aSDavid Gibson #else
608d3d2176aSDavid Gibson static void register_nodes(void)
609d3d2176aSDavid Gibson {
610d3d2176aSDavid Gibson 	return;
611d3d2176aSDavid Gibson }
612953039c8SJeremy Kerr 
613d3d2176aSDavid Gibson #endif
614d3d2176aSDavid Gibson 
615d3d2176aSDavid Gibson /* Only valid if CPU is present. */
616*8a25a2fdSKay Sievers static ssize_t show_physical_id(struct device *dev,
617*8a25a2fdSKay Sievers 				struct device_attribute *attr, char *buf)
618d3d2176aSDavid Gibson {
619*8a25a2fdSKay Sievers 	struct cpu *cpu = container_of(dev, struct cpu, dev);
620d3d2176aSDavid Gibson 
621*8a25a2fdSKay Sievers 	return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->dev.id));
622d3d2176aSDavid Gibson }
623*8a25a2fdSKay Sievers static DEVICE_ATTR(physical_id, 0444, show_physical_id, NULL);
624d3d2176aSDavid Gibson 
625d3d2176aSDavid Gibson static int __init topology_init(void)
626d3d2176aSDavid Gibson {
627d3d2176aSDavid Gibson 	int cpu;
628d3d2176aSDavid Gibson 
629d3d2176aSDavid Gibson 	register_nodes();
630d3d2176aSDavid Gibson 	register_cpu_notifier(&sysfs_cpu_nb);
631d3d2176aSDavid Gibson 
6320e551954SKAMEZAWA Hiroyuki 	for_each_possible_cpu(cpu) {
633d3d2176aSDavid Gibson 		struct cpu *c = &per_cpu(cpu_devices, cpu);
634d3d2176aSDavid Gibson 
635d3d2176aSDavid Gibson 		/*
636d3d2176aSDavid Gibson 		 * For now, we just see if the system supports making
637d3d2176aSDavid Gibson 		 * the RTAS calls for CPU hotplug.  But, there may be a
638d3d2176aSDavid Gibson 		 * more comprehensive way to do this for an individual
639d3d2176aSDavid Gibson 		 * CPU.  For instance, the boot cpu might never be valid
640d3d2176aSDavid Gibson 		 * for hotplugging.
641d3d2176aSDavid Gibson 		 */
64272486f1fSSiddha, Suresh B 		if (ppc_md.cpu_die)
64372486f1fSSiddha, Suresh B 			c->hotpluggable = 1;
644d3d2176aSDavid Gibson 
64572486f1fSSiddha, Suresh B 		if (cpu_online(cpu) || c->hotpluggable) {
64676b67ed9SKAMEZAWA Hiroyuki 			register_cpu(c, cpu);
647d3d2176aSDavid Gibson 
648*8a25a2fdSKay Sievers 			device_create_file(&c->dev, &dev_attr_physical_id);
649d3d2176aSDavid Gibson 		}
650d3d2176aSDavid Gibson 
651d3d2176aSDavid Gibson 		if (cpu_online(cpu))
652d3d2176aSDavid Gibson 			register_cpu_online(cpu);
653d3d2176aSDavid Gibson 	}
654efcac658SAlexey Kardashevskiy #ifdef CONFIG_PPC64
655efcac658SAlexey Kardashevskiy 	sysfs_create_dscr_default();
656efcac658SAlexey Kardashevskiy #endif /* CONFIG_PPC64 */
657d3d2176aSDavid Gibson 
658d3d2176aSDavid Gibson 	return 0;
659d3d2176aSDavid Gibson }
660e9e77ce8SKevin Corry subsys_initcall(topology_init);
661