pussuw commented on code in PR #5985:
URL: https://github.com/apache/incubator-nuttx/pull/5985#discussion_r844915323
##########
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:
_please use flags instead_ I don't know what you mean by flags. Can you give
an example ?
I think having the init function and sl list is fine, as it also allows
releasing a CPU. There are many other init functions that are called from the
chip specific start routines, so I did not think this would be so different
from those. And yes, `__mpfs_start()` must be fixed to work with SMP. All other
init routines are also executed on all harts too, so currently with SMP calling
`__mpfs_start()` will fail miserably.
Using, the global variable then leaves the stack unallocated, and a similar
mechanism would be needed for that, so it would converge into something like
this:
uintptr_t g_init_index;
lock();
riscv_percpu_t *percpu = &g_percpu[g_init_index++];
unlock();
That implementation is something I tried to avoid by using sl list.
--
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]