You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/07 08:24:25 UTC
[GitHub] [incubator-nuttx] masayuki2009 opened a new pull request, #7252: Riscv smp mmu
masayuki2009 opened a new pull request, #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252
## Summary
- This commit adds SMP support for BUILD_KERNEL
## Impact
- RISC-V: BUILD_KERNEL + SMP only
## Testing
- Tested with QEMU 6.2
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990568619
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
sure
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r989921215
##########
arch/risc-v/src/common/riscv_cpustart.c:
##########
@@ -38,8 +38,21 @@
#include "sched/sched.h"
#include "init/init.h"
#include "riscv_internal.h"
+
+#ifdef CONFIG_BUILD_KERNEL
+# include "riscv_mmu.h"
+#endif
+
#include "chip.h"
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef CONFIG_BUILD_KERNEL
+extern uintptr_t g_kernel_pgt_pbase;
Review Comment:
@xiaoxiang781216
I think `riscv_mmu.h` might be better.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #7252: Riscv smp mmu
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#issuecomment-1271282788
@xiaoxiang781216
I think this PR is much simpler than #7247
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990331657
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
@xiaoxiang781216
Let me consider it later but I think we should do that in another PR.
What do you think?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990015140
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
In this case, should we let the secondary core wait the IPI before running any useful code? So, all many places can share the code path for primary and secondary core except one time initialization which just need be done for primary core.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990030405
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
@xiaoxiang781216
In RISC-V with BUILD_KERNEL case, IPI send/receive sequence can be done in S-mode.
However, some code initialization must be done in M-mode on each CPU as well before entering S-mode.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r989927588
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
@xiaoxiang781216
Because the per CPU areas exist in BSS and the areas are cleared by CPU0, so non-primary CPUs should call `riscv_percpu_add_hart(mhartid)` after the IPI received in `riscv_cpu_boot()` .
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r989902382
##########
arch/risc-v/src/common/riscv_cpustart.c:
##########
@@ -38,8 +38,21 @@
#include "sched/sched.h"
#include "init/init.h"
#include "riscv_internal.h"
+
+#ifdef CONFIG_BUILD_KERNEL
+# include "riscv_mmu.h"
+#endif
+
#include "chip.h"
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef CONFIG_BUILD_KERNEL
+extern uintptr_t g_kernel_pgt_pbase;
Review Comment:
should we put to the riscv_internal.h
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
should we do riscv_percpu_add_hart for all core not only he first one
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990030405
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
@xiaoxiang781216
In RISC-V with BUILD_KERNEL case, IPI send/receive sequence via `up_cpu_start()` can be done in S-mode.
However, some code initialization must be done in M-mode on each CPU as well before entering S-mode.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990052145
##########
arch/risc-v/src/common/riscv_cpustart.c:
##########
@@ -38,8 +38,21 @@
#include "sched/sched.h"
#include "init/init.h"
#include "riscv_internal.h"
+
+#ifdef CONFIG_BUILD_KERNEL
+# include "riscv_mmu.h"
+#endif
+
#include "chip.h"
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef CONFIG_BUILD_KERNEL
+extern uintptr_t g_kernel_pgt_pbase;
Review Comment:
Done.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #7252: Riscv smp mmu
Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#issuecomment-1271281032
See the original discussion in https://github.com/apache/incubator-nuttx/pull/7247
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990015140
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
In this case, should we let the secondary core wait the IPI before running any useful code? So, many places can share the code path for primary and secondary core except one time initialization which just need be done for primary core.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7252: RISC-V: BUILD_KERNEL + SMP
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7252:
URL: https://github.com/apache/incubator-nuttx/pull/7252#discussion_r990185619
##########
arch/risc-v/src/qemu-rv/qemu_rv_start.c:
##########
@@ -144,13 +146,22 @@ void qemu_rv_start(int mhartid)
#ifdef CONFIG_BUILD_KERNEL
+/****************************************************************************
+ * Name: qemu_rv_start_s
+ ****************************************************************************/
+
void qemu_rv_start_s(int mhartid)
{
- qemu_rv_clear_bss();
+ /* NOTE: still in M-mode */
- /* Initialize the per CPU areas */
+ if (0 == mhartid)
+ {
+ qemu_rv_clear_bss();
+
+ /* Initialize the per CPU areas */
- riscv_percpu_add_hart(mhartid);
+ riscv_percpu_add_hart(mhartid);
Review Comment:
Can we do the initialization in assembly code and then wait the IPI before enter the C?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org