-
Notifications
You must be signed in to change notification settings - Fork 8.2k
flash: spi_nor: automatically handle device runtime PM (remove IDLE_IN_DPD)
#73246
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
flash: spi_nor: automatically handle device runtime PM (remove IDLE_IN_DPD)
#73246
Conversation
|
@JordanYates, that is a very nice solution. |
c9d17d7 to
aa4e140
Compare
|
@krish2718 I had to revert #72519 as the flash driver fails to compile on main due to a missing interface driver ( |
aa4e140 to
59e9a3d
Compare
This means that the driver which defines the device isn't included in the build, let me check and fix this. |
Please go ahead with the revert, this needs more changes from downstream, I had tested this downstream and submitted the PR, haven't verified upstream, thanks. |
|
you also need to revert b1de9a6 same issue as earlier sample, |
In my case, I found
At this point I settled on setting IDLE_IN_DPD=n and in my application I created the following routing which I current call before and after various calls to write the flash. Would using the PM_DEVICE_RUNTIME take care of the SPI bus too? I am thinking not. How would I continue to enable / disable the SPI bus, which is a significant power consumer, when PM_DEVICE_RUNTIME feature is used? I am having trouble finding it in the documentation now, but I thought I read somewhere not to use PM_DEVICE_RUNTIME while trying to manually change things. Especially if you are introducing a CONFIG_SPI_NOR_DEEP_POWER_DOWN_INACTIVITY_TIMEOUT_MS. How can you opt in/out devices from PM_DEVICE_RUNTIME. Doesn't this imply all devices in the system support it but maybe I do not want it enabled on all devices. |
59e9a3d to
16626fd
Compare
It does not automatically, but that has been added to this PR.
Correct, we recommend to never use
Device runtime PM has no effect unless it is explicitly enabled for a device. There is no implication about all devices in the application. |
Happy for you to do a more complete revert in an alternate PR, I don't expect this one will move quickly. |
drivers/flash/spi_nor.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.
If DPD_INACTIVITY_TIMEOUT_MS is 0, should this call pm_device_runtime_put() instead of put_async()? Otherwise it puts the work on the system workqueue without delay, which seems like needless extra work.
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 sort of optimization is better suited to occur in the PM implementation so that all users get the benefits and code isn't copy pasted everywhere.
|
@anangl PTAL |
16626fd to
7f9c52a
Compare
7f9c52a to
c0011c2
Compare
|
Rebased on |
|
@JordanYates This needs rebase as it fails on some unrelated issues. |
c0011c2 to
e535b32
Compare
Remove `SPI_NOR_IDLE_IN_DPD` to simplify the possible transition states in the `spi_nor` driver. This option was originally added 5 years ago when device runtime PM was in a much less mature state. I do not believe having a separate power management implementation for this one in-tree driver is in the interests of the project. The behaviour of `SPI_NOR_IDLE_IN_DPD` leads to extremly suboptimal behaviour in use cases where multiple small reads are performed sequentially, see zephyrproject-rtos#69588. Removal of this option does not break the behaviour of any existing applications, only increases current consumption in idle by ~10uA until device runtime PM is enabled. Signed-off-by: Jordan Yates <[email protected]>
Automatically handle device runtime PM for all flash API calls. Asynchronously release the device after a small delay to minimise power state transitions under multiple sequential API calls (e.g. NVS). Signed-off-by: Jordan Yates <[email protected]>
Automatically request and release the SPI bus before talking to the flash chip. Signed-off-by: Jordan Yates <[email protected]>
e535b32 to
6b7a852
Compare
|
ping @de-nordic |
Automatically handle device runtime PM for all flash API calls. Asynchronously release the device after a small delay to minimise power state transitions under multiple sequential API calls (e.g. NVS).
Remove
SPI_NOR_IDLE_IN_DPDto simplify the possible transition states in thespi_nordriver. This option was originally added 5 years ago when device runtime PM was in a much less mature state.I do not believe having a separate power management implementation for this one in-tree driver is in the interests of the project.
The behaviour of
SPI_NOR_IDLE_IN_DPDleads to extremly suboptimal behaviour in use cases where multiple small reads are performed sequentially, see #69588.Removal of this option does not break the behaviour of any existing applications, only increases current consumption in idle by ~10uA until device runtime PM is enabled.