-
Notifications
You must be signed in to change notification settings - Fork 8.2k
devicetree: add dependency information to edtlib #19454
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
Conversation
|
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
pizi-nordic
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.
I fully support all work towards proper handling of dependencies in Zephyr :)
|
FYI: @barsok |
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.
Some nits and a defaultdict tip.
Feels like a simpler algo might be possible if all that's needed is ordering + dependency loop detection, but shouldn't hurt at least.
scripts/dts/edtlib.py
Outdated
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.
Accidental blank line.
scripts/dts/edtlib.py
Outdated
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.
Could call it init_order maybe, to give a better hint about what it's about. I like it better than init_ordinal, even if the node would never get initialized.
scripts/dts/grutils.py
Outdated
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.
Could have add_edge(self, source, target), etc., to be consistent with the rest of the code.
scripts/dts/grutils.py
Outdated
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.
Could use a set literal:
self.__roots = {root}
scripts/dts/edtlib.py
Outdated
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.
Could rephrase to be less academicy maybe.
scripts/dts/grutils.py
Outdated
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.
Instead of reset, maybe there could be an internal _dirty flag or the like that gets set whenever the graph is updated.
Wonder if the caching here might be a bit overkill though.
scripts/dts/grutils.py
Outdated
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.
Rest of the code uses format(), which is a bit less quirky. Makes it easier to switch to f-strings later too.
scripts/dts/edtlib.py
Outdated
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.
If the raise Exception within tarjan() is kept, then it should be transformed into an EDTError exception here, so that the library consistently raises that.
scripts/dts/testedtlib.py
Outdated
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.
Missing space before not.
|
@ulfalizer OK, done with updates, please re-check. Many of your comments (style, features) are due to "grutil" being derived from a more general dependency module I wrote in Python 2 over ten years ago. I've done what I can to convert the code to your preferred style. One thing I have not done is changed the term I don't want to call this "init(ialization) order" because that's not what it is. Zephyr partitions initialization into four phases: There is a relation between initialization order and the partial order defined by dependencies, and that order should ultimately be provided by the devicetree scripting, but it won't be the same as this order. I also don't want to call the Node attribute "order" because that's not what it is either. It's the position of a node within a sequence, i.e. its ordinal. |
What about something like Personally, I try hard to avoid using a word/term when I suspect most people might not know what it means. It's a bit more effort and less auto-pilot, but can make stuff more efficient for people reading the code. |
34cf70a to
b2abb50
Compare
|
@ulfalizer ok exception handling and attribute rename done. |
ulfalizer
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.
Markup in docstrings and __ variables aren't used elsewhere, so that's a bit inconsistent, but not super important.
|
Remembered another thing. Might be good to generate edges for |
|
Rebased and updated generated text to be consistent with new documentation format: |
Device tree nodes have a dependency on their parents, as well as other nodes. To ensure driver instances are initialized in the proper we need to identify these dependencies and construct a total order on nodes that ensures no node is initialized before something it depends on. Add a Graph class that calculates a partial order on nodes, taking into account the potential for cycles in the dependency graph. When generating devicetree value headers calculate the dependency graph and document the order and dependencies in the derived files. In the future these dependencies may be expressed in binding data. Signed-off-by: Peter A. Bigot <[email protected]>
Device tree nodes have a dependency on their parents, as well as other nodes. To ensure driver instances are initialized in the proper we need to identify these dependencies and construct a total order on nodes that ensures no node is initialized before something it depends on.
Add a Graph class that calculates a partial order on nodes, taking into account the potential for cycles in the dependency graph.
When generating devicetree value headers calculate the dependency graph and document the order and dependencies in the derived files. In the future these dependencies may be expressed in binding data.
Example of content added by this: