Hi Josep,
I have found[1] that sof driver works (for now?) only two power states: D0 (DSP ON) and D3 (DSP OFF). In a laptop with battery, not connected to AC, I have many "D0->D3->D0" state changes during system operation [3].When entering into to D0, all firmware is loaded again, DSP set up and so (obvious, as DSPs where off).
My guess is that this transition happens in a power state transition lower than Suspend to RAM, i.e., Suspend-to-idle or Standby. [2]
Should not be the transition to D3 state done in a kernel transition to S3 or higher only (Suspend to RAM, hibernate)?
Adding to Paul Olaru's answer: it's a feature not a bug ;-)
There are two types of suspend/resume operations, tied to transitions between S (platform) and D (device) states.
a) system suspend/resume, where the platform goes to a different S state. On system suspend, the platform goes e.g. to S3 to hibernate, and that forces the device state to go to D3 - platform and device states are not completely independent.
b) pm_runtime suspend/resume. Here the platform remains in S0 (active) but since when the audio subsystem is not used, the pm_runtime framework will trigger a transition to D3, typically after a timeout. Conversely every time you want to play/record the ALSA/ASoC framework will do a pm_runtime_get_sync() and force the DSP to be powered, initialized, etc.
Not all platforms have the same power management capabilities. On Intel recent hardware, the DSP is power-gated so all state is lost. That's why we have to re-download it on each D0 transition. If you look at older hardware, we didn't have power gating, only clock gating so re-downloading the firmware was not necessarily needed for pm_runtime, and only needed on system resume.
If you look at sound/soc/sof/pm.c you will see we have two hooks for each type of suspend/resume, and calls into the platform specific parts for the implementation.
To be complete I should also add that there are additional states such as S0ix and D0ix but that's likely not enabled on your HDaudio-based platform. There's also G, P and C states if you really want to get into the complicated stuff [1]
Hope this helps -Pierre
[1] https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface#Pow...