Skip to content

Commit

Permalink
watchdog: sp805: Flush posted writes in enable/disable.
Browse files Browse the repository at this point in the history
There are no reads in these functions, so if MMIO writes are posted,
the writes in enable/disable may not have completed by the time these
functions return.  If the functions run from different CPUs, it's
in theory possible for the writes to be interleaved, which would be
disastrous for this driver.

At the very least, we need an mmiowb() before releasing the lock, but
since it seems desirable for the watchdog timer to be actually stopped
or reset when these functions return, read the lock register to force
the writes out.

Signed-off-by: Nick Bowler <nbowler@elliptictech.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Nick Bowler authored and Wim Van Sebroeck committed Jul 26, 2011
1 parent da3e515 commit 081d83a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/watchdog/sp805_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ static void wdt_enable(void)
writel(INT_ENABLE | RESET_ENABLE, wdt->base + WDTCONTROL);
writel(LOCK, wdt->base + WDTLOCK);

/* Flush posted writes. */
readl(wdt->base + WDTLOCK);
spin_unlock(&wdt->lock);
}

Expand All @@ -146,6 +148,8 @@ static void wdt_disable(void)
writel(0, wdt->base + WDTCONTROL);
writel(LOCK, wdt->base + WDTLOCK);

/* Flush posted writes. */
readl(wdt->base + WDTLOCK);
spin_unlock(&wdt->lock);
}

Expand Down

0 comments on commit 081d83a

Please sign in to comment.