Subject: Re: [PATCH v2] powerpc/xmon: Wait for secondaries before IPI'ing on system reset

From: Anton Blanchard <[email-masked]>
Date: Sun, 30 Apr 2017 22:27:58 +1000

Hi Nick,

> An externally triggered system reset (e.g., via QEMU nmi command, or
> pseries reset button) can cause system reset interrupts on all CPUs.
> In case this causes xmon to be entered, it is undesirable for the
> primary (first) CPU into xmon to trigger an NMI IPI to others,
> because this may cause a nested system reset interrupt.
> 
> So spin for a time waiting for secondaries to join xmon before
> performing the NMI IPI, similarly to what the crash dump code does.

That reminds me of similar delays in our crash path:

/*
 * The primary CPU waits a while for all secondary CPUs to enter. This is to
 * avoid sending an IPI if the secondary CPUs are entering
 * crash_kexec_secondary on their own (eg via a system reset).
 *
 * The secondary timeout has to be longer than the primary. Both timeouts are
 * in milliseconds.
 */
#define PRIMARY_TIMEOUT         500
#define SECONDARY_TIMEOUT       1000

...

        /*
         * If we came in via system reset, wait a while for the secondary
         * CPUs to enter.
         */
        if (TRAP(regs) == 0x100)
                mdelay(PRIMARY_TIMEOUT);

We might want to consolidate the juggling we do. Not sure if many people use
it, but kdb and kgdb may benefit if we make it common.

Anton