Re: [PATCH v5 3/7] ASoC: meson: aiu-encoder-i2s: ensure clk divider gets disabled in hw_free
From: Martin Blumenstingl
Date: Sun Nov 15 2026 - 16:09:50 EST
On Sun, Oct 18, 2026 at 12:18 PM Valerio Setti <vsetti@xxxxxxxxxxxx> wrote:
>
> A recent Sashiko review [1] on this code revealed the following problem:
>
> 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.
>
> This commit resolves this problem by using the 'clk_enabled' field of
> 'struct gx_stream'. In particular when 'hw_free()' is called on a stream
> the code check what is the status of the other stream and then only if
> both are off the clock divider is disabled.
>
> [1]: https://lore.kernel.org/all/20260917212019.4ECE61F00893@xxxxxxxxxxxxxxx/
>
> Signed-off-by: Valerio Setti <vsetti@xxxxxxxxxxxx>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>