mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Peter Mamonov <pmamonov@gmail.com>,
	Peter Korsgaard <peter@korsgaard.com>,
	Sascha Hauer <sha@pengutronix.de>
Subject: [PATCH v3 12/16] common: poller: replace explicit calls to poller_call() with resched()
Date: Wed, 10 Mar 2021 09:47:56 +0100	[thread overview]
Message-ID: <20210310084800.3584-13-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20210310084800.3584-1-a.fatoum@pengutronix.de>

From: Ahmad Fatoum <ahmad@a3f.at>

We won't replace pollers with bthreads completely over night. To make
migration easier, replace explicit calls to poller_call with a new
resched() function. This can be made to call bthread_reschedule() in
future and eventually replaced with bthread_reschedule() once pollers
are removed.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 common/clock.c   |  4 ++--
 common/console.c |  4 ++--
 include/sched.h  | 12 ++++++++++++
 lib/readline.c   |  4 ++--
 4 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 include/sched.h

diff --git a/common/clock.c b/common/clock.c
index 7eeba88317ac..fa90d1a4576f 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -13,7 +13,7 @@
 #include <init.h>
 #include <linux/math64.h>
 #include <clock.h>
-#include <poller.h>
+#include <sched.h>
 
 static uint64_t time_ns;
 
@@ -172,7 +172,7 @@ int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
 	int ret = is_timeout_non_interruptible(start_ns, time_offset_ns);
 
 	if (time_offset_ns >= 100 * USECOND)
-		poller_call();
+		resched();
 
 	return ret;
 }
diff --git a/common/console.c b/common/console.c
index 306149c99ea1..a436c37aa3e8 100644
--- a/common/console.c
+++ b/common/console.c
@@ -17,7 +17,7 @@
 #include <clock.h>
 #include <kfifo.h>
 #include <module.h>
-#include <poller.h>
+#include <sched.h>
 #include <ratp_bb.h>
 #include <magicvar.h>
 #include <globalvar.h>
@@ -585,7 +585,7 @@ int ctrlc(void)
 	if (ctrlc_abort)
 		return 1;
 
-	poller_call();
+	resched();
 
 #ifdef ARCH_HAS_CTRLC
 	ret = arch_ctrlc();
diff --git a/include/sched.h b/include/sched.h
new file mode 100644
index 000000000000..43d239c3ef63
--- /dev/null
+++ b/include/sched.h
@@ -0,0 +1,12 @@
+/* SPDX License Identifier: GPL-2.0 */
+#ifndef __BAREBOX_SCHED_H_
+#define __BAREBOX_SCHED_H_
+
+#include <poller.h>
+
+static inline void resched(void)
+{
+	poller_call();
+}
+
+#endif
diff --git a/lib/readline.c b/lib/readline.c
index e5370f9c7b6e..25aa99b95e46 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -2,7 +2,7 @@
 #include <readkey.h>
 #include <init.h>
 #include <libbb.h>
-#include <poller.h>
+#include <sched.h>
 #include <xfuncs.h>
 #include <complete.h>
 #include <linux/ctype.h>
@@ -200,7 +200,7 @@ int readline(const char *prompt, char *buf, int len)
 
 	while (1) {
 		while (!tstc())
-			poller_call();
+			resched();
 
 		ichar = read_key();
 
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-03-10  8:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10  8:47 [PATCH v3 00/16] common: introduce bthreads, co-operative Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 01/16] common: introduce HAS_ARCH_SJLJ Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 02/16] ARM: asm: setjmp: annotate setjmp/longjmp for GCC Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 03/16] ARM: asm: setjmp: implement coroutine dependency initjmp() Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 04/16] sandbox: asm: implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 05/16] riscv: Add asm/asm.h Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 06/16] riscv: Add asm/linkage.h Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 07/16] riscv: Implement setjmp/longjmp/initjmp for RV32I Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 08/16] mips: Add linkage.h Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 09/16] mips: Implement setjmp/longjmp/initjmp for 32BIT Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 10/16] powerpc: Implement initjmp/setjmp/longjmp Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 11/16] x86: implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-10  8:47 ` Ahmad Fatoum [this message]
2021-03-10  8:47 ` [PATCH v3 13/16] console: unconditionally run resched() in ctrlc() Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 14/16] common: introduce bthreads, co-operative barebox threads Ahmad Fatoum
2021-03-10  8:47 ` [PATCH v3 15/16] commands: add new bthread test command Ahmad Fatoum
2021-03-10  8:48 ` [PATCH v3 16/16] RFC: led: migrate from poller to bthread Ahmad Fatoum
2021-03-15  8:34 ` [PATCH v3 00/16] common: introduce bthreads, co-operative Sascha Hauer

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=20210310084800.3584-13-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=peter@korsgaard.com \
    --cc=pmamonov@gmail.com \
    --cc=sha@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox