summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBinyuan Lan <lby@rock-chips.com>2018-03-23 22:57:33 +0800
committerTao Huang <huangtao@rock-chips.com>2018-03-27 09:21:42 +0800
commit7482a49a2de604f36f42b12b00eebed622897599 (patch)
treecb089109dac9da49b24ac5b9322c4dd8eb341ef9
parent7c4f5712a011e423ee3cf2cd919e2d7bf6836e1b (diff)
ASoC: rockchip: i2s: protect I2S_XFER_TXS/I2S_XFER_RXS with spin lock
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>
-rw-r--r--sound/soc/rockchip/rockchip_i2s.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index 7687368779db..41a25e50edd3 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -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>
@@ -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);
@@ -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);
@@ -135,6 +140,7 @@ 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)
@@ -142,6 +148,7 @@ 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);
@@ -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,