This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 3e3701b272 riscv: Some judgments are missing
3e3701b272 is described below
commit 3e3701b2721c216cea47b72835a13966da52b555
Author: hujun5 <[email protected]>
AuthorDate: Tue Dec 3 16:41:20 2024 +0800
riscv: Some judgments are missing
This commit fixes the regression from
https://github.com/apache/nuttx/pull/14984
Signed-off-by: hujun5 <[email protected]>
---
arch/risc-v/src/common/riscv_doirq.c | 13 +++++++++++--
arch/risc-v/src/common/supervisor/riscv_perform_syscall.c | 10 ++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/arch/risc-v/src/common/riscv_doirq.c
b/arch/risc-v/src/common/riscv_doirq.c
index 1e1df6163d..4325bdad50 100644
--- a/arch/risc-v/src/common/riscv_doirq.c
+++ b/arch/risc-v/src/common/riscv_doirq.c
@@ -61,6 +61,7 @@
uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
{
struct tcb_s **running_task = &g_running_tasks[this_cpu()];
+ bool restore_context = false;
struct tcb_s *tcb = this_task();
board_autoled_on(LED_INIRQ);
@@ -77,6 +78,10 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
{
(*running_task)->xcp.regs = regs;
}
+ else
+ {
+ restore_context = true;
+ }
}
else
{
@@ -98,7 +103,7 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
/* Check for a context switch. */
- if (*running_task != tcb)
+ if (*running_task != tcb || restore_context)
{
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
@@ -112,7 +117,11 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
/* Update scheduler parameters */
- nxsched_suspend_scheduler(*running_task);
+ if (!restore_context)
+ {
+ nxsched_suspend_scheduler(*running_task);
+ }
+
nxsched_resume_scheduler(tcb);
/* Record the new "running" task when context switch occurred.
diff --git a/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c
b/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c
index 4f13d78d26..cb4b6c4333 100644
--- a/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c
+++ b/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c
@@ -40,11 +40,13 @@
void *riscv_perform_syscall(uintreg_t *regs)
{
struct tcb_s **running_task = &g_running_tasks[this_cpu()];
+ bool restore_context = true;
struct tcb_s *tcb;
if (regs[REG_A0] != SYS_restore_context)
{
(*running_task)->xcp.regs = regs;
+ restore_context = false;
}
/* Set irq flag */
@@ -56,7 +58,7 @@ void *riscv_perform_syscall(uintreg_t *regs)
riscv_swint(0, regs, NULL);
tcb = this_task();
- if (*running_task != tcb)
+ if (*running_task != tcb || restore_context)
{
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
@@ -69,7 +71,11 @@ void *riscv_perform_syscall(uintreg_t *regs)
#endif
/* Update scheduler parameters */
- nxsched_suspend_scheduler(*running_task);
+ if (!restore_context)
+ {
+ nxsched_suspend_scheduler(*running_task);
+ }
+
nxsched_resume_scheduler(tcb);
/* Record the new "running" task. g_running_tasks[] is only used by