40
40
#define REAL_MODE_TIMEOUT 10000
41
41
42
42
static int time_to_dump ;
43
+
44
+ /*
45
+ * In case of system reset, secondary CPUs enter crash_kexec_secondary with out
46
+ * having to send an IPI explicitly. So, indicate if the crash is via
47
+ * system reset to avoid sending another IPI.
48
+ */
49
+ static int is_via_system_reset ;
50
+
43
51
/*
44
52
* crash_wake_offline should be set to 1 by platforms that intend to wake
45
53
* up offline cpus prior to jumping to a kdump kernel. Currently powernv
@@ -101,7 +109,7 @@ void crash_ipi_callback(struct pt_regs *regs)
101
109
/* NOTREACHED */
102
110
}
103
111
104
- static void crash_kexec_prepare_cpus (int cpu )
112
+ static void crash_kexec_prepare_cpus (void )
105
113
{
106
114
unsigned int msecs ;
107
115
volatile unsigned int ncpus = num_online_cpus () - 1 ;/* Excluding the panic cpu */
@@ -113,7 +121,15 @@ static void crash_kexec_prepare_cpus(int cpu)
113
121
if (crash_wake_offline )
114
122
ncpus = num_present_cpus () - 1 ;
115
123
116
- crash_send_ipi (crash_ipi_callback );
124
+ /*
125
+ * If we came in via system reset, secondaries enter via crash_kexec_secondary().
126
+ * So, wait a while for the secondary CPUs to enter for that case.
127
+ * Else, send IPI to all other CPUs.
128
+ */
129
+ if (is_via_system_reset )
130
+ mdelay (PRIMARY_TIMEOUT );
131
+ else
132
+ crash_send_ipi (crash_ipi_callback );
117
133
smp_wmb ();
118
134
119
135
again :
@@ -202,7 +218,7 @@ void crash_kexec_secondary(struct pt_regs *regs)
202
218
203
219
#else /* ! CONFIG_SMP */
204
220
205
- static void crash_kexec_prepare_cpus (int cpu )
221
+ static void crash_kexec_prepare_cpus (void )
206
222
{
207
223
/*
208
224
* move the secondaries to us so that we can copy
@@ -248,6 +264,32 @@ noinstr static void __maybe_unused crash_kexec_wait_realmode(int cpu)
248
264
static inline void crash_kexec_wait_realmode (int cpu ) {}
249
265
#endif /* CONFIG_SMP && CONFIG_PPC64 */
250
266
267
+ void crash_kexec_prepare (void )
268
+ {
269
+ /* Avoid hardlocking with irresponsive CPU holding logbuf_lock */
270
+ printk_deferred_enter ();
271
+
272
+ /*
273
+ * This function is only called after the system
274
+ * has panicked or is otherwise in a critical state.
275
+ * The minimum amount of code to allow a kexec'd kernel
276
+ * to run successfully needs to happen here.
277
+ *
278
+ * In practice this means stopping other cpus in
279
+ * an SMP system.
280
+ * The kernel is broken so disable interrupts.
281
+ */
282
+ hard_irq_disable ();
283
+
284
+ /*
285
+ * Make a note of crashing cpu. Will be used in machine_kexec
286
+ * such that another IPI will not be sent.
287
+ */
288
+ crashing_cpu = smp_processor_id ();
289
+
290
+ crash_kexec_prepare_cpus ();
291
+ }
292
+
251
293
/*
252
294
* Register a function to be called on shutdown. Only use this if you
253
295
* can't reset your device in the second kernel.
@@ -311,35 +353,10 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
311
353
unsigned int i ;
312
354
int (* old_handler )(struct pt_regs * regs );
313
355
314
- /* Avoid hardlocking with irresponsive CPU holding logbuf_lock */
315
- printk_deferred_enter ();
316
-
317
- /*
318
- * This function is only called after the system
319
- * has panicked or is otherwise in a critical state.
320
- * The minimum amount of code to allow a kexec'd kernel
321
- * to run successfully needs to happen here.
322
- *
323
- * In practice this means stopping other cpus in
324
- * an SMP system.
325
- * The kernel is broken so disable interrupts.
326
- */
327
- hard_irq_disable ();
328
-
329
- /*
330
- * Make a note of crashing cpu. Will be used in machine_kexec
331
- * such that another IPI will not be sent.
332
- */
333
- crashing_cpu = smp_processor_id ();
334
-
335
- /*
336
- * If we came in via system reset, wait a while for the secondary
337
- * CPUs to enter.
338
- */
339
356
if (TRAP (regs ) == INTERRUPT_SYSTEM_RESET )
340
- mdelay ( PRIMARY_TIMEOUT ) ;
357
+ is_via_system_reset = 1 ;
341
358
342
- crash_kexec_prepare_cpus ( crashing_cpu );
359
+ crash_smp_send_stop ( );
343
360
344
361
crash_save_cpu (regs , crashing_cpu );
345
362
0 commit comments