summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2026-07-16 12:07:07 -0600
committerTom Rini <[email protected]>2026-07-16 16:11:24 -0600
commit96c308b8d2a6a1496c0a7366db9a7becf42d2454 (patch)
tree3b4f8fdff66ff6c54d04546d27d7ffd87cb3a229 /common
parent91303d8a663248e15bd76801778ff709e490d88d (diff)
parent9c1b13b3fd271500cd8a61f86816d822e4852a90 (diff)
Merge patch series "cyclic: update and optimization"main
Patrice Chotard <[email protected]> says: First patch is replacing uint64_t by u64 as suggested by b4 Second patch optimizes cyclic_run() to parse cyclic list only if a cyclic function's timestamp is elapsed. Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'common')
-rw-r--r--common/cyclic.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/common/cyclic.c b/common/cyclic.c
index ec952a01ee1..573e715587d 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -41,7 +41,7 @@ static bool cyclic_is_registered(const struct cyclic_info *cyclic)
}
void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func,
- uint64_t delay_us, const char *name)
+ u64 delay_us, const char *name)
{
cyclic_unregister(cyclic);
@@ -67,26 +67,28 @@ static void cyclic_run(void)
{
struct cyclic_info *cyclic;
struct hlist_node *tmp;
- uint64_t now, cpu_time;
+ u64 now, after, cpu_time;
/* 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) {
/*
* Check if this cyclic function needs to get called, e.g.
* do not call the cyclic func too often
*/
- now = get_timer_us(0);
if (time_after_eq64(now, cyclic->next_call)) {
/* Call cyclic function and account it's cpu-time */
cyclic->next_call = now + cyclic->delay_us;
cyclic->func(cyclic);
+ after = get_timer_us(0);
cyclic->run_cnt++;
- cpu_time = get_timer_us(0) - now;
+ cpu_time = after - now;
cyclic->cpu_time_us += cpu_time;
+ now = after;
/* Check if cpu-time exceeds max allowed time */
if ((cpu_time > CONFIG_CYCLIC_MAX_CPU_TIME_US) &&