Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>,
	kai.vehmanen@linux.intel.com,
	Keyon Jie <yang.jie@linux.intel.com>,
	pierre-louis.bossart@linux.intel.com,
	ranjani.sridharan@linux.intel.com, daniel.baluta@nxp.com,
	Rander Wang <rander.wang@linux.intel.com>
Subject: [PATCH 3/3] ASoC: SOF: topology: fix core enable sequence
Date: Wed,  2 Sep 2020 17:07:56 +0300	[thread overview]
Message-ID: <20200902140756.1427005-4-kai.vehmanen@linux.intel.com> (raw)
In-Reply-To: <20200902140756.1427005-1-kai.vehmanen@linux.intel.com>

From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

Core power up involves 2 steps: The first step tries to
power up the core by setting the ADSPCS.SPA bit for the host-managed
cores. The second step involves sending the IPC to power up other
cores that are not host managed. The enabled_cores_mask should
be updated only when both these steps are successful. If the
IPC to the DSP fails, the host-managed core that was powered in
step 1 should be powered off before returning the error.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Keyon Jie <yang.jie@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/soc/sof/topology.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 46468fb7b6d1..d47da407a1bd 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1303,7 +1303,7 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core)
 	if (sdev->enabled_cores_mask & BIT(core))
 		return 0;
 
-	/* power up the core */
+	/* power up the core if it is host managed */
 	ret = snd_sof_dsp_core_power_up(sdev, BIT(core));
 	if (ret < 0) {
 		dev_err(sdev->dev, "error: %d powering up core %d\n",
@@ -1311,16 +1311,24 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core)
 		return ret;
 	}
 
-	/* update enabled cores mask */
-	sdev->enabled_cores_mask |= BIT(core);
-
-	/* Now notify DSP that the core has been powered up */
+	/* Now notify DSP */
 	ret = sof_ipc_tx_message(sdev->ipc, pm_core_config.hdr.cmd,
 				 &pm_core_config, sizeof(pm_core_config),
 				 &pm_core_config, sizeof(pm_core_config));
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(sdev->dev, "error: core %d enable ipc failure %d\n",
 			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 */
+	if (snd_sof_dsp_core_power_down(sdev, BIT(core)) < 0)
+		dev_err(sdev->dev, "error: powering down core %d\n", core);
 
 	return ret;
 }
-- 
2.27.0


  parent reply	other threads:[~2020-09-02 14:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 14:07 [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Kai Vehmanen
2020-09-02 14:07 ` [PATCH 1/3] ASoC: SOF: add a "core" parameter to widget loading functions Kai Vehmanen
2020-09-02 14:07 ` [PATCH 2/3] ASoC: SOF: support topology components on secondary cores Kai Vehmanen
2020-09-02 14:07 ` Kai Vehmanen [this message]
2020-09-04 10:03 ` [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200902140756.1427005-4-kai.vehmanen@linux.intel.com \
    --to=kai.vehmanen@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=guennadi.liakhovetski@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rander.wang@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=yang.jie@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox