-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[DNM][WIP][do not review yet]Service and Device initialization: automatic priorities #79340
Open
tbursztyka
wants to merge
31
commits into
zephyrproject-rtos:main
Choose a base branch
from
tbursztyka:init_auto_prio
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,635
−4,061
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tbursztyka
requested review from
Kludentwo,
loicpoulain,
nandojve,
mniestroj,
softwarecki,
thedjnK,
nordic-krch,
katsuster,
albertofloyd,
dcpleung,
henrikbrixandersen,
ydamigos,
andy-liu-telink,
danieldegrasse,
soburi,
sylvioalves,
karstenkoenig,
jukkar,
GTLin08,
lorc,
firscity,
aaillet,
julius-barendt,
ssekar15,
parthitce,
yonsch,
carlescufi,
Mani-Sadhasivam,
anangl and
nashif
as code owners
October 2, 2024 19:57
Run after Kconfig and DTS, so it can build up on top of the edt object. Thus filling in any gap left by Kconfig and DTS. Signed-off-by: Tomasz Bursztyka <[email protected]>
All service or device init files added to any valid CMakeLists.txt will now be used to generate include/zephyr/generated/zinit.h header file, with computed priorities. Signed-off-by: Tomasz Bursztyka <[email protected]>
It provides useful macros to manipulate generated ZINIT_ macros from gen_init_priorities.py script. Signed-off-by: Tomasz Bursztyka <[email protected]>
The sub-prio is entirely removed, as the new macros will bring uniquely computed priorities. This is seamless: none of this is of public API, so no deprecation and macro replacement is necessary at this stage. Signed-off-by: Tomasz Bursztyka <[email protected]>
Now that priorities are automatically computed, and mostly coming from DTS, it can easily go beyond 99. Actually, this arbitrary limit of 99 in level sections has no real meaning anymore (if it ever had any). Signed-off-by: Tomasz Bursztyka <[email protected]>
This is an optional commit, but it makes things slightly easier to read in zephyr.map. Signed-off-by: Tomasz Bursztyka <[email protected]>
SERVICE_INSTANCE_INIT_ONCE is a direct replacement for SYS_INIT_NAMED, removing the priority parameter as it is now provided by gen_init_priorities.py script. No alias will be created for SYS_INIT as we seek to limit the usage of SERVICE_INSTANCE_INIT_ONCE, on the contrary to SYS_INIT which got widely abused in the past. Signed-off-by: Tomasz Bursztyka <[email protected]>
In order to get rid of the manually inserted initialization priority, device object generation need new macros. Until now, 2 set of macros have co-existed because of legacy support. Indeed, devices used to be created fully manually before devicetree introduction. Once devicetree appeared, DT based macros were added. Now is the time to get rid of such difference, and have a unique macro for creating device objects. So instead of DEVICE_DEFINE() and DEVICE_DT_DEFINE() there will be DEVICE_INSTANCE(). Instead of DEVICE_DT_INST_DEFINE() there will be DEVICE_INSTANCE_FROM_DT_INST(). Instead of DEVICE_GET() and DEVICE_DT_GET(), there will be DEVICE_INSTANCE_GET(). Same for DEVICE_INIT_DT_GET() and DEVICE_INIT_GET(), there will be DEVICE_INIT_ENTRY_GET() In the future step of deprecating old macros, these are then identified: - DEVICE_DEFINE - DEVICE_DT_DEFINE - DEVICE_GET - DEVICE_DT_GET - DEVICE_INIT_DT_GET - DEVICE_INIT_GET - DEVICE_NAME_GET() could be replaced by DEVICE_INSTANCE_NAME()) - DEVICE_DT_NAME_GET() could be replaced by DEVICE_INSTANCE_NAME()) - DEVICE_DECLARE() could be replaced as well And probably some more, thus reducing the amount of macros which would help to clean-up the header and have a more concise set. The difference is now that priority parameter is removed, as well as the name parameter (originaly from DEVICE_DEFINE legacy macro). In this case it is just simpler to reuse the "unique token" dev_id. Because of the dependency being fully computed _prior_ to building zephyr, these new macros do not support CONFIG_DEVICE_DEPS anymore. This feature was never really used anywhere and is a legacy thing. So new macros do not accept variable arguments. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to DEVICE_INSTANCE and DEVICE_INSTANCE_FROM_DT_INST, thus merging former DEVICE_DEFINE and DEVICE_DT_DEFINE into one, so removing the name parameter from the earier and finally removing the prio parameter on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to DEVICE_INSTANCE and DEVICE_INSTANCE_FROM_DT_INST, thus merging former DEVICE_DEFINE and DEVICE_DT_DEFINE into one, so removing the name parameter from the earier and finally removing the prio parameter on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to DEVICE_INSTANCE and DEVICE_INSTANCE_FROM_DT_INST, thus merging former DEVICE_DEFINE and DEVICE_DT_DEFINE into one, so removing the name parameter from the earier and finally removing the prio parameter on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
In order to get rid of the manually inserted initialization priority, device object generation need new macros. Again removing the prio parameter. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to SENSOR_DEVICE_INSTANCE and SENSOR_DEVICE_INSTANCE_FROM_DT_INST, thus removing the prio parameter on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter. Managing the ident as a DT node-id or dev_id helps to reduce the number from 12 to 7 macros. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to NET_DEVICE_INSTANCE, NET_DEVICE_INSTANCE_FROM_DT_INST, NET_DEVICE_INSTANCE_MULTI, NET_DEVICE_INSTANCE_MULT_FROM_DT_INST, NET_DEVICE_OFFLOAD_INSTANCE and NET_DEVICE_OFFLOAD_INSTANCE_FROM_DT_INST. Thus removing prio and name parameters on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio and name parameters. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to ETH_NET_DEVICE_INSTANCE, ETH_NET_DEVICE_INSTANCE_FROM_DT_INST and ETH_NET_DEVICE_INSTANCE_MULTI. Thus removing prio and name parameters on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to NET_DEVICE_INSTANCE, NET_DEVICE_INSTANCE_FROM_DT_INST, NET_DEVICE_INSTANCE_MULTI, NET_DEVICE_INSTANCE_MULT_FROM_DT_INST, NET_DEVICE_OFFLOAD_INSTANCE and NET_DEVICE_OFFLOAD_INSTANCE_FROM_DT_INST. Thus removing prio and name parameters on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to CAN_DEVICE_INSTANCE and CAN_DEVICE_INSTANCE_FROM_DT_INST relevantly. Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to SMBUS_DEVICE_INSTANCE and SMBUS_DEVICE_INSTANCE_FROM_DT_INST relevantly. Signed-off-by: Tomasz Bursztyka <[email protected]>
Lone files that define their own wrapper macro on top of formely DEVICE_DT_DEFINE macros. Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to I2C_DEVICE_INSTANCE and I2C_DEVICE_INSTANCE_FROM_DT_INST relevantly. Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter. However, original macro does not seem to be used anywhere... Signed-off-by: Tomasz Bursztyka <[email protected]>
Again removing the prio parameter. And switching the unique macro call in drivers. Signed-off-by: Tomasz Bursztyka <[email protected]>
Switching to DEVICE_INSTANCE and DEVICE_INSTANCE_FROM_DT_INST, thus merging former DEVICE_DEFINE and DEVICE_DT_DEFINE into one, so removing the name parameter from the earier and finally removing the prio parameter on all. Signed-off-by: Tomasz Bursztyka <[email protected]>
A few test and samples require explicit dependency resolution as the devices they introduce do not have any DTS counter-part. Signed-off-by: Tomasz Bursztyka <[email protected]>
tbursztyka
force-pushed
the
init_auto_prio
branch
from
October 3, 2024 18:23
fa9b7cf
to
2892bda
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT REVIEW YET (I just need to see first what CI will find out, my potato PC cannot run the whole test suites)
This is a fix for #76937 after discussing on the RFC #73836
I applied most comments made during these discussion.
Added to this I (tried to) switch most device macro calls to new ones. Which make this PR a huge one in files touched and modified lines. There are few corner cases which prevent changes: PTP and ethernet's DSA. These needs to switch to DTS.
Last but not least: brace for impact /o\