-
Notifications
You must be signed in to change notification settings - Fork 8.2k
init: remove the need for a dummy device pointer in SYS_INIT functions #51217
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: remove the need for a dummy device pointer in SYS_INIT functions #51217
Conversation
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.
Drop RFC from the PR title?
|
Since this commit SOF compilation with For exact reproduction steps stay tuned. |
OK that was really easy, nothing special required: Yet https://github.com/zephyrproject-rtos/zephyr/actions/runs/4678432008/jobs/8288559016 did not care. Twister used to compile with Twister also failed to catch this regression: #56701 (demoed again in #56791) |
|
Just spotted this sorry "NOTE: This is a breaking change! All SYS_INIT functions will need..." The 267 comments put me off. Still, dropping |
there is a PR submitted to SOF to deal with this. |
|
@gmarull any idea why SOF build are failing? I think this is related to your change. https://github.com/thesofproject/sof/actions/runs/4686511690/jobs/8304685904?pr=7429 |
|
@dbaluta for SOF the API change was submitted a long time ago by @gmarull here: Next time a similar situation arises, corresponding module changes like this one will hopefully be present in the module branch used by Zephyr first (and required by Zephyr CI). Among others this should preserve bisectability on both sides (as long as |
[PR#51217](zephyrproject-rtos#51217) changed the `init_entry` structure, but `Z_INIT_ENTRY_NAME` (called by `SYS_INIT` or `SYS_INIT_NAMED`) does not initialize all of the members of the struct, leading to errors when building with `-Werror=missing-field-initializers`. Change the macro to initialize the `dev` member to `NULL` so that all members of the struct are initialized. Signed-off-by: Paul Fagerburg <[email protected]>
As a breaking change, the update needs to happen in multiple steps here. First in Zephyr fork, then upstream, then sync Zephyr fork. I don't see any better way if we allow Zephyr glue code in modules that have an upstream counterpart and that are tested in Zephyr CI. |
[PR#51217](#51217) changed the `init_entry` structure, but `Z_INIT_ENTRY_NAME` (called by `SYS_INIT` or `SYS_INIT_NAMED`) does not initialize all of the members of the struct, leading to errors when building with `-Werror=missing-field-initializers`. Change the macro to initialize the `dev` member to `NULL` so that all members of the struct are initialized. Signed-off-by: Paul Fagerburg <[email protected]>
The upstream change zephyrproject-rtos/zephyr#51217 modified the function signature for the SYS_INIT call, eliminating the unused device pointer. Run the Zephyr provided script ./zephyr/scripts/utils/migrate_sys_init.py to update all callers. BUG=b:278595739 BRANCH=none TEST=zmake build -a Cq-Depend: chromium:4422804 Change-Id: I881bc536cef43a7c3ac4bc5eb3ce1893237bbd1f Signed-off-by: Keith Short <[email protected]> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4437049 Reviewed-by: Tristan Honscheid <[email protected]>
[PR#51217](zephyrproject-rtos/zephyr#51217) changed the `init_entry` structure, but `Z_INIT_ENTRY_NAME` (called by `SYS_INIT` or `SYS_INIT_NAMED`) does not initialize all of the members of the struct, leading to errors when building with `-Werror=missing-field-initializers`. Change the macro to initialize the `dev` member to `NULL` so that all members of the struct are initialized. (cherry picked from commit 04611a5) Original-Signed-off-by: Paul Fagerburg <[email protected]> GitOrigin-RevId: 04611a5 Change-Id: Id6fb67679e514fc6ca7139a7eecf461fc344df3e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4427441 Commit-Queue: Keith Short <[email protected]> Tested-by: CopyBot Service Account <[email protected]> Reviewed-by: Keith Short <[email protected]> Tested-by: Keith Short <[email protected]>
NOTE: This is a breaking change! All
SYS_INITfunctions will needto be converted to the new signature. See the script offered in c5c637c.
The init infrastructure, found in
init.h, is currently used by:SYS_INIT: to call functions beforemainDEVICE_*: to initialize devicesThey are all sorted according to an initialization level + a priority.
SYS_INITcalls are really orthogonal to devices, however, the requiredfunction signature requires a
const struct device *devas a firstargument. The only reason for that is because the same init machinery is
used by devices, so we have something like:
As a result, we end up with such weird/ugly pattern:
This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:
This is achieved using a union:
This solution does not increase ROM usage, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.
NOTE: This is a breaking change! All
SYS_INITfunctions will needto be converted to the new signature. See the script offered in c5c637c.