Skip to content

Commit 48b3105

Browse files
committed
runtime/rp2040: disable interrupts before flash-safe handshake
1 parent 67b66a1 commit 48b3105

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/runtime/runtime_rp2040_flashsafe_cores.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ var rp2040FlashSafeState volatile.Register8
2323
// rp2040EnterFlashSafeSection enters a section in which RP2040 flash operations
2424
// may temporarily disable XIP.
2525
//
26-
// The multicore path asks the other core to enter the flash-safe interrupt
27-
// handler and waits until it acknowledges that it is parked. Local interrupts
28-
// are disabled after the other core is parked.
26+
// The multicore path serializes flash-safe initiators, then disables local
27+
// interrupts before asking the other core to park. Keeping local interrupts
28+
// disabled while waiting for the acknowledgement prevents a GC stop-the-world
29+
// interrupt from blocking this core while the other core is parked in the
30+
// flash-safe handler.
2931
func rp2040EnterFlashSafeSection() interrupt.State {
3032
if !secondaryCoresStarted {
3133
return interrupt.Disable()
3234
}
3335

3436
flashSafeLock.Lock()
3537

38+
state := interrupt.Disable()
39+
3640
core := currentCPU()
3741
rp2040FlashSafeState.Set(rp2040FlashSafeIdle)
3842

@@ -47,7 +51,7 @@ func rp2040EnterFlashSafeSection() interrupt.State {
4751
spinLoopWait()
4852
}
4953

50-
return interrupt.Disable()
54+
return state
5155
}
5256

5357
// rp2040ExitFlashSafeSection exits a section entered by

0 commit comments

Comments
 (0)