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 <vbucha@codeaurora.org>
This commit is contained in:
Vatsal Bucha
2021-04-22 16:11:51 +05:30
committed by Gerrit - the friendly Code Review server
parent 43c99c7f0a
commit c5698c8a0b

View File

@@ -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, bolero_clk_rsc_fs_gen_request(tx_priv->dev,
true); true);
mutex_lock(&tx_priv->mclk_lock);
if (tx_priv->tx_mclk_users == 0) { if (tx_priv->tx_mclk_users == 0) {
regmap_update_bits(regmap, regmap_update_bits(regmap,
BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK, 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); 0x01, 0x01);
} }
tx_priv->tx_mclk_users++; tx_priv->tx_mclk_users++;
mutex_unlock(&tx_priv->mclk_lock);
} }
if (tx_priv->swr_clk_users == 0) { if (tx_priv->swr_clk_users == 0) {
dev_dbg(tx_priv->dev, "%s: reset_swr: %d\n", 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) if (clk_type == TX_MCLK)
tx_macro_mclk_enable(tx_priv, 0); tx_macro_mclk_enable(tx_priv, 0);
if (clk_type == VA_MCLK) { if (clk_type == VA_MCLK) {
mutex_lock(&tx_priv->mclk_lock);
if (tx_priv->tx_mclk_users <= 0) { if (tx_priv->tx_mclk_users <= 0) {
dev_err(tx_priv->dev, "%s: clock already disabled\n", dev_err(tx_priv->dev, "%s: clock already disabled\n",
__func__); __func__);
tx_priv->tx_mclk_users = 0; tx_priv->tx_mclk_users = 0;
mutex_unlock(&tx_priv->mclk_lock);
goto tx_clk; goto tx_clk;
} }
tx_priv->tx_mclk_users--; 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, BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
0x01, 0x00); 0x01, 0x00);
} }
mutex_unlock(&tx_priv->mclk_lock);
bolero_clk_rsc_fs_gen_request(tx_priv->dev, bolero_clk_rsc_fs_gen_request(tx_priv->dev,
false); false);
ret = bolero_clk_rsc_request_clock(tx_priv->dev, ret = bolero_clk_rsc_request_clock(tx_priv->dev,