[PATCH v2 4/6] ASoC: meson: aiu: add I2S Capture DAI
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Sep 17 14:20:18 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ASoC: meson: permanent clock divider leak in aiu_encoder_i2s_hw_free()
--
commit 7076c7f044003c89d276b88e15e27dd0533c4d92
Author: Valerio Setti <vsetti at baylibre.com>
ASoC: meson: aiu: add I2S Capture DAI
This commit adds a capture stream to the CPU_I2S_ENCODER, enabling it to
handle both playback and capture streams concurrently. It also formats
and buffers the captured data using existing components.
> diff --git a/sound/soc/meson/aiu.c b/sound/soc/meson/aiu.c
> index 535fbf7c16394..14d0e20a4bd66 100644
> --- a/sound/soc/meson/aiu.c
> +++ b/sound/soc/meson/aiu.c
> @@ -153,6 +153,13 @@ static struct snd_soc_dai_driver aiu_cpu_dai_drv[] = {
> .rates = SNDRV_PCM_RATE_8000_192000,
> .formats = AIU_FORMATS,
> },
> + .capture = {
> + .stream_name = "I2S Encoder Capture",
> + .channels_min = 2,
> + .channels_max = 2,
> + .rates = SNDRV_PCM_RATE_8000_192000,
> + .formats = SNDRV_PCM_FMTBIT_S16_LE,
> + },
[Severity: High]
Does adding this capture stream introduce a permanent clock divider leak when
hw_free is explicitly called?
Now that both playback and capture streams can be active simultaneously,
snd_soc_dai_active(dai) can evaluate to 2.
In sound/soc/meson/aiu-encoder-i2s.c:aiu_encoder_i2s_hw_free():
if (snd_soc_dai_active(dai) <= 1)
aiu_encoder_i2s_divider_enable(component, 0);
If a user opens both streams so snd_soc_dai_active(dai) evaluates to 2, and
explicitly calls SNDRV_PCM_IOCTL_HW_FREE before closing them,
snd_soc_dai_active(dai) remains 2. This skips disabling the clock divider.
When the streams are subsequently closed, the ALSA core skips invoking hw_free
again because the state was already changed to SNDRV_PCM_STATE_OPEN. This
would leave the clock divider permanently enabled, potentially draining battery
or blocking system suspend.
> .ops = &aiu_encoder_i2s_dai_ops,
> .symmetric_rate = 1,
> },
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917-audin-v2-0-38de4bc1de34@baylibre.com?part=4
More information about the linux-amlogic
mailing list