From 30876e2a06f35b525dc71f94dfc3c6f329e55a28 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 28 Jan 2021 11:38:49 +0200 Subject: [PATCH] ASoC: SOF: Filter out unneeded core power up/downs 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 Reviewed-by: Ranjani Sridharan Signed-off-by: Kai Vehmanen Link: https://lore.kernel.org/r/20210128093850.1041387-5-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown --- 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 2e9a8da..5099ad0 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.7.4