From 3dce2241838b8bf9f7123512de4f287cc5ebe34a Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 16 Sep 2025 17:49:39 -0400 Subject: [PATCH] fix(rp2): switch spinlock busy loop to wfe --- src/runtime/runtime_rp2.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/runtime/runtime_rp2.go b/src/runtime/runtime_rp2.go index 93e488d02..f248ecda6 100644 --- a/src/runtime/runtime_rp2.go +++ b/src/runtime/runtime_rp2.go @@ -311,15 +311,13 @@ func (l *spinLock) Lock() { // Wait for the lock to be available. spinlock := l.spinlock() for spinlock.Get() == 0 { - // TODO: use wfe and send an event when unlocking so the CPU can go to - // sleep while waiting for the lock. - // Unfortunately when doing that, time.Sleep() seems to hang somewhere. - // This needs some debugging to figure out. + arm.Asm("wfe") } } func (l *spinLock) Unlock() { l.spinlock().Set(0) + arm.Asm("sev") } // Wait until a signal is received, indicating that it can resume from the