From: Valerio Setti <vsetti@baylibre.com>
To: sashiko-reviews@lists.linux.dev
Cc: neil.armstrong@linaro.org, linux-amlogic@lists.infradead.org
Subject: Re: [PATCH 2/4] ASoC: meson: aiu-encoder-i2s: use gx_iface and gx_stream structures
Date: Thu, 21 May 2026 16:59:12 +0200 [thread overview]
Message-ID: <b274a43d-de3a-420d-911d-6b233b4294ed@baylibre.com> (raw)
In-Reply-To: <20260515161047.C0701C2BCF7@smtp.kernel.org>
>> static void aiu_encoder_i2s_shutdown(struct snd_pcm_substream *substream,
>> struct snd_soc_dai *dai)
>> {
>> struct aiu *aiu = snd_soc_component_get_drvdata(dai->component);
>> + struct gx_stream *ts = snd_soc_dai_get_dma_data(dai, substream);
>> + struct gx_iface *iface = ts->iface;
>> +
>> + if (!snd_soc_dai_active(dai))
>> + iface->rate = 0;
>
> The ASoC core invokes the shutdown callback before decrementing the stream's
> active count.
>
> Because of this, does snd_soc_dai_active(dai) always evaluate to at least 1
> during the shutdown of the final stream?
>
> If so, iface->rate will never be reset to 0, which would cause subsequent
> streams with different sample rates to permanently fail with -EINVAL until
> the driver is reloaded.
>
I might be missing something also here, but I don't think this is
correct. It seems to me that when 'aiu_encoder_i2s_shutdown' is called
the number of active streams have already been decreased so everything
works as expected.
In support of my hypothesis I have tried this patch series together with
the upcoming one adding also capture stream and I didn't experience
problems, so I think that 'iface->date' is correctly reset when expected.
>> +static int aiu_encoder_i2s_trigger(struct snd_pcm_substream *substream,
>> + int cmd,
>> + struct snd_soc_dai *dai)
>> +{
>> + struct gx_stream *ts = snd_soc_dai_get_dma_data(dai, substream);
>> + int ret;
>> +
>> + switch (cmd) {
>> + case SNDRV_PCM_TRIGGER_START:
>> + case SNDRV_PCM_TRIGGER_RESUME:
>> + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
>> + ret = gx_stream_start(ts);
>> + break;
>> + case SNDRV_PCM_TRIGGER_SUSPEND:
>> + case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>> + case SNDRV_PCM_TRIGGER_STOP:
>> + gx_stream_stop(ts);
>> + ret = 0;
>> + break;
>
> The PCM trigger callback typically executes in an atomic context with the
> PCM stream spinlock held and hardware interrupts disabled, unless the DAI
> is explicitly marked with nonatomic = 1.
>
> Looking at gx_stream_start() and gx_stream_stop(), they both unconditionally
> acquire a sleeping lock via mutex_lock(&ts->lock).
>
> Does acquiring a mutex in this atomic context trigger a scheduling while
> atomic kernel panic?
>
This is one of the parts that has been copied from AXG. I would say that
the problem highlighted here would only appear in case two formatters
are started/stopped on same stream concurrently. If that's the case then
this is not a problem for GX because we're going to have 1 single
formatter per stream.
--
Valerio
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-05-21 15:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 15:10 [PATCH 0/4] ASoC: meson: aiu: align I2S design to the AXG one Valerio Setti
2026-05-15 15:10 ` [PATCH 1/4] ASoC: meson: gx: add gx-formatter and gx-interface Valerio Setti
2026-05-15 15:36 ` sashiko-bot
2026-05-20 16:05 ` Valerio Setti
2026-05-15 15:10 ` [PATCH 2/4] ASoC: meson: aiu-encoder-i2s: use gx_iface and gx_stream structures Valerio Setti
2026-05-15 16:10 ` sashiko-bot
2026-05-21 14:59 ` Valerio Setti [this message]
2026-05-15 15:10 ` [PATCH 3/4] ASoC: meson: aiu: introduce I2S output formatter Valerio Setti
2026-05-15 15:10 ` [PATCH 4/4] ASoC: meson: aiu: use aiu-formatter-i2s to format I2S output data Valerio Setti
2026-05-15 17:40 ` sashiko-bot
2026-05-21 23:15 ` Mark Brown
2026-05-22 16:24 ` Valerio Setti
2026-05-28 15:01 ` Valerio Setti
2026-05-28 15:53 ` Mark Brown
2026-06-10 13:27 ` Jerome Brunet
2026-05-21 11:36 ` [PATCH 0/4] ASoC: meson: aiu: align I2S design to the AXG one Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b274a43d-de3a-420d-911d-6b233b4294ed@baylibre.com \
--to=vsetti@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox