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)
This commit is contained in:
Tom Rini
2026-08-06 19:36:40 -06:00
5 changed files with 25 additions and 23 deletions
+4 -1
View File
@@ -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",
+17 -10
View File
@@ -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;
+3 -3
View File
@@ -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.
+1
View File
@@ -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" },
{ }
};
-9
View File
@@ -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,