Kaynağa Gözat

asoc: codecs: Check for core votes count before accessing registers

Check for core votes count before accessing swrm registers
to avoid NOC errors.

Change-Id: I5689d6a6db0886ed4cc791738a28290f3d953412
Signed-off-by: Aditya Bavanari <[email protected]>
Aditya Bavanari 5 yıl önce
ebeveyn
işleme
d577af909c

+ 15 - 0
asoc/codecs/bolero/bolero-cdc.c

@@ -1180,6 +1180,21 @@ int bolero_runtime_suspend(struct device *dev)
 }
 EXPORT_SYMBOL(bolero_runtime_suspend);
 
+bool bolero_check_core_votes(struct device *dev)
+{
+	struct bolero_priv *priv = dev_get_drvdata(dev->parent);
+	bool ret = true;
+
+	mutex_lock(&priv->vote_lock);
+	if ((priv->lpass_core_hw_vote && !priv->core_hw_vote_count) ||
+		(priv->lpass_audio_hw_vote && !priv->core_audio_vote_count))
+		ret = false;
+	mutex_unlock(&priv->vote_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL(bolero_check_core_votes);
+
 static const struct of_device_id bolero_dt_match[] = {
 	{.compatible = "qcom,bolero-codec"},
 	{}

+ 6 - 0
asoc/codecs/bolero/bolero-cdc.h

@@ -84,6 +84,7 @@ int bolero_tx_clk_switch(struct snd_soc_component *component);
 int bolero_register_event_listener(struct snd_soc_component *component,
 				   bool enable);
 void bolero_wsa_pa_on(struct device *dev);
+bool bolero_check_core_votes(struct device *dev);
 #else
 static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
 {
@@ -158,5 +159,10 @@ static inline int bolero_register_event_listener(
 static void bolero_wsa_pa_on(struct device *dev)
 {
 }
+
+static inline bool bolero_check_core_votes(struct device *dev)
+{
+	return false;
+}
 #endif /* CONFIG_SND_SOC_BOLERO */
 #endif /* BOLERO_CDC_H */

+ 4 - 1
asoc/codecs/bolero/rx-macro.c

@@ -3499,7 +3499,10 @@ static int rx_macro_core_vote(void *handle, bool enable)
 		pm_runtime_mark_last_busy(rx_priv->dev);
 	}
 
-	return 0;
+	if (bolero_check_core_votes(rx_priv->dev))
+		return 0;
+	else
+		return -EINVAL;
 }
 
 static int rx_swrm_clock(void *handle, bool enable)

+ 4 - 2
asoc/codecs/bolero/tx-macro.c

@@ -1952,7 +1952,6 @@ static int tx_macro_clk_switch(struct snd_soc_component *component)
 static int tx_macro_core_vote(void *handle, bool enable)
 {
 	struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
-	int ret = 0;
 
 	if (tx_priv == NULL) {
 		pr_err("%s: tx priv data is NULL\n", __func__);
@@ -1964,7 +1963,10 @@ static int tx_macro_core_vote(void *handle, bool enable)
 		pm_runtime_mark_last_busy(tx_priv->dev);
 	}
 
-	return ret;
+	if (bolero_check_core_votes(tx_priv->dev))
+		return 0;
+	else
+		return -EINVAL;
 }
 
 static int tx_macro_swrm_clock(void *handle, bool enable)

+ 4 - 2
asoc/codecs/bolero/wsa-macro.c

@@ -2802,7 +2802,6 @@ static void wsa_macro_init_reg(struct snd_soc_component *component)
 static int wsa_macro_core_vote(void *handle, bool enable)
 {
 	struct wsa_macro_priv *wsa_priv = (struct wsa_macro_priv *) handle;
-	int ret = 0;
 
 	if (wsa_priv == NULL) {
 		pr_err("%s: wsa priv data is NULL\n", __func__);
@@ -2814,7 +2813,10 @@ static int wsa_macro_core_vote(void *handle, bool enable)
 		pm_runtime_mark_last_busy(wsa_priv->dev);
 	}
 
-	return ret;
+	if (bolero_check_core_votes(wsa_priv->dev))
+		return 0;
+	else
+		return -EINVAL;
 }
 
 static int wsa_swrm_clock(void *handle, bool enable)