linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Corey Minyard <cminyard@mvista.com>
To: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dave Young <dyoung@redhat.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Baoquan He <bhe@redhat.com>, Ralf Baechle <ralf@linux-mips.org>
Cc: x86@kernel.org, David Daney <david.daney@cavium.com>,
	Xunlei Pang <xpang@redhat.com>,
	Aaro Koskinen <aaro.koskinen@iki.fi>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>,
	linux-mips@linux-mips.org, Masami Hiramatsu <mhiramat@kernel.org>,
	"Steven J. Hill" <steven.hill@cavium.com>,
	xen-devel@lists.xenproject.org,
	Daniel Walker <dwalker@fifo99.com>,
	Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [V4 PATCH 2/2] mips/panic: Replace smp_send_stop() with kdump friendly version in panic path
Date: Thu, 18 Aug 2016 16:18:17 -0500	[thread overview]
Message-ID: <bdfd7136-6b0e-3820-dbac-d72529a4f058@mvista.com> (raw)
In-Reply-To: <20160810080950.11028.28000.stgit@sysi4-13.yrl.intra.hitachi.co.jp>

Sorry this took so long, but I have finally tested this, it seems to 
work fine:

Tested-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Corey Minyard <cminyard@mvista.com>

On 08/10/2016 03:09 AM, Hidehiro Kawai wrote:
> Daniel Walker reported problems which happens when
> crash_kexec_post_notifiers kernel option is enabled
> (https://lkml.org/lkml/2015/6/24/44).
>
> In that case, smp_send_stop() is called before entering kdump routines
> which assume other CPUs are still online.  As the result, kdump
> routines fail to save other CPUs' registers.  Additionally for MIPS
> OCTEON, it misses to stop the watchdog timer.
>
> To fix this problem, call a new kdump friendly function,
> crash_smp_send_stop(), instead of the smp_send_stop() when
> crash_kexec_post_notifiers is enabled.  crash_smp_send_stop() is a
> weak function, and it just call smp_send_stop().  Architecture
> codes should override it so that kdump can work appropriately.
> This patch provides MIPS version.
>
> Reported-by: Daniel Walker <dwalker@fifo99.com>
> Fixes: f06e5153f4ae (kernel/panic.c: add "crash_kexec_post_notifiers" option)
> Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: David Daney <david.daney@cavium.com>
> Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
> Cc: "Steven J. Hill" <steven.hill@cavium.com>
> Cc: Corey Minyard <cminyard@mvista.com>
>
> ---
> I'm not familiar with MIPS, and I don't have a test environment and
> just did build tests only.  Please don't apply this patch until
> someone does enough tests, otherwise simply drop this patch.
> ---
>   arch/mips/cavium-octeon/setup.c  |   14 ++++++++++++++
>   arch/mips/include/asm/kexec.h    |    1 +
>   arch/mips/kernel/crash.c         |   18 +++++++++++++++++-
>   arch/mips/kernel/machine_kexec.c |    1 +
>   4 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
> index cb16fcc..5537f95 100644
> --- a/arch/mips/cavium-octeon/setup.c
> +++ b/arch/mips/cavium-octeon/setup.c
> @@ -267,6 +267,17 @@ static void octeon_crash_shutdown(struct pt_regs *regs)
>   	default_machine_crash_shutdown(regs);
>   }
>   
> +#ifdef CONFIG_SMP
> +void octeon_crash_smp_send_stop(void)
> +{
> +	int cpu;
> +
> +	/* disable watchdogs */
> +	for_each_online_cpu(cpu)
> +		cvmx_write_csr(CVMX_CIU_WDOGX(cpu_logical_map(cpu)), 0);
> +}
> +#endif
> +
>   #endif /* CONFIG_KEXEC */
>   
>   #ifdef CONFIG_CAVIUM_RESERVE32
> @@ -911,6 +922,9 @@ void __init prom_init(void)
>   	_machine_kexec_shutdown = octeon_shutdown;
>   	_machine_crash_shutdown = octeon_crash_shutdown;
>   	_machine_kexec_prepare = octeon_kexec_prepare;
> +#ifdef CONFIG_SMP
> +	_crash_smp_send_stop = octeon_crash_smp_send_stop;
> +#endif
>   #endif
>   
>   	octeon_user_io_init();
> diff --git a/arch/mips/include/asm/kexec.h b/arch/mips/include/asm/kexec.h
> index ee25ebb..493a3cc 100644
> --- a/arch/mips/include/asm/kexec.h
> +++ b/arch/mips/include/asm/kexec.h
> @@ -45,6 +45,7 @@ extern const unsigned char kexec_smp_wait[];
>   extern unsigned long secondary_kexec_args[4];
>   extern void (*relocated_kexec_smp_wait) (void *);
>   extern atomic_t kexec_ready_to_reboot;
> +extern void (*_crash_smp_send_stop)(void);
>   #endif
>   #endif
>   
> diff --git a/arch/mips/kernel/crash.c b/arch/mips/kernel/crash.c
> index 610f0f3..1723b17 100644
> --- a/arch/mips/kernel/crash.c
> +++ b/arch/mips/kernel/crash.c
> @@ -47,9 +47,14 @@ static void crash_shutdown_secondary(void *passed_regs)
>   
>   static void crash_kexec_prepare_cpus(void)
>   {
> +	static int cpus_stopped;
>   	unsigned int msecs;
> +	unsigned int ncpus;
>   
> -	unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
> +	if (cpus_stopped)
> +		return;
> +
> +	ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
>   
>   	dump_send_ipi(crash_shutdown_secondary);
>   	smp_wmb();
> @@ -64,6 +69,17 @@ static void crash_kexec_prepare_cpus(void)
>   		cpu_relax();
>   		mdelay(1);
>   	}
> +
> +	cpus_stopped = 1;
> +}
> +
> +/* Override the weak function in kernel/panic.c */
> +void crash_smp_send_stop(void)
> +{
> +	if (_crash_smp_send_stop)
> +		_crash_smp_send_stop();
> +
> +	crash_kexec_prepare_cpus();
>   }
>   
>   #else /* !defined(CONFIG_SMP)  */
> diff --git a/arch/mips/kernel/machine_kexec.c b/arch/mips/kernel/machine_kexec.c
> index 50980bf3..5972520 100644
> --- a/arch/mips/kernel/machine_kexec.c
> +++ b/arch/mips/kernel/machine_kexec.c
> @@ -25,6 +25,7 @@ void (*_machine_crash_shutdown)(struct pt_regs *regs) = NULL;
>   #ifdef CONFIG_SMP
>   void (*relocated_kexec_smp_wait) (void *);
>   atomic_t kexec_ready_to_reboot = ATOMIC_INIT(0);
> +void (*_crash_smp_send_stop)(void) = NULL;
>   #endif
>   
>   int
>
>

  parent reply	other threads:[~2016-08-19  1:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10  8:09 [V4 PATCH 0/2] kexec: crash_kexec_post_notifiers boot option related fixes Hidehiro Kawai
2016-08-10  8:09 ` [V4 PATCH 1/2] x86/panic: Replace smp_send_stop() with kdump friendly version in panic path Hidehiro Kawai
2016-08-12  3:16   ` Dave Young
2016-08-15 11:22     ` 河合英宏 / KAWAI,HIDEHIRO
2016-09-20  7:40       ` Xunlei Pang
2016-09-20  8:53         ` 河合英宏 / KAWAI,HIDEHIRO
2016-09-20 11:22           ` 河合英宏 / KAWAI,HIDEHIRO
2016-09-22  1:53             ` 'Dave Young'
2016-08-10  8:09 ` [V4 PATCH 2/2] mips/panic: " Hidehiro Kawai
2016-08-12  3:17   ` Dave Young
2016-08-12 13:55     ` Corey Minyard
2016-08-15 11:35       ` 河合英宏 / KAWAI,HIDEHIRO
2016-08-15 17:06         ` Corey Minyard
2016-08-15 18:01           ` Corey Minyard
2016-08-16 10:29             ` 河合英宏 / KAWAI,HIDEHIRO
2016-08-18 21:18   ` Corey Minyard [this message]
2016-09-20 11:37     ` 河合英宏 / KAWAI,HIDEHIRO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bdfd7136-6b0e-3820-dbac-d72529a4f058@mvista.com \
    --to=cminyard@mvista.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=d.hatayama@jp.fujitsu.com \
    --cc=david.daney@cavium.com \
    --cc=dwalker@fifo99.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=mhiramat@kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=steven.hill@cavium.com \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xpang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).