Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] watchdog: sbsa_gwdt: disable watchdog when system panic was trigged by signal WS0
@ 2020-03-02  8:46 luanshi
  2020-03-02 14:19 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: luanshi @ 2020-03-02  8:46 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck; +Cc: linux-watchdog, linux-kernel, luanshi

When ARM SBSA Generic Watchdog worked in the two stages mode by setting
module parameter action to 1, when the timeout is reached, the first
signal (WS0) will trigger panic. Before panic, the value of register
SBSA_GWDT_WCS was 0x0, after panic and system startup, the value of
register SBSA_GWDT_WCS was 0x7, status bits SBSA_GWDT_WCS_EN
SBSA_GWDT_WCS_WS0 and SBSA_GWDT_WCS_WS1 were set, this will increase the
refcnt of module sbsa_gwdt by function watchdog_cdev_register because
flag WDOG_HW_RUNNING was set, so we cannot unload the module again. To be
consistent with reboot, watchdog should be disabled when system panic was
trigged by signal(WS0).

Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
---
 drivers/watchdog/sbsa_gwdt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
index f0f1e3b..6bee5bb 100644
--- a/drivers/watchdog/sbsa_gwdt.c
+++ b/drivers/watchdog/sbsa_gwdt.c
@@ -194,6 +194,12 @@ static int sbsa_gwdt_stop(struct watchdog_device *wdd)
 
 static irqreturn_t sbsa_gwdt_interrupt(int irq, void *dev_id)
 {
+	struct sbsa_gwdt *gwdt = (struct sbsa_gwdt *)dev_id;
+	struct watchdog_device *wdd = &gwdt->wdd;
+
+	if (wdd->ops->stop)
+		wdd->ops->stop(wdd);
+
 	panic(WATCHDOG_NAME " timeout");
 
 	return IRQ_HANDLED;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog: sbsa_gwdt: disable watchdog when system panic was trigged by signal WS0
  2020-03-02  8:46 [PATCH] watchdog: sbsa_gwdt: disable watchdog when system panic was trigged by signal WS0 luanshi
@ 2020-03-02 14:19 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-03-02 14:19 UTC (permalink / raw)
  To: luanshi, Wim Van Sebroeck; +Cc: linux-watchdog, linux-kernel

On 3/2/20 12:46 AM, luanshi wrote:
> When ARM SBSA Generic Watchdog worked in the two stages mode by setting
> module parameter action to 1, when the timeout is reached, the first
> signal (WS0) will trigger panic. Before panic, the value of register
> SBSA_GWDT_WCS was 0x0, after panic and system startup, the value of
> register SBSA_GWDT_WCS was 0x7, status bits SBSA_GWDT_WCS_EN
> SBSA_GWDT_WCS_WS0 and SBSA_GWDT_WCS_WS1 were set, this will increase the
> refcnt of module sbsa_gwdt by function watchdog_cdev_register because
> flag WDOG_HW_RUNNING was set, so we cannot unload the module again. To be
> consistent with reboot, watchdog should be disabled when system panic was
> trigged by signal(WS0).
> 
> Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
> ---
>  drivers/watchdog/sbsa_gwdt.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
> index f0f1e3b..6bee5bb 100644
> --- a/drivers/watchdog/sbsa_gwdt.c
> +++ b/drivers/watchdog/sbsa_gwdt.c
> @@ -194,6 +194,12 @@ static int sbsa_gwdt_stop(struct watchdog_device *wdd)
>  
>  static irqreturn_t sbsa_gwdt_interrupt(int irq, void *dev_id)
>  {
> +	struct sbsa_gwdt *gwdt = (struct sbsa_gwdt *)dev_id;
> +	struct watchdog_device *wdd = &gwdt->wdd;
> +
> +	if (wdd->ops->stop)
> +		wdd->ops->stop(wdd);
> +
>  	panic(WATCHDOG_NAME " timeout");
>  
>  	return IRQ_HANDLED;
> 

This prevents the 2nd stage (the actual system reset) from working if the panic
call gets stuck and doesn't result in a reboot. I don't think it is a good idea
to do that. It effectively disables the second stage.

Ultimately, this is a bios problem; the bios/rommon should have stopped
the watchdog when rebooting. If you don't want the watchdog to run on startup,
you have to add a module parameter to disable the watchdog if it is running
at probe time.

Guenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02  8:46 [PATCH] watchdog: sbsa_gwdt: disable watchdog when system panic was trigged by signal WS0 luanshi
2020-03-02 14:19 ` Guenter Roeck

Linux-Watchdog Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-watchdog/0 linux-watchdog/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-watchdog linux-watchdog/ https://lore.kernel.org/linux-watchdog \
		linux-watchdog@vger.kernel.org
	public-inbox-index linux-watchdog

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-watchdog


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git