linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Robin Gong <yibin.gong@nxp.com>
To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org,
	s.hauer@pengutronix.de, festevam@gmail.com
Cc: linux-imx@nxp.com, kernel@pengutronix.de,
	linux-watchdog@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v1] watchdog: imx2_wdt: clear WDOG_HW_RUNNING before suspend
Date: Tue, 11 May 2021 19:20:32 +0800	[thread overview]
Message-ID: <1620732032-7675-1-git-send-email-yibin.gong@nxp.com> (raw)

Since watchdog_ping_work is not freezable so that it maybe scheduled before
imx2_wdt_resume where watchdog clock enabled, hence, kernel will hang in
imx2_wdt_ping without clock, and then watchdog reset happen. Prevent the
above case by clearing WDOG_HW_RUNNING before suspend, and restore it with
ping in imx2_wdt_resume.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
---
 drivers/watchdog/imx2_wdt.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index b84f80f..d3751e9 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -357,6 +357,13 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev)
 		 */
 		__imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME);
 		imx2_wdt_ping(wdog);
+
+		/*
+		 * clear WDOG_HW_RUNNING to prevent watchdog_ping_work running
+		 * before imx2_wdt_resume where clock enabled, otherwise kernel
+		 * will hang and watchdog reset happen then.
+		 */
+		clear_bit(WDOG_HW_RUNNING, &wdog->status);
 	}
 
 	clk_disable_unprepare(wdev->clk);
@@ -386,6 +393,7 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev)
 	if (imx2_wdt_is_running(wdev)) {
 		imx2_wdt_set_timeout(wdog, wdog->timeout);
 		imx2_wdt_ping(wdog);
+		set_bit(WDOG_HW_RUNNING, &wdog->status);
 	}
 
 	return 0;
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2021-05-11 10:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 11:20 Robin Gong [this message]
2021-05-11  3:59 ` [PATCH v1] watchdog: imx2_wdt: clear WDOG_HW_RUNNING before suspend Guenter Roeck
2021-05-12 11:34   ` Robin Gong
2021-05-12 14:14     ` Guenter Roeck
2021-05-13  3:49       ` Robin Gong

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=1620732032-7675-1-git-send-email-yibin.gong@nxp.com \
    --to=yibin.gong@nxp.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=wim@linux-watchdog.org \
    /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).