From: Nick Bowler Date: Fri, 15 Jul 2011 15:04:02 +0000 (-0400) Subject: watchdog: sp805: Flush posted writes in enable/disable. X-Git-Tag: next-20110726~18^2~14 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=55e30c3a90abe9a022ea064c00aea06fd42aa152;p=karo-tx-linux.git watchdog: sp805: Flush posted writes in enable/disable. 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 Signed-off-by: Wim Van Sebroeck --- diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index c1e099aa57f3..cc2cfbe33b30 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -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); } @@ -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); }