Commit 42077f08 authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: SOF: update dsp core power status in common APIs

Only manage enabled_cores_mask in common snd_sof_dsp_core_power_up/down
APIs to ensure it stays in sync with actual DSP core state.
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210128093850.1041387-4-kai.vehmanen@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent cedd502d
...@@ -811,7 +811,6 @@ EXPORT_SYMBOL(snd_sof_load_firmware); ...@@ -811,7 +811,6 @@ EXPORT_SYMBOL(snd_sof_load_firmware);
int snd_sof_run_firmware(struct snd_sof_dev *sdev) int snd_sof_run_firmware(struct snd_sof_dev *sdev)
{ {
int ret; int ret;
int init_core_mask;
init_waitqueue_head(&sdev->boot_wait); init_waitqueue_head(&sdev->boot_wait);
...@@ -843,8 +842,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) ...@@ -843,8 +842,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev)
return ret; return ret;
} }
init_core_mask = ret;
/* /*
* now wait for the DSP to boot. There are 3 possible outcomes: * now wait for the DSP to boot. There are 3 possible outcomes:
* 1. Boot wait times out indicating FW boot failure. * 1. Boot wait times out indicating FW boot failure.
...@@ -874,9 +871,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) ...@@ -874,9 +871,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev)
return ret; return ret;
} }
/* fw boot is complete. Update the active cores mask */
sdev->enabled_cores_mask = init_core_mask;
return 0; return 0;
} }
EXPORT_SYMBOL(snd_sof_run_firmware); EXPORT_SYMBOL(snd_sof_run_firmware);
......
...@@ -76,19 +76,29 @@ static inline int snd_sof_dsp_reset(struct snd_sof_dev *sdev) ...@@ -76,19 +76,29 @@ static inline int snd_sof_dsp_reset(struct snd_sof_dev *sdev)
static inline int snd_sof_dsp_core_power_up(struct snd_sof_dev *sdev, static inline int snd_sof_dsp_core_power_up(struct snd_sof_dev *sdev,
unsigned int core_mask) unsigned int core_mask)
{ {
if (sof_ops(sdev)->core_power_up) int ret = 0;
return sof_ops(sdev)->core_power_up(sdev, core_mask);
return 0; if (sof_ops(sdev)->core_power_up) {
ret = sof_ops(sdev)->core_power_up(sdev, core_mask);
if (!ret)
sdev->enabled_cores_mask |= core_mask;
}
return ret;
} }
static inline int snd_sof_dsp_core_power_down(struct snd_sof_dev *sdev, static inline int snd_sof_dsp_core_power_down(struct snd_sof_dev *sdev,
unsigned int core_mask) unsigned int core_mask)
{ {
if (sof_ops(sdev)->core_power_down) int ret = 0;
return sof_ops(sdev)->core_power_down(sdev, core_mask);
return 0; if (sof_ops(sdev)->core_power_down) {
ret = sof_ops(sdev)->core_power_down(sdev, core_mask);
if (!ret)
sdev->enabled_cores_mask &= ~core_mask;
}
return ret;
} }
/* pre/post fw load */ /* pre/post fw load */
......
...@@ -256,7 +256,6 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) ...@@ -256,7 +256,6 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
/* reset FW state */ /* reset FW state */
sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; sdev->fw_state = SOF_FW_BOOT_NOT_STARTED;
sdev->enabled_cores_mask = 0;
return ret; return ret;
} }
......
...@@ -1352,10 +1352,6 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core) ...@@ -1352,10 +1352,6 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core)
core, ret); core, ret);
goto err; goto err;
} }
/* update enabled cores mask */
sdev->enabled_cores_mask |= BIT(core);
return ret; return ret;
err: err:
/* power down core if it is host managed and return the original error if this fails too */ /* power down core if it is host managed and return the original error if this fails too */
...@@ -2603,10 +2599,6 @@ static int sof_widget_unload(struct snd_soc_component *scomp, ...@@ -2603,10 +2599,6 @@ static int sof_widget_unload(struct snd_soc_component *scomp,
if (ret < 0) if (ret < 0)
dev_err(scomp->dev, "error: powering down pipeline schedule core %d\n", dev_err(scomp->dev, "error: powering down pipeline schedule core %d\n",
pipeline->core); pipeline->core);
/* update enabled cores mask */
sdev->enabled_cores_mask &= ~(1 << pipeline->core);
break; break;
default: default:
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment