Skip to content

Commit cc0df5e

Browse files
AntonioBorneoWim Van Sebroeck
authored andcommitted
watchdog: arm_smc_wdt: get wdt status through SMCWD_GET_TIMELEFT
The optional SMCWD_GET_TIMELEFT command can be used to detect if the watchdog has already been started. See the implementation in OP-TEE secure OS [1]. At probe time, check if the watchdog is already started and then set WDOG_HW_RUNNING in the watchdog status. This will cause the watchdog framework to ping the watchdog until a userspace watchdog daemon takes over the control. Link: OP-TEE/optee_os@a7f2d4bd8632 [1] Signed-off-by: Antonio Borneo <[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 27a46a0 commit cc0df5e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/watchdog/arm_smc_wdt.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ static int smcwd_call(struct watchdog_device *wdd, enum smcwd_call call,
4646
return -ENODEV;
4747
if (res->a0 == PSCI_RET_INVALID_PARAMS)
4848
return -EINVAL;
49+
if (res->a0 == PSCI_RET_DISABLED)
50+
return -ENODATA;
4951
if (res->a0 != PSCI_RET_SUCCESS)
5052
return -EIO;
5153
return 0;
@@ -131,10 +133,19 @@ static int smcwd_probe(struct platform_device *pdev)
131133

132134
wdd->info = &smcwd_info;
133135
/* get_timeleft is optional */
134-
if (smcwd_call(wdd, SMCWD_GET_TIMELEFT, 0, NULL))
135-
wdd->ops = &smcwd_ops;
136-
else
136+
err = smcwd_call(wdd, SMCWD_GET_TIMELEFT, 0, NULL);
137+
switch (err) {
138+
case 0:
139+
set_bit(WDOG_HW_RUNNING, &wdd->status);
140+
fallthrough;
141+
case -ENODATA:
137142
wdd->ops = &smcwd_timeleft_ops;
143+
break;
144+
default:
145+
wdd->ops = &smcwd_ops;
146+
break;
147+
}
148+
138149
wdd->timeout = res.a2;
139150
wdd->max_timeout = res.a2;
140151
wdd->min_timeout = res.a1;

0 commit comments

Comments
 (0)