From 18342de1778711dcdfebe6783ae23cbe1b727f61 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 22 Apr 2021 10:03:49 +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 d9a24015fbf2..9671f55a5d65 100644 --- a/asoc/codecs/bolero/tx-macro.c +++ b/asoc/codecs/bolero/tx-macro.c @@ -2690,6 +2690,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, @@ -2702,6 +2703,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", @@ -2746,10 +2748,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--; @@ -2761,7 +2765,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,