]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cyclic: Don't disable cylic function upon exceeding CPU time
authorStefan Roese <sr@denx.de>
Mon, 17 Oct 2022 07:00:58 +0000 (09:00 +0200)
committerStefan Roese <sr@denx.de>
Mon, 24 Oct 2022 09:10:21 +0000 (11:10 +0200)
With the migration of the watchdog infrastructure to cyclic functions
it's been noticed, that at least one watchdog driver is broken now. As
the execution time of it's watchdog reset function is quite long.

In general it's not really necessary (right now) to disable the cyclic
function upon exceeding CPU time usage. So instead of disabling the
cylic function in this case, let's just print a warning once to show
this potential problem to the user.

Signed-off-by: Stefan Roese <sr@denx.de>
Suggested-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Tom Rini <trini@konsulko.com>
Cc: Pali Rohár <pali@kernel.org>
common/cyclic.c
include/cyclic.h

index b3c180bd1a62c14835f7e81d266f296ae98399fa..7abb82c16a909841339282d572261452864d875a 100644 (file)
@@ -85,13 +85,17 @@ 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;
                        }
                }
        }
index 760163643345cd6869d31bf66ad81f78a320a059..9c5c4fcc54681680540487ba0b7af9fde66405e9 100644 (file)
@@ -39,6 +39,7 @@ struct cyclic_drv {
  * @run_cnt: Counter of executions occurances
  * @next_call: Next time in us, when the function shall be executed again
  * @list: List node
+ * @already_warned: Flag that we've warned about exceeding CPU time usage
  */
 struct cyclic_info {
        void (*func)(void *ctx);
@@ -50,6 +51,7 @@ struct cyclic_info {
        uint64_t run_cnt;
        uint64_t next_call;
        struct list_head list;
+       bool already_warned;
 };
 
 /** Function type for cyclic functions */