From: sashiko-bot@kernel.org
To: "Gianfranco Mariotti" <gianfranco.mariotti94@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 08/10] drm/msm/dp: keep PHY initialized while plugged across link unprepare
Date: Fri, 27 Nov 2026 11:01:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-237202@kernel.org> (raw)
In-Reply-To: <20261127101417.24303-9-gianfranco.mariotti94@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/msm/dp: unbalanced link and PHY teardown when atomic_enable
fails
- [High] drm/msm/dp: race on power_on in msm_dp_hpd_unplug_handle()
exits powered PHY
--
commit 0a488765100dee43f3575efbfcd59d2d2be4bb48
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>
drm/msm/dp: keep PHY initialized while plugged across link unprepare
This commit keeps the DP PHY initialized across link unprepare while a sink
remains plugged in, exits the PHY on unplug when power_on is false, and
balances PHY exit and init across runtime PM suspend and resume.
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index a48f42a173657..d3f4b5a9e723f 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -483,8 +483,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)
> if (!dp->msm_dp_display.is_edp)
> drm_edid_connector_update(dp->msm_dp_display.connector, NULL);
>
> - /* triggered by irq_hdp with sink_count = 0 */
> - if (dp->link->sink_count == 0)
> + if (!dp->msm_dp_display.power_on)
> msm_dp_display_host_phy_exit(dp);
>
> dp->link->has_sink_count = false;
[Severity: High]
Can an unplug during modeset enable cause msm_dp_hpd_unplug_handle() to exit
the PHY while it is powered on and msm_dp_ctrl_on_stream() is running?
msm_dp_display_prepare_link() powers on the PHY and enables link clocks
under dp->plugged_lock, then drops the lock while msm_dp_display->power_on
is still false. msm_dp_display_enable() then runs msm_dp_ctrl_on_stream()
and sets power_on = true without holding dp->plugged_lock:
CPU0 CPU1
msm_dp_display_atomic_enable()
msm_dp_display_prepare_link()
lock(&dp->plugged_lock)
msm_dp_ctrl_on_link()
phy_power_on(phy)
unlock(&dp->plugged_lock)
msm_dp_hpd_unplug_handle()
lock(&dp->plugged_lock)
if (!dp->msm_dp_display.power_on)
msm_dp_display_host_phy_exit(dp)
...
phy_exit(phy) <-- PHY is powered on
msm_dp_display_enable()
msm_dp_ctrl_on_stream()
msm_dp_display->power_on = true
This resets the PHY/PLL and calls phy_exit() while phy->power_count is 1 and
msm_dp_ctrl_on_stream() is accessing link and stream registers clocked by
the PHY PLL.
[ ... ]
> @@ -1533,19 +1534,21 @@ static void msm_dp_display_unprepare(struct msm_dp_display_private *dp)
> {
> struct msm_dp *msm_dp_display = &dp->msm_dp_display;
>
> - /* dongle is still connected but sinks are disconnected */
> - if (dp->link->sink_count == 0)
> - msm_dp_link_psm_config(dp->link, &dp->panel->link_info, true);
> + scoped_guard(mutex, &dp->plugged_lock) {
> + /* dongle is still connected but sinks are disconnected */
> + if (dp->link->sink_count == 0 && dp->plugged)
> + msm_dp_link_psm_config(dp->link, &dp->panel->link_info,
> + true);
>
> - msm_dp_ctrl_off_link(dp->ctrl, dp->panel);
> + msm_dp_ctrl_off_link(dp->ctrl, dp->panel);
>
> - if (dp->link->sink_count == 0)
> - /* re-init the PHY so that we can listen to Dongle disconnect */
> - msm_dp_ctrl_reinit_phy(dp->ctrl);
> - else
> + /* Keep PHY initialized for AUX and IRQ_HPD while a sink remains plugged */
> msm_dp_display_host_phy_exit(dp);
> + if (dp->plugged)
> + msm_dp_display_host_phy_init(dp);
>
> - msm_dp_display->power_on = false;
> + msm_dp_display->power_on = false;
> + }
[Severity: High]
What happens in msm_dp_display_atomic_post_disable() when an earlier
msm_dp_display_atomic_enable() failed and left msm_dp_display->power_on
false?
If msm_dp_display_prepare_link() fails (returning -ENOTCONN or failing link
training in msm_dp_ctrl_on_link(), where msm_dp_ctrl_deinitialize_mainlink()
already disables link clocks and calls phy_power_off()), a later
msm_dp_display_atomic_post_disable() still calls msm_dp_display_unprepare()
unconditionally. Because msm_dp_display_unprepare() does not check
power_on, msm_dp_ctrl_off_link() accesses REG_DP_MAINLINK_CTRL with link
clocks off, calls clk_bulk_disable_unprepare() on already-disabled link
clocks, and calls phy_power_off() when phy->power_count is already 0
(decrementing it to -1 so subsequent phy_power_on() calls never invoke
phy->ops->power_on()).
Conversely, if msm_dp_display_prepare_link() succeeds (leaving the PHY
powered on) and msm_dp_display_enable() fails in msm_dp_ctrl_on_stream(),
power_on is also false, so an unplug or the eDP msm_dp_hpd_unplug_handle()
call at the start of msm_dp_display_atomic_post_disable() now sees
!dp->msm_dp_display.power_on and calls msm_dp_display_host_phy_exit() ->
phy_exit() before msm_dp_display_unprepare() calls phy_power_off().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127101417.24303-1-gianfranco.mariotti94@gmail.com?part=8
next prev parent reply other threads:[~2026-11-27 11:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 10:14 [PATCH v2 00/10] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 01/10] drm/msm/dp: configure voltage swing and pre-emphasis for all active lanes Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 02/10] drm/msm/dp: reset cached link_info before reading DPCD capabilities Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 03/10] drm/msm/dp: keep training pattern active until stream video is ready Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 04/10] drm/msm/dp: reinit video_comp and guard stream state on link maintenance Gianfranco Mariotti
2026-11-27 10:31 ` sashiko-bot
2026-11-27 10:14 ` [PATCH v2 05/10] drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 06/10] drm/msm/dp: track DP_SINK_COUNT capability and sync prev_sink_count Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 07/10] drm/msm/dp: fix HPD plugged, AUX gate, and runtime PM tracking Gianfranco Mariotti
2026-11-27 10:59 ` sashiko-bot
2026-11-27 10:14 ` [PATCH v2 08/10] drm/msm/dp: keep PHY initialized while plugged across link unprepare Gianfranco Mariotti
2026-11-27 11:01 ` sashiko-bot [this message]
2026-11-27 10:14 ` [PATCH v2 09/10] drm/msm/dp: re-read EDID on demand in get_modes when blob is missing Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 10/10] drm/msm/dp: dispatch native IRQ_HPD directly to msm_dp_irq_hpd_handle() Gianfranco Mariotti
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-237202@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gianfranco.mariotti94@gmail.com \
--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