diff --git a/common/startup.c b/common/startup.c index 71a28a7..2fed4b7 100644 --- a/common/startup.c +++ b/common/startup.c @@ -43,6 +43,7 @@ #include #include #include +#include extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[], __barebox_initcalls_end[]; @@ -356,6 +357,9 @@ if (autoboot == AUTOBOOT_MENU) run_command(MENUFILE); + if (autoboot == AUTOBOOT_ABORT && autoboot == global_autoboot_state) + watchdog_inhibit_all(); + run_shell(); run_command(MENUFILE); diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c index a17234f..ab1dcaa 100644 --- a/drivers/watchdog/wd_core.c +++ b/drivers/watchdog/wd_core.c @@ -45,6 +45,9 @@ if (timeout > wd->timeout_max) return -EINVAL; + if (watchdog_hw_running(wd) == false) + return 0; + pr_debug("setting timeout on %s to %ds\n", watchdog_name(wd), timeout); ret = wd->set_timeout(wd, timeout); @@ -273,3 +276,30 @@ return NULL; } EXPORT_SYMBOL(watchdog_get_by_name); + +int watchdog_inhibit_all(void) +{ + struct watchdog *wd; + int ret = 0; + + list_for_each_entry(wd, &watchdog_list, list) { + int err; + if (!wd->priority || watchdog_hw_running(wd) == false) + continue; + + err = watchdog_set_timeout(wd, 0); + if (!err) + continue; + + if (err != -ENOSYS || !IS_ENABLED(CONFIG_WATCHDOG_POLLER)) { + ret = err; + continue; + } + + wd->poller_enable = true; + watchdog_poller_start(wd); + } + + return ret; +} +EXPORT_SYMBOL(watchdog_inhibit_all); diff --git a/include/watchdog.h b/include/watchdog.h index 419c1cd..81414ef 100644 --- a/include/watchdog.h +++ b/include/watchdog.h @@ -45,6 +45,7 @@ struct watchdog *watchdog_get_default(void); struct watchdog *watchdog_get_by_name(const char *name); int watchdog_set_timeout(struct watchdog*, unsigned); +int watchdog_inhibit_all(void); #else static inline int watchdog_register(struct watchdog *w) { @@ -70,6 +71,11 @@ { return 0; } + +static inline int watchdog_inhibit_all(void) +{ + return -ENOSYS; +} #endif #define WATCHDOG_DEFAULT_PRIORITY 100