Commit 2029d73d authored by Mark Brown's avatar Mark Brown

Merge series "ASoC: SOF: use common code for DSP core pm" from Kai Vehmanen...

Merge series "ASoC: SOF: use common code for DSP core pm" from Kai Vehmanen <kai.vehmanen@linux.intel.com>:

Series to refactor the DSP core management:
 - move tracking of powered up DSP cores to common SOF code
 - add logic filter unnecessary power actions
 - modify existing implementations to use common code
   whenever DSP cores are powered, so the state in common
   code stays in sync

Bard Liao (5):
  ASoC: SOF: Intel: hda: use snd_sof_dsp_core_power_up/down API
  ASoC: SOF: Intel: hda-loader: keep init cores alive
  ASoC: SOF: update dsp core power status in common APIs
  ASoC: SOF: Filter out unneeded core power up/downs
  ASoC: SOF: intel: hda-loader: use snd_sof_dsp_core_power_down/up APIs

 sound/soc/sof/intel/hda-dsp.c    |  2 +-
 sound/soc/sof/intel/hda-loader.c |  9 +++++----
 sound/soc/sof/intel/hda.c        |  2 +-
 sound/soc/sof/loader.c           |  6 ------
 sound/soc/sof/ops.h              | 24 ++++++++++++++++++------
 sound/soc/sof/pm.c               |  1 -
 sound/soc/sof/topology.c         |  8 --------
 7 files changed, 25 insertions(+), 27 deletions(-)

base-commit: e32df142
--
2.29.2
parents 1fc96dc2 92c6ec60
......@@ -624,7 +624,7 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
#endif
/* power down DSP */
ret = hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
ret = snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask);
if (ret < 0) {
dev_err(sdev->dev,
"error: failed to power down core during suspend\n");
......
......@@ -93,7 +93,7 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)
int i;
/* step 1: power up corex */
ret = hda_dsp_core_power_up(sdev, chip->host_managed_cores_mask);
ret = snd_sof_dsp_core_power_up(sdev, chip->host_managed_cores_mask);
if (ret < 0) {
if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS)
dev_err(sdev->dev, "error: dsp core 0/1 power up failed\n");
......@@ -147,8 +147,9 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)
chip->ipc_ack_mask,
chip->ipc_ack_mask);
/* step 5: power down corex */
ret = hda_dsp_core_power_down(sdev, chip->host_managed_cores_mask & ~(BIT(0)));
/* step 5: power down cores that are no longer needed */
ret = snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask &
~(chip->init_core_mask));
if (ret < 0) {
if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS)
dev_err(sdev->dev,
......@@ -183,7 +184,7 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)
flags |= SOF_DBG_DUMP_FORCE_ERR_LEVEL;
hda_dsp_dump(sdev, flags);
hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask);
return ret;
}
......
......@@ -928,7 +928,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)
/* disable cores */
if (chip)
hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask);
snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask);
/* disable DSP */
snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL,
......
......@@ -811,7 +811,6 @@ EXPORT_SYMBOL(snd_sof_load_firmware);
int snd_sof_run_firmware(struct snd_sof_dev *sdev)
{
int ret;
int init_core_mask;
init_waitqueue_head(&sdev->boot_wait);
......@@ -843,8 +842,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev)
return ret;
}
init_core_mask = ret;
/*
* now wait for the DSP to boot. There are 3 possible outcomes:
* 1. Boot wait times out indicating FW boot failure.
......@@ -874,9 +871,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev)
return ret;
}
/* fw boot is complete. Update the active cores mask */
sdev->enabled_cores_mask = init_core_mask;
return 0;
}
EXPORT_SYMBOL(snd_sof_run_firmware);
......
......@@ -76,19 +76,31 @@ 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,
unsigned int core_mask)
{
if (sof_ops(sdev)->core_power_up)
return sof_ops(sdev)->core_power_up(sdev, core_mask);
int ret = 0;
return 0;
core_mask &= ~sdev->enabled_cores_mask;
if (sof_ops(sdev)->core_power_up && core_mask) {
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,
unsigned int core_mask)
{
if (sof_ops(sdev)->core_power_down)
return sof_ops(sdev)->core_power_down(sdev, core_mask);
int ret = 0;
return 0;
core_mask &= sdev->enabled_cores_mask;
if (sof_ops(sdev)->core_power_down && core_mask) {
ret = sof_ops(sdev)->core_power_down(sdev, core_mask);
if (!ret)
sdev->enabled_cores_mask &= ~core_mask;
}
return ret;
}
/* pre/post fw load */
......
......@@ -256,7 +256,6 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
/* reset FW state */
sdev->fw_state = SOF_FW_BOOT_NOT_STARTED;
sdev->enabled_cores_mask = 0;
return ret;
}
......
......@@ -1352,10 +1352,6 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core)
core, ret);
goto err;
}
/* update enabled cores mask */
sdev->enabled_cores_mask |= BIT(core);
return ret;
err:
/* 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,
if (ret < 0)
dev_err(scomp->dev, "error: powering down pipeline schedule core %d\n",
pipeline->core);
/* update enabled cores mask */
sdev->enabled_cores_mask &= ~(1 << pipeline->core);
break;
default:
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