-
Notifications
You must be signed in to change notification settings - Fork 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
timer: start directly in init.c #74228
Conversation
|
||
/** | ||
* @brief Initialize system clock driver | ||
* @note This function is called by the kernel during system initialization. | ||
* It should not be called by application code. | ||
* @return 0 on success, negative errno code on fail | ||
*/ | ||
int init_sys_clock_driver(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.
this prototype should likely not be exposed in the docs, otherwise it may seem like a public API (even if stated it's not like that).
Ideally we should have an internal level of headers, where APIs to be consumed by Zephyr could be exposed to the Kernel/arch/soc code, but not to the application.
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.
fully agree.
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.
Also, should we prefix these with z_
? To avoid any init_
name collisions and to make it clearer that these aren't supposed to be called by the application.
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.
yeah, I am working my way through all of this and already thinking about a unified prefix for all those initialization calls. we now have a mix of z_
, init_
, ..._init()
etc.
This PR is just trying to show the potential of how we could fix mis-use of SYS_INIT and reduce the boot dependency problem to something manageable.
The commit message fails to say why this needs to be changed, it would be nice to mention that. |
6e7503b
to
a2b9988
Compare
done :) |
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.
CONFIG_SYSTEM_CLOCK_INIT_PRIORITY Can be removed as well from drivers/timers/Kconfig
@@ -666,6 +667,7 @@ FUNC_NORETURN void z_cstart(void) | |||
arch_smp_init(); | |||
#endif | |||
z_sys_init_run_level(INIT_LEVEL_PRE_KERNEL_2); | |||
init_sys_clock_driver(); |
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.
Perhaps invert these 2 lines?
clock priority is 0, so started as one of the very first of PRE_KERNEL_2
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.
yeah, we should not be far away from getting rid of PRE_KERNEL_2 anyways :)
Do not use SYS_INIT, directly call init_sys_clock_driver() during the init process. The system timer driver is not a traditional driver and its dependencies are fixed. It is needed at a fixes location during the boot process and is not something you want to change or tamper with. Any change to where the timer is started might have negative consquences and non-functioning system. Thus, call this "driver" and initialize it at a fixed location and avoid the SYS_INIT use. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
a2b9988
to
981f6c7
Compare
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Do not use SYS_INIT, directly call init_sys_clock_driver() during the
init process.
Signed-off-by: Anas Nashif anas.nashif@intel.com