-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
init: per-core init hook #78496
init: per-core init hook #78496
Conversation
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.
I think calling z_riscv_pmp_init())
deep from SOC code is odd and wrong.
That ought to remain out of the SOC code's concern.
Similarly for IRQs.
7e95a68
to
d38858b
Compare
Reverted the implementation to align with #65824, is it better now? |
arch/riscv/Kconfig
Outdated
@@ -112,6 +112,12 @@ config RISCV_SOC_HAS_CUSTOM_SYS_IO | |||
the RISC-V SoC needs to do something different and more than reading and | |||
writing the registers. | |||
|
|||
config RISCV_SOC_HAS_CUSTOM_PER_CORE_INIT |
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.
this should not be riscv specific, the same pattern is use elsewhere, maybe such customization is used here first, but IMO this should be generalized to accomodate future usage by other arches, so I suggest doing this the same way we did it in include/zephyr/platform/hooks.h
and use a similar pattern.
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.
arch/riscv/core/smp.c
Outdated
@@ -28,6 +28,10 @@ extern void __start(void); | |||
void soc_interrupt_init(void); | |||
#endif | |||
|
|||
#ifdef CONFIG_RISCV_SOC_HAS_CUSTOM_PER_CORE_INIT | |||
void z_soc_per_core_init(void); |
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.
lets not add more z_soc...
code into the tree, just drop the z_
from the name, this can be confusing as it describes something internal to zephyr that should not be used outside of zephyr, what you are doing here is defining a new "interface", so it is an API somehow.
d38858b
to
7f3da46
Compare
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.
Looks reasonable. ACK for ARC part.
The function `pma_init_per_core()`, as its name suggest, should be run from every core, so call it from `soc_per_core_init_hook()` Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
Refactor out the `soc_early_init_hook()` function from `pma.c` to `soc.c` which is always compiled so that it can be extended to run other init functions easily in the future. Then, restore the function in `pma.c` to `pma_init()`. Signed-off-by: Yong Cong Sin <[email protected]>
b819176
7f3da46
to
b819176
Compare
Oops, good catch. I also refactored the |
Spinned-off from #65824, with an in-tree example of how it can be used.