All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
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	[thread overview]
Message-ID: <20220917081450.21549-3-sr@denx.de> (raw)
In-Reply-To: <20220917081450.21549-1-sr@denx.de>

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 <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
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


  parent reply	other threads:[~2022-09-17  8:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-17  8:14 [PATCH v2 0/6] Migrate watchdog reset to cyclic infrastructure Stefan Roese
2022-09-17  8:14 ` [PATCH v2 1/6] watchdog: Integrate watchdog triggering into the cyclic framework Stefan Roese
2022-09-17  8:14 ` Stefan Roese [this message]
2022-09-17  8:14 ` [PATCH v2 3/6] cyclic: Use schedule() instead of WATCHDOG_RESET() Stefan Roese
2022-09-17  8:14 ` [PATCH v2 4/6] watchdog: Get rid of ASSEMBLY hacks Stefan Roese
2022-09-17  8:14 ` [PATCH v2 5/6] watchdog: Remove WATCHDOG_RESET macro Stefan Roese
2022-09-17  8:14 ` [PATCH v2 6/6] watchdog: Further cleanup Stefan Roese
2022-09-17 14:08 ` [PATCH v2 0/6] Migrate watchdog reset to cyclic infrastructure Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220917081450.21549-3-sr@denx.de \
    --to=sr@denx.de \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.