irq: remove restore_critical_section in irq

Only in the non-critical region, nuttx can the respond to the irq and not hold the lock
When returning from the irq, there is no need to check whether the lock needs to be released
we also need keep restore_critical_section in svc call

test:
Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2023-12-19 13:03:51 +08:00 committed by archer
parent d499ac9d58
commit 1d6a099180
17 changed files with 30 additions and 24 deletions

View File

@ -79,7 +79,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
g_running_tasks[this_cpu()] = this_task();
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -34,6 +34,7 @@
#include <arch/irq.h>
#include <nuttx/sched.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "exc_return.h"
#include "arm_internal.h"
@ -473,5 +474,10 @@ int arm_svcall(int irq, void *context, void *arg)
# endif
#endif
if (regs != CURRENT_REGS)
{
restore_critical_section();
}
return OK;
}

View File

@ -92,7 +92,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
g_running_tasks[this_cpu()] = this_task();
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -79,7 +79,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
g_running_tasks[this_cpu()] = this_task();
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -35,6 +35,7 @@
#include <nuttx/sched.h>
#include <nuttx/userspace.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "exc_return.h"
#include "arm_internal.h"
@ -482,5 +483,10 @@ int arm_svcall(int irq, void *context, void *arg)
# endif
#endif
if (regs != CURRENT_REGS)
{
restore_critical_section();
}
return OK;
}

View File

@ -71,7 +71,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
g_running_tasks[this_cpu()] = this_task();
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -128,7 +128,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
g_running_tasks[this_cpu()] = this_task();
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -34,6 +34,7 @@
#include <nuttx/sched.h>
#include <nuttx/userspace.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "exc_return.h"
#include "arm_internal.h"
@ -483,5 +484,10 @@ int arm_svcall(int irq, void *context, void *arg)
# endif
#endif
if (regs != CURRENT_REGS)
{
restore_critical_section();
}
return OK;
}

View File

@ -71,8 +71,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
*/
g_running_tasks[this_cpu()] = this_task();
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -98,7 +98,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
if (regs != CURRENT_REGS)
{
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -99,9 +99,6 @@ uint64_t *arm64_doirq(int irq, uint64_t * regs)
g_running_tasks[this_cpu()] = this_task();
/* Restore the cpu lock */
restore_critical_section();
regs = (uint64_t *)CURRENT_REGS;
}

View File

@ -85,7 +85,6 @@ uint32_t *ceva_doirq(int irq, uint32_t *regs)
g_running_tasks[this_cpu()] = this_task();
restore_critical_section();
regs = CURRENT_REGS;
}

View File

@ -109,10 +109,6 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
g_running_tasks[this_cpu()] = this_task();
/* Restore the cpu lock */
restore_critical_section();
/* If a context switch occurred while processing the interrupt then
* CURRENT_REGS may have change value. If we return any value
* different from the input regs, then the lower level will know

View File

@ -40,6 +40,7 @@
# include <syscall.h>
#endif
#include "sched/sched.h"
#include "signal/signal.h"
#include "riscv_internal.h"
#include "addrenv.h"
@ -498,5 +499,10 @@ int riscv_swint(int irq, void *context, void *arg)
}
#endif
if (regs != CURRENT_REGS)
{
restore_critical_section();
}
return OK;
}

View File

@ -118,13 +118,6 @@ uint32_t *sparc_doirq(int irq, uint32_t *regs)
regs = (uint32_t *)((uint32_t)CURRENT_REGS -
CPU_MINIMUM_STACK_FRAME_SIZE);
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
{
restore_critical_section();
}
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
* interrupt handler.
*/

View File

@ -94,7 +94,6 @@ uint32_t *xtensa_irq_dispatch(int irq, uint32_t *regs)
if (regs != CURRENT_REGS)
{
restore_critical_section();
regs = (uint32_t *)CURRENT_REGS;
}

View File

@ -32,6 +32,7 @@
#include <nuttx/arch.h>
#include <sys/syscall.h>
#include "sched/sched.h"
#include "chip.h"
#include "signal/signal.h"
#include "xtensa.h"
@ -439,5 +440,10 @@ int xtensa_swint(int irq, void *context, void *arg)
}
#endif
if (regs != CURRENT_REGS)
{
restore_critical_section();
}
return OK;
}