-
Notifications
You must be signed in to change notification settings - Fork 8.2k
devicetree: Update generation/API #24769
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
mbolivar-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 really think we need to discuss this in detail with an issue that describes the impact on the API as discussed on slack.
what impact will this have on the API? This isn't related to "status". |
|
All checks are passing now. checkpatch (informational only, not a failure)Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
ioannisg
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.
This solves the problem of having new-style DT defines generated for nodes without the compatible property, which seems required in several cases. Looks fine to me, and I don't see any negative impact (but my DT expertise is limited)
pabigot
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'm OK with the change the PR is proposed to do, but not the secondary one that discards one of the main roles of compatible.
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 added these to /:
special = "this";
subspecial {
bar = "that";
};
The subordinate node was generated, but neither /special nor /subspecial/bar were generated
Is that what was intended? Generating the node without its properties seems odd; will this satisfy the need identified in #24460 (comment)
Here are some ways I find this PR leading to inconsistent or wrong results. Some of them do relate to status. DT_HAS_NODE()This is now returning true for any node that exists in the tree, regardless of whether it has status okay and a matching binding, which contradicts the docstring: I think that docstring is probably already wrong, since we just need status != "disabled", but that's because of the weird way we deal with status right now, which is maybe a bug now that I look at it. DT_NODE_HAS_PROP()This PR makes it possible to add a node (This is because edtlib refuses to initialize REG and IRQ APIsThese behave in inconsistent ways between themselves and depending on the status of the node. For example, if some node In other words, even though the API claims But if you disable the node using status, you can't read its reg anymore, and DT_REG_ADDR is a build error. Without this PR, things are more consistent. For example, Similar comments should apply to IRQ properties, though I didn't check explicitly. |
Though this may take a global search/replace on nodelabel-based device access in samples and drivers. |
|
I agree that the test cases should verify that this does what's expected. An example based on the use case it's supposed to solve would make this more compelling. The behavior now is just as I'd described at #24769 (review) except that I'm seeing a few more things generated as well (e.g. compatibles properties for the buttons and LEDs and a few other root nodes like @mbolivar not sure what specifically you want my view on. I would like |
|
@mbolivar-nordic are wanting this PR to handle both issues of generating properties for nodes w/o binding matches and the status change? |
They're interrelated IMO, given the way status can affect REG and IRQ with this change as I detailed in #24769 (comment)
Sound like you're just wanting it done by release and don't have a strong view on which PRs should have things done in. OK. |
scripts/dts/gen_defines.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.
So if we're moving to #25002, I think this should be removed too, right? We had discussed being able to read any property we have semantics for (at least 'reg' and 'interrupts') regardless of status.
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 also think things like compat2enabled in the EDT object may need changes, since we're changing the semantics of "enabled" in C to be status == "okay" instead of status != "disabled" and adding macros like DT_HAS_COMPAT_STATUS_OKAY in #25002. So it seems like we should be doing compat2statusokay or something instead.
In general I'm having trouble keeping all the pull requests together and I don't see enough Python changes to accompany all the C changes. What am I missing?
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 reworked how enabled was defined. If we want to leave that alone we can create a new 'available' which would be similar to the linux concept https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/of/base.c#n581
Why not just assign a default.yaml binding to active nodes without a binding. The binding can contain any property of above or just include base.yaml. The explicit addition of default properties in the current solution does not scale well and also makes edtlib.py less generic. |
If a devicetree node doesn't have a matching binding we will at least populate a common standard set of properties for that node. The list of standard properties is: compatible status reg reg-names label interrupt interrupts-extended interrupt-names interrupt-controller This allows us to handle cases like memory nodes that don't have any compatible property, we can still generate the reg values. We limit this to known properties as for any other property we can not fully determine the property type without a binding and thus we can't ensure the generation for that property is correct or may not change. Signed-off-by: Kumar Gala <[email protected]>
There are cases like having a reserved memory node that will not having a compatible string and thus will not match a binding. However we might set a chosen property like zephyr,sram or zephyr,ipc_shm to such a node. Thus we should generate defines for such nodes. Signed-off-by: Kumar Gala <[email protected]>
I was torn about this, since it makes an assumption about there being a specific file in one of the binding dirs. |
tests/lib/devicetree/src/main.c
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.
Leaving a comment here since we've merged ifdeffed out tests before, to make sure it doesn't happen this time
Change node.enabled from being True unless status = "disabled", to True if no status, status = "okay", or status = "ok". Signed-off-by: Kumar Gala <[email protected]>
This macro takes a node identifier and status value and returns 0 or 1 if the status property on the node referred to by the node identifier matches the status value passed. We also update DT_HAS_NODE_STATUS_OKAY to utilize DT_NODE_HAS_STATUS Signed-off-by: Kumar Gala <[email protected]>
If the specific binding file default.yaml is not found it does not hurt. If it is found it is available on purpose (like e.g. base.yaml) and the default properties will be generated. With the current solution you get the opposite situation - every user of edtlib.py gets the default properties generated. This may not be a problem within Zephyr but usability outside of Zephyr may be reduced. Using default.yaml gives a choice and does not reduce usability in any way. |
I've chosen a different strategy with a similar effect in #25009. Please have a look. |
|
I get the desire @b0661 and would say we can add some way to optionally extend the base set of properties if someone desires that. However, while I'm not super happy about hard coding a list of properties into EDT, I think its the most reasonable tradeoff for the set of properties that are defined as part of the base DTS spec. |
There are cases like having a reserved memory node that will not having
a compatible string and thus will not match a binding. However we might
set a chosen property like zephyr,sram or zephyr,ipc_shm to such a node.
Thus we should generate defines for such nodes.
Signed-off-by: Kumar Gala [email protected]