From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: bst@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/3] menu: schedule pollers/workqueues while waiting for menu item selection
Date: Tue, 1 Jul 2025 10:52:51 +0200 [thread overview]
Message-ID: <20250701085251.148111-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250701085251.148111-1-a.fatoum@pengutronix.de>
Pollers are already run during the menu, because getchar() will poll the
console driver every 100us and 100us happens to be the time at which
is_timeout starts scheduling. Workqueus can only be run outside command
context however, so running menutree (e.g., because shell was exited)
will not process any fastboot packets in the workqueue.
Fix this by releasing the slice for the duration of readkey. We do a
similar thing in the readline command as well.
Unlike the readline command, menutree can execute arbitrary scripts as
a result of the user input, so we restrict the slice only to the console
and rescheduling parts.
Reported-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
| 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--git a/common/menu.c b/common/menu.c
index 128043c225df..c985f2987751 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -9,6 +9,7 @@
#include <init.h>
#include <menu.h>
#include <malloc.h>
+#include <slice.h>
#include <xfuncs.h>
#include <errno.h>
#include <readkey.h>
@@ -290,10 +291,14 @@ int menu_show(struct menu *m)
struct menu_entry *old_selected = m->selected;
int repaint = 0;
- if (m->auto_select >= 0)
+ if (m->auto_select >= 0) {
ch = BB_KEY_RETURN;
- else
+ } else {
+ /* Ensure workqueues can run during menu, e.g. for fastboot */
+ command_slice_release();
ch = read_key();
+ command_slice_acquire();
+ }
m->auto_select = -1;
--
2.39.5
next prev parent reply other threads:[~2025-07-01 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 8:52 [PATCH 1/3] commands: sleep: add support for running without pollers Ahmad Fatoum
2025-07-01 8:52 ` [PATCH 2/3] poller: add option to detect delayed poller activation Ahmad Fatoum
2025-07-01 8:52 ` Ahmad Fatoum [this message]
2025-07-01 9:24 ` [PATCH 3/3] menu: schedule pollers/workqueues while waiting for menu item selection Bastian Krause
2025-07-02 7:00 ` [PATCH 1/3] commands: sleep: add support for running without pollers 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=20250701085251.148111-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=bst@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