mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 01:04:19 +08:00
ASoC: SOF: add mutex to protect the dsp_power_state access
There could be more than one thread read/write the dsp_power_state simultaneously (e.g. hda_dsp_d0i3_work and sof_ipc_tx_message), add a mutex power_state_access to make sure the access to it is mutually exclusive. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <bard.liao@intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20210105155640.3725238-1-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f2973a1de9
commit
8b66d7c58c
@ -316,6 +316,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
|
||||
INIT_LIST_HEAD(&sdev->route_list);
|
||||
spin_lock_init(&sdev->ipc_lock);
|
||||
spin_lock_init(&sdev->hw_lock);
|
||||
mutex_init(&sdev->power_state_access);
|
||||
|
||||
if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
|
||||
INIT_WORK(&sdev->probe_work, sof_probe_work);
|
||||
|
@ -208,11 +208,16 @@ static inline int
|
||||
snd_sof_dsp_set_power_state(struct snd_sof_dev *sdev,
|
||||
const struct sof_dsp_power_state *target_state)
|
||||
{
|
||||
if (sof_ops(sdev)->set_power_state)
|
||||
return sof_ops(sdev)->set_power_state(sdev, target_state);
|
||||
int ret = 0;
|
||||
|
||||
/* D0 substate is not supported, do nothing here. */
|
||||
return 0;
|
||||
mutex_lock(&sdev->power_state_access);
|
||||
|
||||
if (sof_ops(sdev)->set_power_state)
|
||||
ret = sof_ops(sdev)->set_power_state(sdev, target_state);
|
||||
|
||||
mutex_unlock(&sdev->power_state_access);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* debug */
|
||||
|
@ -375,6 +375,8 @@ struct snd_sof_dev {
|
||||
|
||||
/* current DSP power state */
|
||||
struct sof_dsp_power_state dsp_power_state;
|
||||
/* mutex to protect the dsp_power_state access */
|
||||
struct mutex power_state_access;
|
||||
|
||||
/* Intended power target of system suspend */
|
||||
enum sof_system_suspend_state system_suspend_target;
|
||||
|
Loading…
Reference in New Issue
Block a user