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 4EC2EC6FA86 for ; Sat, 17 Sep 2022 08:15:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3850A84BF2; Sat, 17 Sep 2022 10:15:16 +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=1663402516; bh=+nesXryrDc0PjqgClG6pisVmVCF+4iuf8RlfG8qkYLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MIt8rzt3xTNFeSRun69blqzbcaBXwWyiW7URrVuXJFzIynVROSAkeERBD0THZxPmz Hv9pg1qnpscypVOrL0kwdqapqhuHRsyLsrZQhgR1FsRg+BPGuwuVnH9t3Fn37NMfc4 XC6nz5/5VLnP9bXSdIiFn6OQcJAMIM1cINBtBR2gKJwYDc3xjt1jo41RkNO3Neqqph rXMAC974+XaGZeOagq2Oarl8QjyJmUdzo3OVACTi1iFQULxJbBTzydzN9aTpQl+Acc A1YGbQF8kbzo/FeNCcv5GgTAl4H4ZFfgUWpZ7tEro/8uy8l5Hsqf3AGACsFwFrgKqV f0mUa3a8BjWGQ== Received: by phobos.denx.de (Postfix, from userid 109) id 3449084B5A; Sat, 17 Sep 2022 10:14:58 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:101:465::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 6B72484B5A for ; Sat, 17 Sep 2022 10:14:54 +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 smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (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 4MV3dS45cFz9sSf; Sat, 17 Sep 2022 10:14:52 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, rasmus.villemoes@prevas.dk Subject: [PATCH v2 2/6] cyclic: Introduce schedule() function Date: Sat, 17 Sep 2022 10:14:46 +0200 Message-Id: <20220917081450.21549-3-sr@denx.de> In-Reply-To: <20220917081450.21549-1-sr@denx.de> References: <20220917081450.21549-1-sr@denx.de> MIME-Version: 1.0 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 This patch introduces a schedule() function, which shall be used instead of the old WATCHDOG_RESET. Follow-up patches will make sure, that this new function is used. Signed-off-by: Stefan Roese Reviewed-by: Simon Glass --- v2: - Add some checks in schedule(), that the cyclic IF is ready before calling into it. This fixes booting on some AM335x platforms. v1: - Add Simon's RB tag - Add more comments in the header to fully document the prototypes common/cyclic.c | 16 ++++++++++++++++ include/cyclic.h | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/common/cyclic.c b/common/cyclic.c index cd5dcb1f2b94..b3c180bd1a62 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -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; @@ -96,6 +98,20 @@ void cyclic_run(void) 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; diff --git a/include/cyclic.h b/include/cyclic.h index 23902234cc87..760163643345 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -106,6 +106,14 @@ struct list_head *cyclic_get_list(void); * needs to be executed, then call into these registered functions. */ void cyclic_run(void); + +/** + * schedule() - Schedule all potentially waiting tasks + * + * Basically a wrapper for cyclic_run(), pontentially enhanced by some + * other parts, that need to get handled periodically. + */ +void schedule(void); #else static inline struct cyclic_info *cyclic_register(cyclic_func_t func, uint64_t delay_us, @@ -124,6 +132,10 @@ static inline void cyclic_run(void) { } +static inline void schedule(void) +{ +} + static inline int cyclic_init(void) { return 0; -- 2.37.3