xiaoxiang781216 commented on code in PR #5985:
URL: https://github.com/apache/incubator-nuttx/pull/5985#discussion_r844266512
##########
arch/risc-v/src/common/riscv_percpu.c:
##########
@@ -120,3 +152,24 @@ uintptr_t riscv_percpu_get_hartid(void)
return ((struct riscv_percpu_s *)scratch)->hartid;
Review Comment:
replace all "struct riscv_percpu_s" with "riscv_percpu_t"
##########
arch/risc-v/src/common/riscv_percpu.c:
##########
@@ -86,13 +92,39 @@ void riscv_percpu_init(void)
void riscv_percpu_add_hart(uintptr_t hartid)
{
- /* Hart IDs go from 0...4 */
+ riscv_percpu_t *percpu;
+ uintptr_t stack_top;
+
+ /* Get free entry for this hart, this must not fail */
+
+ percpu = (riscv_percpu_t *)sq_remfirst(&g_freelist);
Review Comment:
why need allocate from g_freelist, we can simplify to:
1. Remove g_freelist and riscv_percpu_t::next
2. Remove riscv_percpu_init
3. Access the new percpu_t instance by g_percpu[hartid]
##########
arch/risc-v/src/common/riscv_percpu.c:
##########
@@ -86,13 +92,39 @@ void riscv_percpu_init(void)
void riscv_percpu_add_hart(uintptr_t hartid)
{
- /* Hart IDs go from 0...4 */
+ riscv_percpu_t *percpu;
+ uintptr_t stack_top;
+
+ /* Get free entry for this hart, this must not fail */
+
+ percpu = (riscv_percpu_t *)sq_remfirst(&g_freelist);
+ DEBUGASSERT(percpu);
+
+ /* Get interrupt stack (if any) */
+
+ stack_top = 0;
Review Comment:
remove
##########
arch/risc-v/src/common/riscv_percpu.c:
##########
@@ -86,13 +92,39 @@ void riscv_percpu_init(void)
void riscv_percpu_add_hart(uintptr_t hartid)
{
- /* Hart IDs go from 0...4 */
+ riscv_percpu_t *percpu;
+ uintptr_t stack_top;
+
+ /* Get free entry for this hart, this must not fail */
+
+ percpu = (riscv_percpu_t *)sq_remfirst(&g_freelist);
+ DEBUGASSERT(percpu);
+
+ /* Get interrupt stack (if any) */
+
+ stack_top = 0;
+
+#if CONFIG_ARCH_INTERRUPTSTACK > 15
+#if CONFIG_SMP_NCPUS > 1
+ /* Calculate offset first (stack size * hartid) */
- DEBUGASSERT(hartid < HART_CNT);
+ stack_top = (uintptr_t)&g_intstacktop - (uintptr_t)&g_intstackalloc
+ stack_top = stack_top * hartid;
+ stack_top = (uintptr_t)&g_intstacktop - stack_top;
Review Comment:
stack_top = (uintptr_t)&g_intstacktop -
STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK) * hartid
##########
arch/risc-v/src/common/riscv_macros.S:
##########
@@ -29,6 +29,11 @@
#include <arch/arch.h>
#include <arch/irq.h>
+#include <sys/types.h>
Review Comment:
why need
##########
arch/risc-v/src/common/riscv_exception_common.S:
##########
@@ -28,8 +28,12 @@
#include <arch/irq.h>
#include <arch/mode.h>
+#include <sys/types.h>
Review Comment:
why need
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]