Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9db16cf

Browse files
projectgusdpgeorge
authored andcommitted
rp2: Fix wakeup from WFE on core1.
If core1 executes `mp_wfe_or_timeout()` then it needs to receive aninterrupt or a SEV to resume execution, but the soft timer interrupt onlyfires on core 0. This fix adds a SEV to the soft timer interrupt handler.This issue was masked by the issue fixed in the previous commit, as WFEpreviously wasn't suspending properly.Verified via the existing thread_sleep2 test.This work was funded through GitHub Sponsors.Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parenteced9d8 commit9db16cf

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

‎ports/rp2/mphalport.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ static void soft_timer_hardware_callback(unsigned int alarm_num) {
228228
// The timer alarm ISR needs to call here and trigger PendSV dispatch via
229229
// a second ISR, as PendSV may be currently suspended by the other CPU.
230230
pendsv_schedule_dispatch(PENDSV_DISPATCH_SOFT_TIMER,soft_timer_handler);
231+
232+
// This ISR only runs on core0, but if core1 is running Python code then it
233+
// may be blocked in WFE so wake it up as well. Unfortunately this also sets
234+
// the event flag on core0, so a subsequent WFE on this core will not suspend
235+
if (core1_entry!=NULL) {
236+
__sev();
237+
}
231238
}
232239

233240
voidsoft_timer_init(void) {

‎ports/rp2/mpthreadport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern uint8_t __StackTop, __StackBottom;
3939
void*core_state[2];
4040

4141
// This will be non-NULL while Python code is executing.
42-
staticvoid*(*core1_entry)(void*)=NULL;
42+
core_entry_func_tcore1_entry=NULL;
4343

4444
staticvoid*core1_arg=NULL;
4545
staticuint32_t*core1_stack=NULL;

‎ports/rp2/mpthreadport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ typedef struct mutex mp_thread_mutex_t;
3232

3333
externvoid*core_state[2];
3434

35+
typedefvoid*(*core_entry_func_t)(void*);
36+
37+
externcore_entry_func_tcore1_entry;
38+
3539
voidmp_thread_init(void);
3640
voidmp_thread_deinit(void);
3741
voidmp_thread_gc_others(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp