Skip to content

Commit

Permalink
ASoC: rockchip: i2s: protect I2S_XFER_TXS/I2S_XFER_RXS with spin lock
Browse files Browse the repository at this point in the history
fix bug error log: "rockchip-i2s ff070000.i2s: fail to clear".
When the TX/RX have started, can not do 'clear operation'.

Change-Id: Ia156144490a61f4fa9823b1313588e44688f4bce
Signed-off-by: Binyuan Lan <lby@rock-chips.com>
  • Loading branch information
Binyuan Lan authored and rkhuangtao committed Mar 27, 2018
1 parent 7c4f571 commit 7482a49
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sound/soc/rockchip/rockchip_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/spinlock.h>
#include <sound/pcm_params.h>
#include <sound/dmaengine_pcm.h>

Expand Down Expand Up @@ -54,6 +55,9 @@ struct rk_i2s_dev {
unsigned int bclk_fs;
};

/* txctrl/rxctrl lock */
static DEFINE_SPINLOCK(lock);

static int i2s_runtime_suspend(struct device *dev)
{
struct rk_i2s_dev *i2s = dev_get_drvdata(dev);
Expand Down Expand Up @@ -95,6 +99,7 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
unsigned int val = 0;
int retry = 10;

spin_lock(&lock);
if (on) {
regmap_update_bits(i2s->regmap, I2S_DMACR,
I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE);
Expand Down Expand Up @@ -135,13 +140,15 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
}
}
}
spin_unlock(&lock);
}

static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
{
unsigned int val = 0;
int retry = 10;

spin_lock(&lock);
if (on) {
regmap_update_bits(i2s->regmap, I2S_DMACR,
I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE);
Expand Down Expand Up @@ -182,6 +189,7 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
}
}
}
spin_unlock(&lock);
}

static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
Expand Down

0 comments on commit 7482a49

Please sign in to comment.