From: sashiko-bot@kernel.org
To: "Ankit Nautiyal" <ankit.k.nautiyal@intel.com>,
intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 12/15] drm/i915/dp: Store the PCON FRL rate in the crtc state
Date: Fri, 04 Dec 2026 10:00:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-249560@kernel.org> (raw)
In-Reply-To: <20261204085746.391918-13-ankit.k.nautiyal@intel.com>
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 <ankit.k.nautiyal@intel.com>
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/i915/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 *intel_dp,
> return false;
> }
>
> -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 = 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 = 0, frl_trained_mask;
> bool is_active;
>
> - max_pcon_frl_bw = intel_dp->dfp.pcon_max_frl_bw;
> - drm_dbg(display->drm, "PCON max rate = %d Gbps\n", max_pcon_frl_bw);
> -
> - max_edid_frl_bw = intel_dp_hdmi_sink_max_frl(intel_dp);
> - drm_dbg(display->drm, "Sink max rate from EDID = %d Gbps\n",
> - max_edid_frl_bw);
> -
> - max_frl_bw = min(max_edid_frl_bw, max_pcon_frl_bw);
> + max_frl_bw = crtc_state->pcon_config.frl_rate_gbps;
> + drm_dbg(display->drm, "FRL max rate = %d Gbps (PCON max rate = %d Gbps)\n",
> + max_frl_bw, intel_dp->dfp.pcon_max_frl_bw);
>
> if (max_frl_bw <= 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 here,
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 *intel_dp)
> return 0;
> }
>
> -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 = to_intel_display(intel_dp);
>
> @@ -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;
>
> - if (intel_dp_pcon_start_frl_training(intel_dp) < 0) {
> + /* A link trained at a lower rate than the stream needs has to be retrained */
> + if (intel_dp->frl.is_trained &&
> + intel_dp->frl.trained_rate_gbps >= crtc_state->pcon_config.frl_rate_gbps)
> + return;
> +
> + if (intel_dp_pcon_start_frl_training(intel_dp, crtc_state) < 0) {
> int ret, mode;
>
> 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() would
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 = to_intel_display(encoder);
> struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
> + struct intel_crtc *crtc;
> u8 pipe_mask;
> int ret;
>
> @@ -4668,7 +4673,10 @@ int intel_dp_pcon_frl_recover(struct intel_encoder *encoder,
> if (pipe_mask == 0)
> return 0;
>
> - intel_dp_check_frl_training(intel_dp);
> + /* The stream is on the pipe of the connector's CRTC, locked above */
> + crtc = intel_crtc_for_pipe(display, ffs(pipe_mask) - 1);
> +
> + intel_dp_check_frl_training(intel_dp, to_intel_crtc_state(crtc->base.state));
>
> 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 == 0, fails with -EINVAL,
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() for
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_port, bool long_hpd)
> * the next enable.
> */
> intel_dp->frl.is_trained = false;
> + intel_dp->frl.trained_rate_gbps = 0;
>
> 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 = 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 == 0 or lose the disconnect reset.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204085746.391918-1-ankit.k.nautiyal@intel.com?part=12
next prev parent reply other threads:[~2026-12-04 10:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 8:57 [PATCH v5 00/15] DP-HDMI PCON DSC fixes Ankit Nautiyal
2026-12-04 8:57 ` [PATCH v5 01/15] drm/i915/dp: Forget the PCON FRL training state on a long HPD Ankit Nautiyal
2026-12-04 9:45 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 02/15] drm/i915/dp: Account for FRL 16b/18b encoding overhead Ankit Nautiyal
2026-12-04 9:36 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 03/15] drm/i915/hdmi: Clamp the target_bpp only when it equals the link bpp Ankit Nautiyal
2026-12-04 8:57 ` [PATCH v5 04/15] drm/i915/dp: Add PCON DSC state to crtc_state Ankit Nautiyal
2026-12-04 9:43 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 05/15] drm/dp: Add a helper to disable the PCON DSC encoder Ankit Nautiyal
2026-12-04 8:57 ` [PATCH v5 06/15] drm/i915/dp: Compute the PCON DSC operation Ankit Nautiyal
2026-12-04 9:38 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 07/15] drm/i915/dp: Disable the PCON DSC encoder unless it is needed Ankit Nautiyal
2026-12-04 9:38 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 08/15] drm/i915/dp: Clamp PCON DSC bpp to the FRL link bandwidth Ankit Nautiyal
2026-12-04 9:33 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 09/15] drm/i915/dp: Add a helper for the FRL payload bandwidth Ankit Nautiyal
2026-12-04 8:57 ` [PATCH v5 10/15] drm/i915/dp: Compute the PCON DSC encoder parameters Ankit Nautiyal
2026-12-04 9:52 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 11/15] drm/i915/dp: Retrain the PCON FRL link from the link check work Ankit Nautiyal
2026-12-04 9:52 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 12/15] drm/i915/dp: Store the PCON FRL rate in the crtc state Ankit Nautiyal
2026-12-04 10:00 ` sashiko-bot [this message]
2026-12-04 8:57 ` [PATCH v5 13/15] drm/i915/dp: Use the FRL rate of the stream on the HDMI link Ankit Nautiyal
2026-12-04 9:58 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 14/15] drm/i915/dp: Pick the bpc for a PCON DSC stream Ankit Nautiyal
2026-12-04 9:58 ` sashiko-bot
2026-12-04 8:57 ` [PATCH v5 15/15] drm/i915/dp: Allow PCON DSC modes through the FRL bw check Ankit Nautiyal
2026-12-04 9:53 ` sashiko-bot
2026-12-04 9:31 ` ✓ CI.KUnit: success for DP-HDMI PCON DSC fixes (rev5) Patchwork
2026-12-04 10:10 ` ✓ Xe.CI.BAT: " Patchwork
2026-12-04 11:05 ` ✗ i915.CI.BAT: failure " Patchwork
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-249560@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ankit.k.nautiyal@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.