Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: rockchip: i2s-tdm: register the PCM before the DAI
@ 2026-11-10  7:16 Arun Iyengar via B4 Relay
  2026-11-10  7:16 ` [PATCH 1/2] ASoC: rockchip: i2s-tdm: Register " Arun Iyengar via B4 Relay
  2026-11-10  7:16 ` [PATCH 2/2] ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults Arun Iyengar via B4 Relay
  0 siblings, 2 replies; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-10  7:16 UTC (permalink / raw)
  To: Nicolas Frattaroli, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Heiko Stuebner
  Cc: linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel

The Rockchip I2S-TDM driver registers its DAI component before the
dmaengine PCM component. A sound card that was registered earlier and
waits for the CPU DAI is bound by snd_soc_component_register() as soon
as the DAI component appears, which also satisfies the DAI link's
platform (it defaults to the CPU of_node), so the card binds without the
PCM component. Every open of the PCM then fails with -EINVAL from
snd_pcm_hw_constraints_complete(), silently. On RK3588 this happens to
the HDMI sound card whenever the HDMI codec probes before the I2S
controller. Patch 1 registers the PCM first, as rockchip_spdif already
does.

Patch 2 adds the missing regmap default for I2S_XFER, which otherwise
warns "using zero-initialized flat cache" on its first cached access.

The non-TDM rockchip_i2s driver has the same registration order; the
same change for it will follow once it is tested on a board that uses
that controller (the RK3588 board here only has I2S-TDM instances).

Tested on an Orange Pi 5 (RK3588S): with patch 1 the HDMI card has its
dma:fddf0000.i2s component (debugfs asoc/hdmi0), speaker-test on
plughw:CARD=hdmi0 plays, and "aplay -D hw:<hdmi>,0" no longer fails
with "Invalid argument" (traced before the fix to
snd_pcm_hw_constraint_mask returning -22 with no dmaengine component on
the runtime). With patch 2 the flat-cache warning for fddf0000.i2s is
gone and HDMI playback is unchanged.

This series was developed with Claude (Anthropic) as a coding assistant:
it wrote the code and the commit messages, and I reviewed and tested
every change as described above.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Arun Iyengar (2):
      ASoC: rockchip: i2s-tdm: Register the PCM before the DAI
      ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults

 sound/soc/rockchip/rockchip_i2s_tdm.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
base-commit: cde5523c75f1320a55ac1d55a717ccbb566557f0
change-id: 20261110-asoc-rockchip-i2s-tdm-d6a6f86e81a9

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>



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

* [PATCH 1/2] ASoC: rockchip: i2s-tdm: Register the PCM before the DAI
  2026-11-10  7:16 [PATCH 0/2] ASoC: rockchip: i2s-tdm: register the PCM before the DAI Arun Iyengar via B4 Relay
@ 2026-11-10  7:16 ` Arun Iyengar via B4 Relay
  2026-11-10  7:16 ` [PATCH 2/2] ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults Arun Iyengar via B4 Relay
  1 sibling, 0 replies; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-10  7:16 UTC (permalink / raw)
  To: Nicolas Frattaroli, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Heiko Stuebner
  Cc: linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel

From: Arun Iyengar <aiyengar1990@gmail.com>

A card that was registered before its CPU DAI is put on the unbind list
by snd_soc_bind_card(), and snd_soc_component_register() retries the
bind as soon as any component is added. The DAI component of the I2S
controller satisfies the DAI link's platform, which defaults to the CPU
of_node, so the card binds right after the DAI is registered and before
the dmaengine PCM component of the same device exists. The PCM component
is then never added to the runtime, runtime->hw stays empty and every
open of the PCM fails with -EINVAL from
snd_pcm_hw_constraints_complete(), without any error being logged.

This is seen on RK3588 when the HDMI codec probes before the I2S
controller of the HDMI sound card: the card has no "dma:fddf0000.i2s"
component and "aplay -D hw:0,0" fails with "Invalid argument".

Register the dmaengine PCM first, as rockchip_spdif already does, so the
card finds both components when the DAI appears.

Fixes: 081068fd6414 ("ASoC: rockchip: add support for i2s-tdm controller")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 sound/soc/rockchip/rockchip_i2s_tdm.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c
index 983319a538b1..0abd200a4268 100644
--- a/sound/soc/rockchip/rockchip_i2s_tdm.c
+++ b/sound/soc/rockchip/rockchip_i2s_tdm.c
@@ -1371,13 +1371,18 @@ static int rockchip_i2s_tdm_probe(struct platform_device *pdev)
 	if (i2s_tdm->soc_data && i2s_tdm->soc_data->init)
 		i2s_tdm->soc_data->init(&pdev->dev, res->start);
 
-	ret = devm_snd_soc_register_component(&pdev->dev,
-					      &rockchip_i2s_tdm_component,
-					      i2s_tdm->dai, 1);
+	/*
+	 * Register the PCM before the DAI: adding the DAI component can bind a
+	 * waiting card right away, and the card must find the PCM component
+	 * then or its DAI link ends up without one.
+	 */
+	ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
 	if (ret)
 		goto err_suspend;
 
-	ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
+	ret = devm_snd_soc_register_component(&pdev->dev,
+					      &rockchip_i2s_tdm_component,
+					      i2s_tdm->dai, 1);
 	if (ret)
 		goto err_suspend;
 

-- 
2.55.0



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

* [PATCH 2/2] ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults
  2026-11-10  7:16 [PATCH 0/2] ASoC: rockchip: i2s-tdm: register the PCM before the DAI Arun Iyengar via B4 Relay
  2026-11-10  7:16 ` [PATCH 1/2] ASoC: rockchip: i2s-tdm: Register " Arun Iyengar via B4 Relay
@ 2026-11-10  7:16 ` Arun Iyengar via B4 Relay
  2026-11-10  7:36   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-10  7:16 UTC (permalink / raw)
  To: Nicolas Frattaroli, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Heiko Stuebner
  Cc: linux-rockchip, linux-sound, linux-arm-kernel, linux-kernel

From: Arun Iyengar <aiyengar1990@gmail.com>

I2S_XFER (0x1c) is writeable and not volatile, so it is cached, but it
has no entry in rockchip_i2s_tdm_reg_defaults[]. The flat cache then
treats it as uninitialised, and the first cached access of it -- the
regmap_update_bits() in the trigger and stop paths, or regcache_sync()
after a runtime suspend -- warns

  rockchip-i2s-tdm fddf0000.i2s: using zero-initialized flat cache, this may cause unexpected behavior

It is the only cached register without a default: TXFIFOLR, INTSR, CLR,
TXDR, RXDR and RXFIFOLR are volatile and all other registers have one.

Add XFER with its reset value of 0 (TX and RX stopped), which is also
what the zero-initialised cache assumed so far, so no register value
written to the hardware changes.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 sound/soc/rockchip/rockchip_i2s_tdm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c
index 0abd200a4268..63ef7f676a75 100644
--- a/sound/soc/rockchip/rockchip_i2s_tdm.c
+++ b/sound/soc/rockchip/rockchip_i2s_tdm.c
@@ -926,6 +926,7 @@ static const struct reg_default rockchip_i2s_tdm_reg_defaults[] = {
 	{0x08, 0x00001f1f},
 	{0x10, 0x001f0000},
 	{0x14, 0x01f00000},
+	{0x1c, 0x00000000},
 	{0x30, 0x00003eff},
 	{0x34, 0x00003eff},
 	{0x38, 0x00000707},

-- 
2.55.0



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

* Re: [PATCH 2/2] ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults
  2026-11-10  7:16 ` [PATCH 2/2] ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults Arun Iyengar via B4 Relay
@ 2026-11-10  7:36   ` sashiko-bot
  2026-11-10  8:37     ` Arun Iyengar
  0 siblings, 1 reply; 5+ messages in thread
From: sashiko-bot @ 2026-11-10  7:36 UTC (permalink / raw)
  To: Arun Iyengar; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ASoC: rockchip: i2s-tdm: missing Fixes trailer for I2S_XFER
  reg_default
--

commit fcc3b955539c797b954dd2c22348b8e552e615ec
Author: Arun Iyengar <aiyengar1990@gmail.com>

> ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults
>
> I2S_XFER (0x1c) is writeable and not volatile, so it is cached, but it
> has no entry in rockchip_i2s_tdm_reg_defaults[]. The flat cache then
> treats it as uninitialised, and the first cached access of it -- the
> regmap_update_bits() in the trigger and stop paths, or regcache_sync()
> after a runtime suspend -- warns
>
>   rockchip-i2s-tdm fddf0000.i2s: using zero-initialized flat cache, this may cause unexpected behavior
>
> It is the only cached register without a default: TXFIFOLR, INTSR, CLR,
> TXDR, RXDR and RXFIFOLR are volatile and all other registers have one.
>
> Add XFER with its reset value of 0 (TX and RX stopped), which is also
> what the zero-initialised cache assumed so far, so no register value
> written to the hardware changes.
>
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

[Severity: Low]
Since I2S_XFER (0x1c) was omitted from rockchip_i2s_tdm_reg_defaults[]
when the driver was added, should this include a Fixes: tag so stable
trees can pick it up?

  Fixes: 081068fd6414 ("ASoC: rockchip: add support for i2s-tdm controller")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261110-asoc-rockchip-i2s-tdm-v1-0-f32951b3c527@gmail.com?part=2

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

* Re: [PATCH 2/2] ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults
  2026-11-10  7:36   ` sashiko-bot
@ 2026-11-10  8:37     ` Arun Iyengar
  0 siblings, 0 replies; 5+ messages in thread
From: Arun Iyengar @ 2026-11-10  8:37 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-sound

> Should this include a Fixes: tag so stable trees can pick it up?

Yes, thanks: the regmap warning is printed since the 7.0 cycle, so
stable trees from there on show it.

Fixes: 081068fd6414 ("ASoC: rockchip: add support for i2s-tdm controller")

Arun


On Mon, Nov 9, 2026 at 11:36 PM <sashiko-bot@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] ASoC: rockchip: i2s-tdm: missing Fixes trailer for I2S_XFER
>   reg_default
> --
>
> commit fcc3b955539c797b954dd2c22348b8e552e615ec
> Author: Arun Iyengar <aiyengar1990@gmail.com>
>
> > ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults
> >
> > I2S_XFER (0x1c) is writeable and not volatile, so it is cached, but it
> > has no entry in rockchip_i2s_tdm_reg_defaults[]. The flat cache then
> > treats it as uninitialised, and the first cached access of it -- the
> > regmap_update_bits() in the trigger and stop paths, or regcache_sync()
> > after a runtime suspend -- warns
> >
> >   rockchip-i2s-tdm fddf0000.i2s: using zero-initialized flat cache, this may cause unexpected behavior
> >
> > It is the only cached register without a default: TXFIFOLR, INTSR, CLR,
> > TXDR, RXDR and RXFIFOLR are volatile and all other registers have one.
> >
> > Add XFER with its reset value of 0 (TX and RX stopped), which is also
> > what the zero-initialised cache assumed so far, so no register value
> > written to the hardware changes.
> >
> > Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
>
> [Severity: Low]
> Since I2S_XFER (0x1c) was omitted from rockchip_i2s_tdm_reg_defaults[]
> when the driver was added, should this include a Fixes: tag so stable
> trees can pick it up?
>
>   Fixes: 081068fd6414 ("ASoC: rockchip: add support for i2s-tdm controller")
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261110-asoc-rockchip-i2s-tdm-v1-0-f32951b3c527@gmail.com?part=2

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

end of thread, other threads:[~2026-11-10  8:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  7:16 [PATCH 0/2] ASoC: rockchip: i2s-tdm: register the PCM before the DAI Arun Iyengar via B4 Relay
2026-11-10  7:16 ` [PATCH 1/2] ASoC: rockchip: i2s-tdm: Register " Arun Iyengar via B4 Relay
2026-11-10  7:16 ` [PATCH 2/2] ASoC: rockchip: i2s-tdm: add the reset value of XFER to the regmap defaults Arun Iyengar via B4 Relay
2026-11-10  7:36   ` sashiko-bot
2026-11-10  8:37     ` Arun Iyengar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox