You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2020/11/21 22:48:07 UTC
[incubator-nuttx] 04/06: arch: k210: Fix the pause handler for SMP
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 249dc11e0508a8ce11c93020af6e8c1627b6db3f
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Nov 20 13:45:53 2020 +0900
arch: k210: Fix the pause handler for SMP
Summary:
- Apply the same logic added to cxd56_cpupause.c
Impact:
- SMP only
Testing:
- Tested with maix-bit:smp (QEMU)
- Run smp and ostest
Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
arch/risc-v/src/k210/k210_cpupause.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/risc-v/src/k210/k210_cpupause.c b/arch/risc-v/src/k210/k210_cpupause.c
index 88af783..2eaa573 100644
--- a/arch/risc-v/src/k210/k210_cpupause.c
+++ b/arch/risc-v/src/k210/k210_cpupause.c
@@ -205,6 +205,7 @@ int up_cpu_paused(int cpu)
int riscv_pause_handler(int irq, void *c, FAR void *arg)
{
int cpu = up_cpu_index();
+ int ret = OK;
/* Clear machine software interrupt */
@@ -217,10 +218,21 @@ int riscv_pause_handler(int irq, void *c, FAR void *arg)
if (spin_islocked(&g_cpu_paused[cpu]))
{
- return up_cpu_paused(cpu);
+ /* NOTE: up_cpu_paused() needs to be executed in a critical section
+ * to ensure that this CPU holds g_cpu_irqlock. However, adding
+ * a critical section in up_cpu_paused() is not a good idea,
+ * because it is also called in enter_critical_section() to break
+ * a deadlock
+ */
+
+ irqstate_t flags = enter_critical_section();
+
+ ret = up_cpu_paused(cpu);
+
+ leave_critical_section(flags);
}
- return OK;
+ return ret;
}
/****************************************************************************