This is an automated email from the ASF dual-hosted git repository.
archer 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 1d6a099180 irq: remove restore_critical_section in irq
1d6a099180 is described below
commit 1d6a09918039499b6c7eeb341fd86e72e8aca964
Author: hujun5 <[email protected]>
AuthorDate: Tue Dec 19 13:03:51 2023 +0800
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 <[email protected]>
---
arch/arm/src/armv6-m/arm_doirq.c | 1 -
arch/arm/src/armv6-m/arm_svcall.c | 6 ++++++
arch/arm/src/armv7-a/arm_doirq.c | 1 -
arch/arm/src/armv7-m/arm_doirq.c | 1 -
arch/arm/src/armv7-m/arm_svcall.c | 6 ++++++
arch/arm/src/armv7-r/arm_doirq.c | 1 -
arch/arm/src/armv8-m/arm_doirq.c | 1 -
arch/arm/src/armv8-m/arm_svcall.c | 6 ++++++
arch/arm/src/armv8-r/arm_doirq.c | 2 --
arch/arm/src/tlsr82/tc32/tc32_doirq.c | 1 -
arch/arm64/src/common/arm64_doirq.c | 3 ---
arch/ceva/src/common/ceva_doirq.c | 1 -
arch/risc-v/src/common/riscv_doirq.c | 4 ----
arch/risc-v/src/common/riscv_swint.c | 6 ++++++
arch/sparc/src/sparc_v8/sparc_v8_doirq.c | 7 -------
arch/xtensa/src/common/xtensa_irqdispatch.c | 1 -
arch/xtensa/src/common/xtensa_swint.c | 6 ++++++
17 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/arch/arm/src/armv6-m/arm_doirq.c b/arch/arm/src/armv6-m/arm_doirq.c
index 80b076636f..22a89cb673 100644
--- a/arch/arm/src/armv6-m/arm_doirq.c
+++ b/arch/arm/src/armv6-m/arm_doirq.c
@@ -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;
}
diff --git a/arch/arm/src/armv6-m/arm_svcall.c
b/arch/arm/src/armv6-m/arm_svcall.c
index 2775079dca..c6b9801b56 100644
--- a/arch/arm/src/armv6-m/arm_svcall.c
+++ b/arch/arm/src/armv6-m/arm_svcall.c
@@ -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;
}
diff --git a/arch/arm/src/armv7-a/arm_doirq.c b/arch/arm/src/armv7-a/arm_doirq.c
index 652de6a233..1dfa76983d 100644
--- a/arch/arm/src/armv7-a/arm_doirq.c
+++ b/arch/arm/src/armv7-a/arm_doirq.c
@@ -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;
}
diff --git a/arch/arm/src/armv7-m/arm_doirq.c b/arch/arm/src/armv7-m/arm_doirq.c
index e7b6411faa..10faadf111 100644
--- a/arch/arm/src/armv7-m/arm_doirq.c
+++ b/arch/arm/src/armv7-m/arm_doirq.c
@@ -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;
}
diff --git a/arch/arm/src/armv7-m/arm_svcall.c
b/arch/arm/src/armv7-m/arm_svcall.c
index c761a972a6..51377d7d87 100644
--- a/arch/arm/src/armv7-m/arm_svcall.c
+++ b/arch/arm/src/armv7-m/arm_svcall.c
@@ -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;
}
diff --git a/arch/arm/src/armv7-r/arm_doirq.c b/arch/arm/src/armv7-r/arm_doirq.c
index de5929dc9d..22299e999f 100644
--- a/arch/arm/src/armv7-r/arm_doirq.c
+++ b/arch/arm/src/armv7-r/arm_doirq.c
@@ -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;
}
diff --git a/arch/arm/src/armv8-m/arm_doirq.c b/arch/arm/src/armv8-m/arm_doirq.c
index 5e942d7aa5..b4a921367b 100644
--- a/arch/arm/src/armv8-m/arm_doirq.c
+++ b/arch/arm/src/armv8-m/arm_doirq.c
@@ -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;
}
diff --git a/arch/arm/src/armv8-m/arm_svcall.c
b/arch/arm/src/armv8-m/arm_svcall.c
index 1d384392e5..8e87625768 100644
--- a/arch/arm/src/armv8-m/arm_svcall.c
+++ b/arch/arm/src/armv8-m/arm_svcall.c
@@ -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;
}
diff --git a/arch/arm/src/armv8-r/arm_doirq.c b/arch/arm/src/armv8-r/arm_doirq.c
index c949d21b96..beb83fcccc 100644
--- a/arch/arm/src/armv8-r/arm_doirq.c
+++ b/arch/arm/src/armv8-r/arm_doirq.c
@@ -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;
}
diff --git a/arch/arm/src/tlsr82/tc32/tc32_doirq.c
b/arch/arm/src/tlsr82/tc32/tc32_doirq.c
index d19cdfbb00..7c772d330a 100644
--- a/arch/arm/src/tlsr82/tc32/tc32_doirq.c
+++ b/arch/arm/src/tlsr82/tc32/tc32_doirq.c
@@ -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;
}
diff --git a/arch/arm64/src/common/arm64_doirq.c
b/arch/arm64/src/common/arm64_doirq.c
index c7ece5b76d..264475dcad 100644
--- a/arch/arm64/src/common/arm64_doirq.c
+++ b/arch/arm64/src/common/arm64_doirq.c
@@ -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;
}
diff --git a/arch/ceva/src/common/ceva_doirq.c
b/arch/ceva/src/common/ceva_doirq.c
index 7a24a14671..81effb4a85 100644
--- a/arch/ceva/src/common/ceva_doirq.c
+++ b/arch/ceva/src/common/ceva_doirq.c
@@ -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;
}
diff --git a/arch/risc-v/src/common/riscv_doirq.c
b/arch/risc-v/src/common/riscv_doirq.c
index 7ed1a1ebe0..c72fd21c8f 100644
--- a/arch/risc-v/src/common/riscv_doirq.c
+++ b/arch/risc-v/src/common/riscv_doirq.c
@@ -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
diff --git a/arch/risc-v/src/common/riscv_swint.c
b/arch/risc-v/src/common/riscv_swint.c
index aebeef1cb9..66872cc157 100644
--- a/arch/risc-v/src/common/riscv_swint.c
+++ b/arch/risc-v/src/common/riscv_swint.c
@@ -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;
}
diff --git a/arch/sparc/src/sparc_v8/sparc_v8_doirq.c
b/arch/sparc/src/sparc_v8/sparc_v8_doirq.c
index d434e3c7e0..0733aace99 100644
--- a/arch/sparc/src/sparc_v8/sparc_v8_doirq.c
+++ b/arch/sparc/src/sparc_v8/sparc_v8_doirq.c
@@ -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.
*/
diff --git a/arch/xtensa/src/common/xtensa_irqdispatch.c
b/arch/xtensa/src/common/xtensa_irqdispatch.c
index 17457147e0..be2c671b50 100644
--- a/arch/xtensa/src/common/xtensa_irqdispatch.c
+++ b/arch/xtensa/src/common/xtensa_irqdispatch.c
@@ -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;
}
diff --git a/arch/xtensa/src/common/xtensa_swint.c
b/arch/xtensa/src/common/xtensa_swint.c
index 51bf2c1b79..702adfe2af 100644
--- a/arch/xtensa/src/common/xtensa_swint.c
+++ b/arch/xtensa/src/common/xtensa_swint.c
@@ -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;
}