Skip to content

Commit ff5213f

Browse files
committed
ASoC: SOF: topology: fix core enable sequence
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>
1 parent 894bb74 commit ff5213f

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

sound/soc/sof/topology.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,29 +1315,38 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core)
13151315
},
13161316
.enable_mask = sdev->enabled_cores_mask | BIT(core),
13171317
};
1318-
int ret;
1318+
int ret, ret1;
13191319

13201320
if (sdev->enabled_cores_mask & BIT(core))
13211321
return 0;
13221322

1323-
/* power up the core */
1323+
/* power up the core if it host managed */
13241324
ret = snd_sof_dsp_core_power_up(sdev, BIT(core));
13251325
if (ret < 0) {
13261326
dev_err(sdev->dev, "error: %d powering up core %d\n",
13271327
ret, core);
13281328
return ret;
13291329
}
13301330

1331-
/* update enabled cores mask */
1332-
sdev->enabled_cores_mask |= BIT(core);
1333-
1334-
/* Now notify DSP that the core has been powered up */
1331+
/* Now notify DSP */
13351332
ret = sof_ipc_tx_message(sdev->ipc, pm_core_config.hdr.cmd,
13361333
&pm_core_config, sizeof(pm_core_config),
13371334
&pm_core_config, sizeof(pm_core_config));
1338-
if (ret < 0)
1335+
if (ret < 0) {
13391336
dev_err(sdev->dev, "error: core %d enable ipc failure %d\n",
13401337
core, ret);
1338+
goto err;
1339+
}
1340+
1341+
/* update enabled cores mask */
1342+
sdev->enabled_cores_mask |= BIT(core);
1343+
1344+
return ret;
1345+
err:
1346+
/* power down core if it host managed and return the original error if this fails too */
1347+
ret1 = snd_sof_dsp_core_power_down(sdev, BIT(core));
1348+
if (ret1 < 0)
1349+
dev_err(sdev->dev, "error: %d powering down core %d\n", ret, core);
13411350

13421351
return ret;
13431352
}

0 commit comments

Comments
 (0)