diff options
| author | Tom Rini <[email protected]> | 2026-08-06 14:11:12 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-08-06 19:36:40 -0600 |
| commit | 482f9d63b504ba9d33dbfbd6610801d8386c9b13 (patch) | |
| tree | a0ea4cd16bbae06b70eda00753fb20f8246f7c39 | |
| parent | 8fac9697048dc01fe77c7511a9ce0b76cbd2715b (diff) | |
| parent | d9ce7ed30571ae01cdcb5fdfd2991e4a7be93c9f (diff) | |
Merge tag 'u-boot-watchdog-20260803' of https://git.u-boot-project.org/u-boot/custodians/u-boot-watchdog
CI: https://git.u-boot-project.org/u-boot/custodians/u-boot-watchdog/-/pipelines/867
u-boot-watchdog changes 2026-08-03:
- cyclic: get rid of cyclic_get_list() helper (Rasmus)
- cyclic: return early from cyclic_run() if the list is empty (Rasmus)
- watchdog: ast2600: add AST2700 support (Ryan)
| -rw-r--r-- | cmd/cyclic.c | 5 | ||||
| -rw-r--r-- | common/cyclic.c | 27 | ||||
| -rw-r--r-- | drivers/watchdog/Kconfig | 6 | ||||
| -rw-r--r-- | drivers/watchdog/ast2600_wdt.c | 1 | ||||
| -rw-r--r-- | include/cyclic.h | 9 |
5 files changed, 25 insertions, 23 deletions
diff --git a/cmd/cyclic.c b/cmd/cyclic.c index 339dd4a7bce..880cd648aae 100644 --- a/cmd/cyclic.c +++ b/cmd/cyclic.c @@ -16,6 +16,9 @@ #include <vsprintf.h> #include <linux/delay.h> #include <linux/kernel.h> +#include <asm/global_data.h> + +DECLARE_GLOBAL_DATA_PTR; struct cyclic_demo_info { struct cyclic_info cyclic; @@ -64,7 +67,7 @@ static int do_cyclic_list(struct cmd_tbl *cmdtp, int flag, int argc, struct hlist_node *tmp; u64 cnt, freq; - hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) { + hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic_list, list) { cnt = cyclic->run_cnt * 1000000ULL * 100ULL; freq = lldiv(cnt, timer_get_us() - cyclic->start_time_us); printf("function: %s, cpu-time: %lld us, frequency: %lld.%02d times/s\n", diff --git a/common/cyclic.c b/common/cyclic.c index 573e715587d..1cf5b25d1d8 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -22,17 +22,11 @@ DECLARE_GLOBAL_DATA_PTR; void hw_watchdog_reset(void); -struct hlist_head *cyclic_get_list(void) -{ - /* Silence "discards 'volatile' qualifier" warning. */ - return (struct hlist_head *)&gd->cyclic_list; -} - static bool cyclic_is_registered(const struct cyclic_info *cyclic) { const struct cyclic_info *c; - hlist_for_each_entry(c, cyclic_get_list(), list) { + hlist_for_each_entry(c, &gd->cyclic_list, list) { if (c == cyclic) return true; } @@ -52,7 +46,7 @@ void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, cyclic->name = name; cyclic->delay_us = delay_us; cyclic->start_time_us = get_timer_us(0); - hlist_add_head(&cyclic->list, cyclic_get_list()); + hlist_add_head(&cyclic->list, &gd->cyclic_list); } void cyclic_unregister(struct cyclic_info *cyclic) @@ -69,13 +63,26 @@ static void cyclic_run(void) struct hlist_node *tmp; u64 now, after, cpu_time; + /* + * Nothing to do if the list is empty. Also, schedule() can be + * called before timer infrastructure is ready, in which case + * calling get_timer_us() before the (empty) loop could cause + * a divide-by-0 or otherwise crash the system. No clients + * should be registered before the timer infrastructure is up, + * so the check for the list being empty should be + * ok. Otherwise, we would need a new GD_FLG_TIMERS_READY + * flag. + */ + if (hlist_empty(&gd->cyclic_list)) + return; + /* Prevent recursion */ if (gd->flags & GD_FLG_CYCLIC_RUNNING) return; gd->flags |= GD_FLG_CYCLIC_RUNNING; now = get_timer_us(0); - hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) { + hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic_list, list) { /* * Check if this cyclic function needs to get called, e.g. * do not call the cyclic func too often @@ -129,7 +136,7 @@ int cyclic_unregister_all(void) struct cyclic_info *cyclic; struct hlist_node *tmp; - hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) + hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic_list, list) cyclic_unregister(cyclic); return 0; diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index b91727e1265..3c56c541505 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -130,11 +130,11 @@ config WDT_ASPEED Second Boot. config WDT_AST2600 - bool "Aspeed AST2600 watchdog timer support" - depends on WDT && ASPEED_AST2600 + bool "Aspeed AST2600/AST2700 watchdog timer support" + depends on WDT && (ASPEED_AST2600 || ASPEED_AST2700) default y help - Select this to enable watchdog timer for Aspeed ast2500/ast2400 devices. + Select this to enable watchdog timer for Aspeed ast2600/ast2700 devices. The watchdog timer is stopped when initialized. It performs reset, either full SoC reset or CPU or just some peripherals, based on the flags. diff --git a/drivers/watchdog/ast2600_wdt.c b/drivers/watchdog/ast2600_wdt.c index 190490f3692..5eb9b4ba96f 100644 --- a/drivers/watchdog/ast2600_wdt.c +++ b/drivers/watchdog/ast2600_wdt.c @@ -87,6 +87,7 @@ static const struct wdt_ops ast2600_wdt_ops = { static const struct udevice_id ast2600_wdt_ids[] = { { .compatible = "aspeed,ast2600-wdt" }, + { .compatible = "aspeed,ast2700-wdt" }, { } }; diff --git a/include/cyclic.h b/include/cyclic.h index df8b725e3d0..ec2c53b6ecf 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -78,15 +78,6 @@ void cyclic_unregister(struct cyclic_info *cyclic); */ int cyclic_unregister_all(void); -/** - * cyclic_get_list() - Get cyclic list pointer - * - * Return the cyclic list pointer - * - * @return: pointer to cyclic_list - */ -struct hlist_head *cyclic_get_list(void); - #else static inline void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, |
