All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 04/10] drm/msm/dp: Move link training to atomic_enable()
Date: Thu, 13 Aug 2026 22:02:39 +0000	[thread overview]
Message-ID: <20260813220239.E76AA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260314-hpd-refactor-v5-4-0c8450737d64@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:

New issues:
- [High] Silent link training failure in atomic_enable leaves userspace with a broken display state.
- [High] Moving DP link training to `atomic_enable()` leaves the unplug handler performing unbalanced clock disable and PHY power off, which corrupts the PHY power state.
- [Medium] Commit message and implementation mismatch regarding hpd_notify().

Pre-existing issues:
- [High] Missing PM runtime put on error paths in `msm_dp_bridge_atomic_enable` causes a usage counter leak.
- [High] Failure during `msm_dp_ctrl_on_stream()` permanently leaks link clocks, stream clocks, and PHY power.
--

--- Patch [4]: [PATCH v5 04/10] drm/msm/dp: Move link training to atomic_enable() ---
commit c64d2d707d517a12463d9c1b31e96a4e25a831e3
Author: Jessica Zhang <jesszhan0024@gmail.com>

drm/msm/dp: Move link training to atomic_enable()

This commit moves DP link training from the HPD handler into atomic_enable().
It also states that plug and unplug handlers are called directly in
hpd_notify() to prevent preemption by other events.

> Finally, call the plug/unplug handlers directly in hpd_notify() instead
> of queueing them in the event thread so that they aren't preempted by
> other events.

[Severity: Medium]
Is this description accurate regarding hpd_notify()?

Looking at msm_dp_bridge_hpd_notify(), the code continues to queue events via
msm_dp_add_event() rather than calling the handlers directly:

drivers/gpu/drm/msm/dp/dp_display.c:msm_dp_bridge_hpd_notify() {
    if (!msm_dp_display->link_ready && status == connector_status_connected)
        msm_dp_add_event(dp, EV_HPD_PLUG_INT, 0, 0);
    else if (msm_dp_display->link_ready && status == connector_status_disconnected)
        msm_dp_add_event(dp, EV_HPD_UNPLUG_INT, 0, 0);
}

Could the commit message or implementation be updated to match?

> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index a05144de3b93f..e7b1ed5491c49 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -436,11 +436,6 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)
>  	msm_dp_link_psm_config(dp->link, &dp->panel->link_info, false);
>  
>  	msm_dp_link_reset_phy_params_vx_px(dp->link);
> -	rc = msm_dp_ctrl_on_link(dp->ctrl);
> -	if (rc) {
> -		DRM_ERROR("failed to complete DP link training\n");
> -		goto end;
> -	}

[Severity: High]
Does removing the link training here leave the unplug handler performing an
unbalanced clock disable and PHY power off?

If a user unplugs the display while in ST_MAINLINK_READY (before userspace
issues an atomic commit), msm_dp_hpd_unplug_handle() will call
msm_dp_ctrl_off_link().

This blindly calls clk_bulk_disable_unprepare() and phy_power_off() on clocks
and PHYs that were never enabled, leading to an unbalanced clock disable
warning and decrementing the PHY power_count to a negative value. Once the
power_count drops to -1, the next phy_power_on() increments it to 0 and
bypasses the actual hardware callback, which seems like it would break the
display until reboot.

>  
>  	msm_dp_add_event(dp, EV_USER_NOTIFICATION, true, 0);
>  

[ ... ]

> @@ -1695,6 +1690,11 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
>  		force_link_train = true;
>  	}
>  
> +	rc = msm_dp_ctrl_on_link(msm_dp_display->ctrl);
> +	if (rc)
> +		DRM_ERROR("Failed link training (rc=%d)\n", rc);
> +	// TODO: schedule drm_connector_set_link_status_property()
> +

[Severity: High]
Will this leave userspace with a silently broken display state if
msm_dp_ctrl_on_link() fails?

The error is logged, but execution proceeds to enable the display anyway.
Without the mentioned drm_connector_set_link_status_property() update to mark
the link as BAD, does userspace have any way to know it must trigger a
recovery modeset?

[Severity: High]
This is a pre-existing issue, but does this function leak a PM runtime usage
counter on its error paths?

Earlier in msm_dp_bridge_atomic_enable(), a reference is acquired via
pm_runtime_resume_and_get(), but the early returns do not release it:

drivers/gpu/drm/msm/dp/dp_display.c:msm_dp_bridge_atomic_enable() {
    ...
    hpd_state = msm_dp_display->hpd_state;
    if (hpd_state != ST_DISPLAY_OFF && hpd_state != ST_MAINLINK_READY) {
        mutex_unlock(&msm_dp_display->event_mutex);
        return;
    }

    rc = msm_dp_display_set_mode(dp, &msm_dp_display->msm_dp_mode);
    if (rc) {
        DRM_ERROR("Failed to perform a mode set, rc=%d\n", rc);
        mutex_unlock(&msm_dp_display->event_mutex);
        return;
    }
    ...
}

If either condition fails, the function returns early without calling
pm_runtime_put_sync(). Will this permanently prevent the display controller
from entering suspend states?

[Severity: High]
This is also a pre-existing issue, but can a failure during stream setup
permanently leak link clocks, stream clocks, and PHY power?

In msm_dp_ctrl_on_stream():

drivers/gpu/drm/msm/dp/dp_ctrl.c:msm_dp_ctrl_on_stream() {
    ...
    msm_dp_ctrl_enable_mainlink_clks(ctrl);

    ret = msm_dp_ctrl_set_tu(ctrl);
    if (ret)
        return ret;
    ...
}

If msm_dp_ctrl_set_tu() (or a subsequent step) fails, the function returns
without disabling the clocks and PHY power enabled earlier.

The caller (msm_dp_display_enable) then skips setting
msm_dp_display->power_on = true.

Later, msm_dp_display_disable() bypasses teardown:

drivers/gpu/drm/msm/dp/dp_display.c:msm_dp_display_disable() {
    if (!msm_dp_display->power_on)
        return 0;
    ...
}

Does this bypass cement the resource leak and permanently block PM?

>  	msm_dp_display_enable(msm_dp_display, force_link_train);
>  
>  	rc = msm_dp_display_post_enable(dp);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260314-hpd-refactor-v5-0-0c8450737d64@oss.qualcomm.com?part=4

  parent reply	other threads:[~2026-08-13 22:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-14  1:09 [PATCH v5 00/10] drm/msm/dp: Drop the HPD state machine Dmitry Baryshkov
2026-03-14  1:09 ` [PATCH v5 01/10] drm/msm/dp: fix HPD state status bit shift value Dmitry Baryshkov
2026-05-22 11:28   ` Konrad Dybcio
2026-03-14  1:09 ` [PATCH v5 02/10] drm/msm/dp: Fix the ISR_* enum values Dmitry Baryshkov
2026-05-22 11:28   ` Konrad Dybcio
2026-03-14  1:09 ` [PATCH v5 03/10] drm/msm/dp: Read DPCD and sink count in bridge detect() Dmitry Baryshkov
2026-05-22 11:30   ` Konrad Dybcio
2026-05-22 14:38     ` Dmitry Baryshkov
2026-05-22 14:41       ` Konrad Dybcio
2026-08-13 21:46   ` sashiko-bot
2026-03-14  1:09 ` [PATCH v5 04/10] drm/msm/dp: Move link training to atomic_enable() Dmitry Baryshkov
2026-05-22 11:33   ` Konrad Dybcio
2026-05-24  9:51     ` Dmitry Baryshkov
2026-05-22 11:33   ` Konrad Dybcio
2026-08-13 22:02   ` sashiko-bot [this message]
2026-03-14  1:09 ` [PATCH v5 05/10] drm/msm/dp: Drop EV_USER_NOTIFICATION Dmitry Baryshkov
2026-05-22 11:35   ` Konrad Dybcio
2026-05-22 11:35   ` Konrad Dybcio
2026-03-14  1:09 ` [PATCH v5 06/10] drm/msm/dp: drop event data Dmitry Baryshkov
2026-05-22 11:36   ` Konrad Dybcio
2026-03-14  1:09 ` [PATCH v5 07/10] drm/msm/dp: rework HPD handling Dmitry Baryshkov
2026-03-14  1:09 ` [PATCH v5 08/10] drm/msm/dp: Add sink_count to debug logs Dmitry Baryshkov
2026-05-22 11:40   ` Konrad Dybcio
2026-05-24  9:57     ` Dmitry Baryshkov
2026-03-14  1:09 ` [PATCH v5 09/10] drm/msm/dp: turn link_ready into plugged Dmitry Baryshkov
2026-05-22 11:47   ` Konrad Dybcio
2026-03-14  1:09 ` [PATCH v5 10/10] drm/msm/dp: clear EDID on display unplug Dmitry Baryshkov
2026-05-22 11:49   ` Konrad Dybcio
2026-05-22 12:02     ` Dmitry Baryshkov
2026-05-22 12:06       ` Konrad Dybcio
2026-03-15  0:51 ` [PATCH v5 00/10] drm/msm/dp: Drop the HPD state machine Val Packett
2026-03-15  1:10   ` Val Packett
2026-03-16  3:23     ` Dmitry Baryshkov
2026-03-17 23:15       ` Val Packett
2026-03-18  1:03         ` Dmitry Baryshkov
2026-03-18  1:58           ` Val Packett
2026-05-22 11:27         ` Konrad Dybcio
2026-05-19  6:25 ` Yongxing Mou
2026-05-20 16:14 ` Dmitry Baryshkov

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=20260813220239.E76AA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@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.