From e249d0522ef2e6669eef20635b23f078cc74e5da Mon Sep 17 00:00:00 2001 From: Binyuan Lan Date: Fri, 23 Mar 2018 22:57:33 +0800 Subject: [PATCH] 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 --- sound/soc/rockchip/rockchip_i2s.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index e5a227d6c2c7..219b197bf1a6 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,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); @@ -96,6 +100,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); @@ -136,6 +141,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) @@ -143,6 +149,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); @@ -183,6 +190,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,