Skip to content

Commit cae5851

Browse files
jmentiWim Van Sebroeck
authored andcommitted
watchdog: rti_wdt: Set min_hw_heartbeat_ms to accommodate a safety margin
On AM62x, the watchdog is pet before the valid window is open. Fix min_hw_heartbeat and accommodate a 2% + static offset safety margin. The static offset accounts for max hardware error. Remove the hack in the driver which shifts the open window boundary, since it is no longer necessary due to the fix mentioned above. cc: [email protected] Fixes: 5527483 ("watchdog: rti-wdt: attach to running watchdog during probe") Signed-off-by: Judith Mendez <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 52df67b commit cae5851

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

drivers/watchdog/rti_wdt.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
#define PON_REASON_EOF_NUM 0xCCCCBBBB
6060
#define RESERVED_MEM_MIN_SIZE 12
6161

62+
#define MAX_HW_ERROR 250
63+
6264
static int heartbeat = DEFAULT_HEARTBEAT;
6365

6466
/*
@@ -97,7 +99,7 @@ static int rti_wdt_start(struct watchdog_device *wdd)
9799
* to be 50% or less than that; we obviouly want to configure the open
98100
* window as large as possible so we select the 50% option.
99101
*/
100-
wdd->min_hw_heartbeat_ms = 500 * wdd->timeout;
102+
wdd->min_hw_heartbeat_ms = 520 * wdd->timeout + MAX_HW_ERROR;
101103

102104
/* Generate NMI when wdt expires */
103105
writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL);
@@ -131,31 +133,33 @@ static int rti_wdt_setup_hw_hb(struct watchdog_device *wdd, u32 wsize)
131133
* be petted during the open window; not too early or not too late.
132134
* The HW configuration options only allow for the open window size
133135
* to be 50% or less than that.
136+
* To avoid any glitches, we accommodate 2% + max hardware error
137+
* safety margin.
134138
*/
135139
switch (wsize) {
136140
case RTIWWDSIZE_50P:
137-
/* 50% open window => 50% min heartbeat */
138-
wdd->min_hw_heartbeat_ms = 500 * heartbeat;
141+
/* 50% open window => 52% min heartbeat */
142+
wdd->min_hw_heartbeat_ms = 520 * heartbeat + MAX_HW_ERROR;
139143
break;
140144

141145
case RTIWWDSIZE_25P:
142-
/* 25% open window => 75% min heartbeat */
143-
wdd->min_hw_heartbeat_ms = 750 * heartbeat;
146+
/* 25% open window => 77% min heartbeat */
147+
wdd->min_hw_heartbeat_ms = 770 * heartbeat + MAX_HW_ERROR;
144148
break;
145149

146150
case RTIWWDSIZE_12P5:
147-
/* 12.5% open window => 87.5% min heartbeat */
148-
wdd->min_hw_heartbeat_ms = 875 * heartbeat;
151+
/* 12.5% open window => 89.5% min heartbeat */
152+
wdd->min_hw_heartbeat_ms = 895 * heartbeat + MAX_HW_ERROR;
149153
break;
150154

151155
case RTIWWDSIZE_6P25:
152-
/* 6.5% open window => 93.5% min heartbeat */
153-
wdd->min_hw_heartbeat_ms = 935 * heartbeat;
156+
/* 6.5% open window => 95.5% min heartbeat */
157+
wdd->min_hw_heartbeat_ms = 955 * heartbeat + MAX_HW_ERROR;
154158
break;
155159

156160
case RTIWWDSIZE_3P125:
157-
/* 3.125% open window => 96.9% min heartbeat */
158-
wdd->min_hw_heartbeat_ms = 969 * heartbeat;
161+
/* 3.125% open window => 98.9% min heartbeat */
162+
wdd->min_hw_heartbeat_ms = 989 * heartbeat + MAX_HW_ERROR;
159163
break;
160164

161165
default:
@@ -233,14 +237,6 @@ static int rti_wdt_probe(struct platform_device *pdev)
233237
return -EINVAL;
234238
}
235239

236-
/*
237-
* If watchdog is running at 32k clock, it is not accurate.
238-
* Adjust frequency down in this case so that we don't pet
239-
* the watchdog too often.
240-
*/
241-
if (wdt->freq < 32768)
242-
wdt->freq = wdt->freq * 9 / 10;
243-
244240
pm_runtime_enable(dev);
245241
ret = pm_runtime_resume_and_get(dev);
246242
if (ret < 0) {

0 commit comments

Comments
 (0)