[PATCH 07/12] slice: have assert_command_context() yield until true if possible

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 15 05:37:00 EST 2021


assert_command_context() is a safety net to warn about pollers doing
file system operations. It so far prints a splat when this happens.

With pollers that may yield, this can be implemented differently by
just yielding until the poller is run in the command context. So so.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 include/slice.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/slice.h b/include/slice.h
index d09d17924fb4..eae74b9fc199 100644
--- a/include/slice.h
+++ b/include/slice.h
@@ -36,8 +36,14 @@ void command_slice_acquire(void);
 void command_slice_release(void);
 
 #ifdef CONFIG_POLLER
-#define assert_command_context() ({    \
-	WARN_ONCE(in_poller(), "%s called in poller\n", __func__); \
+#define assert_command_context() ({                                       \
+	while (in_poller() && !slice_acquired(&command_slice)) {          \
+		if (!IS_ENABLED(CONFIG_POLLER_YIELD)) {                   \
+			WARN_ONCE(1, "%s called in poller\n", __func__);  \
+			break;                                            \
+		}                                                         \
+		poller_yield();                                           \
+	}                                                                 \
 })
 #else
 #define assert_command_context() do { } while (0)
-- 
2.29.2




More information about the barebox mailing list