Skip to content

Commit 87444c5

Browse files
committed
OS/ThreadX: remove IRQ system state updates for SWI scheduling in SMP port
Commit 13248a2 introduced UPDATE_THREADX_SYSTEM_STATE in the normal IRQ entry path to track per-core ISR nesting state. However, the Nuclei RISC-V ThreadX SMP port handles scheduler switching through the SysTimer SWI path, where ``eclic_msip_handler`` saves thread context and ``PortThreadSwitch`` selects the next thread. The normal ``irq_entry`` path only dispatches hardware non-vector interrupts through ``JALMNXTI`` and does not need to mark ``_tx_thread_system_state`` as an ISR nesting counter for the current scheduling model. Keeping that update can prevent ThreadX preemption checks raised from interrupt context from requesting a scheduler switch, because ``_tx_thread_system_state`` is non-zero while the IRQ is active. The port already raises a SysTimer SWI for scheduling and handles that SWI after the normal interrupt path exits, so there is no need to wait on the IRQ-maintained system state before switching. Remove the IRQ entry updates added by 13248a2. Signed-off-by: Huaqi Fang <578567190@qq.com>
1 parent c4c48cc commit 87444c5

2 files changed

Lines changed: 0 additions & 47 deletions

File tree

OS/ThreadX/ports_smp/nuclei/gcc/interrupt.S

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@
1515
csrc CSR_MSTATUS, MSTATUS_MIE
1616
.endm
1717

18-
/* Update ThreadX SMP per-core ISR nesting state.
19-
* This macro must be called after SAVE_CONTEXT because it clobbers t0-t2.
20-
*/
21-
.macro UPDATE_THREADX_SYSTEM_STATE delta
22-
la t0, _tx_thread_system_state
23-
csrr t1, CSR_MHARTID
24-
slli t1, t1, LOG_REGBYTES
25-
add t0, t0, t1
26-
LOAD t2, 0(t0)
27-
addi t2, t2, \delta
28-
STORE t2, 0(t0)
29-
.endm
30-
3118
/**
3219
* \brief Macro for context save
3320
* \details
@@ -215,11 +202,6 @@ irq_entry:
215202
/* Save the necessary CSR registers */
216203
SAVE_CSR_CONTEXT
217204

218-
/* Mark this core as being in a normal IRQ handler.
219-
* eclic_msip_handler is the scheduler SWI path and is handled separately.
220-
*/
221-
UPDATE_THREADX_SYSTEM_STATE 1
222-
223205
/* This special CSR read/write operation, which is actually
224206
* claim the CLIC to find its pending highest ID, if the ID
225207
* is not 0, then automatically enable the mstatus.MIE, and
@@ -230,11 +212,6 @@ irq_entry:
230212
/* Critical section with interrupts disabled */
231213
DISABLE_MIE
232214

233-
/* All nested IRQ work claimed by JALMNXTI is done; leave ThreadX ISR context
234-
* before restoring the interrupted context.
235-
*/
236-
UPDATE_THREADX_SYSTEM_STATE -1
237-
238215
/* Restore the necessary CSR registers */
239216
RESTORE_CSR_CONTEXT
240217
/* Restore the caller saving registers (context) */

OS/ThreadX/ports_smp/nuclei/iar/interrupt.S

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,6 @@ DISABLE_MIE MACRO
55
csrci CSR_MSTATUS, MSTATUS_MIE
66
ENDM
77

8-
/* Update ThreadX SMP per-core ISR nesting state.
9-
* This macro must be called after SAVE_CONTEXT because it clobbers t0-t2.
10-
*/
11-
UPDATE_THREADX_SYSTEM_STATE MACRO delta
12-
la t0, _tx_thread_system_state
13-
csrr t1, CSR_MHARTID
14-
slli t1, t1, LOG_REGBYTES
15-
add t0, t0, t1
16-
LOAD t2, 0(t0)
17-
addi t2, t2, delta
18-
STORE t2, 0(t0)
19-
ENDM
20-
218
SAVE_CONTEXT MACRO
229
#if defined(ECLIC_HW_CTX_AUTO) && defined(CFG_HAS_ECLICV2)
2310
#else
@@ -110,7 +97,6 @@ RESTORE_CSR_CONTEXT MACRO
11097
PUBLIC exc_entry, irq_entry, default_intexc_handler
11198
PUBLIC Undef_Handler
11299
EXTERN core_exception_handler
113-
EXTERN _tx_thread_system_state
114100
SECTION `.text`:CODE:NOROOT(2)
115101
CODE
116102

@@ -176,11 +162,6 @@ irq_entry:
176162
/* Save the necessary CSR registers */
177163
SAVE_CSR_CONTEXT
178164

179-
/* Mark this core as being in a normal IRQ handler.
180-
* eclic_msip_handler is the scheduler SWI path and is handled separately.
181-
*/
182-
UPDATE_THREADX_SYSTEM_STATE 1
183-
184165
/* This special CSR read/write operation, which is actually
185166
* claim the CLIC to find its pending highest ID, if the ID
186167
* is not 0, then automatically enable the mstatus.MIE, and
@@ -191,11 +172,6 @@ irq_entry:
191172
/* Critical section with interrupts disabled */
192173
DISABLE_MIE
193174

194-
/* All nested IRQ work claimed by JALMNXTI is done; leave ThreadX ISR context
195-
* before restoring the interrupted context.
196-
*/
197-
UPDATE_THREADX_SYSTEM_STATE -1
198-
199175
/* Restore the necessary CSR registers */
200176
RESTORE_CSR_CONTEXT
201177
/* Restore the caller saving registers (context) */

0 commit comments

Comments
 (0)