Skip to content

Commit f89a083

Browse files
committed
OS/ThreadX: add memory barriers around ECLIC IRQ priority changes in SMP port
Signed-off-by: Huaqi Fang <578567190@qq.com>
1 parent 4e1cc0f commit f89a083

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • OS/ThreadX/ports_smp/nuclei

OS/ThreadX/ports_smp/nuclei/port.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ void PortThreadSwitch(void)
9090
if (coreid == 0) {
9191
/* increase the timer interrupt to higher priority to enable interrupt nesting */
9292
ECLIC_SetLevelIRQ(SysTimer_IRQn, KERNEL_INTERRUPT_PRIORITY + 1);
93+
__RWMB();
9394
/* swap task stack to interrupt stack to avoid interrupt nesting on task stack */
9495
}
9596
__ASM volatile("csrrw sp, " STRINGIFY(CSR_MSCRATCHCSWL) ", sp");
97+
__RWMB();
9698
/* mcause must be saved and restore if interrupt nested */
9799
rv_csr_t mcause = __RV_CSR_READ(CSR_MCAUSE);
98100
rv_csr_t msubm = __RV_CSR_READ(CSR_MSUBM);
@@ -111,9 +113,11 @@ void PortThreadSwitch(void)
111113
__RV_CSR_WRITE(CSR_MCAUSE, mcause);
112114
/* swap interrupt stack back to task stack */
113115
__ASM volatile("csrrw sp, " STRINGIFY(CSR_MSCRATCHCSWL) ", sp");
116+
__RWMB();
114117
/* restore timer interrupt to origin kernel interrupt priority */
115118
if (coreid == 0) {
116119
ECLIC_SetLevelIRQ(SysTimer_IRQn, KERNEL_INTERRUPT_PRIORITY);
120+
__RWMB();
117121
}
118122
}
119123

0 commit comments

Comments
 (0)