[PATCH 3/3] menu: schedule pollers/workqueues while waiting for menu item selection

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jul 1 01:52:51 PDT 2025


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 at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/menu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --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




More information about the barebox mailing list