diff options
author | Sugar Zhang <sugar.zhang@rock-chips.com> | 2021-09-03 15:07:14 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-09-03 17:19:01 +0200 |
commit | fcb958ee8e832e9cdf43408535207e15f14af755 (patch) | |
tree | 7e73f5dab66462ea741b812989238ecf0f191317 /sound | |
parent | ASoC: mt8195: correct the dts parsing logic about DPTX and HDMITX (diff) | |
download | linux-fcb958ee8e832e9cdf43408535207e15f14af755.tar.xz linux-fcb958ee8e832e9cdf43408535207e15f14af755.zip |
ASoC: rockchip: i2s: Fix concurrency between tx/rx
This patch adds lock to fix comcurrency between tx/rx
to fix 'rockchip-i2s ff070000.i2s; fail to clear'
Considering the situation;
tx stream rx stream
| |
| disable
enable |
| reset
After this patch:
lock
|
tx stream
|
enable
|
unlock
-------- ---------
lock
|
rx stream
|
disable
|
reset
|
unlock
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Link: https://lore.kernel.org/r/1630674434-650-1-git-send-email-sugar.zhang@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/rockchip/rockchip_i2s.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 53e0b4a1c7d2..7e89f5b0c237 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -15,6 +15,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> @@ -53,6 +54,7 @@ struct rk_i2s_dev { bool is_master_mode; const struct rk_i2s_pins *pins; unsigned int bclk_ratio; + spinlock_t lock; /* tx/rx lock */ }; static int i2s_runtime_suspend(struct device *dev) @@ -96,6 +98,7 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) unsigned int val = 0; int retry = 10; + spin_lock(&i2s->lock); if (on) { regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE); @@ -136,6 +139,7 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) } } } + spin_unlock(&i2s->lock); } static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) @@ -143,6 +147,7 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) unsigned int val = 0; int retry = 10; + spin_lock(&i2s->lock); if (on) { regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE); @@ -183,6 +188,7 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) } } } + spin_unlock(&i2s->lock); } static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, @@ -684,6 +690,7 @@ static int rockchip_i2s_probe(struct platform_device *pdev) if (!i2s) return -ENOMEM; + spin_lock_init(&i2s->lock); i2s->dev = &pdev->dev; i2s->grf = syscon_regmap_lookup_by_phandle(node, "rockchip,grf"); |