From: sashiko-bot@kernel.org
To: "Hermes Wu" <Hermes.wu@ite.com.tw>
Cc: devicetree@vger.kernel.org, linux-sound@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH 4/5] media: i2c: it6625: add I2S audio capture DAI
Date: Tue, 03 Nov 2026 07:05:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-194692@kernel.org> (raw)
In-Reply-To: <20261103-upstream-it6625-alsa-i2s-v1-4-bb91e2879b01@ite.com.tw>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] media: i2c: it6625: it6625_dai_shutdown() cancels active rate-settle polling
- [Medium] media: i2c: it6625: it6625_audio_refresh() in DAI ops skips V4L2 ctrl update
--
commit 1dfd81c0e8bfaba0b855fe94b881d239f6f65287
Author: Hermes Wu <Hermes.wu@ite.com.tw>
media: i2c: it6625: add I2S audio capture DAI
This commit registers an ASoC component and I2S capture DAI for the IT6625
and IT6626 HDMI-to-MIPI bridges when #sound-dai-cells is present in the
device tree. It constrains capture streams to the currently observed HDMI
audio status, stops active streams on status changes, and polls for audio
status updates and rate settling.
> diff --git a/drivers/media/i2c/it6625.c b/drivers/media/i2c/it6625.c
> index 6f12a0e760178..f1bd42ad15eda 100644
> --- a/drivers/media/i2c/it6625.c
> +++ b/drivers/media/i2c/it6625.c
[ ... ]
> @@ -2001,6 +2158,369 @@ static int it6625_v4l2_init_controls(struct v4l2_subdev *sd)
> return 0;
> }
>
[ ... ]
> +static void it6625_audio_refresh_work(struct work_struct *work)
> +{
> + struct it6625 *it6625 = container_of(to_delayed_work(work),
> + struct it6625, audio_refresh_work);
> + unsigned long flags;
> + bool rearm;
> +
> + it6625_s_ctrl_audio(&it6625->sd);
> +
> + spin_lock_irqsave(&it6625->audio_lock, flags);
> + /* every run uses up one re-check of a settle budget */
> + if (it6625->audio_settle_polls)
> + it6625->audio_settle_polls--;
> + rearm = (it6625->audio_substream && !it6625->audio_block) ||
> + (it6625->audio_settle_polls && it6625_audio_settling(it6625));
> + spin_unlock_irqrestore(&it6625->audio_lock, flags);
> +
> + if (rearm)
> + schedule_delayed_work(&it6625->audio_refresh_work,
> + msecs_to_jiffies(IT6625_AUDIO_REFRESH_MS));
> +}
> +
> +static struct it6625 *dai_to_6625(struct snd_soc_dai *dai)
> +{
> + /* the I2C client data is the V4L2 subdev */
> + return sd_to_6625(snd_soc_dai_get_drvdata(dai));
> +}
> +
> +static int it6625_dai_startup(struct snd_pcm_substream *substream,
> + struct snd_soc_dai *dai)
> +{
> + struct it6625 *it6625 = dai_to_6625(dai);
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + struct it6625_audio_info info;
> + unsigned long flags;
> + u32 gen;
> + int ret;
> +
> + it6625_audio_refresh(it6625);
[ ... ]
> +/* also called on rollback after a successful .startup */
> +static void it6625_dai_shutdown(struct snd_pcm_substream *substream,
> + struct snd_soc_dai *dai)
> +{
> + struct it6625 *it6625 = dai_to_6625(dai);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&it6625->audio_lock, flags);
> + it6625->audio_block = true;
> + spin_unlock_irqrestore(&it6625->audio_lock, flags);
> +
> + cancel_delayed_work_sync(&it6625->audio_refresh_work);
> + cancel_work_sync(&it6625->audio_xrun_work);
> +
> + spin_lock_irqsave(&it6625->audio_lock, flags);
> + it6625->audio_substream = NULL;
> + it6625->audio_running = false;
> + it6625->audio_block = false;
> + spin_unlock_irqrestore(&it6625->audio_lock, flags);
> +}
[Severity: Medium]
Can it6625_dai_shutdown() prematurely stop rate-settle polling started by
it6625_audio_event()?
If an HDMI format or audio event occurs while a capture stream is running and
leaves audio present without a valid sampling rate, it6625_audio_event()
performs:
it6625_audio_event()
it6625_s_ctrl_audio()
it6625_audio_refresh()
it6625->audio_gen++;
queue_work(system_wq, &it6625->audio_xrun_work);
if (it6625_audio_settling(it6625)) {
it6625->audio_settle_polls = IT6625_AUDIO_SETTLE_POLLS;
schedule_delayed_work(&it6625->audio_refresh_work, ...);
}
Because audio_gen was incremented, subsequent calls to it6625_dai_prepare() or
it6625_dai_hw_params() return -EPIPE, so userspace has to close the capture
stream to recover.
When userspace closes the stream, it6625_dai_shutdown() runs
cancel_delayed_work_sync(&it6625->audio_refresh_work) and does not re-schedule
audio_refresh_work after clearing audio_block even when
it6625->audio_settle_polls > 0 and it6625_audio_settling(it6625) is still
true. If the bridge raises no further interrupt once the rate settles, won't
ctrl_audio_sampling_rate and it6625->audio remain stuck at rate 0?
> +
> +static int it6625_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
> +{
> + if ((fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) != SND_SOC_DAIFMT_CBP_CFP ||
> + (fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S ||
> + (fmt & SND_SOC_DAIFMT_INV_MASK) != SND_SOC_DAIFMT_NB_NF)
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> +static int it6625_dai_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params,
> + struct snd_soc_dai *dai)
> +{
> + struct it6625 *it6625 = dai_to_6625(dai);
> + const struct it6625_audio_stream *s;
> + unsigned long flags;
> + int ret;
> +
> + it6625_audio_refresh(it6625);
> +
> + spin_lock_irqsave(&it6625->audio_lock, flags);
> + ret = it6625_audio_validate_locked(it6625);
> + s = &it6625->audio_accepted;
> + if (!ret &&
> + (params_rate(params) != it6625_audio_fs_to_rate(s->fs_code) ||
> + params_channels(params) != s->channels ||
> + params_format(params) != SNDRV_PCM_FORMAT_S32_LE))
> + ret = -EINVAL;
> + spin_unlock_irqrestore(&it6625->audio_lock, flags);
> +
> + return ret;
> +}
> +
> +static int it6625_dai_prepare(struct snd_pcm_substream *substream,
> + struct snd_soc_dai *dai)
> +{
> + struct it6625 *it6625 = dai_to_6625(dai);
> + unsigned long flags;
> + int ret;
> +
> + it6625_audio_refresh(it6625);
> +
> + spin_lock_irqsave(&it6625->audio_lock, flags);
> + ret = it6625_audio_validate_locked(it6625);
> + spin_unlock_irqrestore(&it6625->audio_lock, flags);
> +
> + return ret;
> +}
[Severity: Medium]
Should it6625_dai_startup(), it6625_dai_hw_params(), and it6625_dai_prepare()
call it6625_s_ctrl_audio(&it6625->sd) instead of calling
it6625_audio_refresh(it6625) directly?
Calling it6625_audio_refresh() updates it6625->audio and increments
it6625->audio_gen when a status change is observed, but skips
it6625_audio_update_ctrls().
If an audio change that raised no interrupt is observed by
it6625_dai_startup() and causes it6625_audio_check() to fail, startup returns
an error without scheduling audio_refresh_work and without updating
ctrl_audio_sampling_rate or ctrl_audio_present. Similarly, if
it6625_dai_hw_params() or it6625_dai_prepare() observes a change and returns
-EPIPE, and userspace closes the substream before audio_refresh_work runs,
it6625_dai_shutdown() cancels audio_refresh_work and leaves the v4l2 controls
out of sync with the sample stored in it6625->audio.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-upstream-it6625-alsa-i2s-v1-0-bb91e2879b01@ite.com.tw?part=4
next prev parent reply other threads:[~2026-11-03 7:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 6:50 [PATCH 0/5] media: i2c: it6625: add HDMI audio capture over I2S Hermes Wu via B4 Relay
2026-11-03 6:50 ` [PATCH 1/5] dt-bindings: media: ite,it6625: add audio DAI properties Hermes Wu via B4 Relay
2026-11-03 6:50 ` [PATCH 2/5] media: Documentation: it6625: document the audio controls Hermes Wu via B4 Relay
2026-11-03 6:50 ` [PATCH 3/5] media: i2c: it6625: decode audio status fields with FIELD_GET() Hermes Wu via B4 Relay
2026-11-03 6:50 ` [PATCH 4/5] media: i2c: it6625: add I2S audio capture DAI Hermes Wu via B4 Relay
2026-11-03 7:05 ` sashiko-bot [this message]
2026-11-03 6:50 ` [PATCH 5/5] media: i2c: it6625: capture compressed and HBR audio, not just LPCM Hermes Wu via B4 Relay
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=sashiko-outbox-194692@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Hermes.wu@ite.com.tw \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.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