Skip to content

Commit 1943f53

Browse files
Michael HolzheuMartin Schwidefsky
authored andcommitted
[S390] Force PSW restart on online CPU
PSW restart can be triggered on offline CPUs. If this happens, currently the PSW restart code fails, because functions like smp_processor_id() do not work on offline CPUs. This patch fixes this as follows: If PSW restart is triggered on an offline CPU, the PSW restart (sigp restart) is done a second time on another CPU that is online and the old CPU is stopped afterwards. Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent d3bf379 commit 1943f53

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎arch/s390/include/asm/smp.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
3333
extern void smp_switch_to_ipl_cpu(void (*func)(void *), void *);
3434
extern void smp_switch_to_cpu(void (*)(void *), void *, unsigned long sp,
3535
int from, int to);
36+
extern void smp_restart_with_online_cpu(void);
3637
extern void smp_restart_cpu(void);
3738

3839
/*
@@ -64,6 +65,10 @@ static inline void smp_switch_to_ipl_cpu(void (*func)(void *), void *data)
6465
func(data);
6566
}
6667

68+
static inline void smp_restart_with_online_cpu(void)
69+
{
70+
}
71+
6772
#define smp_vcpu_scheduled (1)
6873

6974
#endif /* CONFIG_SMP */

‎arch/s390/kernel/ipl.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,7 @@ static struct kobj_attribute on_restart_attr =
17381738

17391739
void do_restart(void)
17401740
{
1741+
smp_restart_with_online_cpu();
17411742
smp_send_stop();
17421743
on_restart_trigger.action->fn(&on_restart_trigger);
17431744
stop_run(&on_restart_trigger);

‎arch/s390/kernel/smp.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,29 @@ static inline int cpu_stopped(int cpu)
9797
return raw_cpu_stopped(cpu_logical_map(cpu));
9898
}
9999

100+
/*
101+
* Ensure that PSW restart is done on an online CPU
102+
*/
103+
void smp_restart_with_online_cpu(void)
104+
{
105+
int cpu;
106+
107+
for_each_online_cpu(cpu) {
108+
if (stap() == __cpu_logical_map[cpu]) {
109+
/* We are online: Enable DAT again and return */
110+
__load_psw_mask(psw_kernel_bits & ~PSW_MASK_MCHECK);
111+
return;
112+
}
113+
}
114+
/* We are not online: Do PSW restart on an online CPU */
115+
while (sigp(cpu, sigp_restart) == sigp_busy)
116+
cpu_relax();
117+
/* And stop ourself */
118+
while (raw_sigp(stap(), sigp_stop) == sigp_busy)
119+
cpu_relax();
120+
for (;;);
121+
}
122+
100123
void smp_switch_to_ipl_cpu(void (*func)(void *), void *data)
101124
{
102125
struct _lowcore *lc, *current_lc;

0 commit comments

Comments
 (0)