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 <[email protected]> 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/[email protected]/ > 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/[email protected]?part=13
