dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Golle" <daniel@makrotopia.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v9 13/14] drm/bridge: it6505: Add audio support
Date: Fri, 20 Nov 2026 00:23:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-224265@kernel.org> (raw)
In-Reply-To: <9fa6e149442b5f7294814762b858ecabc3db4d38.1795132452.git.daniel@makrotopia.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/bridge: it6505: audio not enabled in
  it6505_link_train_ok() when unmuted
- [Medium] drm/bridge: it6505: unlocked chip reset in
  it6505_process_hpd_irq()
- [Medium] drm/bridge: it6505: uncanceled delayed_audio on HPD low in
  it6505_irq_hpd()
--

commit 9525a8456c7b3a8b8b712a90e98e5ba9c8adfe1a
Author: Jiaxin Yu <jiaxin.yu@mediatek.com>

drm/bridge: it6505: Add audio support

This commit registers an hdmi-audio-codec platform device for it6505, wires
up the hdmi_codec_ops callbacks, and serializes audio state and hardware
register updates with an audio_lock mutex.

Link: https://lore.kernel.org/all/20230730180803.22570-4-jiaxin.yu@mediatek.com/

> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 2da58d94127c3..eedc46eaf974b 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c

[ ... ]

> @@ -2326,19 +2337,12 @@ static void it6505_stop_link_train(struct it6505 *it6505)
>  
>  static void it6505_link_train_ok(struct it6505 *it6505)
>  {
> -	struct device *dev = it6505->dev;
> -
>  	it6505->link_state = LINK_OK;
>  	/* disalbe mute enable avi info frame */
>  	it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_VID_MUTE, 0x00);
>  	it6505_set_bits(it6505, REG_INFOFRAME_CTRL,
>  			EN_VID_CTRL_PKT, EN_VID_CTRL_PKT);
>  
> -	if (it6505_audio_input(it6505)) {
> -		DRM_DEV_DEBUG_DRIVER(dev, "Enable audio!");
> -		it6505_enable_audio(it6505);
> -	}
> -
>  	if (it6505->hdcp_desired)
>  		it6505_start_hdcp(it6505);
>  }

[Severity: Medium]
Does removing audio enablement from it6505_link_train_ok() completely leave
audio disabled in hardware whenever link training finishes after the ALSA
stream is already unmuted?

With this removal, __it6505_enable_audio() is only called from
it6505_delayed_audio() (scheduled once, 180 ms after it6505_audio_mute()
unmutes the stream) and from it6505_irq_audio_fifo_error() (which cannot
fire while AUDIO_RESET is asserted and M_AUDIO_I2S_EN is cleared).  If an
active stream is interrupted by an HPD low-to-high pulse (where
it6505_irq_hpd() calls it6505_disable_audio()), or if ALSA unmutes the
stream more than 180 ms before it6505_poweron() and link training complete,
it6505->audio.mute is false when it6505_link_train_ok() runs, yet nothing
re-enables audio.

Should it6505_link_train_ok() still enable audio (or schedule
it6505->delayed_audio) when !it6505->audio.mute?

[ ... ]

> @@ -2785,11 +2791,13 @@ static int it6505_poweron(struct it6505 *it6505)
>  		usleep_range(25000, 35000);
>  	}
>  
> +	mutex_lock(&it6505->audio_lock);
>  	it6505->powered = true;
>  	it6505_reset_logic(it6505);
>  	it6505_int_mask_enable(it6505);
>  	it6505_init(it6505);
>  	it6505_lane_off(it6505);
> +	mutex_unlock(&it6505->audio_lock);
>  
>  	enable_irq(it6505->irq);

[Severity: Medium]
it6505_poweron() holds it6505->audio_lock across it6505_reset_logic(),
it6505_int_mask_enable(), and it6505_init(), but what about
it6505_process_hpd_irq()?

drivers/gpu/drm/bridge/ite-it6505.c:it6505_process_hpd_irq() {
    ...
	if (it6505->branch_device && dpcd_sink_count != it6505->sink_count) {
		memset(it6505->dpcd, 0, sizeof(it6505->dpcd));
		it6505->sink_count = dpcd_sink_count;
		it6505_reset_logic(it6505);
		it6505_int_mask_enable(it6505);
		it6505_init(it6505);
		it6505_remove_edid(it6505);
		return 0;
	}
    ...
}

When a branch device signals a downstream sink-count change via HPD_IRQ,
this runs the same ALL_LOGIC_RESET and register init sequence while
it6505->powered is true without holding it6505->audio_lock, so it can
interleave with __it6505_enable_audio() or __it6505_disable_audio() and
corrupt the audio, mute, and InfoFrame register configuration.

[ ... ]

> @@ -2979,25 +2990,28 @@ static void it6505_remove_notifier_module(struct it6505 *it6505)
>  	flush_work(&it6505->extcon_wq);
>  }
>  
> -static void __maybe_unused it6505_delayed_audio(struct work_struct *work)
> +static void it6505_delayed_audio(struct work_struct *work)
>  {
>  	struct it6505 *it6505 = container_of(work, struct it6505,
>  					     delayed_audio.work);
>  
>  	DRM_DEV_DEBUG_DRIVER(it6505->dev, "start");
>  
> -	if (!it6505->powered)
> +	if (it6505->enable_drv_hold)
>  		return;
>  
> -	if (!it6505->enable_drv_hold)
> -		it6505_enable_audio(it6505);
> +	mutex_lock(&it6505->audio_lock);
> +	if (it6505->powered && !it6505->audio.mute)
> +		__it6505_enable_audio(it6505);
> +	mutex_unlock(&it6505->audio_lock);
>  }

[Severity: Medium]
Can it6505_delayed_audio() re-enable audio and Audio InfoFrames after HPD
has gone low and the link has been shut down?

CPU0                              CPU1
it6505_audio_mute(..., false, ...)
  it6505->audio.mute = false
  queue_delayed_work(...,
    &it6505->delayed_audio, 180ms)
                                  it6505_int_threaded_handler()
                                    it6505_irq_hpd() /* hpd_state == false */
                                      it6505_disable_audio()
                                      it6505_stop_link_train()
                                      it6505_lane_off()
it6505_delayed_audio()
  if (it6505->powered &&
      !it6505->audio.mute)
    __it6505_enable_audio()  <-- enables audio with link and lanes off

When HPD goes low in it6505_irq_hpd(), it6505->delayed_audio is not
cancelled and it6505->powered remains true until extcon or runtime PM powers
the chip off.  it6505_delayed_audio() does not check it6505->hpd_state or
it6505->link_state == LINK_OK before calling __it6505_enable_audio().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795132452.git.daniel@makrotopia.org?part=13

  reply	other threads:[~2026-11-20  0:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 23:58 [PATCH v9 00/14] drm/bridge: it6505: DP audio support + shared-DAI hw_params fix Daniel Golle
2026-11-19 23:58 ` [PATCH v9 01/14] drm/bridge: it6505: quiesce event sources and work on remove() Daniel Golle
2026-11-19 23:59 ` [PATCH v9 02/14] drm/bridge: it6505: quiesce work items before powering off Daniel Golle
2026-11-20  0:19   ` sashiko-bot
2026-11-19 23:59 ` [PATCH v9 03/14] drm/bridge: it6505: balance and disable runtime PM on remove Daniel Golle
2026-11-19 23:59 ` [PATCH v9 04/14] drm/bridge: it6505: unregister DP AUX adapter on bridge detach Daniel Golle
2026-11-19 23:59 ` [PATCH v9 05/14] drm/bridge: it6505: complete poweroff even if disabling regulators fails Daniel Golle
2026-11-20  0:02 ` [PATCH v9 06/14] drm/bridge: it6505: bail out of the IRQ handler when status reads fail Daniel Golle
2026-11-20  0:03 ` [PATCH v9 07/14] drm/bridge: it6505: avoid division by zero in pixel clock calculation Daniel Golle
2026-11-20  0:03 ` [PATCH v9 08/14] drm/bridge: it6505: drop the audio input FS debug print Daniel Golle
2026-11-20  0:04 ` [PATCH v9 09/14] drm/bridge: it6505: guard against zero channel count in audio infoframe Daniel Golle
2026-11-20  0:04 ` [PATCH v9 10/14] drm/bridge: it6505: hold endpoint OF node reference while parsing it Daniel Golle
2026-11-20  0:05 ` [PATCH v9 11/14] drm/bridge: it6505: reject a too short link-frequencies property Daniel Golle
2026-11-20  0:05 ` [PATCH v9 12/14] drm/bridge: it6505: don't write an error code back to the reset register Daniel Golle
2026-11-20  0:06 ` [PATCH v9 13/14] drm/bridge: it6505: Add audio support Daniel Golle
2026-11-20  0:23   ` sashiko-bot [this message]
2026-11-20  0:06 ` [PATCH v9 14/14] drm/bridge: it6505: Don't reject audio hw_params without an encoder Daniel Golle
2026-11-20  0:12 ` [PATCH v9 00/14] drm/bridge: it6505: DP audio support + shared-DAI hw_params fix Daniel Golle

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-224265@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=daniel@makrotopia.org \
    --cc=dri-devel@lists.freedesktop.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