1d3d2176aSDavid Gibson #include <linux/sysdev.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> 7*4b16f8e2SPaul 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 404a0b2b4dSAndi Kleen static ssize_t store_smt_snooze_delay(struct sys_device *dev, 414a0b2b4dSAndi Kleen struct sysdev_attribute *attr, 424a0b2b4dSAndi Kleen const char *buf, 43d3d2176aSDavid Gibson size_t count) 44d3d2176aSDavid Gibson { 45d3d2176aSDavid Gibson struct cpu *cpu = container_of(dev, struct cpu, sysdev); 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 53d3d2176aSDavid Gibson per_cpu(smt_snooze_delay, cpu->sysdev.id) = snooze; 54d3d2176aSDavid Gibson 55d3d2176aSDavid Gibson return count; 56d3d2176aSDavid Gibson } 57d3d2176aSDavid Gibson 584a0b2b4dSAndi Kleen static ssize_t show_smt_snooze_delay(struct sys_device *dev, 594a0b2b4dSAndi Kleen struct sysdev_attribute *attr, 604a0b2b4dSAndi Kleen char *buf) 61d3d2176aSDavid Gibson { 62d3d2176aSDavid Gibson struct cpu *cpu = container_of(dev, struct cpu, sysdev); 63d3d2176aSDavid Gibson 64b878dc00SAnton Blanchard return sprintf(buf, "%ld\n", per_cpu(smt_snooze_delay, cpu->sysdev.id)); 65d3d2176aSDavid Gibson } 66d3d2176aSDavid Gibson 67d3d2176aSDavid Gibson static SYSDEV_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 } \ 1204a0b2b4dSAndi Kleen static ssize_t show_##NAME(struct sys_device *dev, \ 1214a0b2b4dSAndi Kleen struct sysdev_attribute *attr, \ 1224a0b2b4dSAndi Kleen char *buf) \ 123d3d2176aSDavid Gibson { \ 124d3d2176aSDavid Gibson struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 1259a371934SRusty Russell unsigned long val; \ 1269a371934SRusty Russell smp_call_function_single(cpu->sysdev.id, read_##NAME, &val, 1); \ 127d3d2176aSDavid Gibson return sprintf(buf, "%lx\n", val); \ 128d3d2176aSDavid Gibson } \ 1293ff6eeccSAdrian Bunk static ssize_t __used \ 1304a0b2b4dSAndi Kleen store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \ 1314a0b2b4dSAndi Kleen const char *buf, size_t count) \ 132d3d2176aSDavid Gibson { \ 133d3d2176aSDavid Gibson struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 134d3d2176aSDavid Gibson unsigned long val; \ 135d3d2176aSDavid Gibson int ret = sscanf(buf, "%lx", &val); \ 136d3d2176aSDavid Gibson if (ret != 1) \ 137d3d2176aSDavid Gibson return -EINVAL; \ 1389a371934SRusty Russell smp_call_function_single(cpu->sysdev.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 181b950bdd0SBenjamin Herrenschmidt static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra); 182b950bdd0SBenjamin Herrenschmidt static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL); 183b950bdd0SBenjamin Herrenschmidt static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr); 184b950bdd0SBenjamin Herrenschmidt static SYSDEV_ATTR(purr, 0600, show_purr, store_purr); 185efcac658SAlexey Kardashevskiy 186efcac658SAlexey Kardashevskiy unsigned long dscr_default = 0; 187efcac658SAlexey Kardashevskiy EXPORT_SYMBOL(dscr_default); 188efcac658SAlexey Kardashevskiy 189efcac658SAlexey Kardashevskiy static ssize_t show_dscr_default(struct sysdev_class *class, 190efcac658SAlexey Kardashevskiy struct sysdev_class_attribute *attr, char *buf) 191efcac658SAlexey Kardashevskiy { 192efcac658SAlexey Kardashevskiy return sprintf(buf, "%lx\n", dscr_default); 193efcac658SAlexey Kardashevskiy } 194efcac658SAlexey Kardashevskiy 195efcac658SAlexey Kardashevskiy static ssize_t __used store_dscr_default(struct sysdev_class *class, 196efcac658SAlexey Kardashevskiy struct sysdev_class_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 210efcac658SAlexey Kardashevskiy static SYSDEV_CLASS_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)) 217efcac658SAlexey Kardashevskiy err = sysfs_create_file(&cpu_sysdev_class.kset.kobj, 218efcac658SAlexey Kardashevskiy &attr_dscr_default.attr); 219efcac658SAlexey Kardashevskiy } 220b950bdd0SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */ 221b950bdd0SBenjamin Herrenschmidt 222b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T 22325fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0); 22425fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1); 22525fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2); 22625fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3); 22725fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4); 22825fc530eSOlof Johansson SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5); 2292e1957fdSOlof Johansson #ifdef CONFIG_DEBUG_KERNEL 2302e1957fdSOlof Johansson SYSFS_PMCSETUP(hid0, SPRN_HID0); 2312e1957fdSOlof Johansson SYSFS_PMCSETUP(hid1, SPRN_HID1); 2322e1957fdSOlof Johansson SYSFS_PMCSETUP(hid4, SPRN_HID4); 2332e1957fdSOlof Johansson SYSFS_PMCSETUP(hid5, SPRN_HID5); 2342e1957fdSOlof Johansson SYSFS_PMCSETUP(ima0, SPRN_PA6T_IMA0); 2352e1957fdSOlof Johansson SYSFS_PMCSETUP(ima1, SPRN_PA6T_IMA1); 2362e1957fdSOlof Johansson SYSFS_PMCSETUP(ima2, SPRN_PA6T_IMA2); 2372e1957fdSOlof Johansson SYSFS_PMCSETUP(ima3, SPRN_PA6T_IMA3); 2382e1957fdSOlof Johansson SYSFS_PMCSETUP(ima4, SPRN_PA6T_IMA4); 2392e1957fdSOlof Johansson SYSFS_PMCSETUP(ima5, SPRN_PA6T_IMA5); 2402e1957fdSOlof Johansson SYSFS_PMCSETUP(ima6, SPRN_PA6T_IMA6); 2412e1957fdSOlof Johansson SYSFS_PMCSETUP(ima7, SPRN_PA6T_IMA7); 2422e1957fdSOlof Johansson SYSFS_PMCSETUP(ima8, SPRN_PA6T_IMA8); 2432e1957fdSOlof Johansson SYSFS_PMCSETUP(ima9, SPRN_PA6T_IMA9); 2442e1957fdSOlof Johansson SYSFS_PMCSETUP(imaat, SPRN_PA6T_IMAAT); 2452e1957fdSOlof Johansson SYSFS_PMCSETUP(btcr, SPRN_PA6T_BTCR); 2462e1957fdSOlof Johansson SYSFS_PMCSETUP(pccr, SPRN_PA6T_PCCR); 2472e1957fdSOlof Johansson SYSFS_PMCSETUP(rpccr, SPRN_PA6T_RPCCR); 2482e1957fdSOlof Johansson SYSFS_PMCSETUP(der, SPRN_PA6T_DER); 2492e1957fdSOlof Johansson SYSFS_PMCSETUP(mer, SPRN_PA6T_MER); 2502e1957fdSOlof Johansson SYSFS_PMCSETUP(ber, SPRN_PA6T_BER); 2512e1957fdSOlof Johansson SYSFS_PMCSETUP(ier, SPRN_PA6T_IER); 2522e1957fdSOlof Johansson SYSFS_PMCSETUP(sier, SPRN_PA6T_SIER); 2532e1957fdSOlof Johansson SYSFS_PMCSETUP(siar, SPRN_PA6T_SIAR); 2542e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr0, SPRN_PA6T_TSR0); 2552e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr1, SPRN_PA6T_TSR1); 2562e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr2, SPRN_PA6T_TSR2); 2572e1957fdSOlof Johansson SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3); 2582e1957fdSOlof Johansson #endif /* CONFIG_DEBUG_KERNEL */ 259b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */ 2606529c13dSOlof Johansson 261b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_IBM 2626529c13dSOlof Johansson static struct sysdev_attribute ibm_common_attrs[] = { 2636529c13dSOlof Johansson _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 2646529c13dSOlof Johansson _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 2656529c13dSOlof Johansson }; 266b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */ 2676529c13dSOlof Johansson 268b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_G4 269b950bdd0SBenjamin Herrenschmidt static struct sysdev_attribute g4_common_attrs[] = { 270b950bdd0SBenjamin Herrenschmidt _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 271b950bdd0SBenjamin Herrenschmidt _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 272b950bdd0SBenjamin Herrenschmidt _SYSDEV_ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2), 273b950bdd0SBenjamin Herrenschmidt }; 274b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */ 275b950bdd0SBenjamin Herrenschmidt 276b950bdd0SBenjamin Herrenschmidt static struct sysdev_attribute classic_pmc_attrs[] = { 2776529c13dSOlof Johansson _SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1), 2786529c13dSOlof Johansson _SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2), 2796529c13dSOlof Johansson _SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3), 2806529c13dSOlof Johansson _SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4), 2816529c13dSOlof Johansson _SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5), 2826529c13dSOlof Johansson _SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6), 283b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64 2846529c13dSOlof Johansson _SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7), 2856529c13dSOlof Johansson _SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8), 286b950bdd0SBenjamin Herrenschmidt #endif 2876529c13dSOlof Johansson }; 2886529c13dSOlof Johansson 289b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T 2906529c13dSOlof Johansson static struct sysdev_attribute pa6t_attrs[] = { 2916529c13dSOlof Johansson _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 2926529c13dSOlof Johansson _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 2936529c13dSOlof Johansson _SYSDEV_ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0), 2946529c13dSOlof Johansson _SYSDEV_ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1), 2956529c13dSOlof Johansson _SYSDEV_ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2), 2966529c13dSOlof Johansson _SYSDEV_ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3), 2976529c13dSOlof Johansson _SYSDEV_ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4), 2986529c13dSOlof Johansson _SYSDEV_ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5), 2992e1957fdSOlof Johansson #ifdef CONFIG_DEBUG_KERNEL 3002e1957fdSOlof Johansson _SYSDEV_ATTR(hid0, 0600, show_hid0, store_hid0), 3012e1957fdSOlof Johansson _SYSDEV_ATTR(hid1, 0600, show_hid1, store_hid1), 3022e1957fdSOlof Johansson _SYSDEV_ATTR(hid4, 0600, show_hid4, store_hid4), 3032e1957fdSOlof Johansson _SYSDEV_ATTR(hid5, 0600, show_hid5, store_hid5), 3042e1957fdSOlof Johansson _SYSDEV_ATTR(ima0, 0600, show_ima0, store_ima0), 3052e1957fdSOlof Johansson _SYSDEV_ATTR(ima1, 0600, show_ima1, store_ima1), 3062e1957fdSOlof Johansson _SYSDEV_ATTR(ima2, 0600, show_ima2, store_ima2), 3072e1957fdSOlof Johansson _SYSDEV_ATTR(ima3, 0600, show_ima3, store_ima3), 3082e1957fdSOlof Johansson _SYSDEV_ATTR(ima4, 0600, show_ima4, store_ima4), 3092e1957fdSOlof Johansson _SYSDEV_ATTR(ima5, 0600, show_ima5, store_ima5), 3102e1957fdSOlof Johansson _SYSDEV_ATTR(ima6, 0600, show_ima6, store_ima6), 3112e1957fdSOlof Johansson _SYSDEV_ATTR(ima7, 0600, show_ima7, store_ima7), 3122e1957fdSOlof Johansson _SYSDEV_ATTR(ima8, 0600, show_ima8, store_ima8), 3132e1957fdSOlof Johansson _SYSDEV_ATTR(ima9, 0600, show_ima9, store_ima9), 3142e1957fdSOlof Johansson _SYSDEV_ATTR(imaat, 0600, show_imaat, store_imaat), 3152e1957fdSOlof Johansson _SYSDEV_ATTR(btcr, 0600, show_btcr, store_btcr), 3162e1957fdSOlof Johansson _SYSDEV_ATTR(pccr, 0600, show_pccr, store_pccr), 3172e1957fdSOlof Johansson _SYSDEV_ATTR(rpccr, 0600, show_rpccr, store_rpccr), 3182e1957fdSOlof Johansson _SYSDEV_ATTR(der, 0600, show_der, store_der), 3192e1957fdSOlof Johansson _SYSDEV_ATTR(mer, 0600, show_mer, store_mer), 3202e1957fdSOlof Johansson _SYSDEV_ATTR(ber, 0600, show_ber, store_ber), 3212e1957fdSOlof Johansson _SYSDEV_ATTR(ier, 0600, show_ier, store_ier), 3222e1957fdSOlof Johansson _SYSDEV_ATTR(sier, 0600, show_sier, store_sier), 3232e1957fdSOlof Johansson _SYSDEV_ATTR(siar, 0600, show_siar, store_siar), 3242e1957fdSOlof Johansson _SYSDEV_ATTR(tsr0, 0600, show_tsr0, store_tsr0), 3252e1957fdSOlof Johansson _SYSDEV_ATTR(tsr1, 0600, show_tsr1, store_tsr1), 3262e1957fdSOlof Johansson _SYSDEV_ATTR(tsr2, 0600, show_tsr2, store_tsr2), 3272e1957fdSOlof Johansson _SYSDEV_ATTR(tsr3, 0600, show_tsr3, store_tsr3), 3282e1957fdSOlof Johansson #endif /* CONFIG_DEBUG_KERNEL */ 3296529c13dSOlof Johansson }; 330b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */ 331b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_CLASSIC */ 3326529c13dSOlof Johansson 3339ba1984eSNathan Lynch static void __cpuinit register_cpu_online(unsigned int cpu) 334d3d2176aSDavid Gibson { 335d3d2176aSDavid Gibson struct cpu *c = &per_cpu(cpu_devices, cpu); 336d3d2176aSDavid Gibson struct sys_device *s = &c->sysdev; 3376529c13dSOlof Johansson struct sysdev_attribute *attrs, *pmc_attrs; 3386529c13dSOlof Johansson int i, nattrs; 339d3d2176aSDavid Gibson 340b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64 341ad5cb17fSStephen Rothwell if (!firmware_has_feature(FW_FEATURE_ISERIES) && 342ad5cb17fSStephen Rothwell cpu_has_feature(CPU_FTR_SMT)) 343d3d2176aSDavid Gibson sysdev_create_file(s, &attr_smt_snooze_delay); 344b950bdd0SBenjamin Herrenschmidt #endif 345d3d2176aSDavid Gibson 346d3d2176aSDavid Gibson /* PMC stuff */ 3476529c13dSOlof Johansson switch (cur_cpu_spec->pmc_type) { 348b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_IBM 3496529c13dSOlof Johansson case PPC_PMC_IBM: 3506529c13dSOlof Johansson attrs = ibm_common_attrs; 3516529c13dSOlof Johansson nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute); 352b950bdd0SBenjamin Herrenschmidt pmc_attrs = classic_pmc_attrs; 3536529c13dSOlof Johansson break; 354b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_IBM */ 355b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_G4 356b950bdd0SBenjamin Herrenschmidt case PPC_PMC_G4: 357b950bdd0SBenjamin Herrenschmidt attrs = g4_common_attrs; 358b950bdd0SBenjamin Herrenschmidt nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute); 359b950bdd0SBenjamin Herrenschmidt pmc_attrs = classic_pmc_attrs; 360b950bdd0SBenjamin Herrenschmidt break; 361b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */ 362b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T 3636529c13dSOlof Johansson case PPC_PMC_PA6T: 3646529c13dSOlof Johansson /* PA Semi starts counting at PMC0 */ 3656529c13dSOlof Johansson attrs = pa6t_attrs; 3666529c13dSOlof Johansson nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute); 3676529c13dSOlof Johansson pmc_attrs = NULL; 3686529c13dSOlof Johansson break; 369b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */ 3706529c13dSOlof Johansson default: 3716529c13dSOlof Johansson attrs = NULL; 3726529c13dSOlof Johansson nattrs = 0; 3736529c13dSOlof Johansson pmc_attrs = NULL; 3746529c13dSOlof Johansson } 375d3d2176aSDavid Gibson 3766529c13dSOlof Johansson for (i = 0; i < nattrs; i++) 3776529c13dSOlof Johansson sysdev_create_file(s, &attrs[i]); 3786529c13dSOlof Johansson 3796529c13dSOlof Johansson if (pmc_attrs) 3806529c13dSOlof Johansson for (i = 0; i < cur_cpu_spec->num_pmcs; i++) 3816529c13dSOlof Johansson sysdev_create_file(s, &pmc_attrs[i]); 382d3d2176aSDavid Gibson 383b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64 384d3d2176aSDavid Gibson if (cpu_has_feature(CPU_FTR_MMCRA)) 385d3d2176aSDavid Gibson sysdev_create_file(s, &attr_mmcra); 386d3d2176aSDavid Gibson 387afd05423SMichael Neuling if (cpu_has_feature(CPU_FTR_PURR)) 388d3d2176aSDavid Gibson sysdev_create_file(s, &attr_purr); 3894c198557SAnton Blanchard 390f050982aSAnton Blanchard if (cpu_has_feature(CPU_FTR_SPURR)) 391f050982aSAnton Blanchard sysdev_create_file(s, &attr_spurr); 392f050982aSAnton Blanchard 3934c198557SAnton Blanchard if (cpu_has_feature(CPU_FTR_DSCR)) 3944c198557SAnton Blanchard sysdev_create_file(s, &attr_dscr); 395b950bdd0SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */ 396124c27d3SNathan Lynch 39793197a36SNathan Lynch cacheinfo_cpu_online(cpu); 398d3d2176aSDavid Gibson } 399d3d2176aSDavid Gibson 400d3d2176aSDavid Gibson #ifdef CONFIG_HOTPLUG_CPU 401d3d2176aSDavid Gibson static void unregister_cpu_online(unsigned int cpu) 402d3d2176aSDavid Gibson { 403d3d2176aSDavid Gibson struct cpu *c = &per_cpu(cpu_devices, cpu); 404d3d2176aSDavid Gibson struct sys_device *s = &c->sysdev; 4056529c13dSOlof Johansson struct sysdev_attribute *attrs, *pmc_attrs; 4066529c13dSOlof Johansson int i, nattrs; 407d3d2176aSDavid Gibson 40872486f1fSSiddha, Suresh B BUG_ON(!c->hotpluggable); 409d3d2176aSDavid Gibson 410a1e0eb10SMilton Miller #ifdef CONFIG_PPC64 411ad5cb17fSStephen Rothwell if (!firmware_has_feature(FW_FEATURE_ISERIES) && 412ad5cb17fSStephen Rothwell cpu_has_feature(CPU_FTR_SMT)) 413d3d2176aSDavid Gibson sysdev_remove_file(s, &attr_smt_snooze_delay); 414a1e0eb10SMilton Miller #endif 415d3d2176aSDavid Gibson 416d3d2176aSDavid Gibson /* PMC stuff */ 4176529c13dSOlof Johansson switch (cur_cpu_spec->pmc_type) { 418b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_IBM 4196529c13dSOlof Johansson case PPC_PMC_IBM: 4206529c13dSOlof Johansson attrs = ibm_common_attrs; 4216529c13dSOlof Johansson nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute); 422b950bdd0SBenjamin Herrenschmidt pmc_attrs = classic_pmc_attrs; 4236529c13dSOlof Johansson break; 424b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_IBM */ 425b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_G4 426b950bdd0SBenjamin Herrenschmidt case PPC_PMC_G4: 427b950bdd0SBenjamin Herrenschmidt attrs = g4_common_attrs; 428b950bdd0SBenjamin Herrenschmidt nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute); 429b950bdd0SBenjamin Herrenschmidt pmc_attrs = classic_pmc_attrs; 430b950bdd0SBenjamin Herrenschmidt break; 431b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_G4 */ 432b950bdd0SBenjamin Herrenschmidt #ifdef HAS_PPC_PMC_PA6T 4336529c13dSOlof Johansson case PPC_PMC_PA6T: 4346529c13dSOlof Johansson /* PA Semi starts counting at PMC0 */ 4356529c13dSOlof Johansson attrs = pa6t_attrs; 4366529c13dSOlof Johansson nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute); 4376529c13dSOlof Johansson pmc_attrs = NULL; 4386529c13dSOlof Johansson break; 439b950bdd0SBenjamin Herrenschmidt #endif /* HAS_PPC_PMC_PA6T */ 4406529c13dSOlof Johansson default: 4416529c13dSOlof Johansson attrs = NULL; 4426529c13dSOlof Johansson nattrs = 0; 4436529c13dSOlof Johansson pmc_attrs = NULL; 4446529c13dSOlof Johansson } 445d3d2176aSDavid Gibson 4466529c13dSOlof Johansson for (i = 0; i < nattrs; i++) 4476529c13dSOlof Johansson sysdev_remove_file(s, &attrs[i]); 4486529c13dSOlof Johansson 4496529c13dSOlof Johansson if (pmc_attrs) 4506529c13dSOlof Johansson for (i = 0; i < cur_cpu_spec->num_pmcs; i++) 4516529c13dSOlof Johansson sysdev_remove_file(s, &pmc_attrs[i]); 452d3d2176aSDavid Gibson 453b950bdd0SBenjamin Herrenschmidt #ifdef CONFIG_PPC64 454d3d2176aSDavid Gibson if (cpu_has_feature(CPU_FTR_MMCRA)) 455d3d2176aSDavid Gibson sysdev_remove_file(s, &attr_mmcra); 456d3d2176aSDavid Gibson 457afd05423SMichael Neuling if (cpu_has_feature(CPU_FTR_PURR)) 458d3d2176aSDavid Gibson sysdev_remove_file(s, &attr_purr); 4594c198557SAnton Blanchard 460f050982aSAnton Blanchard if (cpu_has_feature(CPU_FTR_SPURR)) 461f050982aSAnton Blanchard sysdev_remove_file(s, &attr_spurr); 462f050982aSAnton Blanchard 4634c198557SAnton Blanchard if (cpu_has_feature(CPU_FTR_DSCR)) 4644c198557SAnton Blanchard sysdev_remove_file(s, &attr_dscr); 465b950bdd0SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */ 466124c27d3SNathan Lynch 46793197a36SNathan Lynch cacheinfo_cpu_offline(cpu); 468d3d2176aSDavid Gibson } 46912633e80SNathan Fontenot 47012633e80SNathan Fontenot #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 47112633e80SNathan Fontenot ssize_t arch_cpu_probe(const char *buf, size_t count) 47212633e80SNathan Fontenot { 47312633e80SNathan Fontenot if (ppc_md.cpu_probe) 47412633e80SNathan Fontenot return ppc_md.cpu_probe(buf, count); 47512633e80SNathan Fontenot 47612633e80SNathan Fontenot return -EINVAL; 47712633e80SNathan Fontenot } 47812633e80SNathan Fontenot 47912633e80SNathan Fontenot ssize_t arch_cpu_release(const char *buf, size_t count) 48012633e80SNathan Fontenot { 48112633e80SNathan Fontenot if (ppc_md.cpu_release) 48212633e80SNathan Fontenot return ppc_md.cpu_release(buf, count); 48312633e80SNathan Fontenot 48412633e80SNathan Fontenot return -EINVAL; 48512633e80SNathan Fontenot } 48612633e80SNathan Fontenot #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 48712633e80SNathan Fontenot 488d3d2176aSDavid Gibson #endif /* CONFIG_HOTPLUG_CPU */ 489d3d2176aSDavid Gibson 4908c78f307SChandra Seetharaman static int __cpuinit sysfs_cpu_notify(struct notifier_block *self, 491d3d2176aSDavid Gibson unsigned long action, void *hcpu) 492d3d2176aSDavid Gibson { 493d3d2176aSDavid Gibson unsigned int cpu = (unsigned int)(long)hcpu; 494d3d2176aSDavid Gibson 495d3d2176aSDavid Gibson switch (action) { 496d3d2176aSDavid Gibson case CPU_ONLINE: 4978bb78442SRafael J. Wysocki case CPU_ONLINE_FROZEN: 498d3d2176aSDavid Gibson register_cpu_online(cpu); 499d3d2176aSDavid Gibson break; 500d3d2176aSDavid Gibson #ifdef CONFIG_HOTPLUG_CPU 501d3d2176aSDavid Gibson case CPU_DEAD: 5028bb78442SRafael J. Wysocki case CPU_DEAD_FROZEN: 503d3d2176aSDavid Gibson unregister_cpu_online(cpu); 504d3d2176aSDavid Gibson break; 505d3d2176aSDavid Gibson #endif 506d3d2176aSDavid Gibson } 507d3d2176aSDavid Gibson return NOTIFY_OK; 508d3d2176aSDavid Gibson } 509d3d2176aSDavid Gibson 5108c78f307SChandra Seetharaman static struct notifier_block __cpuinitdata sysfs_cpu_nb = { 511d3d2176aSDavid Gibson .notifier_call = sysfs_cpu_notify, 512d3d2176aSDavid Gibson }; 513d3d2176aSDavid Gibson 5140344c6c5SChristian Krafft static DEFINE_MUTEX(cpu_mutex); 5150344c6c5SChristian Krafft 5160344c6c5SChristian Krafft int cpu_add_sysdev_attr(struct sysdev_attribute *attr) 5170344c6c5SChristian Krafft { 5180344c6c5SChristian Krafft int cpu; 5190344c6c5SChristian Krafft 5200344c6c5SChristian Krafft mutex_lock(&cpu_mutex); 5210344c6c5SChristian Krafft 5220344c6c5SChristian Krafft for_each_possible_cpu(cpu) { 5230344c6c5SChristian Krafft sysdev_create_file(get_cpu_sysdev(cpu), attr); 5240344c6c5SChristian Krafft } 5250344c6c5SChristian Krafft 5260344c6c5SChristian Krafft mutex_unlock(&cpu_mutex); 5270344c6c5SChristian Krafft return 0; 5280344c6c5SChristian Krafft } 5290344c6c5SChristian Krafft EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr); 5300344c6c5SChristian Krafft 5310344c6c5SChristian Krafft int cpu_add_sysdev_attr_group(struct attribute_group *attrs) 5320344c6c5SChristian Krafft { 5330344c6c5SChristian Krafft int cpu; 5340344c6c5SChristian Krafft struct sys_device *sysdev; 5356bcc4c01SOlof Johansson int ret; 5360344c6c5SChristian Krafft 5370344c6c5SChristian Krafft mutex_lock(&cpu_mutex); 5380344c6c5SChristian Krafft 5390344c6c5SChristian Krafft for_each_possible_cpu(cpu) { 5400344c6c5SChristian Krafft sysdev = get_cpu_sysdev(cpu); 5416bcc4c01SOlof Johansson ret = sysfs_create_group(&sysdev->kobj, attrs); 5426bcc4c01SOlof Johansson WARN_ON(ret != 0); 5430344c6c5SChristian Krafft } 5440344c6c5SChristian Krafft 5450344c6c5SChristian Krafft mutex_unlock(&cpu_mutex); 5460344c6c5SChristian Krafft return 0; 5470344c6c5SChristian Krafft } 5480344c6c5SChristian Krafft EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group); 5490344c6c5SChristian Krafft 5500344c6c5SChristian Krafft 5510344c6c5SChristian Krafft void cpu_remove_sysdev_attr(struct sysdev_attribute *attr) 5520344c6c5SChristian Krafft { 5530344c6c5SChristian Krafft int cpu; 5540344c6c5SChristian Krafft 5550344c6c5SChristian Krafft mutex_lock(&cpu_mutex); 5560344c6c5SChristian Krafft 5570344c6c5SChristian Krafft for_each_possible_cpu(cpu) { 5580344c6c5SChristian Krafft sysdev_remove_file(get_cpu_sysdev(cpu), attr); 5590344c6c5SChristian Krafft } 5600344c6c5SChristian Krafft 5610344c6c5SChristian Krafft mutex_unlock(&cpu_mutex); 5620344c6c5SChristian Krafft } 5630344c6c5SChristian Krafft EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr); 5640344c6c5SChristian Krafft 5650344c6c5SChristian Krafft void cpu_remove_sysdev_attr_group(struct attribute_group *attrs) 5660344c6c5SChristian Krafft { 5670344c6c5SChristian Krafft int cpu; 5680344c6c5SChristian Krafft struct sys_device *sysdev; 5690344c6c5SChristian Krafft 5700344c6c5SChristian Krafft mutex_lock(&cpu_mutex); 5710344c6c5SChristian Krafft 5720344c6c5SChristian Krafft for_each_possible_cpu(cpu) { 5730344c6c5SChristian Krafft sysdev = get_cpu_sysdev(cpu); 5740344c6c5SChristian Krafft sysfs_remove_group(&sysdev->kobj, attrs); 5750344c6c5SChristian Krafft } 5760344c6c5SChristian Krafft 5770344c6c5SChristian Krafft mutex_unlock(&cpu_mutex); 5780344c6c5SChristian Krafft } 5790344c6c5SChristian Krafft EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr_group); 5800344c6c5SChristian Krafft 5810344c6c5SChristian Krafft 582d3d2176aSDavid Gibson /* NUMA stuff */ 583d3d2176aSDavid Gibson 584d3d2176aSDavid Gibson #ifdef CONFIG_NUMA 585d3d2176aSDavid Gibson static void register_nodes(void) 586d3d2176aSDavid Gibson { 587d3d2176aSDavid Gibson int i; 588d3d2176aSDavid Gibson 5890fc44159SYasunori Goto for (i = 0; i < MAX_NUMNODES; i++) 5900fc44159SYasunori Goto register_one_node(i); 591d3d2176aSDavid Gibson } 592953039c8SJeremy Kerr 593953039c8SJeremy Kerr int sysfs_add_device_to_node(struct sys_device *dev, int nid) 594953039c8SJeremy Kerr { 595953039c8SJeremy Kerr struct node *node = &node_devices[nid]; 596953039c8SJeremy Kerr return sysfs_create_link(&node->sysdev.kobj, &dev->kobj, 597953039c8SJeremy Kerr kobject_name(&dev->kobj)); 598953039c8SJeremy Kerr } 59912654f77SJohannes Berg EXPORT_SYMBOL_GPL(sysfs_add_device_to_node); 600953039c8SJeremy Kerr 601953039c8SJeremy Kerr void sysfs_remove_device_from_node(struct sys_device *dev, int nid) 602953039c8SJeremy Kerr { 603953039c8SJeremy Kerr struct node *node = &node_devices[nid]; 604953039c8SJeremy Kerr sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj)); 605953039c8SJeremy Kerr } 60612654f77SJohannes Berg EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node); 607953039c8SJeremy Kerr 608d3d2176aSDavid Gibson #else 609d3d2176aSDavid Gibson static void register_nodes(void) 610d3d2176aSDavid Gibson { 611d3d2176aSDavid Gibson return; 612d3d2176aSDavid Gibson } 613953039c8SJeremy Kerr 614d3d2176aSDavid Gibson #endif 615d3d2176aSDavid Gibson 616d3d2176aSDavid Gibson /* Only valid if CPU is present. */ 61700bf6e90SStephen Rothwell static ssize_t show_physical_id(struct sys_device *dev, 61800bf6e90SStephen Rothwell struct sysdev_attribute *attr, char *buf) 619d3d2176aSDavid Gibson { 620d3d2176aSDavid Gibson struct cpu *cpu = container_of(dev, struct cpu, sysdev); 621d3d2176aSDavid Gibson 622d3d2176aSDavid Gibson return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->sysdev.id)); 623d3d2176aSDavid Gibson } 624d3d2176aSDavid Gibson static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL); 625d3d2176aSDavid Gibson 626d3d2176aSDavid Gibson static int __init topology_init(void) 627d3d2176aSDavid Gibson { 628d3d2176aSDavid Gibson int cpu; 629d3d2176aSDavid Gibson 630d3d2176aSDavid Gibson register_nodes(); 631d3d2176aSDavid Gibson register_cpu_notifier(&sysfs_cpu_nb); 632d3d2176aSDavid Gibson 6330e551954SKAMEZAWA Hiroyuki for_each_possible_cpu(cpu) { 634d3d2176aSDavid Gibson struct cpu *c = &per_cpu(cpu_devices, cpu); 635d3d2176aSDavid Gibson 636d3d2176aSDavid Gibson /* 637d3d2176aSDavid Gibson * For now, we just see if the system supports making 638d3d2176aSDavid Gibson * the RTAS calls for CPU hotplug. But, there may be a 639d3d2176aSDavid Gibson * more comprehensive way to do this for an individual 640d3d2176aSDavid Gibson * CPU. For instance, the boot cpu might never be valid 641d3d2176aSDavid Gibson * for hotplugging. 642d3d2176aSDavid Gibson */ 64372486f1fSSiddha, Suresh B if (ppc_md.cpu_die) 64472486f1fSSiddha, Suresh B c->hotpluggable = 1; 645d3d2176aSDavid Gibson 64672486f1fSSiddha, Suresh B if (cpu_online(cpu) || c->hotpluggable) { 64776b67ed9SKAMEZAWA Hiroyuki register_cpu(c, cpu); 648d3d2176aSDavid Gibson 649d3d2176aSDavid Gibson sysdev_create_file(&c->sysdev, &attr_physical_id); 650d3d2176aSDavid Gibson } 651d3d2176aSDavid Gibson 652d3d2176aSDavid Gibson if (cpu_online(cpu)) 653d3d2176aSDavid Gibson register_cpu_online(cpu); 654d3d2176aSDavid Gibson } 655efcac658SAlexey Kardashevskiy #ifdef CONFIG_PPC64 656efcac658SAlexey Kardashevskiy sysfs_create_dscr_default(); 657efcac658SAlexey Kardashevskiy #endif /* CONFIG_PPC64 */ 658d3d2176aSDavid Gibson 659d3d2176aSDavid Gibson return 0; 660d3d2176aSDavid Gibson } 661e9e77ce8SKevin Corry subsys_initcall(topology_init); 662