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 11/15] drm/i915/dp: Retrain the PCON FRL link from the link check work
Date: Fri, 04 Dec 2026 09:52:15 +0000 [thread overview]
Message-ID: <sashiko-outbox-249544@kernel.org> (raw)
In-Reply-To: <20261204085746.391918-12-ankit.k.nautiyal@intel.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] drm/i915/dp: TOCTOU race before hw_done in
intel_dp_pcon_frl_recover()
- [Medium] drm/i915/dp: missing connected check and lock in
intel_dp_pcon_frl_recover()
- [Medium] drm/i915/dp: intel_dp_pcon_frl_recover() accesses AUX on
suspended display
- [Medium] drm/i915/dp: race between intel_dp_pcon_frl_recover() and HPD
pulse work
- [Low] drm/i915/dp: redundant -EALREADY check in
intel_dp_pcon_frl_recover()
- [Low] drm/i915/dp: missing Fixes trailer for commit 9488a030ac91
--
commit 1499fb0865199b2ac41ce39175d24f1ae4317106
Author: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> drm/i915/dp: Retrain the PCON FRL link from the link check work
>
> When the HDMI link of a PCON goes down while the stream is active, the
> HDMI link status change handler restarts the FRL training, or falls back
> to TMDS mode, directly from the short pulse handling. That runs without
> any modeset lock, so it can race with a modeset that trains the link as
> well, and it has no access to the state of the active stream.
>
> Queue the link check work instead, as it is done for the DP link
> retraining, and restart the FRL training there, with the modeset locks
> held and only if a stream is active. The work restarts the training only
> if the FRL link is not trained and the HDMI link is not active, so it
> does nothing after a fallback to TMDS mode.
>
> This allows to use the state of the active stream for the training in
> the following changes.
>
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
[Severity: Low]
This fixes a concurrency bug in intel_dp_handle_hdmi_link_status_change().
Should this include:
Fixes: 9488a030ac91 ("drm/i915: Add support for enabling link status and recovery")
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 272837cc6efa4..2e92e4898ee6b 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -4637,6 +4637,42 @@ void intel_dp_check_frl_training(struct intel_dp *intel_dp)
> }
> }
>
> +/*
> + * Restart FRL training after the HDMI link went down while the stream is
> + * active, or fall back to TMDS mode.
> + */
> +int intel_dp_pcon_frl_recover(struct intel_encoder *encoder,
> + struct drm_modeset_acquire_ctx *ctx)
> +{
> + struct intel_display *display = to_intel_display(encoder);
> + struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
> + u8 pipe_mask;
> + int ret;
> +
> + 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 ||
> + drm_dp_pcon_hdmi_link_active(&intel_dp->aux))
> + return 0;
[Severity: Medium]
Can intel_dp_pcon_frl_recover() race with intel_dp_detect() and attempt FRL
recovery on a disconnected port?
When the connector is disconnected, intel_dp_retrain_link() returns 0 early
without taking mode_config.connection_mutex, so intel_dp_link_check() still
calls intel_dp_pcon_frl_recover(). This early check then reads
downstream_ports, dpcd, and connector->base.display_info without holding
connection_mutex, racing with intel_dp_detect().
On disconnect while the CRTC is still active, a long HPD clears
frl.is_trained while intel_dp_unset_edid() leaves downstream_ports, dpcd,
and display_info populated. A pending link_check_work then passes the early
check, takes connection_mutex and crtc->base.mutex, and either writes TMDS
fallback DPCD registers to the disconnected port or polls in
intel_dp_pcon_start_frl_training() for up to 1.5 seconds while holding those
locks. Checking intel_dp_is_connected() and locking connection_mutex before
reading the DPCD state would avoid this.
[Severity: Medium]
Can drm_dp_pcon_hdmi_link_active() issue DP AUX transfers against suspended
display hardware on non-TypeC DDI ports?
intel_ddi_init() only sets encoder->suspend_complete (which calls
intel_encoder_link_check_flush_work()) for TypeC encoders, and
__intel_display_driver_pm_suspend() does not flush display->wq.unordered.
Moving FRL recovery from dig_port_work onto encoder->link_check_work allows
a pending work item to run after display access, IRQs, and power domains are
suspended.
Because drm_dp_pcon_hdmi_link_active() runs before acquiring
connection_mutex and checking pipe_mask == 0, it performs AUX MMIO and
runtime PM calls against suspended hardware whenever frl.is_trained is
false. Flushing link_check_work for all DDI encoders on suspend and moving
the AUX read after the active-pipe check would prevent this.
> +
> + /* The connection mutex may be held already by the link retraining */
> + ret = drm_modeset_lock(&display->drm->mode_config.connection_mutex, ctx);
> + if (ret && ret != -EALREADY)
> + return ret;
[Severity: Low]
Is the ret != -EALREADY check needed here? With a non-NULL ctx,
drm_modeset_lock() already converts -EALREADY to 0 internally in
modeset_lock(), so this branch is dead code and "if (ret) return ret;"
matches intel_dp_retrain_link() and intel_dp_get_active_pipes().
> +
> + ret = intel_dp_get_active_pipes(intel_dp, ctx, &pipe_mask);
> + if (ret)
> + return ret;
> +
> + /* Without an active stream the next enable trains the link */
> + if (pipe_mask == 0)
> + return 0;
> +
> + intel_dp_check_frl_training(intel_dp);
[Severity: Medium]
Can intel_dp_pcon_frl_recover() tear down a working TMDS fallback link
because drm_dp_pcon_hdmi_link_active() is checked before
wait_for_connector_hw_done()?
A non-blocking atomic modeset drops the modeset locks and runs
intel_atomic_commit_tail() on display->wq.modeset. If link_check_work runs
concurrently, intel_dp_pcon_frl_recover() reads frl.is_trained and
DP_PCON_HDMI_TX_LINK_STATUS before intel_dp_get_active_pipes() waits on
hw_done, and never re-checks them afterward (unlike intel_dp_retrain_link(),
which re-checks intel_dp_needs_link_retrain()):
CPU0 (wq.modeset) CPU1 (wq.unordered)
intel_atomic_commit_tail()
intel_dp_pcon_frl_recover()
frl.is_trained == false
drm_dp_pcon_hdmi_link_active()
-> false
intel_dp_check_frl_training()
intel_dp_pcon_set_tmds_mode()
signal hw_done
intel_dp_get_active_pipes()
wait_for_connector_hw_done()
intel_dp_check_frl_training()
drm_dp_pcon_frl_prepare()
<-- tears down active TMDS link
When the modeset falls back to TMDS mode, frl.is_trained remains false while
the HDMI link is active in TMDS mode. intel_dp_check_frl_training() then
sees !frl.is_trained and calls drm_dp_pcon_frl_prepare(), disrupting the
active display and repeating up to 1.5 seconds of FRL polling under
connection_mutex and crtc->base.mutex; the pre-wait AUX read can also race
with the in-flight modeset's training. Re-checking frl.is_trained and
drm_dp_pcon_hdmi_link_active() after intel_dp_get_active_pipes() would close
this window.
[Severity: Medium]
Can intel_dp_pcon_frl_recover() race with HPD pulse handling on
frl.is_trained and DP_PCON_HDMI_LINK_CONFIG_1?
Previously, FRL recovery ran in dig_port_work, which serialized it against
intel_dp_hpd_pulse() and intel_dp_handle_hdmi_link_status_change(). In
encoder->link_check_work, intel_dp_pcon_frl_recover() runs on
display->wq.unordered without calling intel_hpd_block(encoder) or sharing a
lock with dig_port_work:
CPU0 (wq.unordered) CPU1 (hotplug.dp_wq)
intel_dp_pcon_frl_recover()
...
intel_dp_pcon_start_frl_training()
intel_dp_pcon_is_frl_trained()
-> true
intel_dp_hpd_pulse() (long HPD)
frl.is_trained = false
frl.is_trained = true <-- overwrites long-HPD reset
Losing the long-HPD reset leaves frl.is_trained set, so the next enable
skips FRL training even though the HDMI link is down. A concurrent short
HPD in intel_dp_handle_hdmi_link_status_change() can also read is_active as
false before training finishes, then see frl.is_trained == true and clear
DP_PCON_ENABLE_HDMI_LINK via an unlocked read-modify-write, tearing down the
freshly trained link. Blocking HPD with intel_hpd_block(encoder) around FRL
recovery would serialize it with dig_port_work.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204085746.391918-1-ankit.k.nautiyal@intel.com?part=11
next prev parent reply other threads:[~2026-12-04 9:52 UTC|newest]
Thread overview: 26+ 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 [this message]
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 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 8:57 ` [PATCH v5 14/15] drm/i915/dp: Pick the bpc for a PCON DSC stream Ankit Nautiyal
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
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-249544@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox