diff options
author | Peter Ujfalusi <peter.ujfalusi@linux.intel.com> | 2024-02-13 13:47:29 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-02-13 14:22:57 +0000 |
commit | b30289e7fa927f921bfb4d0d04727461706ae822 (patch) | |
tree | 5819e481173ef6792e0c62a0804a8e5be2a97df7 /sound/soc/sof/core.c | |
parent | d0611f617d823a87f04186ad165e2990208c040b (diff) |
ASoC: SOF: Fix runtime pm usage counter balance after fw exception
If the retain context is enabled we will unconditionally increment the
device's pm use count on each exception and when the drivers are unloaded
we do not correct this (as we don't know how many times we 'prevented
d3 entry').
Introduce a flag to make sure that we do not increment the use count more
than once and on module unload decrement the use count if needed to
balance it.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240213114729.7055-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/core.c')
-rw-r--r-- | sound/soc/sof/core.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 425b023b03b4..9b00ede2a486 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -679,6 +679,16 @@ int snd_sof_device_remove(struct device *dev) */ snd_sof_machine_unregister(sdev, pdata); + /* + * Balance the runtime pm usage count in case we are faced with an + * exception and we forcably prevented D3 power state to preserve + * context + */ + if (sdev->d3_prevented) { + sdev->d3_prevented = false; + pm_runtime_put_noidle(sdev->dev); + } + if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { sof_fw_trace_free(sdev); ret = snd_sof_dsp_power_down_notify(sdev); |