-
Notifications
You must be signed in to change notification settings - Fork 8.2k
init: add sub-priority to internal ordering #60410
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: add sub-priority to internal ordering #60410
Conversation
Generate a zero padded variant of `_ORD` that is suitable for use in linker scripts with the `SORT` property, so that `6` is correctly placed before `24`, and so on. Signed-off-by: Jordan Yates <[email protected]>
Add a sub-priority field to `Z_INIT_ENTRY_SECTION`, which is used to ensure that multiple drivers running at the same init priority still run in an order that respects their devicetree dependencies. This is primarily useful when multiple instances of the same device are instantiated that can depend on each other, for example power domains and i2c muxes. Signed-off-by: Jordan Yates <[email protected]>
Add tests for sorting devices at the same init priority based on their devicetree ordinals. Signed-off-by: Jordan Yates <[email protected]>
Add basic testing of the new `DT_DEP_ORD_STR_SORTABLE` macro. Signed-off-by: Jordan Yates <[email protected]>
fabiobaltieri
left a comment
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.
@JordanYates could you update https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/build/check_init_priorities.py#L68 to parse the new format and compare/print it properly? (there's also some unit tests https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/build/check_init_priorities_test.py and an integration test that somehow is still working https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/misc/check_init_priorities)
Update the script to parse the new section naming. The ordering type is converted from an integer to a tuple, which still compares correctly due to the elementwise behaviour of tuple comparison. Signed-off-by: Jordan Yates <[email protected]>
Fix the test script for the changes made to section naming. Signed-off-by: Jordan Yates <[email protected]>
fabiobaltieri
left a comment
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.
Thanks for the extra fixes!
tests/misc/check_init_priorities/validate_check_init_priorities_output.py
Show resolved
Hide resolved
andyross
left a comment
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.
Seems reasonable, but also seems worth pointing out that this is yet more code we're adding to make up for our lack of proper dependency tracking on static devices...
Totally agree, but as a minimal internal change with no effect on the API that solves a real problem I think it is worth it |
+1, the init problem® won't be easy to solve. For example, all the flexibility we've given with SYS_INIT is now hitting us hard. |
I'd be surprised at this point if someone comes up with a obviously perfect solution, but for now I think these progressive changes are moving in the right direction. I'm thinking, this takes care of same-level, the build time checking does multiple-level, @bjarki-trackunit were you looking into printing the init call sequence in #55654 (comment)? I'm thinking that having an init sequence printer could be used by subsystem tests and downstream application to compare the final init sequence with a golden sample so that any change gets caught and manually reviewed. That'd be a pretty solid system IMO. |
|
@JordanYates I linked this up in #release on Discord and it's been pointed out that since it's been a hot topic recently, it may be worth running it through the Architecture WG before hitting the merge button (@carlescufi). Any chance you could talk about it? Happy to help out if the time zone is a problem btw. Tagging as DNM for now. |
|
I don't think the change is controversial enough to require me to personally argue its merits 🙂 1am is a high bar. If you are happy to introduce the topic that's good enough for me. |
Yeah well, you never know, but I think the same. Happy to present on your behalf at the next WG then, @gmarull will you be there as well? |
I'll be there, but TBH, I'd just go ahead and merge. This is not really a substantial change, just resolves some issues present in the current implementation. |
dkalowsk
left a comment
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 pretty clean!
Honestly, an LTO plugin seems increasingly more appealing these days .. |
|
Architecture WG:
|
Following #60410, the NXP S32 external interrupt controller device initializes after the core interrupt controller. Bump the NXP S32 intc init level to initialize after the core intc and before the GPIO device driver. Fixes #61218 Signed-off-by: Manuel Argüelles <[email protected]>
Add a sub-priority field to
Z_INIT_ENTRY_SECTION, which is used toensure that multiple drivers running at the same init priority still
run in an order that respects their devicetree dependencies.
This is primarily useful when multiple instances of the same device are
instantiated that can depend on each other, for example power domains
and i2c muxes.
After this PR, an init level now runs all
SYS_INIT/DEVICE_DEFINEmacros first,then
DEVICE_DT_DEFINEmacros in order of devicetree ordinals.Linker section names now look something like this:
Resolves #22545 for multiple instances of the same device