linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: rockchip: i2s-tdm: Fix refcount test
@ 2021-10-15 21:07 Nicolas Frattaroli
  2021-10-20 11:28 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Frattaroli @ 2021-10-15 21:07 UTC (permalink / raw)
  To: Nicolas Frattaroli, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Heiko Stuebner
  Cc: linux-rockchip, alsa-devel, linux-arm-kernel, linux-kernel

During development of V5 of the i2s-tdm patch series, I replaced
the atomic refcount with a regular integer, as it was only ever
accessed within a spinlock.

Foolishly, I got the semantics of atomic_dec_and_test wrong, which
resulted in a test for 0 actually becoming a test for >0.

The result was that setting the audio frequency broke; switching
from 44100 Hz audio playback to 96000 Hz audio playback would
garble the sound most unpleasantly.

Fix this by checking for --refcount == 0, which is what it should
have been all along.

Fixes: 081068fd6414 ("ASoC: rockchip: add support for i2s-tdm controller")
Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
---
 sound/soc/rockchip/rockchip_i2s_tdm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c
index 396277eaa417..5d3abbada72a 100644
--- a/sound/soc/rockchip/rockchip_i2s_tdm.c
+++ b/sound/soc/rockchip/rockchip_i2s_tdm.c
@@ -408,7 +408,7 @@ static void rockchip_snd_txrxctrl(struct snd_pcm_substream *substream,
 		else
 			rockchip_disable_rde(i2s_tdm->regmap);
 
-		if (--i2s_tdm->refcount) {
+		if (--i2s_tdm->refcount == 0) {
 			rockchip_snd_xfer_clear(i2s_tdm,
 						I2S_CLR_TXC | I2S_CLR_RXC);
 		}
-- 
2.33.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: rockchip: i2s-tdm: Fix refcount test
  2021-10-15 21:07 [PATCH] ASoC: rockchip: i2s-tdm: Fix refcount test Nicolas Frattaroli
@ 2021-10-20 11:28 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2021-10-20 11:28 UTC (permalink / raw)
  To: Liam Girdwood, Nicolas Frattaroli, Heiko Stuebner, Takashi Iwai,
	Jaroslav Kysela
  Cc: Mark Brown, linux-arm-kernel, linux-kernel, linux-rockchip, alsa-devel

On Fri, 15 Oct 2021 23:07:29 +0200, Nicolas Frattaroli wrote:
> During development of V5 of the i2s-tdm patch series, I replaced
> the atomic refcount with a regular integer, as it was only ever
> accessed within a spinlock.
> 
> Foolishly, I got the semantics of atomic_dec_and_test wrong, which
> resulted in a test for 0 actually becoming a test for >0.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: rockchip: i2s-tdm: Fix refcount test
      commit: 0ea15e98cfbe56147e227360282ccd311e824b61

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-20 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 21:07 [PATCH] ASoC: rockchip: i2s-tdm: Fix refcount test Nicolas Frattaroli
2021-10-20 11:28 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).