Root/target/linux/generic/patches-3.1/992-mpcore_wdt_fix_watchdog_counter_loading.patch

1Although the commit "98af057092f8f0dabe63c5df08adc2bbfbddb1d2
2 ARM: 6126/1: ARM mpcore_wdt: fix build failure and other fixes"
3resolved long standing mpcore_wdt driver build problems, it
4introduced an error in the relationship between the MPcore watchdog
5timer clock rate and mpcore_margin, "MPcore timer margin in seconds",
6such that watchdog timeouts are now arbitrary rather than the number
7of seconds specified by mpcore_margin.
8
9This change restores mpcore_wdt_keepalive() to its equivalent
10implementation prior to commit 98af057 such that watchdog timeouts now
11occur as specified by mpcore_margin.
12
13The variable 'mpcore_timer_rate' which caused that build failure was
14replaced by 'twd_timer_rate'. Adding exported function to obtain
15'twd_timer_rate' value in mpcore_wdt driver.
16
17MPCORE_WATCHDOG needed to build 'mpcore_wdt' already depends on
18HAVE_ARM_TWD needed to build 'smp_twd', so from the point of view of
19'mpcore_wdt' driver the exported function will always exist.
20
21Signed-off-by: Valentine Barshak <vbarshak@mvista.com>
22Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
23---
24
25 arch/arm/include/asm/smp_twd.h | 1 +
26 arch/arm/kernel/smp_twd.c | 7 +++++++
27 drivers/watchdog/mpcore_wdt.c | 4 +---
28 3 files changed, 9 insertions(+), 3 deletions(-)
29
30--- a/arch/arm/include/asm/smp_twd.h
31+++ b/arch/arm/include/asm/smp_twd.h
32@@ -24,5 +24,6 @@ extern void __iomem *twd_base;
33 
34 int twd_timer_ack(void);
35 void twd_timer_setup(struct clock_event_device *);
36+unsigned long twd_timer_get_rate(void);
37 
38 #endif
39--- a/arch/arm/kernel/smp_twd.c
40+++ b/arch/arm/kernel/smp_twd.c
41@@ -142,3 +142,10 @@ void __cpuinit twd_timer_setup(struct cl
42 
43     clockevents_register_device(clk);
44 }
45+
46+/* Needed by mpcore_wdt */
47+unsigned long twd_timer_get_rate(void)
48+{
49+ return twd_timer_rate;
50+}
51+EXPORT_SYMBOL_GPL(twd_timer_get_rate);
52--- a/drivers/watchdog/mpcore_wdt.c
53+++ b/drivers/watchdog/mpcore_wdt.c
54@@ -99,9 +99,7 @@ static void mpcore_wdt_keepalive(struct
55 
56     spin_lock(&wdt_lock);
57     /* Assume prescale is set to 256 */
58- count = __raw_readl(wdt->base + TWD_WDOG_COUNTER);
59- count = (0xFFFFFFFFU - count) * (HZ / 5);
60- count = (count / 256) * mpcore_margin;
61+ count = (twd_timer_get_rate() / 256) * mpcore_margin;
62 
63     /* Reload the counter */
64     writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);
65

Archive Download this file



interactive