[PATCH 4/5] ASoC: SOF: Filter out unneeded core power up/downs

Kai Vehmanen kai.vehmanen at linux.intel.com
Thu Jan 28 10:38:49 CET 2021


From: Bard Liao <yung-chuan.liao at linux.intel.com>

Exclude cores that are already powered on/off correctly. This allows to
simplify dsp_power_up/down() implementations and avoid unexpected error.

Signed-off-by: Bard Liao <yung-chuan.liao at linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen at linux.intel.com>
---
 sound/soc/sof/ops.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h
index 2e9a8da53d57..5099ad03df72 100644
--- a/sound/soc/sof/ops.h
+++ b/sound/soc/sof/ops.h
@@ -78,7 +78,8 @@ static inline int snd_sof_dsp_core_power_up(struct snd_sof_dev *sdev,
 {
 	int ret = 0;
 
-	if (sof_ops(sdev)->core_power_up) {
+	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;
@@ -92,7 +93,8 @@ static inline int snd_sof_dsp_core_power_down(struct snd_sof_dev *sdev,
 {
 	int ret = 0;
 
-	if (sof_ops(sdev)->core_power_down) {
+	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;
-- 
2.29.2



More information about the Alsa-devel mailing list