diff options
author | Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> | 2021-03-22 11:37:22 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-03-23 17:14:25 +0000 |
commit | 91ec48f540f83022377723a774a0a37a630801af (patch) | |
tree | c5f67e06b50768364ece532f9b348821c5f21dc7 /sound | |
parent | 927280909fa7d8e61596800d82f18047c6cfbbe4 (diff) | |
download | linux-91ec48f540f83022377723a774a0a37a630801af.tar.bz2 |
ASoC: SOF: core: harden shutdown helper
When the probe is handled in a workqueue, we must use
cancel_work_sync() in the shutdown helper to avoid possible race
conditions.
We must also take care of possible errors happening in a probe
workqueue or during pm_runtime resume (called e.g. before shutdown for
PCI devices). We should really only try to access hardware registers
and initiate IPCs if the DSP is fully booted.
Fixes: daff7f1478e12 ("ASoC: SOF: add snd_sof_device_shutdown() helper for shutdown")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Link: https://lore.kernel.org/r/20210322163728.16616-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/sof/core.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 6d8f7d9fd192..4a3d522f612b 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -399,7 +399,13 @@ int snd_sof_device_shutdown(struct device *dev) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); - return snd_sof_shutdown(sdev); + if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) + cancel_work_sync(&sdev->probe_work); + + if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) + return snd_sof_shutdown(sdev); + + return 0; } EXPORT_SYMBOL(snd_sof_device_shutdown); |