spl: Add a separate silence option for SPL
[platform/kernel/u-boot.git] / common / cyclic.c
index cd5dcb1..7abb82c 100644 (file)
@@ -18,6 +18,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void hw_watchdog_reset(void);
+
 struct list_head *cyclic_get_list(void)
 {
        return &gd->cyclic->cyclic_list;
@@ -83,19 +85,37 @@ void cyclic_run(void)
                        cyclic->cpu_time_us += cpu_time;
 
                        /* Check if cpu-time exceeds max allowed time */
-                       if (cpu_time > CONFIG_CYCLIC_MAX_CPU_TIME_US) {
-                               pr_err("cyclic function %s took too long: %lldus vs %dus max, disabling\n",
+                       if ((cpu_time > CONFIG_CYCLIC_MAX_CPU_TIME_US) &&
+                           (!cyclic->already_warned)) {
+                               pr_err("cyclic function %s took too long: %lldus vs %dus max\n",
                                       cyclic->name, cpu_time,
                                       CONFIG_CYCLIC_MAX_CPU_TIME_US);
 
-                               /* Unregister this cyclic function */
-                               cyclic_unregister(cyclic);
+                               /*
+                                * Don't disable this function, just warn once
+                                * about this exceeding CPU time usage
+                                */
+                               cyclic->already_warned = true;
                        }
                }
        }
        gd->cyclic->cyclic_running = false;
 }
 
+void schedule(void)
+{
+       /* The HW watchdog is not integrated into the cyclic IF (yet) */
+       if (IS_ENABLED(CONFIG_HW_WATCHDOG))
+               hw_watchdog_reset();
+
+       /*
+        * schedule() might get called very early before the cyclic IF is
+        * ready. Make sure to only call cyclic_run() when it's initalized.
+        */
+       if (gd && gd->cyclic && gd->cyclic->cyclic_ready)
+               cyclic_run();
+}
+
 int cyclic_uninit(void)
 {
        struct cyclic_info *cyclic, *tmp;