From c5698c8a0b53a2af896b0f55ef43fe2448d407b9 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 22 Apr 2021 16:11:51 +0530 Subject: [PATCH] bolero: tx-macro: Fix link status not connected issue due to clk not enabled Sometimes link status is not connected due to tx_mclk_users not being properly updated. This is due to tx_mclk_users enable and disable not being protected by common mutex lock. Add mutex lock whereever it is accessed to resolve issue. Change-Id: Ibba208be1f2d3eaf63c49e434c2ae48bc3b5b2d8 Signed-off-by: Vatsal Bucha --- asoc/codecs/bolero/tx-macro.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/asoc/codecs/bolero/tx-macro.c b/asoc/codecs/bolero/tx-macro.c index 2ec29d7685..6dc5e519c4 100644 --- a/asoc/codecs/bolero/tx-macro.c +++ b/asoc/codecs/bolero/tx-macro.c @@ -2722,6 +2722,7 @@ static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv, } bolero_clk_rsc_fs_gen_request(tx_priv->dev, true); + mutex_lock(&tx_priv->mclk_lock); if (tx_priv->tx_mclk_users == 0) { regmap_update_bits(regmap, BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK, @@ -2734,6 +2735,7 @@ static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv, 0x01, 0x01); } tx_priv->tx_mclk_users++; + mutex_unlock(&tx_priv->mclk_lock); } if (tx_priv->swr_clk_users == 0) { dev_dbg(tx_priv->dev, "%s: reset_swr: %d\n", @@ -2778,10 +2780,12 @@ static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv, if (clk_type == TX_MCLK) tx_macro_mclk_enable(tx_priv, 0); if (clk_type == VA_MCLK) { + mutex_lock(&tx_priv->mclk_lock); if (tx_priv->tx_mclk_users <= 0) { dev_err(tx_priv->dev, "%s: clock already disabled\n", __func__); tx_priv->tx_mclk_users = 0; + mutex_unlock(&tx_priv->mclk_lock); goto tx_clk; } tx_priv->tx_mclk_users--; @@ -2793,7 +2797,7 @@ static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv, BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL, 0x01, 0x00); } - + mutex_unlock(&tx_priv->mclk_lock); bolero_clk_rsc_fs_gen_request(tx_priv->dev, false); ret = bolero_clk_rsc_request_clock(tx_priv->dev,