Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFA2B606A31C for ; Mon, 30 Nov 2026 03:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hE4YMBTY Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C48B10E12A; Mon, 30 Nov 2026 03:14:16 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 542B210E12A for ; Mon, 30 Nov 2026 03:14:10 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id D5753412A2; Mon, 30 Nov 2026 03:14:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67B931F00899; Mon, 30 Nov 2026 03:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796008449; bh=0UN3bE6B1A2KurVWNQlgZe95phPDHniA00affjx+n70=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=hE4YMBTYppkykqXean8vFLJpKZM3nD0DeCO69D+ILOf8Pu99uqMGeCoSMs92BzQj9 /ub/HT/qp02U/kH2nfM/isPYsMov68h/2buwoFVRcO3lChOLon/S3jyXw3dDAaRVMR ftqGQ/1xmyWk7pOIvgqfgV399D9ooUlu4+b+IGmNN/3ZH8zzoYFvIXy46IsvBh4tYr rnlTQ+ODwP92rR48ZAyLGFv7TyCSJRo4TB9iketUqooocKE9KeNPnZgmpqccBP0LGv cfobxLw9qH1/IjAoAvpgULw17pQ8lz3lcmKiMrJ9rnZjBGEIIFAXi+oymAMVl87Dsh oYb0zpN+jmQ9A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support To: "Luo Liu" , dri-devel@lists.freedesktop.org In-Reply-To: <20261130025520.766762-4-Luo.Liu@cixtech.com> References: <20261130025520.766762-1-Luo.Liu@cixtech.com> <20261130025520.766762-4-Luo.Liu@cixtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 03:14:08 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] drm/bridge: tda998x: uninitialized hpd_mutex lock in tda998x_detect_work() - [Medium] drm/bridge: tda998x: stale ELD and live state mutation in atomic_check() - [Medium] drm/bridge: tda998x: audio race and DPMS stall in tda998x_bridge_enable() -- commit 759cd5e7edd1580ad6795fbc82cc8be14e7f0776 Author: Luo Liu drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support This commit fixes DRM_BRIDGE_ATTACH_NO_CONNECTOR support in the tda998x bridge driver by retrieving connector display information and ELD from atomic state and reporting hotplug events via drm_bridge_hpd_notify(). > diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridg= e/tda998x_drv.c > index 0b966c9844e70..5a59302e09ec3 100644 > --- a/drivers/gpu/drm/bridge/tda998x_drv.c > +++ b/drivers/gpu/drm/bridge/tda998x_drv.c [ ... ] > @@ -778,10 +788,11 @@ static void tda998x_detect_work(struct work_struct = *work) > { > struct tda998x_priv *priv =3D > container_of(work, struct tda998x_priv, detect_work); > - struct drm_device *dev =3D priv->connector.dev; > =20 > - if (dev) > - drm_kms_helper_hotplug_event(dev); > + if (priv->connector.dev) > + drm_kms_helper_hotplug_event(priv->connector.dev); > + else > + drm_bridge_hpd_notify(&priv->bridge, tda998x_conn_detect(priv)); > } [Severity: Medium] Can tda998x_detect_work() call drm_bridge_hpd_notify() before priv->bridge.hpd_mutex is initialized? tda998x_probe() registers tda998x_irq_thread() and enables HPD interrupts in REG_CEC_RXSHPDINTENA before calling drm_bridge_add(&priv->bridge), which is where mutex_init(&bridge->hpd_mutex) runs. During probe, priv->connector.dev is NULL, so an HPD interrupt that schedules priv->detect_work before drm_bridge_add() finishes (or before a later probe error flushes detect_work at cancel_work) will lock an uninitialized hpd_mutex: CPU0 CPU1 (kworker) tda998x_probe() request_threaded_irq() cec_write(..., CEC_RXSHPDLEV_HPD) tda998x_irq_thread() schedule_work(&priv->detect_work) tda998x_detect_work() drm_bridge_hpd_notify() mutex_lock(&bridge->hpd_mutex) <-- uninitialized mutex ... drm_bridge_add(&priv->bridge) mutex_init(&bridge->hpd_mutex) [ ... ] > @@ -1394,6 +1397,26 @@ static void tda998x_bridge_detach(struct drm_bridg= e *bridge) > drm_connector_cleanup(&priv->connector); > } > =20 > +static int tda998x_bridge_atomic_check(struct drm_bridge *bridge, > + struct drm_bridge_state *bridge_state, > + struct drm_crtc_state *crtc_state, > + struct drm_connector_state *conn_state) > +{ > + struct tda998x_priv *priv =3D bridge_to_tda998x_priv(bridge); > + struct drm_connector *connector =3D conn_state->connector; > + > + priv->rgb_quant_range_selectable =3D > + connector->display_info.rgb_quant_range_selectable; > + > + mutex_lock(&connector->eld_mutex); > + mutex_lock(&priv->audio_mutex); > + memcpy(priv->eld, connector->eld, sizeof(priv->eld)); > + mutex_unlock(&priv->audio_mutex); > + mutex_unlock(&connector->eld_mutex); > + > + return 0; > +} [Severity: Medium] Does populating priv->eld only in tda998x_bridge_atomic_check() leave stale ELD data after the display is unplugged and disabled? When an output is disabled (new_conn_state->crtc =3D=3D NULL), mode_fixup() in drm_atomic_helper.c skips drm_atomic_bridge_chain_check(), and neither tda998x_bridge_disable() nor the HPD disconnect path clears priv->eld. tda998x_audio_get_eld() will continue returning the previous sink's ELD to hdmi_codec_startup(), which checks hcp->eld[0] to decide whether a sink is present, while also returning an empty or outdated ELD after hotplug EDID probing until a modeset runs. In addition, writing priv->rgb_quant_range_selectable and priv->eld here mutates live driver state during DRM_MODE_ATOMIC_TEST_ONLY or failing checks, and taking priv->audio_mutex stalls atomic_check behind the 20 ms msleep() in tda998x_configure_audio(). > @@ -1411,9 +1434,59 @@ static enum drm_mode_status tda998x_bridge_mode_va= lid(struct drm_bridge *bridge, > } > =20 > static void tda998x_bridge_enable(struct drm_bridge *bridge, > - struct drm_atomic_commit *commit) > + struct drm_atomic_commit *state) > { > struct tda998x_priv *priv =3D bridge_to_tda998x_priv(bridge); > + struct drm_connector *connector; > + struct drm_connector_state *conn_state; > + struct drm_crtc_state *crtc_state; > + const struct drm_display_mode *adjusted_mode; > + u8 reg; > + > + connector =3D drm_atomic_get_new_connector_for_encoder(state, > + bridge->encoder); > + conn_state =3D drm_atomic_get_new_connector_state(state, connector); > + > + mutex_lock(&priv->audio_mutex); > + > + if (conn_state && conn_state->crtc) { > + crtc_state =3D drm_atomic_get_new_crtc_state(state, conn_state->crtc); > + adjusted_mode =3D &crtc_state->adjusted_mode; > + > + /* > + * CEA-861B section 6 says that: > + * CEA version 1 (CEA-861) has no support for infoframes. > + * CEA version 2 (CEA-861A) supports version 1 AVI infoframes, > + * and optional basic audio. > + * CEA version 3 (CEA-861B) supports version 1 and 2 AVI infoframes, > + * and optional digital audio, with audio infoframes. > + * > + * Since we only support generation of version 2 AVI infoframes, > + * ignore CEA version 2 and below (iow, behave as if we're a > + * CEA-861 source.) > + */ > + priv->supports_infoframes =3D connector->display_info.cea_rev >=3D 3; > + > + if (priv->supports_infoframes) { > + /* We need to turn HDMI HDCP stuff on to get audio through */ > + reg =3D TBG_CNTRL_1_TGL_EN; > + if (crtc_state->mode.flags & DRM_MODE_FLAG_NHSYNC) > + reg |=3D TBG_CNTRL_1_H_TGL; > + if (crtc_state->mode.flags & DRM_MODE_FLAG_NVSYNC) > + reg |=3D TBG_CNTRL_1_V_TGL; > + reg_write(priv, REG_TBG_CNTRL_1, reg); > + reg_write(priv, REG_ENC_CNTRL, ENC_CNTRL_CTL_CODE(1)); > + reg_set(priv, REG_TX33, TX33_HDMI); > + > + tda998x_write_avi(priv, connector, adjusted_mode); > + tda998x_write_vsi(priv, connector, adjusted_mode); > + > + if (priv->sink_has_audio) > + tda998x_configure_audio(priv); > + } > + } > + > + mutex_unlock(&priv->audio_mutex); [Severity: Medium] Does moving the HDMI and audio setup from tda998x_bridge_mode_set() to tda998x_bridge_enable() reintroduce the audio vs. modeset race that commit 2cae8e028ecb ("drm/i2c: tda998x: avoid race when programming audio") fixed? tda998x_bridge_mode_set() mutes the audio FIFO, disables HDMI mode, and releases priv->audio_mutex while priv->supports_infoframes is still true from the previous mode. Before tda998x_bridge_enable() runs, a concurrent tda998x_audio_hw_params() or tda998x_audio_mute_stream() can acquire priv->audio_mutex, observe priv->supports_infoframes =3D=3D true, a= nd unmute the audio FIFO or write audio infoframes while HDMI mode is still off: CPU0 (modeset) CPU1 (ALSA audio) tda998x_bridge_mode_set() mutex_lock(&priv->audio_mutex) reg_set(..., AIP_CNTRL_0_RST_FIFO) reg_clear(..., TX33_HDMI) mutex_unlock(&priv->audio_mutex) tda998x_audio_mute_stream() mutex_lock(&priv->audio_mutex) if (priv->supports_infoframes) tda998x_audio_mute(priv, false) <-- unmutes FIFO before HDMI on mutex_unlock(&priv->audio_mutex) tda998x_bridge_enable() mutex_lock(&priv->audio_mutex) reg_set(..., TX33_HDMI) Also, because tda998x_bridge_enable() runs on every DPMS ON transition even when tda998x_bridge_disable() only disabled the video ports, every DPMS ON with active audio will now re-run tda998x_configure_audio(), soft-resetting the audio block and sleeping for 20 ms. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130025520.7667= 62-1-Luo.Liu@cixtech.com?part=3D4