mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
watchdog: msc313e: Fix premature reset during timeout update
Updating the 32-bit hardware timeout requires writing to two 16-bit
registers sequentially. If the watchdog is actively running, this
non-atomic update might trigger a premature system reset.
Clear the watchdog counter before updating the registers to prevent the
timer from timing out prematurely against an intermediate threshold.
Fixes: e9800b7994 ("watchdog: Add Mstar MSC313e WDT driver")
Cc: stable@vger.kernel.org
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260913065126.8350-1-tzungbi@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
1d9763f34a
commit
22737cfced
|
|
@ -46,6 +46,9 @@ static void msc313e_wdt_set_hw_timeout(struct msc313e_wdt_priv *priv,
|
|||
{
|
||||
u32 t = timeout * clk_get_rate(priv->clk);
|
||||
|
||||
/* Clear before to prevent premature reset during non-atomic updates. */
|
||||
writew(1, priv->base + REG_WDT_CLR);
|
||||
|
||||
writew(t & 0xffff, priv->base + REG_WDT_MAX_PRD_L);
|
||||
writew((t >> 16) & 0xffff, priv->base + REG_WDT_MAX_PRD_H);
|
||||
writew(1, priv->base + REG_WDT_CLR);
|
||||
|
|
@ -76,6 +79,9 @@ static int msc313e_wdt_stop(struct watchdog_device *wdev)
|
|||
{
|
||||
struct msc313e_wdt_priv *priv = watchdog_get_drvdata(wdev);
|
||||
|
||||
/* Clear before to prevent premature reset during non-atomic updates. */
|
||||
writew(1, priv->base + REG_WDT_CLR);
|
||||
|
||||
writew(0, priv->base + REG_WDT_MAX_PRD_L);
|
||||
writew(0, priv->base + REG_WDT_MAX_PRD_H);
|
||||
writew(0, priv->base + REG_WDT_CLR);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user