74
74
CPU_STATE_CONFIGURED ,
75
75
};
76
76
77
- static DEFINE_PER_CPU (struct cpu * , cpu_device ) ;
78
-
79
77
struct pcpu {
80
78
unsigned long ec_mask ; /* bit mask for ec_xxx functions */
81
79
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)
719
717
}
720
718
}
721
719
722
- static int smp_add_present_cpu (int cpu );
723
-
724
720
static int smp_add_core (struct sclp_core_entry * core , cpumask_t * avail ,
725
721
bool configured , bool early )
726
722
{
@@ -744,7 +740,7 @@ static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail,
744
740
pcpu -> state = CPU_STATE_STANDBY ;
745
741
smp_cpu_set_polarization (cpu , POLARIZATION_UNKNOWN );
746
742
set_cpu_present (cpu , true);
747
- if (!early && smp_add_present_cpu (cpu ) != 0 )
743
+ if (!early && arch_register_cpu (cpu ))
748
744
set_cpu_present (cpu , false);
749
745
else
750
746
nr ++ ;
@@ -831,9 +827,6 @@ void __init smp_detect_cpus(void)
831
827
s_cpus += smp_cpu_mtid + 1 ;
832
828
}
833
829
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);
837
830
memblock_free (info , sizeof (* info ));
838
831
}
839
832
@@ -974,6 +967,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
974
967
if (register_external_irq (EXT_IRQ_EXTERNAL_CALL , do_ext_call_interrupt ))
975
968
panic ("Couldn't request external interrupt 0x1202" );
976
969
system_ctl_set_bit (0 , 13 );
970
+ smp_rescan_cpus (true);
977
971
}
978
972
979
973
void __init smp_prepare_boot_cpu (void )
@@ -1111,35 +1105,34 @@ static struct attribute_group cpu_online_attr_group = {
1111
1105
1112
1106
static int smp_cpu_online (unsigned int cpu )
1113
1107
{
1114
- struct device * s = & per_cpu (cpu_device , cpu )-> dev ;
1108
+ struct cpu * c = & per_cpu (cpu_devices , cpu );
1115
1109
1116
- return sysfs_create_group (& s -> kobj , & cpu_online_attr_group );
1110
+ return sysfs_create_group (& c -> dev . kobj , & cpu_online_attr_group );
1117
1111
}
1118
1112
1119
1113
static int smp_cpu_pre_down (unsigned int cpu )
1120
1114
{
1121
- struct device * s = & per_cpu (cpu_device , cpu )-> dev ;
1115
+ struct cpu * c = & per_cpu (cpu_devices , cpu );
1122
1116
1123
- sysfs_remove_group (& s -> kobj , & cpu_online_attr_group );
1117
+ sysfs_remove_group (& c -> dev . kobj , & cpu_online_attr_group );
1124
1118
return 0 ;
1125
1119
}
1126
1120
1127
- static int smp_add_present_cpu (int cpu )
1121
+ bool arch_cpu_is_hotpluggable (int cpu )
1128
1122
{
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 );
1131
1129
int rc ;
1132
1130
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 );
1139
1132
rc = register_cpu (c , cpu );
1140
1133
if (rc )
1141
1134
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 );
1143
1136
if (rc )
1144
1137
goto out_cpu ;
1145
1138
rc = topology_cpu_init (c );
@@ -1148,14 +1141,14 @@ static int smp_add_present_cpu(int cpu)
1148
1141
return 0 ;
1149
1142
1150
1143
out_topology :
1151
- sysfs_remove_group (& s -> kobj , & cpu_common_attr_group );
1144
+ sysfs_remove_group (& c -> dev . kobj , & cpu_common_attr_group );
1152
1145
out_cpu :
1153
1146
unregister_cpu (c );
1154
1147
out :
1155
1148
return rc ;
1156
1149
}
1157
1150
1158
- int __ref smp_rescan_cpus (void )
1151
+ int __ref smp_rescan_cpus (bool early )
1159
1152
{
1160
1153
struct sclp_core_info * info ;
1161
1154
int nr ;
@@ -1164,7 +1157,7 @@ int __ref smp_rescan_cpus(void)
1164
1157
if (!info )
1165
1158
return - ENOMEM ;
1166
1159
smp_get_core_info (info , 0 );
1167
- nr = __smp_rescan_cpus (info , false );
1160
+ nr = __smp_rescan_cpus (info , early );
1168
1161
kfree (info );
1169
1162
if (nr )
1170
1163
topology_schedule_update ();
@@ -1181,7 +1174,7 @@ static ssize_t __ref rescan_store(struct device *dev,
1181
1174
rc = lock_device_hotplug_sysfs ();
1182
1175
if (rc )
1183
1176
return rc ;
1184
- rc = smp_rescan_cpus ();
1177
+ rc = smp_rescan_cpus (false );
1185
1178
unlock_device_hotplug ();
1186
1179
return rc ? rc : count ;
1187
1180
}
@@ -1190,7 +1183,7 @@ static DEVICE_ATTR_WO(rescan);
1190
1183
static int __init s390_smp_init (void )
1191
1184
{
1192
1185
struct device * dev_root ;
1193
- int cpu , rc = 0 ;
1186
+ int rc ;
1194
1187
1195
1188
dev_root = bus_get_dev_root (& cpu_subsys );
1196
1189
if (dev_root ) {
@@ -1199,17 +1192,9 @@ static int __init s390_smp_init(void)
1199
1192
if (rc )
1200
1193
return rc ;
1201
1194
}
1202
-
1203
- for_each_present_cpu (cpu ) {
1204
- rc = smp_add_present_cpu (cpu );
1205
- if (rc )
1206
- goto out ;
1207
- }
1208
-
1209
1195
rc = cpuhp_setup_state (CPUHP_AP_ONLINE_DYN , "s390/smp:online" ,
1210
1196
smp_cpu_online , smp_cpu_pre_down );
1211
1197
rc = rc <= 0 ? rc : 0 ;
1212
- out :
1213
1198
return rc ;
1214
1199
}
1215
1200
subsys_initcall (s390_smp_init );
0 commit comments