-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: dma: cc23x0: Add power management #92219
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
base: main
Are you sure you want to change the base?
drivers: dma: cc23x0: Add power management #92219
Conversation
Hi @kartben There's only 1 reviewer for this PR. Would it be possible to add at least one please ? |
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 is quite confusing to look at, its unclear why on configure we do a pm get, and then never do a pm put.
Either power management is kept outside of the driver, or its kept inside the driver. Half in/half out is going to lead to confusion, particularly if all our DMA drivers don't work the same way.
I know @bjarki-andreasen and @JordanYates have been looking more closely at PM related stuff and how it should work but this seems a bit awkward to me to have a pm get in configure.
The additions in this PR are not aligned with the way device PM is used in tree and soon to be documented (See PR #90275) It will be fastest if you read that PR instead of me repeating everything written in there :) Sorry about the confusion, documentation on the area is lacking (for now) |
Marked DNM until the PM discussion is sorted out and we actually know how PM should work across zephyr device drivers, otherwise we're going to be left with large inconsistencies. |
Hi @teburd I think there's a confusion here. The function used is The comment in |
Thank you for the link @bjarki-andreasen . I'll read it carefully and will take it into account. |
9f0a31f
to
894371d
Compare
In the link you shared, not sure I understand exactly what may or may not apply to this PR. A clarification would be welcome. What's missing ? Is it just Meanwhile, I prepared a new version which is more aligned with another PR you previously approved, even if there's none |
ok, looking at the code and the dma.h header, the intended behavior of device PM is as follows:
The driver really just needs to respond to the RESUME and SUSPEND actions power PM, reference counting and managing of devices is handled outside the driver :) |
Thank you for this explanation @bjarki-andreasen. IIUC the logic, you assume here that "Device Runtime PM" (i.e With your implementation, do you confirm that it's still possible to use "System Managed Device PM" (i.e. I'm referring to this documentation: https://docs.zephyrproject.org/latest/services/pm/device.html |
Possibly, as even mentioned in the docs, system managed is quite unstable, you will need to manually, from the application, force the system to not enter one of the states which would suspend the device, state locks from devices only works with PM_DEVICE_RUNTIME :) With PM_DEVICE_RUNTIME, user resumes device, and device locks system state. With SYSTEM_MANAGED, system state resumes device, so its completely backwards comparatively, actually, in that case, your device would prevent the system from ever sleeping again. Try instead using zephyr,pm-disabling-states; to move this logic out of the driver :) |
Hello @bjarki-andreasen I thought again about your [1] Not sure your implementation is less confusing than the current one. I mean, with your suggestion, [2] With your implementation, what happens if several DMA clients are running simultaneously ? Let's have a look at the following scenario with crypto and ADC from 2 different threads, for instance:
Maybe worth having other point of views. I do not want to bother the whole world, but maybe @fabiobaltieri (who is also reviewer for #92222) and @ceolin (who is also reviewer for #92221) might have interesting suggestions. Just a reminder/summary for them, in case they would jump into the discussion. DMA related interrupts are a bit unusual on this SoC, as explained in the code:
That's why, I guess, @teburd spoke about a confusing "half in / half out" implementation. And that's what we are discussing now, we are looking for the best implementation. |
The point of device runtime PM is precisely to handle these sorts of use-cases. It performs reference counting automatically, such that the DMA will be left enabled as long as a single user has not yet called |
Oh, interesting. That's good then. :) Thank you for the explanation @JordanYates . Do you confirm that my comment [1] remains true, though ? i.e. If runtime PM is implemented in this DMA driver, my PRs adding PM to the DMA client drivers (serial, crypto, ADC, SPI) will need to be modified so |
Yep, any user of some hardware must request that hardware before using it, and all hardware must implement power management to work together for power management. I find this entirely logical :)
|
OK, great. So let's go for it, I'll update this PR and the related DMA client drivers. Thank you all for your time. |
025a5e3
to
847fe7f
Compare
Done for this PR. I re-requested a review from @teburd but that would be great if somebody else could review the PR too, which is now XS size following @bjarki-andreasen's suggestion. :) |
default: | ||
return -ENOTSUP; | ||
} | ||
} |
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.
Shouldn't you be handling TURN_ON
and OFF
in case this device is part of a power domain ?
Also, I am not sure if those early return in the switch
statement aren't violating our code guidelines. I rather have one variable holding the return value and one return statement in the end of this function :p
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.
Thank you for the review @ceolin. Your feedbacks above are now implemented.
Sorry for jump late into the discussion. This final version is looking good to me |
Add runtime PM support to cc23x0 DMA module. Signed-off-by: Julien Panis <jpanis@baylibre.com>
847fe7f
to
bf0bb93
Compare
|
Hi @teburd I think the PM discussion is sorted out now :) |
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.
Looks good! Nice work :)
This patch adds PM support to DMA driver for the TI cc23x0 SoC.
Datasheet: https://www.ti.com/lit/ds/symlink/cc2340r5.pdf
Another PR, introducing system PM for this SoC, must be merged before: #91401
Other PRs are submitted to add PM support in DMA client drivers (serial, crypto, ADC, SPI):