diff mbox series

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

Message ID 20210128093850.1041387-5-kai.vehmanen@linux.intel.com (mailing list archive)
State Accepted
Commit 30876e2a06f35b525dc71f94dfc3c6f329e55a28
Headers show
Series ASoC: SOF: use common code for DSP core pm | expand

Commit Message

Kai Vehmanen Jan. 28, 2021, 9:38 a.m. UTC
From: Bard Liao <yung-chuan.liao@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@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/soc/sof/ops.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

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;