Skip to content
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

edtlib: link child nodes to parent for nodes with child-bindings #62417

Merged
merged 4 commits into from Oct 26, 2023

Conversation

fabiobaltieri
Copy link
Member

@fabiobaltieri fabiobaltieri commented Sep 7, 2023

Hi, this is pretty much a reiteration of #55657. At the time I did not realize that it was actually fixing an issue and dropped it, but now that we have ordinals in the device init sequence it's pretty clear that not doing this is an issue.

Example of the problem:

Before:

$ west build -p -b nrf52840dk_nrf52840 samples/drivers/led_pwm -DCONFIG_LED_INIT_PRIORITY=50
...
ERROR: /pwmleds POST_KERNEL 50 68 < /soc/pwm@4001c000 POST_KERNEL 50 69

b

After:

$ west build -p -b nrf52840dk_nrf52840 samples/drivers/led_pwm -DCONFIG_LED_INIT_PRIORITY=50
<builds fine>
$ ./scripts/build/check_init_priorities.py -vv
...
INFO: /pwmleds POST_KERNEL 50 69 > /soc/pwm@4001c000 POST_KERNEL 50 68

a

In the first case, the missing dependency is causing the ordinal of pwmleds devices to be lower than the pwm one that they depend on, that means that if they were set with the same level and priority, they would initialize in the incorrect order.

Also tested on https://github.com/zephyrproject-rtos/zephyr-testing/tree/vfabio-edt-child-branch (two unrelated breakages there that don't show up on the main repo for some reason)

@fabiobaltieri
Copy link
Member Author

fabiobaltieri commented Sep 8, 2023

@gmarull note the first two patches moves around few pinctrl nodes for ite and psoc6, this is necessary to avoid circular dependencies, could not really find any better solution to avoid that and keep those nodes under the same parent. It's not really a problem since the pin definition have no actual driver but the script does not know about that.

dts/riscv/ite/it81xx2.dtsi Outdated Show resolved Hide resolved
dts/arm/cypress/psoc6.dtsi Outdated Show resolved Hide resolved
scripts/build/check_init_priorities.py Outdated Show resolved Hide resolved
gmarull
gmarull previously approved these changes Sep 13, 2023
Comment on lines 2058 to 2059
Link node properties to parent_node. Iterates over child nodes
recursively if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of the function is not clear from its name and docstring; can you please expand this? The arguments are parent_node and node but the caller is passing node, node. This feels confusingly written and the scope is a bit muddy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I've renamed functions and variables, added few commments, reworded the function comment and added a wrapper for the first call. Let me know if that's clear enough.

scripts/dts/python-devicetree/src/devicetree/edtlib.py Outdated Show resolved Hide resolved
gmarull
gmarull previously approved these changes Sep 14, 2023
@fabiobaltieri
Copy link
Member Author

@gmarull sorry I just re-reworded the comments. :-)

gmarull
gmarull previously approved these changes Sep 14, 2023
@fabiobaltieri
Copy link
Member Author

rebased (merge conflict in scripts/build/check_init_priorities_test.py)

gmarull
gmarull previously approved these changes Sep 21, 2023
Refactor the pinctrl nodes slightly so that the port devices are not
child of the main pinctrl node. This is because the pinctrl node is
being used as parent for pinctrl setting nodes itself, and having the
port nodes as child end up creating a circular depdency with the edt
child enumeration patch.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Refactor the pinctrl nodes slightly so that the port devices are not
child of the main pinctrl node. This is because the pinctrl node is
being used as parent for pinctrl setting nodes itself, and having the
port nodes as child end up creating a circular depdency with the edt
child enumeration patch.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The current EDT graph logic only use properties directly under a
specific node to add dependencies. For nodes properties in
child-bindings, this means that the child phandles are only linked by
the child node itself, which does have an ordinal but no corresponding
"sturct device" in the code, causing those dependencies to be silently
ignored by gen_handles.py.

Fix that by adding the recursive logic to visit child bindings when
present, which causes all child node property handles to be linked to
the parent node.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Now that child nodes are handled by edtlib there's no need to parse
child nodes in check_init_priorities anymore.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
@fabiobaltieri
Copy link
Member Author

one more conflict, rebase again, @mbolivar-ampere ping

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 bot re-approval

@fabiobaltieri
Copy link
Member Author

@mbolivar-ampere ping

@mbolivar-ampere mbolivar-ampere merged commit 73d5ecc into zephyrproject-rtos:main Oct 26, 2023
30 checks passed
@fabiobaltieri fabiobaltieri deleted the edt-childs branch November 14, 2023 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants