From mboxrd@z Thu Jan 1 00:00:00 1970 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 2BEAE606A322 for ; Fri, 4 Dec 2026 10:00:48 +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=c5K4Mmfz Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E142410E66B; Fri, 4 Dec 2026 10:00:42 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0355D10E647; Fri, 4 Dec 2026 10:00:37 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 9CB1144EC0; Fri, 4 Dec 2026 10:00:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 617E51F000C2; Fri, 4 Dec 2026 10:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796378436; bh=ESCuWS8SAOkC5iZbejP3Q6sRBjdjCNpcH9lqwvOQha0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=c5K4MmfzWscv/WVDYNTa3posWQcMTBe1UIzKfdNaYTfC+I9gVua+3TfkWghSWZSTG GnRWDLdEH2GwF8UaQ6s4lFncFcEuWAG6VOWSs0i+0zrsJskAvF9szJRfjSzN6PKSqu mGOzADYV8dF/FcsWF4YT3SouwIxo15LbWFnMA8xL1EzXNUqj+mDM+ZKWRO5i5+IWoC dNIEbZ3zqml92Kk930sKQgEeQ6l+DpvH33GqG2sb9JoxRYkLDWstbo5gNPs61vDb4o RqlpqKOug9gqyRseCgl0UUSjigT9j2DPG9naqWiPMbKSYNIpjh5m2qBm9w1Nr5xA8X Uqai0S3Ryturg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 12/15] drm/i915/dp: Store the PCON FRL rate in the crtc state To: "Ankit Nautiyal" , intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261204085746.391918-13-ankit.k.nautiyal@intel.com> References: <20261204085746.391918-1-ankit.k.nautiyal@intel.com> <20261204085746.391918-13-ankit.k.nautiyal@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 10:00:36 +0000 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-xe" X-Spam-Status: No, score=-11.2 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 5 potential issues to consider: - [Medium] drm/i915/dp: intel_dp_check_frl_training() leaves stale FRL state on failure - [Medium] drm/i915/dp: intel_dp_pcon_frl_recover() fails with zero frl_rate_gbps - [Medium] drm/i915/dp: HPD pulse races with FRL training on frl state and DPCD - [Medium] drm/i915/dp: unlocked read and TOCTOU in intel_dp_pcon_frl_recover() - [Medium] drm/i915/dp: intel_dp_pcon_frl_recover() may see zero frl_rate_gbps -- commit c3d65efbf1eff2d1822dd7d0fa85881a9934f871 Author: Ankit Nautiyal drm/i915/dp: Store the PCON FRL rate in the crtc state This commit computes the PCON FRL rate in intel_dp_pcon_compute_config(), stores it in crtc_state->pcon_config.frl_rate_gbps, and uses it during FRL training and recovery. It also retrains an already-trained FRL link when a new stream requires a higher rate and clears frl.trained_rate_gbps on long HPD. > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i9= 15/display/intel_dp.c > index 2e92e4898ee6b..da3aeba84c602 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp.c > +++ b/drivers/gpu/drm/i915/display/intel_dp.c [ ... ] > @@ -4507,23 +4510,19 @@ intel_dp_pcon_is_frl_trained(struct intel_dp *int= el_dp, > return false; > } > =20 > -static int intel_dp_pcon_start_frl_training(struct intel_dp *intel_dp) > +static int intel_dp_pcon_start_frl_training(struct intel_dp *intel_dp, > + const struct intel_crtc_state *crtc_state) > { > struct intel_display *display =3D to_intel_display(intel_dp); > #define TIMEOUT_FRL_READY_MS 500 > #define TIMEOUT_HDMI_LINK_ACTIVE_MS 1000 > - int max_frl_bw, max_pcon_frl_bw, max_edid_frl_bw, ret; > + int max_frl_bw, ret; > u8 max_frl_bw_mask =3D 0, frl_trained_mask; > bool is_active; > =20 > - max_pcon_frl_bw =3D intel_dp->dfp.pcon_max_frl_bw; > - drm_dbg(display->drm, "PCON max rate =3D %d Gbps\n", max_pcon_frl_bw); > - > - max_edid_frl_bw =3D intel_dp_hdmi_sink_max_frl(intel_dp); > - drm_dbg(display->drm, "Sink max rate from EDID =3D %d Gbps\n", > - max_edid_frl_bw); > - > - max_frl_bw =3D min(max_edid_frl_bw, max_pcon_frl_bw); > + max_frl_bw =3D crtc_state->pcon_config.frl_rate_gbps; > + drm_dbg(display->drm, "FRL max rate =3D %d Gbps (PCON max rate =3D %d G= bps)\n", > + max_frl_bw, intel_dp->dfp.pcon_max_frl_bw); > =20 > if (max_frl_bw <=3D 0) > return -EINVAL; [Severity: Medium] Can crtc_state->pcon_config.frl_rate_gbps be 0 here for a BIOS-inherited state? pcon_config is not read out from hardware during intel_modeset_readout_hw_state(), and intel_dp_initial_fastset_check() does not force a full modeset for uncompressed DP-to-HDMI PCON outputs. Once intel_dp_detect() populates the HDMI 2.1 sink caps, an inactive HDMI link handled by intel_dp_pcon_frl_recover() passes that inherited crtc_state her= e, causing intel_dp_pcon_start_frl_training() to return -EINVAL and fall back = to TMDS mode instead of recovering FRL. [ ... ] > @@ -4607,7 +4606,8 @@ int intel_dp_pcon_set_tmds_mode(struct intel_dp *in= tel_dp) > return 0; > } > =20 > -void intel_dp_check_frl_training(struct intel_dp *intel_dp) > +void intel_dp_check_frl_training(struct intel_dp *intel_dp, > + const struct intel_crtc_state *crtc_state) > { > struct intel_display *display =3D to_intel_display(intel_dp); > =20 > @@ -4617,11 +4617,15 @@ void intel_dp_check_frl_training(struct intel_dp = *intel_dp) > * -sink is HDMI2.1 > */ > if (!(intel_dp->downstream_ports[2] & DP_PCON_SOURCE_CTL_MODE) || > - !intel_dp_is_hdmi_2_1_sink(intel_dp) || > - intel_dp->frl.is_trained) > + !intel_dp_is_hdmi_2_1_sink(intel_dp)) > return; > =20 > - if (intel_dp_pcon_start_frl_training(intel_dp) < 0) { > + /* A link trained at a lower rate than the stream needs has to be retra= ined */ > + if (intel_dp->frl.is_trained && > + intel_dp->frl.trained_rate_gbps >=3D crtc_state->pcon_config.frl_ra= te_gbps) > + return; > + > + if (intel_dp_pcon_start_frl_training(intel_dp, crtc_state) < 0) { > int ret, mode; > =20 > drm_dbg(display->drm, [Severity: Medium] Does this leave intel_dp->frl.is_trained and intel_dp->frl.trained_rate_gbps stale if retraining to a higher rate fails? When retraining runs with frl.is_trained already true, drm_dp_pcon_frl_prepare() clears DP_PCON_ENABLE_HDMI_LINK and tears down the previous FRL link. If training then fails and intel_dp_check_frl_training() switches the PCON to TMDS mode without clearing frl.is_trained and frl.trained_rate_gbps, later modesets requesting at most the old rate take the early return and stay stuck in TMDS mode, and intel_dp_pcon_frl_recover= () skips recovery. Resetting both fields before drm_dp_pcon_frl_prepare() wou= ld keep software state in sync with hardware. > @@ -4646,6 +4650,7 @@ int intel_dp_pcon_frl_recover(struct intel_encoder = *encoder, > { > struct intel_display *display =3D to_intel_display(encoder); > struct intel_dp *intel_dp =3D enc_to_intel_dp(encoder); > + struct intel_crtc *crtc; > u8 pipe_mask; > int ret; > =20 > @@ -4668,7 +4673,10 @@ int intel_dp_pcon_frl_recover(struct intel_encoder= *encoder, > if (pipe_mask =3D=3D 0) > return 0; > =20 > - intel_dp_check_frl_training(intel_dp); > + /* The stream is on the pipe of the connector's CRTC, locked above */ > + crtc =3D intel_crtc_for_pipe(display, ffs(pipe_mask) - 1); > + > + intel_dp_check_frl_training(intel_dp, to_intel_crtc_state(crtc->base.st= ate)); > =20 > return 0; > } [Severity: Medium] Can intel_dp_pcon_frl_recover() pass a crtc_state whose pcon_config.frl_rate_gbps was computed as 0 before EDID detection? During intel_display_driver_probe(), intel_initial_commit() runs before intel_hpd_init() and intel_dp_set_edid(). Even on a Type-C port where intel_ddi_initial_fastset_check() forces a full modeset, intel_dp_is_hdmi_2_1_sink() is still false during that commit, leaving frl_rate_gbps at 0 while intel_dp_stop_link_train() queues link_check_work. Once intel_dp_detect() populates the HDMI 2.1 sink caps, intel_dp_pcon_frl_recover() runs with frl_rate_gbps =3D=3D 0, fails with -E= INVAL, and demotes the link to TMDS mode instead of training FRL. [Severity: Medium] Can intel_dp_pcon_frl_recover() tear down an active TMDS link because drm_dp_pcon_hdmi_link_active() is not re-checked after intel_dp_get_active_pipes()? CPU0 (commit worker) CPU1 (link_check_work) intel_atomic_commit_tail() intel_dp_pcon_frl_recover() ... if (frl.is_trained || drm_dp_pcon_hdmi_link_active()) /* link not active yet */ intel_dp_get_active_pipes() wait_for_connector_hw_done() intel_dp_check_frl_training() intel_dp_pcon_start_frl_training() /* fails */ intel_dp_pcon_set_tmds_mode() /* hw_done signalled */ /* unblocks, no re-check */ intel_dp_check_frl_training() drm_dp_pcon_frl_prepare() <-- tears down active TMDS link Because intel_dp_get_active_pipes() waits in wait_for_connector_hw_done() f= or in-flight nonblocking commits, an initial check before that wait is stale by the time it returns. Additionally, when intel_dp_retrain_link() returns early on !intel_dp_is_connected(intel_dp) without locking mode_config.connection_mutex, intel_dp_pcon_frl_recover() reads downstream_ports, dpcd, pcon_dsc_dpcd, and connector->base.display_info before acquiring connection_mutex, racing with intel_dp_detect(). [ ... ] > @@ -7237,6 +7245,7 @@ intel_dp_hpd_pulse(struct intel_digital_port *dig_p= ort, bool long_hpd) > * the next enable. > */ > intel_dp->frl.is_trained =3D false; > + intel_dp->frl.trained_rate_gbps =3D 0; > =20 > return IRQ_NONE; > } [Severity: Medium] Can concurrent HPD pulses race with FRL retraining on intel_dp->frl and DP_PCON_HDMI_LINK_CONFIG_1? intel_hpd_block() is not called until intel_dp_start_link_train(), after intel_dp_check_frl_training(), and i915_digport_work_func() runs intel_dp_hpd_pulse() without modeset locks: CPU0 (modeset) CPU1 (i915_digport_work_func) intel_dp_check_frl_training() /* is_trained still true */ intel_dp_pcon_start_frl_training() drm_dp_pcon_frl_prepare() /* HDMI link inactive */ drm_dp_pcon_frl_enable() intel_dp_hpd_pulse() intel_dp_handle_hdmi_link_status_change() /* sees is_trained && !is_active */ clear DP_PCON_ENABLE_HDMI_LINK <-- aborts FRL training frl.is_trained =3D false During a rate-upgrade retrain, drm_dp_pcon_frl_prepare() drops the HDMI link while frl.is_trained is still true and polls for up to 1.5 s, allowing a short HPD to clear DP_PCON_ENABLE_HDMI_LINK mid-training or clobber frl.is_trained after training succeeds. Similarly, a long HPD resets frl.is_trained then frl.trained_rate_gbps in reverse order from intel_dp_pcon_start_frl_training() with no lock, which can leave is_trained true with trained_rate_gbps =3D=3D 0 or lose the disconnect reset. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204085746.3919= 18-1-ankit.k.nautiyal@intel.com?part=3D12