- Notifications
You must be signed in to change notification settings - Fork 8.2k
Add support for arbitrary PM constraint lists from DT and substate change notifier, refactor RW612 power domain #95441
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
Add support for arbitrary PM constraint lists from DT and substate change notifier, refactor RW612 power domain #95441
Conversation
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.
Child devices will resume their power domain, and the power domain locks the state. In which scenarios would the child device lock a state of another device? seems like a strong layering violation to have devices look into implementation details of other devices instead of just resuming them, which causes other devices to lock their states already (or do whatever they need to to remain powered)
You are right, but my intention though was not about actually changing what states are locked, but mostly the issue is related to this pm_policy_device_lock_is_disabling_state which now if the DTS is refactored so that the parent domain is has that info, then the function doesnt return the right value (true/false) for the child. For example if the parent will be disabled by a mode "suspend", then the child also obviously would be disabled by this mode "suspend" even if And to be clear, this is not changing anything if a device has this property already, only if it doesn't then it checks it's power domain parents based on the assumption that if the power domain parents are disabled then it will be too. And beyond just checking if a state will disable a device, as far as the locking mechanism itself - I agree with you that how it's supposed to work is that the power domain parent (in this context) should be the one that locks from entering the state and then the other devices don't need to do this due to as long as one of them is referenced/active then the parent should remain active. I completely understand that and agree. So since my goal wasn't actually to change this locking mechanism, should I change this code to uncouple the pm_policy_device_lock_is_disabling_state to not use the same constraint searching code as the other functions in this file ? I.e, still adding the "special" value of 0 size to indicate to look at the parent device but don't actually do it from the locking functions and only from this checking function (pm_policy_device_lock_is_disabling_state) |
I think the "child" device should just have the disabling states duplicated. Its not actually a child device of the power domain if it does not rely on the parent power domain for managing the soc states. If the parent power domain was used, the soc would never enter a disabling state while the child device is resumed, the power domain would inform the child device that an disabling state may be entered by the TURN_OFF action. |
Okay I considered just doing this but IMO this is what is the layering violation because now it needs to be known by whoever is writing that DT that this device driver has some special implementation that requires this property to be set on it's own node even though the information is redundant with the fact that obviously it would be disabled on a state that also disables the power-domain parent. And on top of this , the device driver implementation is not supposed to be special, it's using a generic subsystem API, which is not acting as expected IMO if it doesn't say for child devices that they will get disabled by a state that disables their power domain. |
The device would also obviously be disabled by the disabling states of the power domains parent power domain, and that grandparents power domain, are we going to store those with the device to? Power domains already solve this issue by walking up the chain. If this driver wants to do something different from what is already supported, then it is special, and it should be treated specially. This is not an issue common to the power management subsystem given we have support for power domains right? |
To be clear, this PR already does handle arbitrary amounts of grandparents, what it does is it goes until it finds the first node that has this zephyr,disabling-power-states property and uses that.
The driver is not doing anything special, it's just using the API which I linked above. Which when I do this DTS refactor causes the driver to get told
|
The API linked above is only used by one driver, and serves a niche purpose to accommodate pm device system managed. This PR is increasing the complexity of a part of device pm which we are actively working towards removing, pm device runtime and power domains already solves this issue, that's why I'm against this addition. So, 1. is actively moving in a direction which goes against transitioning to pm device runtime to solve a short term issue. 2. is closer to the status quo, if an soc has states which disable it, the states are added to the device. The disabling states can be moved to a power domain negating the need to define the states for the device, which can be more efficient. Having a power domain, not using it, and also not defining the disabling state for the device, is a mistake on the part of the dts writer, we should not add what is effectively error handling to PM, its complex enough as is. |
| @bjarki-andreasen I think the confusion here is about why is this device needing to check on if it is a disabling state. Because the point is not to support/accommodate system managed device PM. IIRC, the reason is because this device and some others on this chip actually do not lose function in a low power mode, even if the "domain" suspends, they dont turn off and actually continue operating. But the issue with this chip is that there is not really a coherent concept of domains in the hardware like the zephyr architecture is meant for, it's just a bunch of barely documented behaviors that are seemingly different for each peripheral on the chip. Some of them lose state at certain power mode, some of them still function, some of them retain state but dont function.... and it's not configurable or clear why or how (we mostly are figuring it out by reverse engineering)... So IIRC this UART is one of them that goes in a "low power" mode when system enters this "PM2" mode (associated to suspend in zephyr). In this case, the UART is not able to really do any send and transceive normally as far as I could tell but it could change clock source to some really slow like 1Hz clock which is the only one left active on the system in this mode, and be able to "receive" one bit/byte, and this activity can then be a wakeup cause of the chip. So what this driver is essentially saying is "if my normal function is going to be disabled, reconfigure my clock to the low power clock and configure me as wake up source" (zephyr,disabling-states). Whereas on "PM3" mode (associated to suspend), the UART just completely lose power and state and cannot be a wakeup. So we set the power-domain to this "PM3" domain which is currently just a stupid mechanism to be able to deliver an "OFF" action to all these devices which lose power and state from "standby" mode, and set "zephyr,disabling-states" as "suspend" (and standby technically, but irrelevant) so that it knows it loses function but can reconfigure itself as a wakeup... So do you have any idea about how to handle this problem which is that our device cannot only just be simply "disabled" or "enabled" but can also be in this type of low power mode that it needs to account for? Because from PM device callbacks alone, it's not enough here to handle that "PM2" case, we can handle this PM3 case to get the OFF action and know we will lose state but I am not sure how to differentiate for the "low power operation" case |
| And by the way, I am noticing this is a pretty common thing for us too - for power domains and devices to have not just a binary on/off state but actually different levels of operation (low power modes). Right now we only enabled this uart driver for it's low power mode because we wanted the shell to keep working on PM2 since many of our wifi samples (RW612 is basically mainly a wifi chip) were based on a shell |
Any part of the system, be that drivers, subsystems or applications, can register themselves using |
2211b7d to 5a74f66 Compare | @bjarki-andreasen based on your feedback I have completely changed the approach of this PR, so LMK if it is acceptable. You can see that technically I still have the issue of putting the |
yes, I think the idea will be that this "pm_policy_device_power_lock_get/put()" should only be called from the generic pm subsys code to prevent suspending/resuming of power domains / devices , and BTW, is the pm notifier change alright ? I was surprised it did not already report the substate, and I tried to make the change backwards compatible. I think it will be really important to be able to be told what substate we're going into going forward because my idea of the substates is that they will allow a lot of potential configurability of the hardware/device states that we need.
And also, what I meant by the "temporary approach" , is that, this uart driver is still using |
what I'm pointing out is that
Surprised me to, maybe the notifier was added before substates where or something
ah, got you |
5a74f66 to 1ce0960 Compare | last push addressed review comments, still need to add doc and testing and rebase |
1ce0960 to 5e8f336 Compare | rebased & resolve conflicts |
5e8f336 to d59d3c2 Compare | @bjarki-andreasen if you are ok with what is there now, then I will add doc and testing |
bjarki-andreasen 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.
Really nice, I think this is the way to go forward
d59d3c2 to 9e528c2 Compare 0e72e46 to e28a375 Compare I am surprised this notifier didn't already report the substate id, it seems important since different substate obviously are defined for a reason, they can be having a different effect on the system. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Some pieces of the system may have custom types of constraints that they define based on different effects and reasons than just the standard "zephyr,disabling-states". To avoid every single one of these component reinventing the wheel, make some common APIs to handle these type of custom constraint lists. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Refactor low power state handling to not tie to zephyr,disabling-states and define it's own separate "low power states" property in DT instead. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Update board to use default power domain for the "peripheral" domain, which when resumed prevents SoC from entering suspend and standby states as these power down peripherals. Note by co-author: Cherry-picked this commit and edited it to work without the generic domain refactoring on the branch it came from. Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no> Co-authored-by: Declan Snyder <declan.snyder@nxp.com>
Add test for lock/unlock constraint lists using the new arbitrary DT phandles macros and pm_policy_state_constraints_get/put APIs. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
e28a375 to 465913f Compare |



Cherry-picked the RW612 DTS refactor from #89372 and realized it causes runtime failures due to for example the flexcomm driver is trying to use the
pm_policy_device_is_disabling_stateAPI which stops working if the disabling state is not directly defined on the device's node and is defined on the parent instead, so fix this in the policy_device_lock.c by checking first parent domain constraints