-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arch: riscv: fix hangup of multicore boot #65000
arch: riscv: fix hangup of multicore boot #65000
Conversation
This patch fixes hangup of RISC-V multicore boot. Currently boot sequence uses a riscv_cpu_wake_flag to notify wakeup request for secondary core(s). But initial value of riscv_cpu_wake_flag is undefined, so current mechanism is going to hangup if riscv_cpu_wake_flag and mhartid of secondary core have the same value. This is an example situation of this problem: - hart1: check riscv_cpu_wake_flag (value is 1) and end the loop - hart1: set riscv_cpu_wake_flag to 0 - hart0: set riscv_cpu_wake_flag to 1 hart0 expects it will be changed to 0 by hart1 but it has never happened Note: - hart0's mhartid is 0, hart1's mhartid is 1 - hart0 is main, hart1 is secondary in this example Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @katsuster , I'm sorry for such a late comment on your change. Could you please clarify:
|
Hello @amr-sc, Thanks your comment. I think there is same problem even if riscv_cpu_wake_flag has initial value -1. If someone reset the CPUs after overwriting riscv_cpu_wake_flag area (and unfortunately the value of it is same as one of |
Hello @katsuster , thank you very much for your fast reply! The issue you are highlighting here is very interesting. I was thinking that DATA section is always initialized before we start to execute the Zephyr code, since it is getting copied together with the TEXT to DDR. And the only race condition (on my system it is exactly the case) is possible when we initialize BSS from Primary core. So I'm a bit confused. Could you please clarify the target scenario where we can have a DATA section race condition? P.S.: to me it seems like current Zephyr RISC-V implementation is not ready for such scenario, e.g. we don't even have a code to copy DATA section for a single core.. |
Hello @arm-sc, DATA section is copied and initialized by other boot loader before Zephyr running. If in this mode, using DATA section to set initial value to boot_flag is simple and nice solution. But Zephyr also supports execution in place (XIP) mode by CONFIG_XIP = y. In this mode DATA section is stored in ROM and it is readonly. The kernel copy data from ROM to RAM in boot time. RISC-V case: If you have interest, please check CONFIG_XIP and z_data_copy() function at kernel/xip.c. |
Hi @katsuster, I didn't know about that functionality. Thanks a lot for flashing a light on it! |
This patch fixes hangup of RISC-V multicore boot.
Currently boot sequence uses a riscv_cpu_wake_flag to notify wakeup request for secondary core(s).
But initial value of riscv_cpu_wake_flag is undefined, so current mechanism is going to hangup if riscv_cpu_wake_flag and mhartid of secondary core have the same value.
This is an example situation of this problem:
Note: