From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DDABC433FE for ; Mon, 17 Oct 2022 07:01:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7FB9D84F69; Mon, 17 Oct 2022 09:01:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1665990074; bh=INy7Purqk5J637SQTrnoBcLQntCbq+BcooRRn8DQEoE=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=R3JmOJaiMTvKQCHhZXN8fcZVRrhxi+ppix+r+P6yQugTtEhtRr2f6UNDraxa9YYVH 5pa8DI6KbADznjiFI8NERuKGU5gKdG+tuDgx/COaDfDIVbQY7UiIBWkscN/sAb/gOu U0ElvtvVPEedySP7UK0y3c8RiAfgQTyvc/giKgsRzvz0Xt5ctcwPVBpshw5/pcH6VX g996JUbFN/GDpnjG1WTMadN3l7SaejXAHs5jJ4rJoRoSY9ZZM2sGVvldKktRFnjJtt Gl0bZXpzOak1iA2RzVwyUklwVSTaQreISotnjVFrU/zH+PEqhuP9yNFuPmWkOJ7nvR J04mw3v9pLn/A== Received: by phobos.denx.de (Postfix, from userid 109) id A34BE84F6B; Mon, 17 Oct 2022 09:01:11 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [80.241.59.204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 021B084F51 for ; Mon, 17 Oct 2022 09:01:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4MrSZM3Vsyz9sQj; Mon, 17 Oct 2022 09:00:59 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: Rasmus Villemoes , Tom Rini , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH] cyclic: Don't disable cylic function upon exceeding CPU time Date: Mon, 17 Oct 2022 09:00:58 +0200 Message-Id: <20221017070058.1794734-1-sr@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 Suggested-by: Rasmus Villemoes Cc: Rasmus Villemoes Cc: Tom Rini Cc: Pali Rohár --- common/cyclic.c | 12 ++++++++---- include/cyclic.h | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/cyclic.c b/common/cyclic.c index b3c180bd1a62..7abb82c16a90 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -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; } } } diff --git a/include/cyclic.h b/include/cyclic.h index 760163643345..9c5c4fcc5468 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -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 */ -- 2.38.0