From fb8d1525f4a7220a8c1a332402c1068da83902ea Mon Sep 17 00:00:00 2001 From: Lephe Date: Sun, 11 Apr 2021 18:36:07 +0200 Subject: [PATCH] kernel: guarantee availability of drivers based on dependency levels The question of how to handle a partially-restored world state begs for an elegant symmetrical answer, but that doesn't work unless both kernels do the save/restore for themselves. So far, things have worked out because any order works since interrupts are disabled therefore partially-restored drivers are inactive. However the USB module requires waits that are best performed with timers, so the order cannot be chosen arbitrarily. This commit enforces a gint-centric order where code from a gint driver is only run when all lower-level drivers are active. This solves some pretty bad freezes with the USB module. --- src/kernel/kernel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 33b86de..91dd028 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -100,7 +100,7 @@ static void drivers_switch(int who) /* Restore the other context */ ctx_restore(who ? &sys_ctx : &gint_ctx); - for driver_asc(d) + for driver_dsc(d) { if(!d->ctx_save || !d->ctx_restore) continue; d->ctx_restore(who ? d->sys_ctx : d->gint_ctx);