Prechádzať zdrojové kódy

asoc: lpass-cdc: add ftrace log for NOC issue

Add ftrace log to debug NOC issues.
When writing/reading lpass codec registers, add vote_lock
to make sure clk is not disabled.

Change-Id: I1df924d6aefee2899f7e5008851c1c324dabf62a
Signed-off-by: Meng Wang <[email protected]>
Meng Wang 3 rokov pred
rodič
commit
2344f44b9c

+ 12 - 6
asoc/codecs/audio-ext-clk-up.c

@@ -84,7 +84,8 @@ static int audio_ext_clk_prepare(struct clk_hw *hw)
 	if ((clk_priv->clk_src >= AUDIO_EXT_CLK_LPASS) &&
 		(clk_priv->clk_src < AUDIO_EXT_CLK_LPASS_MAX) && !clk_priv->clk_cfg.enable)  {
 #ifdef CONFIG_AUDIO_PRM
-	    pr_debug("%s: clk_id %d ",__func__, clk_priv->prm_clk_cfg.clk_id);
+	    pr_debug("%s: clk_id %x ",__func__, clk_priv->prm_clk_cfg.clk_id);
+	    trace_printk("%s: clk_id %x \n", __func__, clk_priv->prm_clk_cfg.clk_id);
 		ret = audio_prm_set_lpass_clk_cfg(&clk_priv->prm_clk_cfg,1);
 #else
 		ret = afe_set_lpass_clk_cfg(IDX_RSVD_3, &clk_priv->clk_cfg);
@@ -134,9 +135,10 @@ static void audio_ext_clk_unprepare(struct clk_hw *hw)
 		(clk_priv->clk_src < AUDIO_EXT_CLK_LPASS_MAX))  {
 		clk_priv->clk_cfg.enable = 0;
 #ifdef CONFIG_AUDIO_PRM
-		pr_debug("%s: clk_id %d",__func__,
+		pr_debug("%s: clk_id %x",__func__,
 				clk_priv->prm_clk_cfg.clk_id);
 		ret = audio_prm_set_lpass_clk_cfg(&clk_priv->prm_clk_cfg,0);
+		 trace_printk("%s: clk_id %x \n", __func__, clk_priv->prm_clk_cfg.clk_id);
 #else
 		ret = afe_set_lpass_clk_cfg(IDX_RSVD_3, &clk_priv->clk_cfg);
 #endif
@@ -177,9 +179,10 @@ static int lpass_hw_vote_prepare(struct clk_hw *hw)
 
 	if (clk_priv->clk_src == AUDIO_EXT_CLK_LPASS_CORE_HW_VOTE)  {
 #ifdef CONFIG_AUDIO_PRM
-		pr_debug("%s: clk_id %d ",__func__, clk_priv->prm_clk_cfg.clk_id);
+		pr_debug("%s: core vote clk_id %x \n",__func__, clk_priv->prm_clk_cfg.clk_id);
 		ret = audio_prm_set_lpass_hw_core_req(&clk_priv->prm_clk_cfg,
 			HW_CORE_ID_LPASS, 1);
+		 trace_printk("%s: core vote clk_id %x \n", __func__, clk_priv->prm_clk_cfg.clk_id);
 #else
 		ret = afe_vote_lpass_core_hw(AFE_LPASS_CORE_HW_MACRO_BLOCK,
 			"LPASS_HW_MACRO",
@@ -194,9 +197,10 @@ static int lpass_hw_vote_prepare(struct clk_hw *hw)
 
 	if (clk_priv->clk_src == AUDIO_EXT_CLK_LPASS_AUDIO_HW_VOTE)  {
 #ifdef CONFIG_AUDIO_PRM
-		pr_debug("%s: clk_id %d ",__func__, clk_priv->prm_clk_cfg.clk_id);
+		pr_debug("%s: audio vote clk_id %x \n",__func__, clk_priv->prm_clk_cfg.clk_id);
 		ret = audio_prm_set_lpass_hw_core_req(&clk_priv->prm_clk_cfg,
 			HW_CORE_ID_DCODEC, 1);
+		trace_printk("%s: audio vote clk_id %x \n", __func__, clk_priv->prm_clk_cfg.clk_id);
 #else
 		ret = afe_vote_lpass_core_hw(AFE_LPASS_CORE_HW_DCODEC_BLOCK,
 			"LPASS_HW_DCODEC",
@@ -220,9 +224,10 @@ static void lpass_hw_vote_unprepare(struct clk_hw *hw)
 
 	if (clk_priv->clk_src == AUDIO_EXT_CLK_LPASS_CORE_HW_VOTE) {
 #ifdef CONFIG_AUDIO_PRM
-                pr_debug("%s: clk_id %d ",__func__, clk_priv->prm_clk_cfg.clk_id);
+                pr_debug("%s: core vote clk_id %x \n",__func__, clk_priv->prm_clk_cfg.clk_id);
                 ret = audio_prm_set_lpass_hw_core_req(&clk_priv->prm_clk_cfg,
                         HW_CORE_ID_LPASS, 0);
+		 trace_printk("%s: core vote clk_id %x \n", __func__, clk_priv->prm_clk_cfg.clk_id);
 #else
 		ret = afe_unvote_lpass_core_hw(
 			AFE_LPASS_CORE_HW_MACRO_BLOCK,
@@ -237,9 +242,10 @@ static void lpass_hw_vote_unprepare(struct clk_hw *hw)
 	if (clk_priv->clk_src == AUDIO_EXT_CLK_LPASS_AUDIO_HW_VOTE) {
 
 #ifdef CONFIG_AUDIO_PRM
-                pr_debug("%s: clk_id %d ",__func__, clk_priv->prm_clk_cfg.clk_id);
+                pr_debug("%s: audio vote clk_id %x \n",__func__, clk_priv->prm_clk_cfg.clk_id);
                 ret = audio_prm_set_lpass_hw_core_req(&clk_priv->prm_clk_cfg,
                         HW_CORE_ID_DCODEC, 0);
+		trace_printk("%s: audio vote clk_id %x \n", __func__, clk_priv->prm_clk_cfg.clk_id);
 #else
 		ret = afe_unvote_lpass_core_hw(
 			AFE_LPASS_CORE_HW_DCODEC_BLOCK,

+ 2 - 0
asoc/codecs/lpass-cdc/lpass-cdc-va-macro.c

@@ -709,6 +709,7 @@ static int lpass_cdc_va_macro_core_vote(void *handle, bool enable)
 		pr_err("%s: va priv data is NULL\n", __func__);
 		return -EINVAL;
 	}
+	trace_printk("%s, enter: enable %d\n", __func__, enable);
 	if (enable) {
 		pm_runtime_get_sync(va_priv->dev);
 		if (lpass_cdc_check_core_votes(va_priv->dev)) {
@@ -722,6 +723,7 @@ static int lpass_cdc_va_macro_core_vote(void *handle, bool enable)
 		pm_runtime_put_autosuspend(va_priv->dev);
 		pm_runtime_mark_last_busy(va_priv->dev);
 	}
+	trace_printk("%s, leave\n", __func__);
 	return rc;
 }
 

+ 21 - 7
asoc/codecs/lpass-cdc/lpass-cdc.c

@@ -105,14 +105,18 @@ static int __lpass_cdc_reg_read(struct lpass_cdc_priv *priv,
 
 	if (priv->macro_params[VA_MACRO].dev) {
 		pm_runtime_get_sync(priv->macro_params[VA_MACRO].dev);
-		if (!lpass_cdc_check_core_votes(priv->macro_params[VA_MACRO].dev))
+		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))) {
+			mutex_unlock(&priv->vote_lock);
 			goto ssr_err;
+		}
 	}
-
 	lpass_cdc_ahb_read_device(
 		priv->macro_params[macro_id].io_base, reg, val);
 
 	if (priv->macro_params[VA_MACRO].dev) {
+		mutex_unlock(&priv->vote_lock);
 		pm_runtime_mark_last_busy(priv->macro_params[VA_MACRO].dev);
 		pm_runtime_put_autosuspend(priv->macro_params[VA_MACRO].dev);
 	}
@@ -135,14 +139,18 @@ static int __lpass_cdc_reg_write(struct lpass_cdc_priv *priv,
 	}
 	if (priv->macro_params[VA_MACRO].dev) {
 		pm_runtime_get_sync(priv->macro_params[VA_MACRO].dev);
-		if (!lpass_cdc_check_core_votes(priv->macro_params[VA_MACRO].dev))
+		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))) {
+			mutex_unlock(&priv->vote_lock);
 			goto ssr_err;
+		}
 	}
-
 	lpass_cdc_ahb_write_device(
-			priv->macro_params[macro_id].io_base, reg, val);
+		priv->macro_params[macro_id].io_base, reg, val);
 
 	if (priv->macro_params[VA_MACRO].dev) {
+		mutex_unlock(&priv->vote_lock);
 		pm_runtime_mark_last_busy(priv->macro_params[VA_MACRO].dev);
 		pm_runtime_put_autosuspend(priv->macro_params[VA_MACRO].dev);
 	}
@@ -1353,6 +1361,7 @@ int lpass_cdc_runtime_resume(struct device *dev)
 	struct lpass_cdc_priv *priv = dev_get_drvdata(dev->parent);
 	int ret = 0;
 
+	trace_printk("%s, enter\n", __func__);
 	mutex_lock(&priv->vote_lock);
 	if (priv->lpass_core_hw_vote == NULL) {
 		dev_dbg(dev, "%s: Invalid lpass core hw node\n", __func__);
@@ -1391,6 +1400,7 @@ audio_vote:
 
 done:
 	mutex_unlock(&priv->vote_lock);
+	trace_printk("%s, leave\n", __func__);
 	pm_runtime_set_autosuspend_delay(priv->dev, LPASS_CDC_AUTO_SUSPEND_DELAY);
 	return 0;
 }
@@ -1400,6 +1410,7 @@ int lpass_cdc_runtime_suspend(struct device *dev)
 {
 	struct lpass_cdc_priv *priv = dev_get_drvdata(dev->parent);
 
+	trace_printk("%s, enter\n", __func__);
 	mutex_lock(&priv->vote_lock);
 	if (priv->lpass_core_hw_vote != NULL) {
 		if (--priv->core_hw_vote_count == 0)
@@ -1428,6 +1439,7 @@ int lpass_cdc_runtime_suspend(struct device *dev)
 		__func__, priv->core_audio_vote_count);
 
 	mutex_unlock(&priv->vote_lock);
+	trace_printk("%s, leave\n", __func__);
 	return 0;
 }
 EXPORT_SYMBOL(lpass_cdc_runtime_suspend);
@@ -1437,12 +1449,14 @@ bool lpass_cdc_check_core_votes(struct device *dev)
 {
 	struct lpass_cdc_priv *priv = dev_get_drvdata(dev->parent);
 	bool ret = true;
-
+	trace_printk("%s, enter\n", __func__);
 	mutex_lock(&priv->vote_lock);
-	if ((priv->lpass_core_hw_vote && !priv->core_hw_vote_count) ||
+	if (!priv->dev_up ||
+		(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);
+	trace_printk("%s, leave\n", __func__);
 
 	return ret;
 }

+ 1 - 0
soc/swr-mstr-ctrl.c

@@ -2248,6 +2248,7 @@ handle_irq:
 	if (intr_sts_masked) {
 		dev_dbg(swrm->dev, "%s: new interrupt received 0x%x\n",
 			__func__, intr_sts_masked);
+		trace_printk("%s, new interrupt received\n", __func__);
 		goto handle_irq;
 	}