You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/01/23 10:28:45 UTC

[incubator-nuttx] branch master updated (da56591 -> 71d3ff1)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from da56591  Fix regression where used code was marked as unused
     new 422e005  arch/risc-v: Move xxx_cpustart.c to common
     new 71d3ff1  arch/risc-v: Remove g_serial_ok

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/risc-v/src/c906/c906_start.c                  |  5 ---
 .../k210_cpustart.c => common/riscv_cpustart.c}    | 50 ++++------------------
 arch/risc-v/src/common/riscv_internal.h            |  5 +++
 arch/risc-v/src/k210/Make.defs                     |  3 +-
 arch/risc-v/src/k210/k210_start.c                  |  7 +--
 arch/risc-v/src/mpfs/mpfs_start.c                  |  3 --
 6 files changed, 15 insertions(+), 58 deletions(-)
 rename arch/risc-v/src/{k210/k210_cpustart.c => common/riscv_cpustart.c} (77%)

[incubator-nuttx] 01/02: arch/risc-v: Move xxx_cpustart.c to common

Posted by xi...@apache.org.
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/incubator-nuttx.git

commit 422e005183be08dcdf886829e45c1ab6f52db5bc
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Sat Jan 22 19:01:53 2022 +0800

    arch/risc-v: Move xxx_cpustart.c to common
    
    It's a common solution for MSIP and IPI based risc-v smp soc,
    also works on qemu-rv smp (WIP).
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 arch/risc-v/src/c906/c906_start.c                  |  2 --
 .../k210_cpustart.c => common/riscv_cpustart.c}    | 34 +++++-----------------
 arch/risc-v/src/common/riscv_internal.h            |  5 ++++
 arch/risc-v/src/k210/Make.defs                     |  3 +-
 arch/risc-v/src/k210/k210_start.c                  |  4 +--
 5 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/arch/risc-v/src/c906/c906_start.c b/arch/risc-v/src/c906/c906_start.c
index 3bc3e68..1b58cf4 100644
--- a/arch/risc-v/src/c906/c906_start.c
+++ b/arch/risc-v/src/c906/c906_start.c
@@ -61,8 +61,6 @@
 uintptr_t g_idle_topstack = C906_IDLESTACK_TOP;
 volatile bool g_serial_ok = false;
 
-extern void c906_cpu_boot(uint32_t);
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
diff --git a/arch/risc-v/src/k210/k210_cpustart.c b/arch/risc-v/src/common/riscv_cpustart.c
similarity index 87%
rename from arch/risc-v/src/k210/k210_cpustart.c
rename to arch/risc-v/src/common/riscv_cpustart.c
index 51049b0..e6984ad 100644
--- a/arch/risc-v/src/k210/k210_cpustart.c
+++ b/arch/risc-v/src/common/riscv_cpustart.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/risc-v/src/k210/k210_cpustart.c
+ * arch/risc-v/src/common/riscv_cpustart.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -41,37 +41,22 @@
 #include "riscv_internal.h"
 #include "chip.h"
 
-#ifdef CONFIG_SMP
-
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
-#if 0
-#  define DPRINTF(fmt, args...) _err(fmt, ##args)
-#else
-#  define DPRINTF(fmt, args...) do {} while (0)
-#endif
-
-#ifdef CONFIG_DEBUG_FEATURES
-#  define showprogress(c) riscv_lowputc(c)
-#else
-#  define showprogress(c)
-#endif
-
 /****************************************************************************
  * Public Data
  ****************************************************************************/
 
 extern volatile bool g_serial_ok;
-extern int riscv_pause_handler(int irq, void *c, void *arg);
 
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: k210_cpu_boot
+ * Name: riscv_cpu_boot
  *
  * Description:
  *   Boot handler for cpu1
@@ -84,7 +69,7 @@ extern int riscv_pause_handler(int irq, void *c, void *arg);
  *
  ****************************************************************************/
 
-void k210_cpu_boot(int cpu)
+void riscv_cpu_boot(int cpu)
 {
   if (1 < cpu)
     {
@@ -99,7 +84,7 @@ void k210_cpu_boot(int cpu)
 
   /* Clear machine software interrupt for CPU(cpu) */
 
-  putreg32(0, (uintptr_t)K210_CLINT_MSIP + (4 * cpu));
+  putreg32(0, (uintptr_t)RISCV_CLINT_MSIP + (4 * cpu));
 
   /* Enable machine software interrupt for IPI to boot */
 
@@ -109,8 +94,7 @@ void k210_cpu_boot(int cpu)
 
   asm("WFI");
 
-  showprogress('b');
-  DPRINTF("CPU%d Started\n", this_cpu());
+  _info("CPU%d Started\n", this_cpu());
 
 #ifdef CONFIG_STACK_COLORATION
   struct tcb_s *tcb = this_task();
@@ -127,7 +111,7 @@ void k210_cpu_boot(int cpu)
 
   /* Clear machine software interrupt for CPU(cpu) */
 
-  putreg32(0, (uintptr_t)K210_CLINT_MSIP + (4 * cpu));
+  putreg32(0, (uintptr_t)RISCV_CLINT_MSIP + (4 * cpu));
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION
   /* Notify that this CPU has started */
@@ -171,7 +155,7 @@ void k210_cpu_boot(int cpu)
 
 int up_cpu_start(int cpu)
 {
-  DPRINTF("cpu=%d\n", cpu);
+  _info("CPU=%d\n", cpu);
 
 #ifdef CONFIG_SCHED_INSTRUMENTATION
   /* Notify of the start event */
@@ -181,9 +165,7 @@ int up_cpu_start(int cpu)
 
   /* Send IPI to CPU(cpu) */
 
-  putreg32(1, (uintptr_t)K210_CLINT_MSIP + (cpu * 4));
+  putreg32(1, (uintptr_t)RISCV_CLINT_MSIP + (cpu * 4));
 
   return 0;
 }
-
-#endif /* CONFIG_SMP */
diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h
index e020568..87c4158 100644
--- a/arch/risc-v/src/common/riscv_internal.h
+++ b/arch/risc-v/src/common/riscv_internal.h
@@ -215,6 +215,11 @@ void riscv_exception(uintptr_t mcause, uintptr_t *regs);
 void riscv_stack_color(void *stackbase, size_t nbytes);
 #endif
 
+#ifdef CONFIG_SMP
+void riscv_cpu_boot(int cpu);
+int riscv_pause_handler(int irq, void *c, void *arg);
+#endif
+
 #undef EXTERN
 #ifdef __cplusplus
 }
diff --git a/arch/risc-v/src/k210/Make.defs b/arch/risc-v/src/k210/Make.defs
index 36c3fb5..2ac5eff 100644
--- a/arch/risc-v/src/k210/Make.defs
+++ b/arch/risc-v/src/k210/Make.defs
@@ -36,7 +36,7 @@ CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c
 CMN_CSRCS += riscv_mdelay.c riscv_copyfullstate.c
 
 ifeq ($(CONFIG_SMP), y)
-CMN_CSRCS += riscv_cpuindex.c riscv_cpupause.c
+CMN_CSRCS += riscv_cpuindex.c riscv_cpupause.c riscv_cpustart.c
 endif
 
 ifeq ($(CONFIG_SCHED_BACKTRACE),y)
@@ -59,7 +59,6 @@ CHIP_CSRCS += k210_start.c k210_timerisr.c k210_gpiohs.c
 
 ifeq ($(CONFIG_SMP), y)
 CHIP_CSRCS += k210_cpuidlestack.c
-CHIP_CSRCS += k210_cpustart.c
 endif
 
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
diff --git a/arch/risc-v/src/k210/k210_start.c b/arch/risc-v/src/k210/k210_start.c
index 427c714..f915952 100644
--- a/arch/risc-v/src/k210/k210_start.c
+++ b/arch/risc-v/src/k210/k210_start.c
@@ -55,8 +55,6 @@
 uintptr_t g_idle_topstack = K210_IDLESTACK0_TOP;
 volatile bool g_serial_ok = false;
 
-extern void k210_cpu_boot(uint32_t);
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -139,7 +137,7 @@ cpu1:
   showprogress('a');
 
 #if defined(CONFIG_SMP) && (CONFIG_SMP_NCPUS == 2)
-  k210_cpu_boot(mhartid);
+  riscv_cpu_boot(mhartid);
 #endif
 
   while (true)

[incubator-nuttx] 02/02: arch/risc-v: Remove g_serial_ok

Posted by xi...@apache.org.
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/incubator-nuttx.git

commit 71d3ff104553aebf4cb938ee8abc6fd7d34fd239
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Sun Jan 23 15:38:02 2022 +0800

    arch/risc-v: Remove g_serial_ok
    
    `WFI` is enough to wait the ready signal from master core,
    so we can remove it.
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 arch/risc-v/src/c906/c906_start.c       |  3 ---
 arch/risc-v/src/common/riscv_cpustart.c | 16 ----------------
 arch/risc-v/src/k210/k210_start.c       |  3 ---
 arch/risc-v/src/mpfs/mpfs_start.c       |  3 ---
 4 files changed, 25 deletions(-)

diff --git a/arch/risc-v/src/c906/c906_start.c b/arch/risc-v/src/c906/c906_start.c
index 1b58cf4..0248374 100644
--- a/arch/risc-v/src/c906/c906_start.c
+++ b/arch/risc-v/src/c906/c906_start.c
@@ -59,7 +59,6 @@
  */
 
 uintptr_t g_idle_topstack = C906_IDLESTACK_TOP;
-volatile bool g_serial_ok = false;
 
 /****************************************************************************
  * Public Functions
@@ -115,8 +114,6 @@ void __c906_start(uint32_t mhartid)
 
   showprogress('B');
 
-  g_serial_ok = true;
-
   /* Do board initialization */
 
   c906_boardinitialize();
diff --git a/arch/risc-v/src/common/riscv_cpustart.c b/arch/risc-v/src/common/riscv_cpustart.c
index e6984ad..abc2086 100644
--- a/arch/risc-v/src/common/riscv_cpustart.c
+++ b/arch/risc-v/src/common/riscv_cpustart.c
@@ -42,16 +42,6 @@
 #include "chip.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-extern volatile bool g_serial_ok;
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -76,12 +66,6 @@ void riscv_cpu_boot(int cpu)
       return;
     }
 
-  /* Wait for g_serial_ok set by cpu0 when booting */
-
-  while (!g_serial_ok)
-    {
-    }
-
   /* Clear machine software interrupt for CPU(cpu) */
 
   putreg32(0, (uintptr_t)RISCV_CLINT_MSIP + (4 * cpu));
diff --git a/arch/risc-v/src/k210/k210_start.c b/arch/risc-v/src/k210/k210_start.c
index f915952..51993e8 100644
--- a/arch/risc-v/src/k210/k210_start.c
+++ b/arch/risc-v/src/k210/k210_start.c
@@ -53,7 +53,6 @@
  */
 
 uintptr_t g_idle_topstack = K210_IDLESTACK0_TOP;
-volatile bool g_serial_ok = false;
 
 /****************************************************************************
  * Public Functions
@@ -109,8 +108,6 @@ void __k210_start(uint32_t mhartid)
 
   showprogress('B');
 
-  g_serial_ok = true;
-
   /* Do board initialization */
 
   k210_boardinitialize();
diff --git a/arch/risc-v/src/mpfs/mpfs_start.c b/arch/risc-v/src/mpfs/mpfs_start.c
index bf764d8..398659d 100755
--- a/arch/risc-v/src/mpfs/mpfs_start.c
+++ b/arch/risc-v/src/mpfs/mpfs_start.c
@@ -61,7 +61,6 @@
  */
 
 uintptr_t g_idle_topstack = MPFS_IDLESTACK_TOP;
-volatile bool g_serial_ok = false;
 
 /* Default boot address for every hart */
 
@@ -159,8 +158,6 @@ void __mpfs_start(uint32_t mhartid)
 
   showprogress('B');
 
-  g_serial_ok = true;
-
   /* Do board initialization */
 
   mpfs_boardinitialize();