Attention is currently required from: Raul Rangel, Julius Werner, Rob Barnes, Karthik Ramasubramanian. Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/59320 )
Change subject: lib: Add a mutex ......................................................................
Patch Set 6:
(2 comments)
File src/include/mutex.h:
https://review.coreboot.org/c/coreboot/+/59320/comment/e7f9117f_f72a440d PS6, Line 32: } I put the following in <rules.h>
#if ENV_X86 #define STAGE_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE #elif ENV_RISCV #define STAGE_HAS_SPINLOCKS 1 #else #define STAGE_HAS_SPINLOCKS 0 #endif
/* When set <arch/smp/spinlock.h> is included for the spinlock implementation. */ #define ENV_STAGE_SUPPORTS_SMP (CONFIG(SMP) && STAGE_HAS_SPINLOCKS)
The implementation of spinlock needed .data while mutex can do with .bss? With that taken into account, you would never call the non-smp variants _mutex_lock_coop() or _mutex_unlock_coop() since romstage would also see ENV_STAGE_SUPPORTS_SMP=y ?
File src/lib/mutex.c:
https://review.coreboot.org/c/coreboot/+/59320/comment/9fcfa56c_42563eea PS6, Line 23: if (thread_yield() < 0) { This path already handles COOP_MULTITHREADING=y, do you really want a separate _mutex_lock_coop() below that does not quarantee atomicity?