7474 CPU_STATE_CONFIGURED ,
7575};
7676
77- static DEFINE_PER_CPU (struct cpu * , cpu_device ) ;
78-
7977struct pcpu {
8078 unsigned long ec_mask ; /* bit mask for ec_xxx functions */
8179 unsigned long ec_clk ; /* sigp timestamp for ec_xxx */
@@ -719,8 +717,6 @@ static void __ref smp_get_core_info(struct sclp_core_info *info, int early)
719717 }
720718}
721719
722- static int smp_add_present_cpu (int cpu );
723-
724720static int smp_add_core (struct sclp_core_entry * core , cpumask_t * avail ,
725721 bool configured , bool early )
726722{
@@ -744,7 +740,7 @@ static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail,
744740 pcpu -> state = CPU_STATE_STANDBY ;
745741 smp_cpu_set_polarization (cpu , POLARIZATION_UNKNOWN );
746742 set_cpu_present (cpu , true);
747- if (!early && smp_add_present_cpu (cpu ) != 0 )
743+ if (!early && arch_register_cpu (cpu ))
748744 set_cpu_present (cpu , false);
749745 else
750746 nr ++ ;
@@ -831,9 +827,6 @@ void __init smp_detect_cpus(void)
831827 s_cpus += smp_cpu_mtid + 1 ;
832828 }
833829 pr_info ("%d configured CPUs, %d standby CPUs\n" , c_cpus , s_cpus );
834-
835- /* Add CPUs present at boot */
836- __smp_rescan_cpus (info , true);
837830 memblock_free (info , sizeof (* info ));
838831}
839832
@@ -974,6 +967,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
974967 if (register_external_irq (EXT_IRQ_EXTERNAL_CALL , do_ext_call_interrupt ))
975968 panic ("Couldn't request external interrupt 0x1202" );
976969 system_ctl_set_bit (0 , 13 );
970+ smp_rescan_cpus (true);
977971}
978972
979973void __init smp_prepare_boot_cpu (void )
@@ -1111,35 +1105,34 @@ static struct attribute_group cpu_online_attr_group = {
11111105
11121106static int smp_cpu_online (unsigned int cpu )
11131107{
1114- struct device * s = & per_cpu (cpu_device , cpu )-> dev ;
1108+ struct cpu * c = & per_cpu (cpu_devices , cpu );
11151109
1116- return sysfs_create_group (& s -> kobj , & cpu_online_attr_group );
1110+ return sysfs_create_group (& c -> dev . kobj , & cpu_online_attr_group );
11171111}
11181112
11191113static int smp_cpu_pre_down (unsigned int cpu )
11201114{
1121- struct device * s = & per_cpu (cpu_device , cpu )-> dev ;
1115+ struct cpu * c = & per_cpu (cpu_devices , cpu );
11221116
1123- sysfs_remove_group (& s -> kobj , & cpu_online_attr_group );
1117+ sysfs_remove_group (& c -> dev . kobj , & cpu_online_attr_group );
11241118 return 0 ;
11251119}
11261120
1127- static int smp_add_present_cpu (int cpu )
1121+ bool arch_cpu_is_hotpluggable (int cpu )
11281122{
1129- struct device * s ;
1130- struct cpu * c ;
1123+ return !!cpu ;
1124+ }
1125+
1126+ int arch_register_cpu (int cpu )
1127+ {
1128+ struct cpu * c = & per_cpu (cpu_devices , cpu );
11311129 int rc ;
11321130
1133- c = kzalloc (sizeof (* c ), GFP_KERNEL );
1134- if (!c )
1135- return - ENOMEM ;
1136- per_cpu (cpu_device , cpu ) = c ;
1137- s = & c -> dev ;
1138- c -> hotpluggable = !!cpu ;
1131+ c -> hotpluggable = arch_cpu_is_hotpluggable (cpu );
11391132 rc = register_cpu (c , cpu );
11401133 if (rc )
11411134 goto out ;
1142- rc = sysfs_create_group (& s -> kobj , & cpu_common_attr_group );
1135+ rc = sysfs_create_group (& c -> dev . kobj , & cpu_common_attr_group );
11431136 if (rc )
11441137 goto out_cpu ;
11451138 rc = topology_cpu_init (c );
@@ -1148,14 +1141,14 @@ static int smp_add_present_cpu(int cpu)
11481141 return 0 ;
11491142
11501143out_topology :
1151- sysfs_remove_group (& s -> kobj , & cpu_common_attr_group );
1144+ sysfs_remove_group (& c -> dev . kobj , & cpu_common_attr_group );
11521145out_cpu :
11531146 unregister_cpu (c );
11541147out :
11551148 return rc ;
11561149}
11571150
1158- int __ref smp_rescan_cpus (void )
1151+ int __ref smp_rescan_cpus (bool early )
11591152{
11601153 struct sclp_core_info * info ;
11611154 int nr ;
@@ -1164,7 +1157,7 @@ int __ref smp_rescan_cpus(void)
11641157 if (!info )
11651158 return - ENOMEM ;
11661159 smp_get_core_info (info , 0 );
1167- nr = __smp_rescan_cpus (info , false );
1160+ nr = __smp_rescan_cpus (info , early );
11681161 kfree (info );
11691162 if (nr )
11701163 topology_schedule_update ();
@@ -1181,7 +1174,7 @@ static ssize_t __ref rescan_store(struct device *dev,
11811174 rc = lock_device_hotplug_sysfs ();
11821175 if (rc )
11831176 return rc ;
1184- rc = smp_rescan_cpus ();
1177+ rc = smp_rescan_cpus (false );
11851178 unlock_device_hotplug ();
11861179 return rc ? rc : count ;
11871180}
@@ -1190,7 +1183,7 @@ static DEVICE_ATTR_WO(rescan);
11901183static int __init s390_smp_init (void )
11911184{
11921185 struct device * dev_root ;
1193- int cpu , rc = 0 ;
1186+ int rc ;
11941187
11951188 dev_root = bus_get_dev_root (& cpu_subsys );
11961189 if (dev_root ) {
@@ -1199,17 +1192,9 @@ static int __init s390_smp_init(void)
11991192 if (rc )
12001193 return rc ;
12011194 }
1202-
1203- for_each_present_cpu (cpu ) {
1204- rc = smp_add_present_cpu (cpu );
1205- if (rc )
1206- goto out ;
1207- }
1208-
12091195 rc = cpuhp_setup_state (CPUHP_AP_ONLINE_DYN , "s390/smp:online" ,
12101196 smp_cpu_online , smp_cpu_pre_down );
12111197 rc = rc <= 0 ? rc : 0 ;
1212- out :
12131198 return rc ;
12141199}
12151200subsys_initcall (s390_smp_init );
0 commit comments