drm/msm/dp: Prerequisite cleanup for upcoming MST support
v8 cover drm/msm/dp: Prerequisite cleanup for upcoming MST support
This series is the SST-only prerequisite portion of the MSM DP MST work. It refactors the existing DP code paths so that MST can plug in cleanly in a follow-up series, without bundling the cleanup with MST functionality in the same submission.
SST behaviour is preserved end-to-end; no new functionality is added here. The intent is to land these refactors first to keep the follow-up MST series focused, smaller, and easier to review.
---
Changes in v8:
- Rebase to next-20260717.
- Fix comments from sashiko-bot.
- Link to v7: https://lore.kernel.org/r/[email protected]
Changes in v7:
- patch 7: Use WARN_ON_ONCE() when pixel clock is already on. [Konrad]
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- patch 4: fixed the RMW comments. [Dmitry]
- patch 10: do not rename the existing struct. [Dmitry]
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Split out from v4: only the SST prerequisite cleanup (patches 1-15)
is sent here; the MST implementation will follow on top.
- Rebased onto linux-next-20260527; adapted bridge callbacks to the
new drm_atomic_commit* API.
- patch 3: added Suggested-by: Dmitry Baryshkov.
- patch 4: fixed "splite" typo, reworded body, added RMW comment
covering both SST and MST paths. [Dmitry]
- patch 10: drop cached panel from msm_dp_ctrl_private; pass panel
explicitly to all stream-related dp_ctrl APIs. [Dmitry]
- patch 13/14: introduce bridge wrappers and atomic_prepare with drm_atomic_commit* from the start to preserve bisectability.
- patch 15: fixed pass panel inside the func. [Dmitry]
- Link to v4: https://lore.kernel.org/all/[email protected]/
---
Abhinav Kumar (6):
drm/msm/dp: break up dp_display_enable into two parts drm/msm/dp: re-arrange dp_display_disable() into functional parts drm/msm/dp: allow dp_ctrl stream APIs to use any panel passed to it drm/msm/dp: split dp_ctrl_off() into stream and link parts drm/msm/dp: make bridge helpers use dp_display to allow re-use drm/msm/dp: separate dp_display_prepare() into its own API
Yongxing Mou (9):
drm/msm/dp: remove cached drm_edid from panel
drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable drm/msm/dp: move mode setup into msm_dp_panel_init_panel_info() drm/msm/dp: split msm_dp_ctrl_config_ctrl() into link parts and stream parts drm/msm/dp: extract MISC1_MISC0 configuration into a separate function drm/msm/dp: split link setup from source params
drm/msm/dp: move the pixel clock control to its own API drm/msm/dp: simplify link and clock disable sequence drm/msm/dp: pass panel to display enable/disable helpers
drivers/gpu/drm/msm/dp/dp_ctrl.c | 383 ++++++++++++++++++++---------------- drivers/gpu/drm/msm/dp/dp_ctrl.h | 30 ++- drivers/gpu/drm/msm/dp/dp_display.c | 277 +++++++++++++------------- drivers/gpu/drm/msm/dp/dp_display.h | 8 + drivers/gpu/drm/msm/dp/dp_drm.c | 43 +++- drivers/gpu/drm/msm/dp/dp_drm.h | 12 -- drivers/gpu/drm/msm/dp/dp_panel.c | 77 ++------ drivers/gpu/drm/msm/dp/dp_panel.h | 17 +- 8 files changed, 456 insertions(+), 391 deletions(-)
---
base-commit: 0718283ab28bc3907e10b61a6b4be6fefa1cbb2f
change-id: 20260528-dp_mstclean-f094cea8ca24
Best regards,
Signature · 1 line
Yongxing Mou <[email protected]>
PATCH v8 1/15 drm/msm/dp: remove cached drm_edid from panel
The cached drm_edid seems unnecessary here. Use the drm_edid pointer directly in the plug stage instead of caching it. Remove the cached drm_edid and the corresponding oneliner to simplify the code.
--- drivers/gpu/drm/msm/dp/dp_display.c | 28 +++++++++++------- drivers/gpu/drm/msm/dp/dp_panel.c | 59 ++++--------------------------------- drivers/gpu/drm/msm/dp/dp_panel.h | 13 +++----- 3 files changed, 27 insertions(+), 73 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +18 -10
@@ -269,6 +269,7 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)const struct drm_display_info *info = &connector->display_info;int rc =0 ;u8 dpcd[DP_RECEIVER_CAP_SIZE ]; +const struct drm_edid *drm_edid =NULL ; rc =drm_dp_read_dpcd_caps (dp->aux, dpcd);if (rc)
@@ -276,10 +277,20 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp) dp->link->lttpr_count =msm_dp_display_lttpr_init (dp, dpcd); - rc =msm_dp_panel_read_sink_caps (dp->panel, connector); + rc =msm_dp_panel_read_link_caps (dp->panel, connector);if (rc) goto end; + drm_edid =drm_edid_read_ddc (connector, &dp->aux->ddc); +drm_edid_connector_update (connector, drm_edid); + +if (!drm_edid) { +DRM_ERROR ("panel edid read failed\n" ); +/* check edid read fail is due to unplug */ +if (!msm_dp_aux_is_link_connected (dp->aux)) +return -ETIMEDOUT ; + } +msm_dp_link_process_request (dp->link);if (!dp->msm_dp_display.is_edp)
@@ -291,7 +302,7 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp) dp->msm_dp_display.psr_supported = dp->panel->psr_cap.version && psr_enabled; dp->audio_supported = info->has_audio; -msm_dp_panel_handle_sink_request (dp->panel); +msm_dp_panel_handle_sink_request (dp->panel, drm_edid);/* * set sink to normal operation mode -- D0
@@ -302,6 +313,7 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)msm_dp_link_reset_phy_params_vx_px (dp->link); end: +drm_edid_free (drm_edid);return rc; }
@@ -453,7 +465,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)/* Don't forget modes for eDP */ if (!dp->msm_dp_display.is_edp) -msm_dp_panel_unplugged (dp->panel, dp->msm_dp_display.connector); +drm_edid_connector_update (dp->msm_dp_display.connector,NULL );/* triggered by irq_hdp with sink_count = 0 */ if (dp->link->sink_count ==0 )
@@ -515,7 +527,6 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp)static void msm_dp_display_deinit_sub_modules (struct msm_dp_display_private *dp) {msm_dp_audio_put (dp->audio); -msm_dp_panel_put (dp->panel);msm_dp_aux_put (dp->aux); }
@@ -566,7 +577,7 @@ static int msm_dp_init_sub_modules(struct msm_dp_display_private *dp) rc =PTR_ERR (dp->ctrl);DRM_ERROR ("failed to initialize ctrl, rc = %d\n" , rc); dp->ctrl =NULL ; - goto error_ctrl; + goto error_link; } dp->audio =msm_dp_audio_get (dp->msm_dp_display.pdev, dp->link_base);
@@ -574,13 +585,11 @@ static int msm_dp_init_sub_modules(struct msm_dp_display_private *dp) rc =PTR_ERR (dp->audio);pr_err ("failed to initialize audio, rc = %d\n" , rc); dp->audio =NULL ; - goto error_ctrl; + goto error_link; }return rc; -error_ctrl: -msm_dp_panel_put (dp->panel); error_link:msm_dp_aux_put (dp->aux); error:
@@ -744,8 +753,7 @@ int msm_dp_display_get_modes(struct msm_dp *dp) msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display); -return msm_dp_panel_get_modes (msm_dp_display->panel, - dp->connector); +return drm_edid_connector_add_modes (msm_dp_display->panel->connector); }bool msm_dp_display_check_video_test (struct msm_dp *dp)
drivers/gpu/drm/msm/dp/dp_panel.c +5 -54
95 lines not on this page · raw message
drivers/gpu/drm/msm/dp/dp_panel.h +4 -9
@@ -33,7 +33,6 @@ struct msm_dp_panel {u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS ];struct msm_dp_link_info link_info; -const struct drm_edid *drm_edid;struct drm_connector *connector;struct msm_dp_display_mode msm_dp_mode;struct msm_dp_panel_psr psr_cap;
@@ -47,15 +46,12 @@ struct msm_dp_panel {int msm_dp_panel_init_panel_info (struct msm_dp_panel *msm_dp_panel);int msm_dp_panel_deinit (struct msm_dp_panel *msm_dp_panel);int msm_dp_panel_timing_cfg (struct msm_dp_panel *msm_dp_panel,bool wide_bus_en); -int msm_dp_panel_read_sink_caps (struct msm_dp_panel *msm_dp_panel, -struct drm_connector *connector); -void msm_dp_panel_unplugged (struct msm_dp_panel *msm_dp_panel, -struct drm_connector *connector); +int msm_dp_panel_read_link_caps (struct msm_dp_panel *msm_dp_panel, +struct drm_connector *connector);u32 msm_dp_panel_get_mode_bpp (struct msm_dp_panel *msm_dp_panel,u32 mode_max_bpp,u32 mode_pclk_khz); -int msm_dp_panel_get_modes (struct msm_dp_panel *msm_dp_panel, -struct drm_connector *connector); -void msm_dp_panel_handle_sink_request (struct msm_dp_panel *msm_dp_panel); +void msm_dp_panel_handle_sink_request (struct msm_dp_panel *msm_dp_panel, +const struct drm_edid *drm_edid);void msm_dp_panel_tpg_config (struct msm_dp_panel *msm_dp_panel,bool enable);void msm_dp_panel_clear_dsc_dto (struct msm_dp_panel *msm_dp_panel);
@@ -94,5 +90,4 @@ struct msm_dp_panel *msm_dp_panel_get(struct device *dev, struct drm_dp_aux *auxstruct msm_dp_link *link, void __iomem *link_base, void __iomem *p0_base); -void msm_dp_panel_put (struct msm_dp_panel *msm_dp_panel);#endif /* _DP_PANEL_H_ */
Signature · 1 line
2.43.0
PATCH v8 2/15 drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable
In reply to Yongxing MouThe bridge .mode_set() callback is deprecated. Remove it and move all mode setup logic to .atomic_enable(), where the adjusted_mode is available from the atomic CRTC state.
Drop msm_dp_mode from msm_dp_display_private and store the mode directly in the panel, as it was only used as a temporary cache. Both changes are limited to msm_dp_display_set_mode and are kept in a single patch.
--- drivers/gpu/drm/msm/dp/dp_display.c | 81 ++++++++++++++----------------------- drivers/gpu/drm/msm/dp/dp_drm.c | 2 - drivers/gpu/drm/msm/dp/dp_drm.h | 3 -- 3 files changed, 31 insertions(+), 55 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +31 -50
@@ -63,7 +63,6 @@ struct msm_dp_display_private {struct msm_dp_panel *panel;struct msm_dp_ctrl *ctrl; -struct msm_dp_display_mode msm_dp_mode;struct msm_dp msm_dp_display;/* wait for audio signaling */
@@ -597,16 +596,33 @@ static int msm_dp_init_sub_modules(struct msm_dp_display_private *dp) }static int msm_dp_display_set_mode (struct msm_dp *msm_dp_display, -struct msm_dp_display_mode *mode) +const struct drm_display_mode *adjusted_mode, +struct msm_dp_panel *msm_dp_panel) {struct msm_dp_display_private *dp; +u32 bpp; dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); -drm_mode_copy (&dp->panel->msm_dp_mode.drm_mode, &mode->drm_mode); - dp->panel->msm_dp_mode.bpp = mode->bpp; - dp->panel->msm_dp_mode.out_fmt_is_yuv_420 = mode->out_fmt_is_yuv_420; -msm_dp_panel_init_panel_info (dp->panel); +drm_mode_copy (&msm_dp_panel->msm_dp_mode.drm_mode, adjusted_mode); +if (msm_dp_display_check_video_test (msm_dp_display)) + bpp =msm_dp_display_get_test_bpp (msm_dp_display); +else + bpp = msm_dp_panel->connector->display_info.bpc *3 ; + + msm_dp_panel->msm_dp_mode.bpp = bpp ? bpp :24 ;/* Default bpp */ + msm_dp_panel->msm_dp_mode.v_active_low = + !!(adjusted_mode->flags &DRM_MODE_FLAG_NVSYNC ); + msm_dp_panel->msm_dp_mode.h_active_low = + !!(adjusted_mode->flags &DRM_MODE_FLAG_NHSYNC ); + msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420 = +drm_mode_is_420_only (&msm_dp_panel->connector->display_info, adjusted_mode) && + msm_dp_panel->vsc_sdp_supported; +msm_dp_panel_init_panel_info (msm_dp_panel); + +/* populate wide_bus_support to different layers */ + dp->ctrl->wide_bus_en = + msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420 ? false : dp->wide_bus_supported;return 0 ; }
@@ -1309,7 +1325,7 @@ bool msm_dp_wide_bus_available(const struct msm_dp *msm_dp_display) dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); -if (dp->msm_dp_mode.out_fmt_is_yuv_420) +if (dp->panel->msm_dp_mode.out_fmt_is_yuv_420)return false;return dp->wide_bus_supported;
@@ -1365,15 +1381,19 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, {struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (drm_bridge);struct msm_dp *dp = msm_dp_bridge->msm_dp_display; +struct drm_crtc *crtc; +struct drm_crtc_state *crtc_state;int rc =0 ;struct msm_dp_display_private *msm_dp_display;bool force_link_train = false; msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display); -if (!msm_dp_display->msm_dp_mode.drm_mode.clock) { -DRM_ERROR ("invalid params\n" ); + + crtc =drm_atomic_get_new_crtc_for_encoder (state, + drm_bridge->encoder); +if (!crtc)return ; - } + crtc_state =drm_atomic_get_new_crtc_state (state, crtc);if (dp->is_edp)msm_dp_hpd_plug_handle (msm_dp_display);
@@ -1386,7 +1406,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,if (msm_dp_display->link->sink_count ==0 )return ; - rc =msm_dp_display_set_mode (dp, &msm_dp_display->msm_dp_mode); + rc =msm_dp_display_set_mode (dp, &crtc_state->adjusted_mode, msm_dp_display->panel);if (rc) {DRM_ERROR ("Failed to perform a mode set, rc=%d\n" , rc);return ;
@@ -1446,45 +1466,6 @@ void msm_dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge,pm_runtime_put_sync (&dp->pdev->dev); } -void msm_dp_bridge_mode_set (struct drm_bridge *drm_bridge, -const struct drm_display_mode *mode, -const struct drm_display_mode *adjusted_mode) -{ -struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (drm_bridge); -struct msm_dp *dp = msm_dp_bridge->msm_dp_display; -struct msm_dp_display_private *msm_dp_display; -struct msm_dp_panel *msm_dp_panel; - - msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display); - msm_dp_panel = msm_dp_display->panel; - -memset (&msm_dp_display->msm_dp_mode,0x0 ,sizeof (struct msm_dp_display_mode )); - -if (msm_dp_display_check_video_test (dp)) - msm_dp_display->msm_dp_mode.bpp =msm_dp_display_get_test_bpp (dp); -else /* Default num_components per pixel = 3 */ - msm_dp_display->msm_dp_mode.bpp = dp->connector->display_info.bpc *3 ; - -if (!msm_dp_display->msm_dp_mode.bpp) - msm_dp_display->msm_dp_mode.bpp =24 ;/* Default bpp */ - -drm_mode_copy (&msm_dp_display->msm_dp_mode.drm_mode, adjusted_mode); - - msm_dp_display->msm_dp_mode.v_active_low = - !!(msm_dp_display->msm_dp_mode.drm_mode.flags &DRM_MODE_FLAG_NVSYNC ); - - msm_dp_display->msm_dp_mode.h_active_low = - !!(msm_dp_display->msm_dp_mode.drm_mode.flags &DRM_MODE_FLAG_NHSYNC ); - - msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 = -drm_mode_is_420_only (&dp->connector->display_info, adjusted_mode) && - msm_dp_panel->vsc_sdp_supported; - -/* populate wide_bus_support to different layers */ - msm_dp_display->ctrl->wide_bus_en = - msm_dp_display->msm_dp_mode.out_fmt_is_yuv_420 ? false : msm_dp_display->wide_bus_supported; -} -void msm_dp_bridge_hpd_enable (struct drm_bridge *bridge) {struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (bridge);
drivers/gpu/drm/msm/dp/dp_drm.c +0 -2
@@ -56,7 +56,6 @@ static const struct drm_bridge_funcs msm_dp_bridge_ops = { .atomic_enable = msm_dp_bridge_atomic_enable, .atomic_disable = msm_dp_bridge_atomic_disable, .atomic_post_disable = msm_dp_bridge_atomic_post_disable, - .mode_set = msm_dp_bridge_mode_set, .mode_valid = msm_dp_bridge_mode_valid, .get_modes = msm_dp_bridge_get_modes, .detect = msm_dp_bridge_detect,
@@ -233,7 +232,6 @@ static const struct drm_bridge_funcs msm_edp_bridge_ops = { .atomic_enable = msm_edp_bridge_atomic_enable, .atomic_disable = msm_edp_bridge_atomic_disable, .atomic_post_disable = msm_edp_bridge_atomic_post_disable, - .mode_set = msm_dp_bridge_mode_set, .mode_valid = msm_edp_bridge_mode_valid, .atomic_create_state = drm_atomic_helper_bridge_create_state, .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
drivers/gpu/drm/msm/dp/dp_drm.h +0 -3
@@ -36,9 +36,6 @@ void msm_dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge,enum drm_mode_status msm_dp_bridge_mode_valid (struct drm_bridge *bridge,const struct drm_display_info *info,const struct drm_display_mode *mode); -void msm_dp_bridge_mode_set (struct drm_bridge *drm_bridge, -const struct drm_display_mode *mode, -const struct drm_display_mode *adjusted_mode);void msm_dp_bridge_hpd_enable (struct drm_bridge *bridge);void msm_dp_bridge_hpd_disable (struct drm_bridge *bridge); void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 02/15] drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Moving mode state updates to .atomic_enable causes the DPU encoder to read stale wide bus configuration.
Pre-existing issues:
- [High] mode_valid incorrectly evaluates wide bus availability based on the currently active mode's state rather than the candidate mode, causing valid modes to be rejected. --
--- Patch [2]: [PATCH v8 02/15] drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable --- commit f8a619167d17d8d750e695eca53077efafe8ab7e
Author: Yongxing Mou <[email protected]>
drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable
The bridge .mode_set() callback is deprecated. Remove it and move all mode setup logic to .atomic_enable(), where the adjusted_mode is available from the atomic CRTC state.
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_display.c +0
-0
[ ... ]
drivers/gpu/drm/msm/dp/dp_display.c bool msm_dp_wide_bus_available(const struct msm_dp *msm_dp_display) · line 1331
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-1@@ -1309,7 +1325,7 @@ bool msm_dp_wide_bus_available(const struct msm_dp *msm_dp_display) dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); -if (dp->msm_dp_mode.out_fmt_is_yuv_420) +if (dp->panel->msm_dp_mode.out_fmt_is_yuv_420)return false;return dp->wide_bus_supported;
[Severity: High]
This is a pre-existing issue, but does msm_dp_wide_bus_available() evaluate the candidate mode correctly during mode probing?
This function checks the currently active mode's format (out_fmt_is_yuv_420) instead of the candidate mode's format.
When msm_dp_bridge_mode_valid() (or msm_edp_bridge_mode_valid()) calls this during mode probing, won't it incorrectly reject valid high-resolution RGB modes if the user is currently running a lower-resolution YUV420 mode?
[ ... ]
drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 1412
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-1@@ -1386,7 +1406,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,if (msm_dp_display->link->sink_count ==0 )return ; - rc =msm_dp_display_set_mode (dp, &msm_dp_display->msm_dp_mode); + rc =msm_dp_display_set_mode (dp, &crtc_state->adjusted_mode, msm_dp_display->panel);if (rc) {DRM_ERROR ("Failed to perform a mode set, rc=%d\n" , rc);return ;
[Severity: High]
Does moving this mode setup into .atomic_enable() cause the DPU encoder to read a stale wide bus configuration?
In the DRM atomic commit flow, the encoder's .atomic_enable() (which executes dpu_encoder_virt_atomic_enable()) is called before the bridge's .atomic_enable().
Because msm_dp_display_set_mode() updates the format state (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420), the DPU encoder will query msm_dp_wide_bus_available() before this new mode's format has been stored.
Won't this cause the hardware to be programmed using the wide bus state from the previously active mode, potentially causing display corruption or a blank screen when switching between RGB and YUV420?
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v8 02/15] drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable
Quoted 28 lines · On Mon, Jul 20, 2026 at 06:33:16AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Moving mode state updates to.atomic_enablecauses the DPU encoder to read stale wide bus configuration.Pre-existing issues:
- [High]mode_validincorrectly evaluates wide bus availability based on the currently active mode's state rather than the candidate mode, causing valid modes to be rejected. --drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 1412
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-1@@ -1386,7 +1406,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,if (msm_dp_display->link->sink_count ==0 )return ; - rc =msm_dp_display_set_mode (dp, &msm_dp_display->msm_dp_mode); + rc =msm_dp_display_set_mode (dp, &crtc_state->adjusted_mode, msm_dp_display->panel);if (rc) {DRM_ERROR ("Failed to perform a mode set, rc=%d\n" , rc);return ;[Severity: High]
Does moving this mode setup into .atomic_enable() cause the DPU encoder to read a stale wide bus configuration?In the DRM atomic commit flow, the encoder's .atomic_enable() (which executes
dpu_encoder_virt_atomic_enable()) is called before the bridge's .atomic_enable().
Quoted 7 lines
Because
msm_dp_display_set_mode()updates the format state (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420), the DPU encoder will querymsm_dp_wide_bus_available()before this new mode's format has been stored.Won't this cause the hardware to be programmed using the wide bus state from the previously active mode, potentially causing display corruption or a blank screen when switching between RGB and YUV420?
Indeed, both look like an issue. Please add a patch before this one, adding drm_display_mode to the msm_dp_wide_bus_available() call. It will solve both issues.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v8 02/15] drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable
Quoted 33 lines · Dmitry Baryshkov
Quoted 32 lines · On Mon, Jul 20, 2026 at 06:33:16AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Moving mode state updates to.atomic_enablecauses the DPU encoder to read stale wide bus configuration.Pre-existing issues:
- [High]mode_validincorrectly evaluates wide bus availability based on the currently active mode's state rather than the candidate mode, causing valid modes to be rejected. --drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 1412
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-1@@ -1386,7 +1406,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,if (msm_dp_display->link->sink_count ==0 )return ; - rc =msm_dp_display_set_mode (dp, &msm_dp_display->msm_dp_mode); + rc =msm_dp_display_set_mode (dp, &crtc_state->adjusted_mode, msm_dp_display->panel);if (rc) {DRM_ERROR ("Failed to perform a mode set, rc=%d\n" , rc);return ;[Severity: High]
Does moving this mode setup into .atomic_enable() cause the DPU encoder to read a stale wide bus configuration?In the DRM atomic commit flow, the encoder's .atomic_enable() (which executes
dpu_encoder_virt_atomic_enable()) is called before the bridge's .atomic_enable().Because
msm_dp_display_set_mode()updates the format state (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420), the DPU encoder will querymsm_dp_wide_bus_available()before this new mode's format has been stored.
Quoted 8 lines
Quoted 3 lines
Won't this cause the hardware to be programmed using the wide bus state from the previously active mode, potentially causing display corruption or a blank screen when switching between RGB and YUV420?
Indeed, both look like an issue. Please add a patch before this one, adding
drm_display_modeto themsm_dp_wide_bus_available()call. It will solve both issues.
Sure. Will update it next version.
Re: [PATCH v8 02/15] drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable
Quoted 39 lines · Yongxing Mou
Quoted 36 lines · Dmitry Baryshkov
Quoted 34 lines · On Mon, Jul 20, 2026 at 06:33:16AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Moving mode state updates to.atomic_enablecauses the DPU encoder to read stale wide bus configuration.Pre-existing issues:
- [High]mode_validincorrectly evaluates wide bus availability based on the currently active mode's state rather than the candidate mode, causing valid modes to be rejected. --drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 1411
Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-1@@ -1386,7 +1406,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,if (msm_dp_display->link->sink_count ==0 )return ; - rc =msm_dp_display_set_mode (dp, &msm_dp_display->msm_dp_mode); + rc =msm_dp_display_set_mode (dp, &crtc_state->adjusted_mode, msm_dp_display->panel);if (rc) {DRM_ERROR ("Failed to perform a mode set, rc=%d\n" , rc);return ;[Severity: High]
Does moving this mode setup into .atomic_enable() cause the DPU encoder to read a stale wide bus configuration?In the DRM atomic commit flow, the encoder's .atomic_enable() (which executes
dpu_encoder_virt_atomic_enable()) is called before the bridge's .atomic_enable().Because
msm_dp_display_set_mode()updates the format state (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420), the DPU encoder will querymsm_dp_wide_bus_available()before this new mode's format has been stored.Won't this cause the hardware to be programmed using the wide bus state from the previously active mode, potentially causing display corruption or a blank screen when switching between RGB and YUV420?
Quoted 5 lines
Quoted 4 lines
Indeed, both look like an issue. Please add a patch before this one, adding
drm_display_modeto themsm_dp_wide_bus_available()call. It will solve both issues.Sure. Will update it next version.
I needed to pick up your patches, so I ended up looking at the issue.
See https://lore.kernel.org/dri-devel/20260722-drm-msm-display-interface-v1-0-368c10fe62fd@oss.qualcomm.com/T/#t
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v8 02/15] drm/msm/dp: drop deprecated .mode_set() and use .atomic_enable
Quoted 40 lines · Dmitry Baryshkov
Quoted 39 lines · Yongxing Mou
Quoted 36 lines · Dmitry Baryshkov
Quoted 34 lines · On Mon, Jul 20, 2026 at 06:33:16AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Moving mode state updates to.atomic_enablecauses the DPU encoder to read stale wide bus configuration.Pre-existing issues:
- [High]mode_validincorrectly evaluates wide bus availability based on the currently active mode's state rather than the candidate mode, causing valid modes to be rejected. --drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 1411
Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-1@@ -1386,7 +1406,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,if (msm_dp_display->link->sink_count ==0 )return ; - rc =msm_dp_display_set_mode (dp, &msm_dp_display->msm_dp_mode); + rc =msm_dp_display_set_mode (dp, &crtc_state->adjusted_mode, msm_dp_display->panel);if (rc) {DRM_ERROR ("Failed to perform a mode set, rc=%d\n" , rc);return ;[Severity: High]
Does moving this mode setup into .atomic_enable() cause the DPU encoder to read a stale wide bus configuration?In the DRM atomic commit flow, the encoder's .atomic_enable() (which executes
dpu_encoder_virt_atomic_enable()) is called before the bridge's .atomic_enable().Because
msm_dp_display_set_mode()updates the format state (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420), the DPU encoder will querymsm_dp_wide_bus_available()before this new mode's format has been stored.Won't this cause the hardware to be programmed using the wide bus state from the previously active mode, potentially causing display corruption or a blank screen when switching between RGB and YUV420?
Quoted 9 lines
Quoted 5 lines
Quoted 4 lines
Indeed, both look like an issue. Please add a patch before this one, adding
drm_display_modeto themsm_dp_wide_bus_available()call. It will solve both issues.Sure. Will update it next version.
I needed to pick up your patches, so I ended up looking at the issue.
See https://lore.kernel.org/dri-devel/20260722-drm-msm-display-interface-v1-0-368c10fe62fd@oss.qualcomm.com/T/#t
Thanks for the series. With modeset() moved into pre_enable(), this issue is no longer present.
Do I still need to send a v9 to address the comments on patch 6/10?
If I send a new version, should I include the first two patches as well, or only resend the remaining patches that still need changes?
PATCH v8 3/15 drm/msm/dp: move mode setup into msm_dp_panel_init_panel_info()
In reply to Yongxing MouThe display layer directly assigns msm_dp_panel mode fields (bpp, sync polarity, yuv420 flag) instead of letting the panel manage its own state. Pass adjusted_mode and bpp as parameters to msm_dp_panel_init_panel_info() and move the assignments inside it.
--- drivers/gpu/drm/msm/dp/dp_display.c | 11 +---------- drivers/gpu/drm/msm/dp/dp_panel.c | 18 +++++++++++++++--- drivers/gpu/drm/msm/dp/dp_panel.h | 4 +++- 3 files changed, 19 insertions(+), 14 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -10
@@ -604,21 +604,12 @@ static int msm_dp_display_set_mode(struct msm_dp *msm_dp_display, dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); -drm_mode_copy (&msm_dp_panel->msm_dp_mode.drm_mode, adjusted_mode);if (msm_dp_display_check_video_test (msm_dp_display)) bpp =msm_dp_display_get_test_bpp (msm_dp_display);else bpp = msm_dp_panel->connector->display_info.bpc *3 ; - msm_dp_panel->msm_dp_mode.bpp = bpp ? bpp :24 ;/* Default bpp */ - msm_dp_panel->msm_dp_mode.v_active_low = - !!(adjusted_mode->flags &DRM_MODE_FLAG_NVSYNC ); - msm_dp_panel->msm_dp_mode.h_active_low = - !!(adjusted_mode->flags &DRM_MODE_FLAG_NHSYNC ); - msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420 = -drm_mode_is_420_only (&msm_dp_panel->connector->display_info, adjusted_mode) && - msm_dp_panel->vsc_sdp_supported; -msm_dp_panel_init_panel_info (msm_dp_panel); +msm_dp_panel_init_panel_info (msm_dp_panel, adjusted_mode, bpp ? bpp :24 );/* populate wide_bus_support to different layers */ dp->ctrl->wide_bus_en =
drivers/gpu/drm/msm/dp/dp_panel.c +15 -3
@@ -647,15 +647,27 @@ int msm_dp_panel_timing_cfg(struct msm_dp_panel *msm_dp_panel, bool wide_bus_en)return 0 ; } -int msm_dp_panel_init_panel_info (struct msm_dp_panel *msm_dp_panel) +int msm_dp_panel_init_panel_info (struct msm_dp_panel *msm_dp_panel, +const struct drm_display_mode *adjusted_mode, +u32 bpp) {struct drm_display_mode *drm_mode;struct msm_dp_panel_private *panel; - drm_mode = &msm_dp_panel->msm_dp_mode.drm_mode; - panel = container_of(msm_dp_panel, struct msm_dp_panel_private, msm_dp_panel); +drm_mode_copy (&msm_dp_panel->msm_dp_mode.drm_mode, adjusted_mode); + msm_dp_panel->msm_dp_mode.bpp = bpp; + msm_dp_panel->msm_dp_mode.v_active_low = + !!(adjusted_mode->flags &DRM_MODE_FLAG_NVSYNC ); + msm_dp_panel->msm_dp_mode.h_active_low = + !!(adjusted_mode->flags &DRM_MODE_FLAG_NHSYNC ); + msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420 = +drm_mode_is_420_only (&msm_dp_panel->connector->display_info, adjusted_mode) && + msm_dp_panel->vsc_sdp_supported; + + drm_mode = &msm_dp_panel->msm_dp_mode.drm_mode; +/* * print resolution info as this is a result * of user initiated action of cable connection
drivers/gpu/drm/msm/dp/dp_panel.h +3 -1
@@ -43,7 +43,9 @@ struct msm_dp_panel {u32 max_bw_code; }; -int msm_dp_panel_init_panel_info (struct msm_dp_panel *msm_dp_panel); +int msm_dp_panel_init_panel_info (struct msm_dp_panel *msm_dp_panel, +const struct drm_display_mode *adjusted_mode, +u32 bpp);int msm_dp_panel_deinit (struct msm_dp_panel *msm_dp_panel);int msm_dp_panel_timing_cfg (struct msm_dp_panel *msm_dp_panel,bool wide_bus_en); int msm_dp_panel_read_link_caps(struct msm_dp_panel *msm_dp_panel,
Signature · 1 line
2.43.0
PATCH v8 4/15 drm/msm/dp: split msm_dp_ctrl_config_ctrl() into link parts and stream parts
In reply to Yongxing MouThe DP_CONFIGURATION_CTRL register contains both link-level and stream-specific fields. Currently, msm_dp_ctrl_config_ctrl() configures all of them together. Separate the configuration into link parts and stream parts to support MST.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 47 +++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +32 -15
@@ -388,26 +388,44 @@ void msm_dp_ctrl_push_idle(struct msm_dp_ctrl *msm_dp_ctrl)drm_dbg_dp (ctrl->drm_dev,"mainlink off\n" ); } -static void msm_dp_ctrl_config_ctrl (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_config_ctrl_streams (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *msm_dp_panel) {u32 config =0 , tbd; + +/* +* RMW: Called from atomic_enable(). Serialized by the DRM atomic framework. +*/ + config =msm_dp_read_link (ctrl,REG_DP_CONFIGURATION_CTRL ); + +if (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420) + config |=DP_CONFIGURATION_CTRL_RGB_YUV ;/* YUV420 */ + + tbd =msm_dp_link_get_test_bits_depth (ctrl->link, + msm_dp_panel->msm_dp_mode.bpp); + + config |= tbd <<DP_CONFIGURATION_CTRL_BPC_SHIFT ; + +if (msm_dp_panel->psr_cap.version) + config |=DP_CONFIGURATION_CTRL_SEND_VSC ; + +drm_dbg_dp (ctrl->drm_dev,"stream DP_CONFIGURATION_CTRL=0x%x\n" , config); + +msm_dp_write_link (ctrl,REG_DP_CONFIGURATION_CTRL , config); +} + +static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl) +{ +u32 config =0 ;const u8 *dpcd = ctrl->panel->dpcd;/* Default-> LSCLK DIV: 1/4 LCLK */ config |= (2 <<DP_CONFIGURATION_CTRL_LSCLK_DIV_SHIFT ); -if (ctrl->panel->msm_dp_mode.out_fmt_is_yuv_420) - config |=DP_CONFIGURATION_CTRL_RGB_YUV ;/* YUV420 */ -/* Scrambler reset enable */ if (drm_dp_alternate_scrambler_reset_cap (dpcd)) config |=DP_CONFIGURATION_CTRL_ASSR ; - tbd =msm_dp_link_get_test_bits_depth (ctrl->link, - ctrl->panel->msm_dp_mode.bpp); - - config |= tbd <<DP_CONFIGURATION_CTRL_BPC_SHIFT ; -/* Num of Lanes */ config |= ((ctrl->link->link_params.num_lanes -1 ) <<DP_CONFIGURATION_CTRL_NUM_OF_LANES_SHIFT );
@@ -421,10 +439,7 @@ static void msm_dp_ctrl_config_ctrl(struct msm_dp_ctrl_private *ctrl) config |=DP_CONFIGURATION_CTRL_STATIC_DYNAMIC_CN ; config |=DP_CONFIGURATION_CTRL_SYNC_ASYNC_CLK ; -if (ctrl->panel->psr_cap.version) - config |=DP_CONFIGURATION_CTRL_SEND_VSC ; - -drm_dbg_dp (ctrl->drm_dev,"DP_CONFIGURATION_CTRL=0x%x\n" , config); +drm_dbg_dp (ctrl->drm_dev,"link DP_CONFIGURATION_CTRL=0x%x\n" , config);msm_dp_write_link (ctrl,REG_DP_CONFIGURATION_CTRL , config); }
@@ -450,7 +465,8 @@ static void msm_dp_ctrl_configure_source_params(struct msm_dp_ctrl_private *ctrlmsm_dp_ctrl_lane_mapping (ctrl);msm_dp_setup_peripheral_flush (ctrl); -msm_dp_ctrl_config_ctrl (ctrl); +msm_dp_ctrl_config_ctrl_link (ctrl); +msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel); test_bits_depth =msm_dp_link_get_test_bits_depth (ctrl->link, ctrl->panel->msm_dp_mode.bpp); colorimetry_cfg =msm_dp_link_get_colorimetry_config (ctrl->link);
@@ -1628,7 +1644,8 @@ static int msm_dp_ctrl_link_train(struct msm_dp_ctrl_private *ctrl,u8 assr;struct msm_dp_link_info link_info = {0 }; -msm_dp_ctrl_config_ctrl (ctrl); +msm_dp_ctrl_config_ctrl_link (ctrl); +msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel); link_info.num_lanes = ctrl->link->link_params.num_lanes; link_info.rate = ctrl->link->link_params.rate;
Signature · 1 line
2.43.0
PATCH v8 5/15 drm/msm/dp: extract MISC1_MISC0 configuration into a separate function
In reply to Yongxing MouRefactor the MISC1_MISC0 register configuration into a standalone helper function to support MST.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +15 -8
@@ -458,17 +458,13 @@ static void msm_dp_ctrl_lane_mapping(struct msm_dp_ctrl_private *ctrl) ln_mapping); } -static void msm_dp_ctrl_configure_source_params (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_config_misc1_misc0 (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *msm_dp_panel) {u32 colorimetry_cfg, test_bits_depth, misc_val; -msm_dp_ctrl_lane_mapping (ctrl); -msm_dp_setup_peripheral_flush (ctrl); - -msm_dp_ctrl_config_ctrl_link (ctrl); -msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel); - - test_bits_depth =msm_dp_link_get_test_bits_depth (ctrl->link, ctrl->panel->msm_dp_mode.bpp); + test_bits_depth =msm_dp_link_get_test_bits_depth (ctrl->link, + msm_dp_panel->msm_dp_mode.bpp); colorimetry_cfg =msm_dp_link_get_colorimetry_config (ctrl->link); misc_val =msm_dp_read_link (ctrl,REG_DP_MISC1_MISC0 );
@@ -482,6 +478,17 @@ static void msm_dp_ctrl_configure_source_params(struct msm_dp_ctrl_private *ctrldrm_dbg_dp (ctrl->drm_dev,"misc settings = 0x%x\n" , misc_val);msm_dp_write_link (ctrl,REG_DP_MISC1_MISC0 , misc_val); +} + +static void msm_dp_ctrl_configure_source_params (struct msm_dp_ctrl_private *ctrl) +{ +msm_dp_ctrl_lane_mapping (ctrl); +msm_dp_setup_peripheral_flush (ctrl); + +msm_dp_ctrl_config_ctrl_link (ctrl); +msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel); + +msm_dp_ctrl_config_misc1_misc0 (ctrl, ctrl->panel);msm_dp_panel_timing_cfg (ctrl->panel, ctrl->msm_dp_ctrl.wide_bus_en); }
Signature · 1 line
2.43.0
PATCH v8 6/15 drm/msm/dp: split link setup from source params
In reply to Yongxing Moumsm_dp_ctrl_configure_source_params() should only handle stream-related configuration. Move the link setup out of it so MST can program link and stream settings separately.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +4 -4
@@ -482,10 +482,6 @@ static void msm_dp_ctrl_config_misc1_misc0(struct msm_dp_ctrl_private *ctrl,static void msm_dp_ctrl_configure_source_params (struct msm_dp_ctrl_private *ctrl) { -msm_dp_ctrl_lane_mapping (ctrl); -msm_dp_setup_peripheral_flush (ctrl); - -msm_dp_ctrl_config_ctrl_link (ctrl);msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel);msm_dp_ctrl_config_misc1_misc0 (ctrl, ctrl->panel);
@@ -2552,6 +2548,10 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl, bool force_link_train*/ reinit_completion (&ctrl->video_comp); +msm_dp_ctrl_lane_mapping (ctrl); +msm_dp_setup_peripheral_flush (ctrl); +msm_dp_ctrl_config_ctrl_link (ctrl); +msm_dp_ctrl_configure_source_params (ctrl); msm_dp_ctrl_config_msa(ctrl,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 06/15] drm/msm/dp: split link setup from source params
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] msm_dp_ctrl_config_ctrl_streams() performs an incomplete Read-Modify-Write (RMW) on…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] msm_dp_ctrl_config_ctrl_streams() performs an incomplete Read-Modify-Write (RMW) on REG_DP_CONFIGURATION_CTRL without clearing stream-specific bitfields, leading to potential hardware state corruption. --
--- Patch [6]: [PATCH v8 06/15] drm/msm/dp: split link setup from source params --- commit ea5efedb46078b56862c196153fb89423c8cb660
Author: Yongxing Mou <[email protected]>
drm/msm/dp: split link setup from source params
msm_dp_ctrl_configure_source_params() should only handle stream-related configuration. Move the link setup out of it so MST can program link and stream settings separately.
drivers/gpu/drm/msm/dp/dp_ctrl.c static void msm_dp_ctrl_config_misc1_misc0(struct msm_dp_ctrl_private *ctrl, · line 485
Quoted 13 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-4@@ -482,10 +482,6 @@ static void msm_dp_ctrl_config_misc1_misc0(struct msm_dp_ctrl_private *ctrl,static void msm_dp_ctrl_configure_source_params (struct msm_dp_ctrl_private *ctrl) { -msm_dp_ctrl_lane_mapping (ctrl); -msm_dp_setup_peripheral_flush (ctrl); - -msm_dp_ctrl_config_ctrl_link (ctrl);msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel);
[Severity: Medium]
By splitting the link setup from the stream setup here, are we exposing an incomplete read-modify-write in msm_dp_ctrl_config_ctrl_streams()?
When MST programs the link and stream settings separately, msm_dp_ctrl_config_ctrl_streams() will be called independently. Looking at msm_dp_ctrl_config_ctrl_streams():
drivers/gpu/drm/msm/dp/dp_ctrl.c:msm_dp_ctrl_config_ctrl_streams() {
...
config = msm_dp_read_link(ctrl, REG_DP_CONFIGURATION_CTRL);
if (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420)
config |= DP_CONFIGURATION_CTRL_RGB_YUV; /* YUV420 */
tbd = msm_dp_link_get_test_bits_depth(ctrl->link,
msm_dp_panel->msm_dp_mode.bpp);
config |= tbd << DP_CONFIGURATION_CTRL_BPC_SHIFT;
...
}Since this function reads the register and bitwise-ORs the new values without clearing the existing stream-specific bitfields (like the BPC or YUV bits), won't this cause bit accumulation and hardware state corruption across multiple streams if the link isn't reset in between?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Re: [PATCH v8 06/15] drm/msm/dp: split link setup from source params
Quoted 22 lines · On Mon, Jul 20, 2026 at 06:27:28AM +0000, [email protected] wrote:
[Severity: Medium]
By splitting the link setup from the stream setup here, are we exposing an incomplete read-modify-write inmsm_dp_ctrl_config_ctrl_streams()?When MST programs the link and stream settings separately,
msm_dp_ctrl_config_ctrl_streams()will be called independently. Looking atmsm_dp_ctrl_config_ctrl_streams():drivers/gpu/drm/msm/dp/dp_ctrl.c:msm_dp_ctrl_config_ctrl_streams() { ... config = msm_dp_read_link(ctrl, REG_DP_CONFIGURATION_CTRL); if (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420) config |= DP_CONFIGURATION_CTRL_RGB_YUV; /* YUV420 */ tbd = msm_dp_link_get_test_bits_depth(ctrl->link, msm_dp_panel->msm_dp_mode.bpp); config |= tbd << DP_CONFIGURATION_CTRL_BPC_SHIFT; ... }
Quoted 4 lines
Since this function reads the register and bitwise-ORs the new values without clearing the existing stream-specific bitfields (like the BPC or YUV bits), won't this cause bit accumulation and hardware state corruption across multiple streams if the link isn't reset in between?
This deserves a comment or a fix.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v8 06/15] drm/msm/dp: split link setup from source params
Quoted 23 lines · Dmitry Baryshkov
Quoted 22 lines · On Mon, Jul 20, 2026 at 06:27:28AM +0000, [email protected] wrote:
[Severity: Medium]
By splitting the link setup from the stream setup here, are we exposing an incomplete read-modify-write inmsm_dp_ctrl_config_ctrl_streams()?When MST programs the link and stream settings separately,
msm_dp_ctrl_config_ctrl_streams()will be called independently. Looking atmsm_dp_ctrl_config_ctrl_streams():drivers/gpu/drm/msm/dp/dp_ctrl.c:msm_dp_ctrl_config_ctrl_streams() { ... config = msm_dp_read_link(ctrl, REG_DP_CONFIGURATION_CTRL); if (msm_dp_panel->msm_dp_mode.out_fmt_is_yuv_420) config |= DP_CONFIGURATION_CTRL_RGB_YUV; /* YUV420 */ tbd = msm_dp_link_get_test_bits_depth(ctrl->link, msm_dp_panel->msm_dp_mode.bpp); config |= tbd << DP_CONFIGURATION_CTRL_BPC_SHIFT; ... }
Quoted 7 lines
Quoted 4 lines
Since this function reads the register and bitwise-ORs the new values without clearing the existing stream-specific bitfields (like the BPC or YUV bits), won't this cause bit accumulation and hardware state corruption across multiple streams if the link isn't reset in between?
This deserves a comment or a fix.
I'll add a clear-before-programming step for these three fields in the next revision.
PATCH v8 7/15 drm/msm/dp: move the pixel clock control to its own API
In reply to Yongxing MouEnable/Disable of DP pixel clock happens in multiple code paths leading to code duplication. Move it into individual helpers so that the helpers can be called wherever necessary.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 80 +++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 38 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +42 -38
@@ -2172,6 +2172,41 @@ static bool msm_dp_ctrl_send_phy_test_pattern(struct msm_dp_ctrl_private *ctrl)return success; } +static int msm_dp_ctrl_on_pixel_clk (struct msm_dp_ctrl_private *ctrl,unsigned long pixel_rate) +{ +int ret; + + ret =clk_set_rate (ctrl->pixel_clk, pixel_rate *1000 ); +if (ret) { +DRM_ERROR ("Failed to set pixel clock rate. ret=%d\n" , ret); +return ret; + } + +if (WARN_ON_ONCE (ctrl->stream_clks_on)) +return 0 ; + + ret =clk_prepare_enable (ctrl->pixel_clk); +if (ret) { +DRM_ERROR ("Failed to start pixel clocks. ret=%d\n" , ret); +return ret; + } + ctrl->stream_clks_on = true; + +return ret; +} + +static void msm_dp_ctrl_off_pixel_clk (struct msm_dp_ctrl *msm_dp_ctrl) +{ +struct msm_dp_ctrl_private *ctrl; + + ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); + +if (ctrl->stream_clks_on) { +clk_disable_unprepare (ctrl->pixel_clk); + ctrl->stream_clks_on = false; + } +} +static int msm_dp_ctrl_process_phy_test_request (struct msm_dp_ctrl_private *ctrl) {int ret;
@@ -2197,22 +2232,9 @@ static int msm_dp_ctrl_process_phy_test_request(struct msm_dp_ctrl_private *ctrl } pixel_rate = ctrl->panel->msm_dp_mode.drm_mode.clock; - ret =clk_set_rate (ctrl->pixel_clk, pixel_rate *1000 ); -if (ret) { -DRM_ERROR ("Failed to set pixel clock rate. ret=%d\n" , ret); + ret =msm_dp_ctrl_on_pixel_clk (ctrl, pixel_rate); +if (ret)return ret; - } - -if (ctrl->stream_clks_on) { -drm_dbg_dp (ctrl->drm_dev,"pixel clks already enabled\n" ); - }else { - ret =clk_prepare_enable (ctrl->pixel_clk); -if (ret) { -DRM_ERROR ("Failed to start pixel clocks. ret=%d\n" , ret); -return ret; - } - ctrl->stream_clks_on = true; - }msm_dp_ctrl_send_phy_test_pattern (ctrl);
@@ -2515,26 +2537,13 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl, bool force_link_train ret =msm_dp_ctrl_enable_mainlink_clocks (ctrl);if (ret) {DRM_ERROR ("Failed to start link clocks. ret=%d\n" , ret); - goto end; +return ret; } } - ret =clk_set_rate (ctrl->pixel_clk, pixel_rate *1000 ); -if (ret) { -DRM_ERROR ("Failed to set pixel clock rate. ret=%d\n" , ret); - goto end; - } - -if (ctrl->stream_clks_on) { -drm_dbg_dp (ctrl->drm_dev,"pixel clks already enabled\n" ); - }else { - ret =clk_prepare_enable (ctrl->pixel_clk); -if (ret) { -DRM_ERROR ("Failed to start pixel clocks. ret=%d\n" , ret); - goto end; - } - ctrl->stream_clks_on = true; - } + ret =msm_dp_ctrl_on_pixel_clk (ctrl, pixel_rate); +if (ret) +return ret;if (force_link_train || !msm_dp_ctrl_channel_eq_ok (ctrl))msm_dp_ctrl_link_retrain (ctrl);
@@ -2573,7 +2582,6 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl, bool force_link_traindrm_dbg_dp (ctrl->drm_dev,"mainlink %s\n" , mainlink_ready ?"READY" :"NOT READY" ); -end:return ret; }
@@ -2621,11 +2629,7 @@ void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl)msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl); -if (ctrl->stream_clks_on) { -clk_disable_unprepare (ctrl->pixel_clk); - ctrl->stream_clks_on = false; - } - +msm_dp_ctrl_off_pixel_clk (msm_dp_ctrl);dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 07/15] drm/msm/dp: move the pixel clock control to its own API
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Spurious WARN_ON_ONCE triggered on display enable retry due to unhandled clock state on error…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Spurious WARN_ON_ONCE triggered on display enable retry due to unhandled clock state on error path.
- [Low] Incomplete refactoring: msm_dp_ctrl_off_link_stream() still uses open-coded pixel clock disablement. --
--- Patch [7]: [PATCH v8 07/15] drm/msm/dp: move the pixel clock control to its own API --- commit 56bf43c0164f110e1bba46e5b2fdcdcbaa97bf82
Author: Yongxing Mou <[email protected]>
drm/msm/dp: move the pixel clock control to its own API
Enable/Disable of DP pixel clock happens in multiple code paths leading to code duplication. Move it into individual helpers so that the helpers can be called wherever necessary.
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-0
[ ... ]
drivers/gpu/drm/msm/dp/dp_ctrl.c static bool msm_dp_ctrl_send_phy_test_pattern(struct msm_dp_ctrl_private *ctrl) · line 2186
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +12
-0+static int msm_dp_ctrl_on_pixel_clk (struct msm_dp_ctrl_private *ctrl,unsigned long pixel_rate) +{ +int ret; + + ret =clk_set_rate (ctrl->pixel_clk, pixel_rate *1000 ); +if (ret) { +DRM_ERROR ("Failed to set pixel clock rate. ret=%d\n" , ret); +return ret; + } + +if (WARN_ON_ONCE (ctrl->stream_clks_on)) +return 0 ;
[Severity: Medium]
Can this WARN_ON_ONCE be triggered by a recoverable hardware timeout?
If msm_dp_ctrl_wait4video_ready() fails in msm_dp_ctrl_on_stream(), it returns directly without disabling the pixel clock, leaving ctrl->stream_clks_on set to true.
Since the display enable failed, msm_dp_display->power_on remains false. A subsequent cleanup call to msm_dp_display_disable() returns immediately because power_on is false, which prevents it from cleaning up the clock state.
When the display is retried, msm_dp_ctrl_on_pixel_clk() will be called again and hit this new warning.
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +12
-0+ + ret =clk_prepare_enable (ctrl->pixel_clk); +if (ret) { +DRM_ERROR ("Failed to start pixel clocks. ret=%d\n" , ret); +return ret; + } + ctrl->stream_clks_on = true; + +return ret; +} + +static void msm_dp_ctrl_off_pixel_clk (struct msm_dp_ctrl *msm_dp_ctrl)
drivers/gpu/drm/msm/dp/dp_ctrl.c static bool msm_dp_ctrl_send_phy_test_pattern(struct msm_dp_ctrl_private *ctrl) · line 2208
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +10
-0+{ +struct msm_dp_ctrl_private *ctrl; + + ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); + +if (ctrl->stream_clks_on) { +clk_disable_unprepare (ctrl->pixel_clk); + ctrl->stream_clks_on = false; + } +}
[Severity: Low]
This isn't a bug, but could this new helper also be used in msm_dp_ctrl_off_link_stream() to replace the open-coded check?
It looks like msm_dp_ctrl_off_link_stream() still retains the duplicated pixel clock disablement logic:
if (ctrl->stream_clks_on) {
clk_disable_unprepare(ctrl->pixel_clk);
ctrl->stream_clks_on = false;
}Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
PATCH v8 8/15 drm/msm/dp: break up dp_display_enable into two parts
In reply to Yongxing MouFrom: Abhinav Kumar <[email protected]>
dp_display_enable() currently re-trains the link if needed and then enables the pixel clock, programs the controller to start sending the pixel stream. Split these two parts into prepare/enable APIs, to support MST bridges_enable insert the MST payloads funcs between enable stream_clks and program register.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 48 ++++++++++------ drivers/gpu/drm/msm/dp/dp_ctrl.h | 3 +- drivers/gpu/drm/msm/dp/dp_display.c | 107 +++++++++++++++++++++++------------- 3 files changed, 104 insertions(+), 54 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +32 -16
@@ -2507,27 +2507,19 @@ static void msm_dp_ctrl_config_msa(struct msm_dp_ctrl_private *ctrl,msm_dp_write_link (ctrl,REG_DP_SOFTWARE_NVID , nvid); } -int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl,bool force_link_train) +int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl,bool force_link_train) {int ret =0 ; -bool mainlink_ready = false;struct msm_dp_ctrl_private *ctrl; -unsigned long pixel_rate; -unsigned long pixel_rate_orig;if (!msm_dp_ctrl)return -EINVAL ; ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); - pixel_rate = pixel_rate_orig = ctrl->panel->msm_dp_mode.drm_mode.clock; - -if (msm_dp_ctrl->wide_bus_en || ctrl->panel->msm_dp_mode.out_fmt_is_yuv_420) - pixel_rate >>=1 ; - -drm_dbg_dp (ctrl->drm_dev,"rate=%d, num_lanes=%d, pixel_rate=%lu\n" , - ctrl->link->link_params.rate, - ctrl->link->link_params.num_lanes, pixel_rate); +drm_dbg_dp (ctrl->drm_dev,"rate=%d, num_lanes=%d\n" , + ctrl->link->link_params.rate, + ctrl->link->link_params.num_lanes); drm_dbg_dp(ctrl->drm_dev, "core_clk_on=%d link_clk_on=%d stream_clk_on=%d\n",
@@ -2541,16 +2533,40 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl, bool force_link_train } } - ret =msm_dp_ctrl_on_pixel_clk (ctrl, pixel_rate); -if (ret) -return ret; -if (force_link_train || !msm_dp_ctrl_channel_eq_ok (ctrl))msm_dp_ctrl_link_retrain (ctrl);/* stop txing train pattern to end link training */ msm_dp_ctrl_clear_training_pattern (ctrl,DP_PHY_DPRX ); +return ret; +} + +int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl) +{ +int ret =0 ; +bool mainlink_ready = false; +struct msm_dp_ctrl_private *ctrl; +unsigned long pixel_rate; +unsigned long pixel_rate_orig; + +if (!msm_dp_ctrl) +return -EINVAL ; + + ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); + + pixel_rate_orig = ctrl->panel->msm_dp_mode.drm_mode.clock; + pixel_rate = pixel_rate_orig; + +if (msm_dp_ctrl->wide_bus_en || ctrl->panel->msm_dp_mode.out_fmt_is_yuv_420) + pixel_rate >>=1 ; + +drm_dbg_dp (ctrl->drm_dev,"pixel_rate=%lu\n" , pixel_rate); + + ret =msm_dp_ctrl_on_pixel_clk (ctrl, pixel_rate); +if (ret) +return ret; +/* * Set up transfer unit values and set controller state to send * video.
drivers/gpu/drm/msm/dp/dp_ctrl.h +2 -1
@@ -17,7 +17,8 @@ struct msm_dp_ctrl {struct phy ;int msm_dp_ctrl_on_link (struct msm_dp_ctrl *msm_dp_ctrl); -int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl,bool force_link_train); +int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl); +int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl,bool force_link_train);void msm_dp_ctrl_off_link_stream (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_push_idle (struct msm_dp_ctrl *msm_dp_ctrl);
drivers/gpu/drm/msm/dp/dp_display.c +70 -37
178 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v8 9/15 drm/msm/dp: re-arrange dp_display_disable() into functional parts
In reply to Yongxing MouFrom: Abhinav Kumar <[email protected]>
dp_display_disable() handles special case of when monitor is disconnected from the dongle while the dongle stays connected thereby needing a separate function dp_ctrl_off_link_stream() for this. However with a slight rework this can still be handled by keeping common paths same for regular and special case.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 19 +------------------ drivers/gpu/drm/msm/dp/dp_ctrl.h | 2 +- drivers/gpu/drm/msm/dp/dp_display.c | 10 +++++++++- 3 files changed, 11 insertions(+), 20 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +1 -18
@@ -2601,7 +2601,7 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl)return ret; } -void msm_dp_ctrl_off_link_stream (struct msm_dp_ctrl *msm_dp_ctrl) +void msm_dp_ctrl_reinit_phy (struct msm_dp_ctrl *msm_dp_ctrl) {struct msm_dp_ctrl_private *ctrl;struct phy *phy;
@@ -2609,23 +2609,6 @@ void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl) ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); phy = ctrl->phy; -msm_dp_panel_disable_vsc_sdp (ctrl->panel); - -/* set dongle to D3 (power off) mode */ -msm_dp_link_psm_config (ctrl->link, &ctrl->panel->link_info, true); - -msm_dp_ctrl_mainlink_disable (ctrl); - -if (ctrl->stream_clks_on) { -clk_disable_unprepare (ctrl->pixel_clk); - ctrl->stream_clks_on = false; - } - -dev_pm_opp_set_rate (ctrl->dev,0 ); -msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl); - -phy_power_off (phy); -/* aux channel down, reinit phy */ phy_exit (phy);phy_init (phy);
drivers/gpu/drm/msm/dp/dp_ctrl.h +1 -1
@@ -19,7 +19,6 @@ struct phy;int msm_dp_ctrl_on_link (struct msm_dp_ctrl *msm_dp_ctrl);int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl);int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl,bool force_link_train); -void msm_dp_ctrl_off_link_stream (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_push_idle (struct msm_dp_ctrl *msm_dp_ctrl);irqreturn_t msm_dp_ctrl_isr (struct msm_dp_ctrl *msm_dp_ctrl);
@@ -46,4 +45,5 @@ void msm_dp_ctrl_core_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_enable_irq (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_disable_irq (struct msm_dp_ctrl *msm_dp_ctrl); +void msm_dp_ctrl_reinit_phy (struct msm_dp_ctrl *msm_dp_ctrl);#endif /* _DP_CTRL_H_ */
drivers/gpu/drm/msm/dp/dp_display.c +9 -1
@@ -716,12 +716,20 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)if (!msm_dp_display->power_on)return 0 ; +msm_dp_panel_disable_vsc_sdp (dp->panel); + +/* dongle is still connected but sinks are disconnected */ if (dp->link->sink_count ==0 ) {/* * irq_hpd with sink_count = 0 * hdmi unplugged out of dongle */ -msm_dp_ctrl_off_link_stream (dp->ctrl); + +/* set dongle to D3 (power off) mode */ +msm_dp_link_psm_config (dp->link, &dp->panel->link_info, true); +msm_dp_ctrl_off (dp->ctrl); +/* re-init the PHY so that we can listen to Dongle disconnect */ +msm_dp_ctrl_reinit_phy (dp->ctrl); }else {/* * unplugged interrupt
Signature · 1 line
2.43.0
PATCH v8 10/15 drm/msm/dp: allow dp_ctrl stream APIs to use any panel passed to it
In reply to Yongxing MouFrom: Abhinav Kumar <[email protected]>
With MST, multiple sinks share a single DP controller, so a cached panel in msm_dp_ctrl_private can no longer represent the per-stream sink. Drop the cache and pass panel explicitly to all stream-related dp_ctrl APIs.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 198 ++++++++++++++++++++---------------- drivers/gpu/drm/msm/dp/dp_ctrl.h | 28 +++-- drivers/gpu/drm/msm/dp/dp_display.c | 24 ++--- 3 files changed, 141 insertions(+), 109 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +111 -87
@@ -114,7 +114,6 @@ struct msm_dp_ctrl_private {struct drm_device *drm_dev;struct device *dev;struct drm_dp_aux *aux; -struct msm_dp_panel *panel;struct msm_dp_link *link;void __iomem *ahb_base;void __iomem *link_base;
@@ -202,7 +201,8 @@ static int msm_dp_aux_link_configure(struct drm_dp_aux *aux,/* * NOTE: resetting DP controller will also clear any pending HPD related interrupts */ -void msm_dp_ctrl_reset (struct msm_dp_ctrl *msm_dp_ctrl) +void msm_dp_ctrl_reset (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel) {struct msm_dp_ctrl_private *ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl);
@@ -219,7 +219,7 @@ void msm_dp_ctrl_reset(struct msm_dp_ctrl *msm_dp_ctrl)if (!ctrl->hw_revision) { ctrl->hw_revision =msm_dp_read_ahb (ctrl,REG_DP_HW_VERSION ); - ctrl->panel->hw_revision = ctrl->hw_revision; + panel->hw_revision = ctrl->hw_revision; } }
@@ -414,10 +414,11 @@ static void msm_dp_ctrl_config_ctrl_streams(struct msm_dp_ctrl_private *ctrl,msm_dp_write_link (ctrl,REG_DP_CONFIGURATION_CTRL , config); } -static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {u32 config =0 ; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd;/* Default-> LSCLK DIV: 1/4 LCLK */ config |= (2 <<DP_CONFIGURATION_CTRL_LSCLK_DIV_SHIFT );
@@ -480,13 +481,14 @@ static void msm_dp_ctrl_config_misc1_misc0(struct msm_dp_ctrl_private *ctrl,msm_dp_write_link (ctrl,REG_DP_MISC1_MISC0 , misc_val); } -static void msm_dp_ctrl_configure_source_params (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_configure_source_params (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) { -msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel); +msm_dp_ctrl_config_ctrl_streams (ctrl, panel); -msm_dp_ctrl_config_misc1_misc0 (ctrl, ctrl->panel); +msm_dp_ctrl_config_misc1_misc0 (ctrl, panel); -msm_dp_panel_timing_cfg (ctrl->panel, ctrl->msm_dp_ctrl.wide_bus_en); +msm_dp_panel_timing_cfg (panel, ctrl->msm_dp_ctrl.wide_bus_en); }/*
@@ -1256,20 +1258,21 @@ static void _dp_ctrl_calc_tu(struct msm_dp_ctrl_private *ctrl, }static void msm_dp_ctrl_calc_tu_parameters (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel,struct msm_dp_vc_tu_mapping_table *tu_table) {struct msm_dp_tu_calc_input in; -struct drm_display_mode *drm_mode; +const struct drm_display_mode *drm_mode; - drm_mode = &ctrl->panel->msm_dp_mode.drm_mode; + drm_mode = &panel->msm_dp_mode.drm_mode; in.lclk = ctrl->link->link_params.rate /1000 ; in.pclk_khz = drm_mode->clock; in.hactive = drm_mode->hdisplay; in.hporch = drm_mode->htotal - drm_mode->hdisplay; in.nlanes = ctrl->link->link_params.num_lanes; - in.bpp = ctrl->panel->msm_dp_mode.bpp; - in.pixel_enc = ctrl->panel->msm_dp_mode.out_fmt_is_yuv_420 ?420 :444 ; + in.bpp = panel->msm_dp_mode.bpp; + in.pixel_enc = panel->msm_dp_mode.out_fmt_is_yuv_420 ?420 :444 ; in.dsc_en =0 ; in.async_en =0 ; in.fec_en =0 ;
@@ -1279,14 +1282,15 @@ static void msm_dp_ctrl_calc_tu_parameters(struct msm_dp_ctrl_private *ctrl,_dp_ctrl_calc_tu (ctrl, &in, tu_table); } -static void msm_dp_ctrl_setup_tr_unit (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_setup_tr_unit (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {u32 msm_dp_tu =0x0 ;u32 valid_boundary =0x0 ;u32 valid_boundary2 =0x0 ;struct msm_dp_vc_tu_mapping_table tu_calc_table; -msm_dp_ctrl_calc_tu_parameters (ctrl, &tu_calc_table); +msm_dp_ctrl_calc_tu_parameters (ctrl, panel, &tu_calc_table); msm_dp_tu |= tu_calc_table.tu_size_minus1; valid_boundary |= tu_calc_table.valid_boundary_link;
@@ -1438,6 +1442,7 @@ static int msm_dp_ctrl_set_pattern_state_bit(struct msm_dp_ctrl_private *ctrl, }static int msm_dp_ctrl_link_train_1 (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel,int *training_step,enum drm_dp_phy dp_phy) {int delay_us;
@@ -1446,7 +1451,7 @@ static int msm_dp_ctrl_link_train_1(struct msm_dp_ctrl_private *ctrl,int const maximum_retries =4 ; delay_us =drm_dp_read_clock_recovery_delay (ctrl->aux, - ctrl->panel->dpcd, dp_phy, false); + panel->dpcd, dp_phy, false);msm_dp_write_link (ctrl,REG_DP_STATE_CTRL ,0 );
@@ -1532,14 +1537,15 @@ static int msm_dp_ctrl_link_rate_down_shift(struct msm_dp_ctrl_private *ctrl)return ret; } -static int msm_dp_ctrl_link_lane_down_shift (struct msm_dp_ctrl_private *ctrl) +static int msm_dp_ctrl_link_lane_down_shift (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {if (ctrl->link->link_params.num_lanes ==1 )return -1 ; ctrl->link->link_params.num_lanes /=2 ; - ctrl->link->link_params.rate = ctrl->panel->link_info.rate; + ctrl->link->link_params.rate = panel->link_info.rate; ctrl->link->phy_params.p_level =0 ; ctrl->link->phy_params.v_level =0 ;
@@ -1548,6 +1554,7 @@ static int msm_dp_ctrl_link_lane_down_shift(struct msm_dp_ctrl_private *ctrl) }static void msm_dp_ctrl_clear_training_pattern (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel,enum drm_dp_phy dp_phy) {int delay_us;
@@ -1555,11 +1562,12 @@ static void msm_dp_ctrl_clear_training_pattern(struct msm_dp_ctrl_private *ctrl,msm_dp_ctrl_train_pattern_set (ctrl,DP_TRAINING_PATTERN_DISABLE , dp_phy); delay_us =drm_dp_read_channel_eq_delay (ctrl->aux, - ctrl->panel->dpcd, dp_phy, false); + panel->dpcd, dp_phy, false);fsleep (delay_us); }static int msm_dp_ctrl_link_train_2 (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel,int *training_step,enum drm_dp_phy dp_phy) {int delay_us;
@@ -1570,16 +1578,16 @@ static int msm_dp_ctrl_link_train_2(struct msm_dp_ctrl_private *ctrl,u8 link_status[DP_LINK_STATUS_SIZE ]; delay_us =drm_dp_read_channel_eq_delay (ctrl->aux, - ctrl->panel->dpcd, dp_phy, false); + panel->dpcd, dp_phy, false);msm_dp_write_link (ctrl,REG_DP_STATE_CTRL ,0 ); *training_step =DP_TRAINING_2 ; -if (drm_dp_tps4_supported (ctrl->panel->dpcd)) { +if (drm_dp_tps4_supported (panel->dpcd)) { pattern =DP_TRAINING_PATTERN_4 ; state_ctrl_bit =4 ; - }else if (drm_dp_tps3_supported (ctrl->panel->dpcd)) { + }else if (drm_dp_tps3_supported (panel->dpcd)) { pattern =DP_TRAINING_PATTERN_3 ; state_ctrl_bit =3 ; }else {
@@ -1616,18 +1624,19 @@ static int msm_dp_ctrl_link_train_2(struct msm_dp_ctrl_private *ctrl, }static int msm_dp_ctrl_link_train_1_2 (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel,int *training_step,enum drm_dp_phy dp_phy) {int ret; - ret =msm_dp_ctrl_link_train_1 (ctrl, training_step, dp_phy); + ret =msm_dp_ctrl_link_train_1 (ctrl, panel, training_step, dp_phy);if (ret) {DRM_ERROR ("link training #1 on phy %d failed. ret=%d\n" , dp_phy, ret);return ret; }drm_dbg_dp (ctrl->drm_dev,"link training #1 on phy %d successful\n" , dp_phy); - ret =msm_dp_ctrl_link_train_2 (ctrl, training_step, dp_phy); + ret =msm_dp_ctrl_link_train_2 (ctrl, panel, training_step, dp_phy);if (ret) {DRM_ERROR ("link training #2 on phy %d failed. ret=%d\n" , dp_phy, ret);return ret;
@@ -1638,17 +1647,18 @@ static int msm_dp_ctrl_link_train_1_2(struct msm_dp_ctrl_private *ctrl, }static int msm_dp_ctrl_link_train (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel,int *training_step) {int i;int ret =0 ; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd;u8 encoding[] = {0 ,DP_SET_ANSI_8B10B };u8 assr;struct msm_dp_link_info link_info = {0 }; -msm_dp_ctrl_config_ctrl_link (ctrl); -msm_dp_ctrl_config_ctrl_streams (ctrl, ctrl->panel); +msm_dp_ctrl_config_ctrl_link (ctrl, panel); +msm_dp_ctrl_config_ctrl_streams (ctrl, panel); link_info.num_lanes = ctrl->link->link_params.num_lanes; link_info.rate = ctrl->link->link_params.rate;
@@ -1671,8 +1681,8 @@ static int msm_dp_ctrl_link_train(struct msm_dp_ctrl_private *ctrl,for (i = ctrl->link->lttpr_count -1 ; i >=0 ; i--) {enum drm_dp_phy dp_phy =DP_PHY_LTTPR (i); - ret =msm_dp_ctrl_link_train_1_2 (ctrl, training_step, dp_phy); -msm_dp_ctrl_clear_training_pattern (ctrl, dp_phy); + ret =msm_dp_ctrl_link_train_1_2 (ctrl, panel, training_step, dp_phy); +msm_dp_ctrl_clear_training_pattern (ctrl, panel, dp_phy);if (ret)break ;
@@ -1683,7 +1693,7 @@ static int msm_dp_ctrl_link_train(struct msm_dp_ctrl_private *ctrl, goto end; } - ret =msm_dp_ctrl_link_train_1_2 (ctrl, training_step,DP_PHY_DPRX ); + ret =msm_dp_ctrl_link_train_1_2 (ctrl, panel, training_step,DP_PHY_DPRX );if (ret) {DRM_ERROR ("link training on sink failed. ret=%d\n" , ret); goto end;
@@ -1696,6 +1706,7 @@ static int msm_dp_ctrl_link_train(struct msm_dp_ctrl_private *ctrl, }static int msm_dp_ctrl_setup_main_link (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel,int *training_step) {int ret =0 ;
@@ -1711,7 +1722,7 @@ static int msm_dp_ctrl_setup_main_link(struct msm_dp_ctrl_private *ctrl,* a link training pattern, we have to first do soft reset. */ - ret =msm_dp_ctrl_link_train (ctrl, training_step); + ret =msm_dp_ctrl_link_train (ctrl, panel, training_step);return ret; }
@@ -1810,11 +1821,12 @@ static void msm_dp_ctrl_link_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl) str_on_off(ctrl->core_clks_on)); } -static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl) +static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {int ret =0 ;struct phy *phy = ctrl->phy; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd; ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes; ctrl->phy_opts.dp.link_rate = ctrl->link->link_params.rate /100 ;
@@ -1866,13 +1878,14 @@ static void msm_dp_ctrl_psr_exit(struct msm_dp_ctrl_private *ctrl)msm_dp_write_link (ctrl,REG_PSR_CMD , cmd); } -void msm_dp_ctrl_config_psr (struct msm_dp_ctrl *msm_dp_ctrl) +void msm_dp_ctrl_config_psr (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel) {struct msm_dp_ctrl_private *ctrl =container_of (msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl);u32 cfg; -if (!ctrl->panel->psr_cap.version) +if (!panel->psr_cap.version)return ;/* enable PSR1 function */
@@ -1887,12 +1900,13 @@ void msm_dp_ctrl_config_psr(struct msm_dp_ctrl *msm_dp_ctrl)drm_dp_dpcd_write (ctrl->aux,DP_PSR_EN_CFG , &cfg,1 ); } -void msm_dp_ctrl_set_psr (struct msm_dp_ctrl *msm_dp_ctrl,bool enter) +void msm_dp_ctrl_set_psr (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel,bool enter) {struct msm_dp_ctrl_private *ctrl =container_of (msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); -if (!ctrl->panel->psr_cap.version) +if (!panel->psr_cap.version)return ;/*
@@ -1962,7 +1976,8 @@ void msm_dp_ctrl_phy_exit(struct msm_dp_ctrl *msm_dp_ctrl)phy_exit (phy); } -static int msm_dp_ctrl_reinitialize_mainlink (struct msm_dp_ctrl_private *ctrl) +static int msm_dp_ctrl_reinitialize_mainlink (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {struct phy *phy = ctrl->phy;int ret =0 ;
@@ -1983,7 +1998,7 @@ static int msm_dp_ctrl_reinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)/* hw recommended delay before re-enabling clocks */ msleep (20 ); - ret =msm_dp_ctrl_enable_mainlink_clocks (ctrl); + ret =msm_dp_ctrl_enable_mainlink_clocks (ctrl, panel);if (ret) {DRM_ERROR ("Failed to enable mainlink clks. ret=%d\n" , ret);return ret;
@@ -1992,7 +2007,8 @@ static int msm_dp_ctrl_reinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)return ret; } -static int msm_dp_ctrl_deinitialize_mainlink (struct msm_dp_ctrl_private *ctrl) +static int msm_dp_ctrl_deinitialize_mainlink (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {struct phy *phy;
@@ -2000,7 +2016,7 @@ static int msm_dp_ctrl_deinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)msm_dp_ctrl_mainlink_disable (ctrl); -msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl); +msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl, panel);dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);
@@ -2014,7 +2030,8 @@ static int msm_dp_ctrl_deinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)return 0 ; } -static int msm_dp_ctrl_link_maintenance (struct msm_dp_ctrl_private *ctrl) +static int msm_dp_ctrl_link_maintenance (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {int ret =0 ;int training_step =DP_TRAINING_NONE ;
@@ -2024,11 +2041,11 @@ static int msm_dp_ctrl_link_maintenance(struct msm_dp_ctrl_private *ctrl) ctrl->link->phy_params.p_level =0 ; ctrl->link->phy_params.v_level =0 ; - ret =msm_dp_ctrl_setup_main_link (ctrl, &training_step); + ret =msm_dp_ctrl_setup_main_link (ctrl, panel, &training_step);if (ret) goto end; -msm_dp_ctrl_clear_training_pattern (ctrl,DP_PHY_DPRX ); +msm_dp_ctrl_clear_training_pattern (ctrl, panel,DP_PHY_DPRX );msm_dp_write_link (ctrl,REG_DP_STATE_CTRL ,DP_STATE_CTRL_SEND_VIDEO );
@@ -2207,7 +2224,8 @@ static void msm_dp_ctrl_off_pixel_clk(struct msm_dp_ctrl *msm_dp_ctrl) } } -static int msm_dp_ctrl_process_phy_test_request (struct msm_dp_ctrl_private *ctrl) +static int msm_dp_ctrl_process_phy_test_request (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {int ret;unsigned long pixel_rate;
@@ -2223,15 +2241,15 @@ static int msm_dp_ctrl_process_phy_test_request(struct msm_dp_ctrl_private *ctrl* running. Add the global reset just before disabling the * link clocks and core clocks. */ -msm_dp_ctrl_off (&ctrl->msm_dp_ctrl); +msm_dp_ctrl_off (&ctrl->msm_dp_ctrl, panel); - ret =msm_dp_ctrl_on_link (&ctrl->msm_dp_ctrl); + ret =msm_dp_ctrl_on_link (&ctrl->msm_dp_ctrl, panel);if (ret) {DRM_ERROR ("failed to enable DP link controller\n" );return ret; } - pixel_rate = ctrl->panel->msm_dp_mode.drm_mode.clock; + pixel_rate = panel->msm_dp_mode.drm_mode.clock; ret =msm_dp_ctrl_on_pixel_clk (ctrl, pixel_rate);if (ret)return ret;
@@ -2241,7 +2259,8 @@ static int msm_dp_ctrl_process_phy_test_request(struct msm_dp_ctrl_private *ctrlreturn 0 ; } -void msm_dp_ctrl_handle_sink_request (struct msm_dp_ctrl *msm_dp_ctrl) +void msm_dp_ctrl_handle_sink_request (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel) {struct msm_dp_ctrl_private *ctrl;u32 sink_request =0x0 ;
@@ -2256,14 +2275,14 @@ void msm_dp_ctrl_handle_sink_request(struct msm_dp_ctrl *msm_dp_ctrl)if (sink_request &DP_TEST_LINK_PHY_TEST_PATTERN ) {drm_dbg_dp (ctrl->drm_dev,"PHY_TEST_PATTERN request\n" ); -if (msm_dp_ctrl_process_phy_test_request (ctrl)) { +if (msm_dp_ctrl_process_phy_test_request (ctrl, panel)) {DRM_ERROR ("process phy_test_req failed\n" );return ; } }if (sink_request &DP_LINK_STATUS_UPDATED ) { -if (msm_dp_ctrl_link_maintenance (ctrl)) { +if (msm_dp_ctrl_link_maintenance (ctrl, panel)) {DRM_ERROR ("LM failed: TEST_LINK_TRAINING\n" );return ; }
@@ -2271,7 +2290,7 @@ void msm_dp_ctrl_handle_sink_request(struct msm_dp_ctrl *msm_dp_ctrl)if (sink_request &DP_TEST_LINK_TRAINING ) {msm_dp_link_send_test_response (ctrl->link); -if (msm_dp_ctrl_link_maintenance (ctrl)) { +if (msm_dp_ctrl_link_maintenance (ctrl, panel)) {DRM_ERROR ("LM failed: TEST_LINK_TRAINING\n" );return ; }
@@ -2307,7 +2326,8 @@ static bool msm_dp_ctrl_channel_eq_ok(struct msm_dp_ctrl_private *ctrl)return drm_dp_channel_eq_ok (link_status, num_lanes); } -int msm_dp_ctrl_on_link (struct msm_dp_ctrl *msm_dp_ctrl) +int msm_dp_ctrl_on_link (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel) {int rc =0 ;struct msm_dp_ctrl_private *ctrl;
@@ -2323,8 +2343,8 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl) ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); - rate = ctrl->panel->link_info.rate; - pixel_rate = ctrl->panel->msm_dp_mode.drm_mode.clock; + rate = panel->link_info.rate; + pixel_rate = panel->msm_dp_mode.drm_mode.clock;msm_dp_ctrl_core_clk_enable (&ctrl->msm_dp_ctrl);
@@ -2336,8 +2356,8 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl) }else { ctrl->link->link_params.rate = rate; ctrl->link->link_params.num_lanes = - ctrl->panel->link_info.num_lanes; -if (ctrl->panel->msm_dp_mode.out_fmt_is_yuv_420) + panel->link_info.num_lanes; +if (panel->msm_dp_mode.out_fmt_is_yuv_420) pixel_rate >>=1 ; }
@@ -2345,13 +2365,13 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl) ctrl->link->link_params.rate, ctrl->link->link_params.num_lanes, pixel_rate); - rc =msm_dp_ctrl_enable_mainlink_clocks (ctrl); + rc =msm_dp_ctrl_enable_mainlink_clocks (ctrl, panel);if (rc)return rc;while (--link_train_max_retries) { training_step =DP_TRAINING_NONE ; - rc =msm_dp_ctrl_setup_main_link (ctrl, &training_step); + rc =msm_dp_ctrl_setup_main_link (ctrl, panel, &training_step);if (rc ==0 ) {/* training completed successfully */ break ;
@@ -2370,7 +2390,7 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl)* some lanes are ready, * reduce lane number */ - rc =msm_dp_ctrl_link_lane_down_shift (ctrl); + rc =msm_dp_ctrl_link_lane_down_shift (ctrl, panel);if (rc <0 ) {/* lane == 1 already */ /* end with failure */ break ;
@@ -2391,7 +2411,7 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl) ctrl->link->link_params.num_lanes)) rc =msm_dp_ctrl_link_rate_down_shift (ctrl); else - rc =msm_dp_ctrl_link_lane_down_shift (ctrl); + rc =msm_dp_ctrl_link_lane_down_shift (ctrl, panel);if (rc <0 ) {/* end with failure */
@@ -2399,10 +2419,10 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl) }/* stop link training before start re training */ -msm_dp_ctrl_clear_training_pattern (ctrl,DP_PHY_DPRX ); +msm_dp_ctrl_clear_training_pattern (ctrl, panel,DP_PHY_DPRX ); } - rc =msm_dp_ctrl_reinitialize_mainlink (ctrl); + rc =msm_dp_ctrl_reinitialize_mainlink (ctrl, panel);if (rc) {DRM_ERROR ("Failed to reinitialize mainlink. rc=%d\n" , rc);break ;
@@ -2423,20 +2443,21 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl)* link training failed * end txing train pattern here */ -msm_dp_ctrl_clear_training_pattern (ctrl,DP_PHY_DPRX ); +msm_dp_ctrl_clear_training_pattern (ctrl, panel,DP_PHY_DPRX ); -msm_dp_ctrl_deinitialize_mainlink (ctrl); +msm_dp_ctrl_deinitialize_mainlink (ctrl, panel); rc = -ECONNRESET ; }return rc; } -static int msm_dp_ctrl_link_retrain (struct msm_dp_ctrl_private *ctrl) +static int msm_dp_ctrl_link_retrain (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {int training_step =DP_TRAINING_NONE ; -return msm_dp_ctrl_setup_main_link (ctrl, &training_step); +return msm_dp_ctrl_setup_main_link (ctrl, panel, &training_step); } static void msm_dp_ctrl_config_msa(struct msm_dp_ctrl_private *ctrl,
@@ -2507,7 +2528,9 @@ static void msm_dp_ctrl_config_msa(struct msm_dp_ctrl_private *ctrl,msm_dp_write_link (ctrl,REG_DP_SOFTWARE_NVID , nvid); } -int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl,bool force_link_train) +int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel, +bool force_link_train) {int ret =0 ;struct msm_dp_ctrl_private *ctrl;
@@ -2526,7 +2549,7 @@ int msm_dp_ctrl_prepare_stream_on(struct msm_dp_ctrl *msm_dp_ctrl, bool force_li ctrl->core_clks_on, ctrl->link_clks_on, ctrl->stream_clks_on);if (!ctrl->link_clks_on) {/* link clk is off */ - ret =msm_dp_ctrl_enable_mainlink_clocks (ctrl); + ret =msm_dp_ctrl_enable_mainlink_clocks (ctrl, panel);if (ret) {DRM_ERROR ("Failed to start link clocks. ret=%d\n" , ret);return ret;
@@ -2534,15 +2557,15 @@ int msm_dp_ctrl_prepare_stream_on(struct msm_dp_ctrl *msm_dp_ctrl, bool force_li }if (force_link_train || !msm_dp_ctrl_channel_eq_ok (ctrl)) -msm_dp_ctrl_link_retrain (ctrl); +msm_dp_ctrl_link_retrain (ctrl, panel);/* stop txing train pattern to end link training */ -msm_dp_ctrl_clear_training_pattern (ctrl,DP_PHY_DPRX ); +msm_dp_ctrl_clear_training_pattern (ctrl, panel,DP_PHY_DPRX );return ret; } -int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl) +int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl,struct msm_dp_panel *panel) {int ret =0 ;bool mainlink_ready = false;
@@ -2555,10 +2578,10 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl) ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); - pixel_rate_orig = ctrl->panel->msm_dp_mode.drm_mode.clock; + pixel_rate_orig = panel->msm_dp_mode.drm_mode.clock; pixel_rate = pixel_rate_orig; -if (msm_dp_ctrl->wide_bus_en || ctrl->panel->msm_dp_mode.out_fmt_is_yuv_420) +if (msm_dp_ctrl->wide_bus_en || panel->msm_dp_mode.out_fmt_is_yuv_420) pixel_rate >>=1 ;drm_dbg_dp (ctrl->drm_dev,"pixel_rate=%lu\n" , pixel_rate);
@@ -2575,18 +2598,18 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl)msm_dp_ctrl_lane_mapping (ctrl);msm_dp_setup_peripheral_flush (ctrl); -msm_dp_ctrl_config_ctrl_link (ctrl); +msm_dp_ctrl_config_ctrl_link (ctrl, panel); -msm_dp_ctrl_configure_source_params (ctrl); +msm_dp_ctrl_configure_source_params (ctrl, panel);msm_dp_ctrl_config_msa (ctrl, ctrl->link->link_params.rate, pixel_rate_orig, - ctrl->panel->msm_dp_mode.out_fmt_is_yuv_420); + panel->msm_dp_mode.out_fmt_is_yuv_420); -msm_dp_panel_clear_dsc_dto (ctrl->panel); +msm_dp_panel_clear_dsc_dto (panel); -msm_dp_ctrl_setup_tr_unit (ctrl); +msm_dp_ctrl_setup_tr_unit (ctrl, panel);msm_dp_write_link (ctrl,REG_DP_STATE_CTRL ,DP_STATE_CTRL_SEND_VIDEO );
@@ -2614,7 +2637,8 @@ void msm_dp_ctrl_reinit_phy(struct msm_dp_ctrl *msm_dp_ctrl)phy_init (phy); } -void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl) +void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel) {struct msm_dp_ctrl_private *ctrl;struct phy *phy;
@@ -2622,11 +2646,11 @@ void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl) ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); phy = ctrl->phy; -msm_dp_panel_disable_vsc_sdp (ctrl->panel); +msm_dp_panel_disable_vsc_sdp (panel);msm_dp_ctrl_mainlink_disable (ctrl); -msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl); +msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl, panel);msm_dp_ctrl_off_pixel_clk (msm_dp_ctrl);dev_pm_opp_set_rate (ctrl->dev,0 );
@@ -2635,7 +2659,8 @@ void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl)phy_power_off (phy); } -irqreturn_t msm_dp_ctrl_isr (struct msm_dp_ctrl *msm_dp_ctrl) +irqreturn_t msm_dp_ctrl_isr (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel) {struct msm_dp_ctrl_private *ctrl;u32 isr;
@@ -2646,7 +2671,7 @@ irqreturn_t msm_dp_ctrl_isr(struct msm_dp_ctrl *msm_dp_ctrl) ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); -if (ctrl->panel->psr_cap.version) { +if (panel->psr_cap.version) { isr =msm_dp_ctrl_get_psr_interrupt (ctrl);if (isr)
@@ -2735,7 +2760,7 @@ static int msm_dp_ctrl_clk_init(struct msm_dp_ctrl *msm_dp_ctrl) }struct msm_dp_ctrl *msm_dp_ctrl_get (struct device *dev,struct msm_dp_link *link, -struct msm_dp_panel *panel,struct drm_dp_aux *aux, +struct drm_dp_aux *aux,struct phy *phy,void __iomem *ahb_base,void __iomem *link_base)
@@ -2743,7 +2768,7 @@ struct msm_dp_ctrl *msm_dp_ctrl_get(struct device *dev, struct msm_dp_link *linkstruct msm_dp_ctrl_private *ctrl;int ret; -if (!dev || !panel || !aux || !link) { +if (!dev || !aux || !link) {DRM_ERROR ("invalid input\n" );return ERR_PTR (-EINVAL ); }
@@ -2771,7 +2796,6 @@ struct msm_dp_ctrl *msm_dp_ctrl_get(struct device *dev, struct msm_dp_link *linkinit_completion (&ctrl->video_comp);/* in parameters */ - ctrl->panel = panel; ctrl->aux = aux; ctrl->link = link; ctrl->dev = dev;
drivers/gpu/drm/msm/dp/dp_ctrl.h +18 -10
@@ -16,28 +16,36 @@ struct msm_dp_ctrl {struct phy ; -int msm_dp_ctrl_on_link (struct msm_dp_ctrl *msm_dp_ctrl); -int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl); -int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl,bool force_link_train); -void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl); +int msm_dp_ctrl_on_link (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel); +int msm_dp_ctrl_on_stream (struct msm_dp_ctrl *msm_dp_ctrl,struct msm_dp_panel *panel); +int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel, +bool force_link_train); +void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel);void msm_dp_ctrl_push_idle (struct msm_dp_ctrl *msm_dp_ctrl); -irqreturn_t msm_dp_ctrl_isr (struct msm_dp_ctrl *msm_dp_ctrl); -void msm_dp_ctrl_handle_sink_request (struct msm_dp_ctrl *msm_dp_ctrl); +irqreturn_t msm_dp_ctrl_isr (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel); +void msm_dp_ctrl_handle_sink_request (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel);struct msm_dp_ctrl *msm_dp_ctrl_get (struct device *dev,struct msm_dp_link *link, -struct msm_dp_panel *panel,struct drm_dp_aux *aux,struct phy *phy,void __iomem *ahb_base,void __iomem *link_base); -void msm_dp_ctrl_reset (struct msm_dp_ctrl *msm_dp_ctrl); +void msm_dp_ctrl_reset (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel);void msm_dp_ctrl_phy_init (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_phy_exit (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_irq_phy_exit (struct msm_dp_ctrl *msm_dp_ctrl); -void msm_dp_ctrl_set_psr (struct msm_dp_ctrl *msm_dp_ctrl,bool enable); -void msm_dp_ctrl_config_psr (struct msm_dp_ctrl *msm_dp_ctrl); +void msm_dp_ctrl_set_psr (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel,bool enable); +void msm_dp_ctrl_config_psr (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel);int msm_dp_ctrl_core_clk_enable (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_core_clk_disable (struct msm_dp_ctrl *msm_dp_ctrl);
drivers/gpu/drm/msm/dp/dp_display.c +12 -12
@@ -359,7 +359,7 @@ static void msm_dp_display_host_init(struct msm_dp_display_private *dp) dp->phy_initialized);msm_dp_ctrl_core_clk_enable (dp->ctrl); -msm_dp_ctrl_reset (dp->ctrl); +msm_dp_ctrl_reset (dp->ctrl, dp->panel);msm_dp_ctrl_enable_irq (dp->ctrl);msm_dp_aux_init (dp->aux); dp->core_initialized = true;
@@ -371,7 +371,7 @@ static void msm_dp_display_host_deinit(struct msm_dp_display_private *dp) dp->msm_dp_display.connector_type, dp->core_initialized, dp->phy_initialized); -msm_dp_ctrl_reset (dp->ctrl); +msm_dp_ctrl_reset (dp->ctrl, dp->panel);msm_dp_ctrl_disable_irq (dp->ctrl);msm_dp_aux_deinit (dp->aux);msm_dp_ctrl_core_clk_disable (dp->ctrl);
@@ -392,7 +392,7 @@ static int msm_dp_display_handle_irq_hpd(struct msm_dp_display_private *dp)drm_dbg_dp (dp->drm_dev,"%d\n" , sink_request); -msm_dp_ctrl_handle_sink_request (dp->ctrl); +msm_dp_ctrl_handle_sink_request (dp->ctrl, dp->panel);if (sink_request &DP_TEST_LINK_VIDEO_PATTERN )msm_dp_display_handle_video_request (dp);
@@ -570,7 +570,7 @@ static int msm_dp_init_sub_modules(struct msm_dp_display_private *dp) goto error_link; } - dp->ctrl =msm_dp_ctrl_get (dev, dp->link, dp->panel, dp->aux, + dp->ctrl =msm_dp_ctrl_get (dev, dp->link, dp->aux, phy, dp->ahb_base, dp->link_base);if (IS_ERR (dp->ctrl)) { rc =PTR_ERR (dp->ctrl);
@@ -642,14 +642,14 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp) force_link_train = true; } - rc =msm_dp_ctrl_on_link (dp->ctrl); + rc =msm_dp_ctrl_on_link (dp->ctrl, dp->panel);if (rc) {DRM_ERROR ("Failed link training (rc=%d)\n" , rc);// TODO: schedule drm_connector_set_link_status_property() return rc; } -return msm_dp_ctrl_prepare_stream_on (dp->ctrl, force_link_train); +return msm_dp_ctrl_prepare_stream_on (dp->ctrl, dp->panel, force_link_train); }static int msm_dp_display_enable (struct msm_dp_display_private *dp)
@@ -663,7 +663,7 @@ static int msm_dp_display_enable(struct msm_dp_display_private *dp)return 0 ; } - rc =msm_dp_ctrl_on_stream (dp->ctrl); + rc =msm_dp_ctrl_on_stream (dp->ctrl, dp->panel);if (!rc) msm_dp_display->power_on = true;
@@ -688,7 +688,7 @@ static int msm_dp_display_post_enable(struct msm_dp *msm_dp_display)msm_dp_display_handle_plugged_change (msm_dp_display, true);if (msm_dp_display->psr_supported) -msm_dp_ctrl_config_psr (dp->ctrl); +msm_dp_ctrl_config_psr (dp->ctrl, dp->panel);return 0 ; }
@@ -727,7 +727,7 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)/* set dongle to D3 (power off) mode */ msm_dp_link_psm_config (dp->link, &dp->panel->link_info, true); -msm_dp_ctrl_off (dp->ctrl); +msm_dp_ctrl_off (dp->ctrl, dp->panel);/* re-init the PHY so that we can listen to Dongle disconnect */ msm_dp_ctrl_reinit_phy (dp->ctrl); }else {
@@ -735,7 +735,7 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)* unplugged interrupt * dongle unplugged out of DUT */ -msm_dp_ctrl_off (dp->ctrl); +msm_dp_ctrl_off (dp->ctrl, dp->panel);msm_dp_display_host_phy_exit (dp); }
@@ -871,7 +871,7 @@ void msm_dp_display_set_psr(struct msm_dp *msm_dp_display, bool enter) } dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); -msm_dp_ctrl_set_psr (dp->ctrl, enter); +msm_dp_ctrl_set_psr (dp->ctrl, dp->panel, enter); }/**
@@ -981,7 +981,7 @@ static irqreturn_t msm_dp_display_irq_handler(int irq, void *dev_id) }/* DP controller isr */ - ret |=msm_dp_ctrl_isr (dp->ctrl); + ret |=msm_dp_ctrl_isr (dp->ctrl, dp->panel);return ret; }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 10/15] drm/msm/dp: allow dp_ctrl stream APIs to use any panel passed to it
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Secondary stream panels fail to have their `hw_revision` initialized, silently breaking…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Secondary stream panels fail to have their hw_revision initialized, silently breaking controller-specific hardware workarounds in MST setups.
- [High] Stream-specific panels are incorrectly passed to mainlink APIs, corrupting shared link state and misconfiguring the link based on leaf monitor capabilities instead of the MST hub. --
--- Patch [10]: [PATCH v8 10/15] drm/msm/dp: allow dp_ctrl stream APIs to use any panel passed to it --- commit 07d3f4b80ae5875a958a8aceb22c9ffab07db108
Author: Abhinav Kumar <[email protected]>
drm/msm/dp: allow dp_ctrl stream APIs to use any panel passed to it
With MST, multiple sinks share a single DP controller, so a cached panel in msm_dp_ctrl_private can no longer represent the per-stream sink. Drop the cache and pass panel explicitly to all stream-related dp_ctrl APIs.
drivers/gpu/drm/msm/dp/dp_ctrl.c void msm_dp_ctrl_reset(struct msm_dp_ctrl *msm_dp_ctrl) · line 224
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +1
-1@@ -219,7 +219,7 @@ void msm_dp_ctrl_reset(struct msm_dp_ctrl *msm_dp_ctrl)if (!ctrl->hw_revision) { ctrl->hw_revision =msm_dp_read_ahb (ctrl,REG_DP_HW_VERSION ); - ctrl->panel->hw_revision = ctrl->hw_revision; + panel->hw_revision = ctrl->hw_revision; } }
[Severity: High]
Does this leave the hw_revision uninitialized for secondary stream panels in an MST setup?
Since ctrl->hw_revision is populated during the host initialization for the primary panel, any subsequent stream panels passed to this function will bypass the assignment. Could this silently break hardware workarounds that depend on panel->hw_revision being set correctly?
[ ... ]
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-0@@ -414,10 +414,11 @@ static void msm_dp_ctrl_config_ctrl_streams(struct msm_dp_ctrl_private *ctrl,msm_dp_write_link (ctrl,REG_DP_CONFIGURATION_CTRL , config); }
drivers/gpu/drm/msm/dp/dp_ctrl.c static void msm_dp_ctrl_config_ctrl_streams(struct msm_dp_ctrl_private *ctrl, · line 424
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +3
-2-static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {u32 config =0 ; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd;/* Default-> LSCLK DIV: 1/4 LCLK */ config |= (2 <<DP_CONFIGURATION_CTRL_LSCLK_DIV_SHIFT );
[Severity: High]
Can the direct write to REG_DP_CONFIGURATION_CTRL at the end of this function erase stream-specific configurations established by previously enabled streams?
Since msm_dp_ctrl_config_ctrl_link() is called on every stream enable from msm_dp_ctrl_on_stream(), it seems this might overwrite the shared register and corrupt the state of active streams.
[ ... ]
Quoted 5 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-1@@ -1810,11 +1821,12 @@ static void msm_dp_ctrl_link_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl) str_on_off(ctrl->core_clks_on)); } -static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl)
drivers/gpu/drm/msm/dp/dp_ctrl.c static void msm_dp_ctrl_link_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl) · line 1832
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +3
-1+static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {int ret =0 ;struct phy *phy = ctrl->phy; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd; ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes; ctrl->phy_opts.dp.link_rate = ctrl->link->link_params.rate /100 ;
[Severity: High]
Is it correct to use the stream-specific (leaf) DPCD to configure shared mainlink properties here and in msm_dp_ctrl_link_train()?
This appears to misconfigure the link based on leaf monitor capabilities instead of the MST hub. If a leaf monitor doesn't support features like enhanced framing or downspread, but the hub does, could this break the link to the hub?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Re: [PATCH v8 10/15] drm/msm/dp: allow dp_ctrl stream APIs to use any panel passed to it
Quoted 33 lines · On Mon, Jul 20, 2026 at 06:24:05AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Secondary stream panels fail to have theirhw_revisioninitialized, silently breaking controller-specific hardware workarounds in MST setups.
- [High] Stream-specific panels are incorrectly passed to mainlink APIs, corrupting shared link state and misconfiguring the link based on leaf monitor capabilities instead of the MST hub. ----- Patch [10]: [PATCH v8 10/15] drm/msm/dp: allow
dp_ctrlstream APIs to use any panel passed to it --- commit07d3f4b80ae5875a958a8aceb22c9ffab07db108
Author: Abhinav Kumar <[email protected]>drm/msm/dp: allow
dp_ctrlstream APIs to use any panel passed to itWith MST, multiple sinks share a single DP controller, so a cached panel in
msm_dp_ctrl_privatecan no longer represent the per-stream sink. Drop the cache and pass panel explicitly to all stream-relateddp_ctrlAPIs.drivers/gpu/drm/msm/dp/dp_ctrl.c void msm_dp_ctrl_reset(struct msm_dp_ctrl *msm_dp_ctrl) · line 224
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +1
-1@@ -219,7 +219,7 @@ void msm_dp_ctrl_reset(struct msm_dp_ctrl *msm_dp_ctrl)if (!ctrl->hw_revision) { ctrl->hw_revision =msm_dp_read_ahb (ctrl,REG_DP_HW_VERSION ); - ctrl->panel->hw_revision = ctrl->hw_revision; + panel->hw_revision = ctrl->hw_revision; } }[Severity: High]
Does this leave thehw_revisionuninitialized for secondary stream panels in an MST setup?
Quoted 4 lines
Since
ctrl->hw_revisionis populated during the host initialization for the primary panel, any subsequent stream panels passed to this function will bypass the assignment. Could this silently break hardware workarounds that depend onpanel->hw_revisionbeing set correctly?
It does. This should be fixed.
Quoted 22 lines
[ ... ]
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-0@@ -414,10 +414,11 @@ static void msm_dp_ctrl_config_ctrl_streams(struct msm_dp_ctrl_private *ctrl,msm_dp_write_link (ctrl,REG_DP_CONFIGURATION_CTRL , config); }drivers/gpu/drm/msm/dp/dp_ctrl.c static void msm_dp_ctrl_config_ctrl_streams(struct msm_dp_ctrl_private *ctrl, · line 424
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +3
-2-static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {u32 config =0 ; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd;/* Default-> LSCLK DIV: 1/4 LCLK */ config |= (2 <<DP_CONFIGURATION_CTRL_LSCLK_DIV_SHIFT );[Severity: High]
Can the direct write toREG_DP_CONFIGURATION_CTRLat the end of this function erase stream-specific configurations established by previously enabled streams?
Quoted 3 lines
Since
msm_dp_ctrl_config_ctrl_link()is called on every stream enable frommsm_dp_ctrl_on_stream(), it seems this might overwrite the shared register and corrupt the state of active streams.
Hmm?
Quoted 29 lines
[ ... ]
Quoted 5 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-1@@ -1810,11 +1821,12 @@ static void msm_dp_ctrl_link_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl) str_on_off(ctrl->core_clks_on)); } -static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl)drivers/gpu/drm/msm/dp/dp_ctrl.c static void msm_dp_ctrl_link_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl) · line 1832
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +3
-1+static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {int ret =0 ;struct phy *phy = ctrl->phy; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd; ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes; ctrl->phy_opts.dp.link_rate = ctrl->link->link_params.rate /100 ;[Severity: High]
Is it correct to use the stream-specific (leaf) DPCD to configure shared mainlink properties here and inmsm_dp_ctrl_link_train()?This appears to misconfigure the link based on leaf monitor capabilities instead of the MST hub. If a leaf monitor doesn't support features like enhanced framing or downspread, but the hub does, could this break the link to the hub?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v8 10/15] drm/msm/dp: allow dp_ctrl stream APIs to use any panel passed to it
Quoted 34 lines · Dmitry Baryshkov
Quoted 33 lines · On Mon, Jul 20, 2026 at 06:24:05AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Secondary stream panels fail to have theirhw_revisioninitialized, silently breaking controller-specific hardware workarounds in MST setups.
- [High] Stream-specific panels are incorrectly passed to mainlink APIs, corrupting shared link state and misconfiguring the link based on leaf monitor capabilities instead of the MST hub. ----- Patch [10]: [PATCH v8 10/15] drm/msm/dp: allow
dp_ctrlstream APIs to use any panel passed to it --- commit07d3f4b80ae5875a958a8aceb22c9ffab07db108
Author: Abhinav Kumar <[email protected]>drm/msm/dp: allow
dp_ctrlstream APIs to use any panel passed to itWith MST, multiple sinks share a single DP controller, so a cached panel in
msm_dp_ctrl_privatecan no longer represent the per-stream sink. Drop the cache and pass panel explicitly to all stream-relateddp_ctrlAPIs.drivers/gpu/drm/msm/dp/dp_ctrl.c void msm_dp_ctrl_reset(struct msm_dp_ctrl *msm_dp_ctrl) · line 224
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +1
-1@@ -219,7 +219,7 @@ void msm_dp_ctrl_reset(struct msm_dp_ctrl *msm_dp_ctrl)if (!ctrl->hw_revision) { ctrl->hw_revision =msm_dp_read_ahb (ctrl,REG_DP_HW_VERSION ); - ctrl->panel->hw_revision = ctrl->hw_revision; + panel->hw_revision = ctrl->hw_revision; } }[Severity: High]
Does this leave thehw_revisionuninitialized for secondary stream panels in an MST setup?
Quoted 7 lines
Quoted 4 lines
Since
ctrl->hw_revisionis populated during the host initialization for the primary panel, any subsequent stream panels passed to this function will bypass the assignment. Could this silently break hardware workarounds that depend onpanel->hw_revisionbeing set correctly?It does. This should be fixed.
Got it. I'll move the panel->hw_revision assignment outside the conditional.
Quoted 58 lines
Quoted 22 lines
[ ... ]
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-0@@ -414,10 +414,11 @@ static void msm_dp_ctrl_config_ctrl_streams(struct msm_dp_ctrl_private *ctrl,msm_dp_write_link (ctrl,REG_DP_CONFIGURATION_CTRL , config); }drivers/gpu/drm/msm/dp/dp_ctrl.c static void msm_dp_ctrl_config_ctrl_streams(struct msm_dp_ctrl_private *ctrl, · line 424
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +3
-2-static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl) +static void msm_dp_ctrl_config_ctrl_link (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {u32 config =0 ; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd;/* Default-> LSCLK DIV: 1/4 LCLK */ config |= (2 <<DP_CONFIGURATION_CTRL_LSCLK_DIV_SHIFT );[Severity: High]
Can the direct write toREG_DP_CONFIGURATION_CTRLat the end of this function erase stream-specific configurations established by previously enabled streams?Quoted 3 lines
Since
msm_dp_ctrl_config_ctrl_link()is called on every stream enable frommsm_dp_ctrl_on_stream(), it seems this might overwrite the shared register and corrupt the state of active streams.Hmm?
Quoted 29 lines
[ ... ]
Quoted 5 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-1@@ -1810,11 +1821,12 @@ static void msm_dp_ctrl_link_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl) str_on_off(ctrl->core_clks_on)); } -static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl)drivers/gpu/drm/msm/dp/dp_ctrl.c static void msm_dp_ctrl_link_clk_disable(struct msm_dp_ctrl *msm_dp_ctrl) · line 1832
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +3
-1+static int msm_dp_ctrl_enable_mainlink_clocks (struct msm_dp_ctrl_private *ctrl, +struct msm_dp_panel *panel) {int ret =0 ;struct phy *phy = ctrl->phy; -const u8 *dpcd = ctrl->panel->dpcd; +const u8 *dpcd = panel->dpcd; ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes; ctrl->phy_opts.dp.link_rate = ctrl->link->link_params.rate /100 ;[Severity: High]
Is it correct to use the stream-specific (leaf) DPCD to configure shared mainlink properties here and inmsm_dp_ctrl_link_train()?This appears to misconfigure the link based on leaf monitor capabilities instead of the MST hub. If a leaf monitor doesn't support features like enhanced framing or downspread, but the hub does, could this break the link to the hub?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
PATCH v8 11/15 drm/msm/dp: split dp_ctrl_off() into stream and link parts
In reply to Yongxing MouFrom: Abhinav Kumar <[email protected]>
Split dp_ctrl_off() into stream and link parts so that for MST cases we can control the link and pixel parts separately.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 10 +++++----- drivers/gpu/drm/msm/dp/dp_ctrl.h | 5 +++-- drivers/gpu/drm/msm/dp/dp_display.c | 7 ++++--- 3 files changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +5 -5
@@ -2212,7 +2212,7 @@ static int msm_dp_ctrl_on_pixel_clk(struct msm_dp_ctrl_private *ctrl, unsigned lreturn ret; } -static void msm_dp_ctrl_off_pixel_clk (struct msm_dp_ctrl *msm_dp_ctrl) +void msm_dp_ctrl_off_pixel_clk (struct msm_dp_ctrl *msm_dp_ctrl) {struct msm_dp_ctrl_private *ctrl;
@@ -2241,7 +2241,8 @@ static int msm_dp_ctrl_process_phy_test_request(struct msm_dp_ctrl_private *ctrl* running. Add the global reset just before disabling the * link clocks and core clocks. */ -msm_dp_ctrl_off (&ctrl->msm_dp_ctrl, panel); +msm_dp_ctrl_off_pixel_clk (&ctrl->msm_dp_ctrl); +msm_dp_ctrl_off_link (&ctrl->msm_dp_ctrl, panel); ret =msm_dp_ctrl_on_link (&ctrl->msm_dp_ctrl, panel);if (ret) {
@@ -2637,8 +2638,8 @@ void msm_dp_ctrl_reinit_phy(struct msm_dp_ctrl *msm_dp_ctrl)phy_init (phy); } -void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl, -struct msm_dp_panel *panel) +void msm_dp_ctrl_off_link (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel) {struct msm_dp_ctrl_private *ctrl;struct phy *phy;
@@ -2652,7 +2653,6 @@ void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl,msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl, panel); -msm_dp_ctrl_off_pixel_clk (msm_dp_ctrl);dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);
drivers/gpu/drm/msm/dp/dp_ctrl.h +3 -2
@@ -22,8 +22,9 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl, struct msm_dp_panel *int msm_dp_ctrl_prepare_stream_on (struct msm_dp_ctrl *msm_dp_ctrl,struct msm_dp_panel *panel,bool force_link_train); -void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl, -struct msm_dp_panel *panel); +void msm_dp_ctrl_off_link (struct msm_dp_ctrl *msm_dp_ctrl, +struct msm_dp_panel *panel); +void msm_dp_ctrl_off_pixel_clk (struct msm_dp_ctrl *msm_dp_ctrl);void msm_dp_ctrl_push_idle (struct msm_dp_ctrl *msm_dp_ctrl);irqreturn_t msm_dp_ctrl_isr (struct msm_dp_ctrl *msm_dp_ctrl,struct msm_dp_panel *panel);
drivers/gpu/drm/msm/dp/dp_display.c +4 -3
@@ -727,15 +727,16 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)/* set dongle to D3 (power off) mode */ msm_dp_link_psm_config (dp->link, &dp->panel->link_info, true); -msm_dp_ctrl_off (dp->ctrl, dp->panel); -/* re-init the PHY so that we can listen to Dongle disconnect */ +msm_dp_ctrl_off_pixel_clk (dp->ctrl); +msm_dp_ctrl_off_link (dp->ctrl, dp->panel);msm_dp_ctrl_reinit_phy (dp->ctrl); }else {/* * unplugged interrupt * dongle unplugged out of DUT */ -msm_dp_ctrl_off (dp->ctrl, dp->panel); +msm_dp_ctrl_off_pixel_clk (dp->ctrl); +msm_dp_ctrl_off_link (dp->ctrl, dp->panel);msm_dp_display_host_phy_exit (dp); }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 11/15] drm/msm/dp: split dp_ctrl_off() into stream and link parts
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Hardware power-down sequence violation leading to potential DP controller underflows.
Pre-existing issues:
- [High] TOCTOU race condition and lockless access to hardware clock state. --
--- Patch [11]: [PATCH v8 11/15] drm/msm/dp: split dp_ctrl_off() into stream and link parts --- commit b7bbbd3dcfb3d3e5bbed08959f3a0e241b42ce06
Author: Abhinav Kumar <[email protected]>
drm/msm/dp: split dp_ctrl_off() into stream and link parts
Split dp_ctrl_off() into stream and link parts so that for MST cases we can control the link and pixel parts separately.
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-0
[ ... ]
drivers/gpu/drm/msm/dp/dp_ctrl.c static int msm_dp_ctrl_process_phy_test_request(struct msm_dp_ctrl_private *ctrl · line 2245
Quoted 7 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +2
-1@@ -2241,7 +2241,8 @@ static int msm_dp_ctrl_process_phy_test_request(struct msm_dp_ctrl_private *ctrl* running. Add the global reset just before disabling the * link clocks and core clocks. */ -msm_dp_ctrl_off (&ctrl->msm_dp_ctrl, panel); +msm_dp_ctrl_off_pixel_clk (&ctrl->msm_dp_ctrl); +msm_dp_ctrl_off_link (&ctrl->msm_dp_ctrl, panel);
[Severity: High]
Does this reverse the hardware power-down sequence?
In the original msm_dp_ctrl_off() implementation, the pixel stream clock was disabled after msm_dp_ctrl_mainlink_disable() and msm_dp_ctrl_reset() had stopped the hardware.
By calling msm_dp_ctrl_off_pixel_clk() before msm_dp_ctrl_off_link() here, could we be killing the pixel stream while the DP mainlink is still enabled and attempting to transport video data? This seems like it could starve the DP controller's stream FIFO and lead to underflows or hardware lockups.
[ ... ]
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_display_disable(struct msm_dp_display_private *dp) · line 731
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_display.c +2
-2@@ -727,15 +727,16 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)/* set dongle to D3 (power off) mode */ msm_dp_link_psm_config (dp->link, &dp->panel->link_info, true); -msm_dp_ctrl_off (dp->ctrl, dp->panel); -/* re-init the PHY so that we can listen to Dongle disconnect */ +msm_dp_ctrl_off_pixel_clk (dp->ctrl); +msm_dp_ctrl_off_link (dp->ctrl, dp->panel);
[Severity: High]
This is a pre-existing issue, but could this concurrent execution lead to a race condition resulting in unbalanced clock disables?
The KMS atomic disable path in msm_dp_display_disable() runs in process context holding DRM modeset locks. However, the HPD notification path triggering msm_dp_ctrl_process_phy_test_request() is executed without modeset locks.
Since msm_dp_ctrl_off_pixel_clk() accesses ctrl->stream_clks_on without synchronization:
drivers/gpu/drm/msm/dp/dp_ctrl.c:msm_dp_ctrl_off_pixel_clk() {
if (ctrl->stream_clks_on) {
clk_disable_unprepare(ctrl->pixel_clk);
ctrl->stream_clks_on = false;
}
}Would an untrusted external DP sink sending concurrent PHY test requests during a KMS atomic commit cause both paths to evaluate the flag as true? This might result in double execution of clk_disable_unprepare() and corruption of the clock reference counters.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
PATCH v8 12/15 drm/msm/dp: simplify link and clock disable sequence
In reply to Yongxing MouMove the common disable steps out of the sink_count check to make the flow easier to follow.
No functional change intended.
--- drivers/gpu/drm/msm/dp/dp_display.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +9 -17
@@ -718,27 +718,19 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)msm_dp_panel_disable_vsc_sdp (dp->panel); -/* dongle is still connected but sinks are disconnected */ -if (dp->link->sink_count ==0 ) { -/* -* irq_hpd with sink_count = 0 -* hdmi unplugged out of dongle -*/ +msm_dp_ctrl_off_pixel_clk (dp->ctrl); -/* set dongle to D3 (power off) mode */ +/* 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); -msm_dp_ctrl_off_pixel_clk (dp->ctrl); -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 { -/* -* unplugged interrupt -* dongle unplugged out of DUT -*/ -msm_dp_ctrl_off_pixel_clk (dp->ctrl); -msm_dp_ctrl_off_link (dp->ctrl, dp->panel); +else msm_dp_display_host_phy_exit (dp); - } msm_dp_display->power_on = false;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 12/15] drm/msm/dp: simplify link and clock disable sequence
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The refactored code introduces a Time-of-Check to Time-of-Use (TOCTOU) race condition by…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The refactored code introduces a Time-of-Check to Time-of-Use (TOCTOU) race condition by evaluating dp->link->sink_count == 0 twice. --
--- Patch [12]: [PATCH v8 12/15] drm/msm/dp: simplify link and clock disable sequence --- commit 84b41be14edf75da081c987f79e9f547234b2511
Author: Yongxing Mou <[email protected]>
drm/msm/dp: simplify link and clock disable sequence
This commit moves common disable steps out of the sink_count check to make the flow easier to follow. No functional change is intended.
Quoted 16 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-6@@ -718,27 +718,19 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)msm_dp_panel_disable_vsc_sdp (dp->panel); -/* dongle is still connected but sinks are disconnected */ -if (dp->link->sink_count ==0 ) { -/* -* irq_hpd with sink_count = 0 -* hdmi unplugged out of dongle -*/ +msm_dp_ctrl_off_pixel_clk (dp->ctrl);
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_display_disable(struct msm_dp_display_private *dp) · line 729
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +6
-3-/* set dongle to D3 (power off) mode */ +/* 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); -msm_dp_ctrl_off_pixel_clk (dp->ctrl); -msm_dp_ctrl_off_link (dp->ctrl, dp->panel); + +msm_dp_ctrl_off_link (dp->ctrl, dp->panel); + +if (dp->link->sink_count ==0 )
[Severity: High]
Can checking dp->link->sink_count twice in this function introduce a race condition?
If a hotplug or unplug event occurs exactly between these two checks, the IRQ thread could dynamically update dp->link->sink_count via msm_dp_irq_hpd_handle() -> msm_dp_link_process_request() while msm_dp_display_disable() is executing.
Since there are no locks serializing the IRQ thread update against this atomic disable sequence, could this result in an inconsistent hardware state?
For example, the dongle might be put into D3 power-off mode during the first check, but if sink_count changes before the second check, the host PHY might be exited instead of re-initialized.
The original code evaluated sink_count once and used an if/else block, which guaranteed a mutually exclusive and consistent teardown sequence. Would it be safer to cache the value of sink_count in a local variable prior to the first check and use that local variable for both conditions?
Quoted 15 lines
drivers/gpu/drm/msm/dp/dp_display.c +2
-8+/* re-init the PHY so that we can listen to Dongle disconnect */ msm_dp_ctrl_reinit_phy (dp->ctrl); - }else { -/* -* unplugged interrupt -* dongle unplugged out of DUT -*/ -msm_dp_ctrl_off_pixel_clk (dp->ctrl); -msm_dp_ctrl_off_link (dp->ctrl, dp->panel); + elsemsm_dp_display_host_phy_exit (dp ); - } msm_dp_display->power_on = false;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
PATCH v8 13/15 drm/msm/dp: make bridge helpers use dp_display to allow re-use
In reply to Yongxing MouFrom: Abhinav Kumar <[email protected]>
dp_bridge helpers take drm_bridge as an input and extract the dp_display object to be used in the dp_display module. Rather than doing it in a roundabout way, directly pass the dp_display object to these helpers so that the MST bridge can also re-use the same helpers.
--- drivers/gpu/drm/msm/dp/dp_display.c | 29 +++++++++------------------ drivers/gpu/drm/msm/dp/dp_display.h | 7 +++++++ drivers/gpu/drm/msm/dp/dp_drm.c | 39 ++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/dp/dp_drm.h | 9 --------- 4 files changed, 54 insertions(+), 30 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +9 -20
@@ -740,24 +740,21 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp)/** * msm_dp_bridge_mode_valid - callback to determine if specified mode is valid -* @bridge: Pointer to drm bridge structure +* @dp: Pointer to dp display structure * @info: display info * @mode: Pointer to drm mode structure * Returns: Validity status for specified mode */ -enum drm_mode_status msm_dp_bridge_mode_valid (struct drm_bridge *bridge, -const struct drm_display_info *info, -const struct drm_display_mode *mode) +enum drm_mode_status msm_dp_display_mode_valid (struct msm_dp *dp, +const struct drm_display_info *info, +const struct drm_display_mode *mode) {const u32 num_components =3 , default_bpp =24 ;struct msm_dp_display_private *msm_dp_display;struct msm_dp_link_info *link_info;u32 mode_rate_khz =0 , supported_rate_khz =0 , mode_bpp =0 ; -struct msm_dp *dp;int mode_pclk_khz = mode->clock; - dp =to_dp_bridge (bridge)->msm_dp_display; -if (!dp || !mode_pclk_khz || !dp->connector) {DRM_ERROR ("invalid params\n" );return -EINVAL ;
@@ -1408,11 +1405,9 @@ int msm_dp_modeset_init(struct msm_dp *msm_dp_display, struct drm_device *dev,return 0 ; } -void msm_dp_bridge_atomic_enable (struct drm_bridge *drm_bridge, -struct drm_atomic_commit *state) +void msm_dp_display_atomic_enable (struct msm_dp *msm_dp_display, +struct drm_atomic_commit *state) { -struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (drm_bridge); -struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display;struct drm_crtc *crtc;struct drm_crtc_state *crtc_state;int rc =0 ;
@@ -1421,7 +1416,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); crtc =drm_atomic_get_new_crtc_for_encoder (state, - drm_bridge->encoder); + msm_dp_display->bridge->encoder);if (!crtc)return ; crtc_state =drm_atomic_get_new_crtc_state (state, crtc);
@@ -1451,11 +1446,8 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,drm_dbg_dp (msm_dp_display->drm_dev,"type=%d Done\n" , msm_dp_display->connector_type); } -void msm_dp_bridge_atomic_disable (struct drm_bridge *drm_bridge, -struct drm_atomic_commit *state) +void msm_dp_display_atomic_disable (struct msm_dp *dp) { -struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (drm_bridge); -struct msm_dp *dp = msm_dp_bridge->msm_dp_display;struct msm_dp_display_private *msm_dp_display; msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display);
@@ -1472,11 +1464,8 @@ static void msm_dp_display_unprepare(struct msm_dp_display_private *dp)drm_dbg_dp (dp->drm_dev,"type=%d Done\n" , msm_dp_display->connector_type); } -void msm_dp_bridge_atomic_post_disable (struct drm_bridge *drm_bridge, -struct drm_atomic_commit *state) +void msm_dp_display_atomic_post_disable (struct msm_dp *dp) { -struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (drm_bridge); -struct msm_dp *dp = msm_dp_bridge->msm_dp_display;struct msm_dp_display_private *msm_dp_display; msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display);
drivers/gpu/drm/msm/dp/dp_display.h +7 -0
@@ -33,5 +33,12 @@ void msm_dp_display_signal_audio_start(struct msm_dp *msm_dp_display);void msm_dp_display_signal_audio_complete (struct msm_dp *msm_dp_display);void msm_dp_display_set_psr (struct msm_dp *dp,bool enter);void msm_dp_display_debugfs_init (struct msm_dp *msm_dp_display,struct dentry *dentry,bool is_edp); +void msm_dp_display_atomic_post_disable (struct msm_dp *dp_display); +void msm_dp_display_atomic_disable (struct msm_dp *dp_display); +void msm_dp_display_atomic_enable (struct msm_dp *dp_display, +struct drm_atomic_commit *state); +enum drm_mode_status msm_dp_display_mode_valid (struct msm_dp *dp, +const struct drm_display_info *info, +const struct drm_display_mode *mode);#endif /* _DP_DISPLAY_H_ */
drivers/gpu/drm/msm/dp/dp_drm.c +38 -1
@@ -49,6 +49,43 @@ static void msm_dp_bridge_debugfs_init(struct drm_bridge *bridge, struct dentrymsm_dp_display_debugfs_init (dp, root, false); } +static void msm_dp_bridge_atomic_enable (struct drm_bridge *drm_bridge, +struct drm_atomic_commit *state) +{ +struct msm_dp_bridge *dp_bridge =to_dp_bridge (drm_bridge); +struct msm_dp *dp = dp_bridge->msm_dp_display; + +msm_dp_display_atomic_enable (dp, state); +} + +static void msm_dp_bridge_atomic_disable (struct drm_bridge *drm_bridge, +struct drm_atomic_commit *state) +{ +struct msm_dp_bridge *dp_bridge =to_dp_bridge (drm_bridge); +struct msm_dp *dp = dp_bridge->msm_dp_display; + +msm_dp_display_atomic_disable (dp); +} + +static void msm_dp_bridge_atomic_post_disable (struct drm_bridge *drm_bridge, +struct drm_atomic_commit *state) +{ +struct msm_dp_bridge *dp_bridge =to_dp_bridge (drm_bridge); +struct msm_dp *dp = dp_bridge->msm_dp_display; + +msm_dp_display_atomic_post_disable (dp); +} + +static enum drm_mode_status msm_dp_bridge_mode_valid (struct drm_bridge *drm_bridge, +const struct drm_display_info *info, +const struct drm_display_mode *mode) +{ +struct msm_dp_bridge *dp_bridge =to_dp_bridge (drm_bridge); +struct msm_dp *dp = dp_bridge->msm_dp_display; + +return msm_dp_display_mode_valid (dp, info, mode); +} +static const struct drm_bridge_funcs msm_dp_bridge_ops = { .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
@@ -115,7 +152,7 @@ static void msm_edp_bridge_atomic_enable(struct drm_bridge *drm_bridge,return ; } -msm_dp_bridge_atomic_enable (drm_bridge, state); +msm_dp_display_atomic_enable (dp, state); } static void msm_edp_bridge_atomic_disable(struct drm_bridge *drm_bridge,
drivers/gpu/drm/msm/dp/dp_drm.h +0 -9
@@ -27,15 +27,6 @@ int msm_dp_bridge_init(struct msm_dp *msm_dp_display, struct drm_device *dev,enum drm_connector_status msm_dp_bridge_detect (struct drm_bridge *bridge,struct drm_connector *connector); -void msm_dp_bridge_atomic_enable (struct drm_bridge *drm_bridge, -struct drm_atomic_commit *state); -void msm_dp_bridge_atomic_disable (struct drm_bridge *drm_bridge, -struct drm_atomic_commit *state); -void msm_dp_bridge_atomic_post_disable (struct drm_bridge *drm_bridge, -struct drm_atomic_commit *state); -enum drm_mode_status msm_dp_bridge_mode_valid (struct drm_bridge *bridge, -const struct drm_display_info *info, -const struct drm_display_mode *mode);void msm_dp_bridge_hpd_enable (struct drm_bridge *bridge);void msm_dp_bridge_hpd_disable (struct drm_bridge *bridge); void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 13/15] drm/msm/dp: make bridge helpers use dp_display to allow re-use
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The refactoring of `msm_dp_display_atomic_enable` hardcodes the primary bridge's encoder…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The refactoring of msm_dp_display_atomic_enable hardcodes the primary bridge's encoder, breaking the MST reuse it was explicitly intended to support. --
--- Patch [13]: [PATCH v8 13/15] drm/msm/dp: make bridge helpers use dp_display to allow re-use --- commit 94e6d1d4d94637e92b8d6868e076b0bb8d8e32d0
Author: Abhinav Kumar <[email protected]>
drm/msm/dp: make bridge helpers use dp_display to allow re-use
This commit refactors the DP bridge helpers to directly take a msm_dp_display object instead of a drm_bridge. The stated goal is to allow the upcoming MST bridge implementation to reuse these same helpers.
Quoted 3 lines
drivers/gpu/drm/msm/dp/dp_display.c +0
-0
[ ... ]
Quoted 15 lines
drivers/gpu/drm/msm/dp/dp_display.c +2
-4@@ -1408,11 +1405,9 @@ int msm_dp_modeset_init(struct msm_dp *msm_dp_display, struct drm_device *dev,return 0 ; } -void msm_dp_bridge_atomic_enable (struct drm_bridge *drm_bridge, -struct drm_atomic_commit *state) +void msm_dp_display_atomic_enable (struct msm_dp *msm_dp_display, +struct drm_atomic_commit *state) { -struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (drm_bridge); -struct msm_dp *msm_dp_display = msm_dp_bridge->msm_dp_display;struct drm_crtc *crtc;struct drm_crtc_state *crtc_state;int rc =0 ;
drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 1419
Quoted 5 lines
drivers/gpu/drm/msm/dp/dp_display.c +1
-1@@ -1421,7 +1416,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); crtc =drm_atomic_get_new_crtc_for_encoder (state, - drm_bridge->encoder); + msm_dp_display->bridge->encoder);
[Severity: Medium]
The commit message mentions this refactoring is done so the MST bridge can re-use these helpers. However, doesn't replacing the caller-provided drm_bridge->encoder with the hardcoded primary encoder break that intended reuse?
If an MST stream calls this helper with its own virtual encoder's state, drm_atomic_get_new_crtc_for_encoder() will evaluate the primary encoder instead. Because the primary encoder won't be attached to the MST stream's CRTC in this atomic state, crtc will be NULL, causing this function to silently return early.
Would it be better to retain the drm_bridge parameter or pass the drm_encoder directly so that MST callers can specify their virtual encoder?
Quoted 2 lines
drivers/gpu/drm/msm/dp/dp_display.c +0
-0if (!crtc)return ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
PATCH v8 14/15 drm/msm/dp: separate dp_display_prepare() into its own API
In reply to Yongxing MouFrom: Abhinav Kumar <[email protected]>
For MST, the link setup should only be done once when multiple sinks are enabled, while stream setup may run multiple times for each sink. Split the link-related preparation out of msm_dp_display_atomic_enable() so it can be called separately before the per-stream enable path.
--- drivers/gpu/drm/msm/dp/dp_display.c | 16 +++++++++++----- drivers/gpu/drm/msm/dp/dp_display.h | 5 +++-- drivers/gpu/drm/msm/dp/dp_drm.c | 6 ++++-- 3 files changed, 18 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +11 -5
@@ -1405,8 +1405,8 @@ int msm_dp_modeset_init(struct msm_dp *msm_dp_display, struct drm_device *dev,return 0 ; } -void msm_dp_display_atomic_enable (struct msm_dp *msm_dp_display, -struct drm_atomic_commit *state) +void msm_dp_display_atomic_prepare (struct msm_dp *msm_dp_display, +struct drm_atomic_commit *state) {struct drm_crtc *crtc;struct drm_crtc_state *crtc_state;
@@ -1428,10 +1428,16 @@ void msm_dp_display_atomic_enable(struct msm_dp *msm_dp_display, } rc =msm_dp_display_prepare_link (dp); -if (rc) { +if (rc)DRM_ERROR ("DP display prepare failed, rc=%d\n" , rc); -return ; - } +} + +void msm_dp_display_atomic_enable (struct msm_dp *msm_dp_display) +{ +struct msm_dp_display_private *dp; +int rc =0 ; + + dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); rc =msm_dp_display_enable (dp);if (rc)
drivers/gpu/drm/msm/dp/dp_display.h +3 -2
@@ -35,8 +35,9 @@ void msm_dp_display_set_psr(struct msm_dp *dp, bool enter);void msm_dp_display_debugfs_init (struct msm_dp *msm_dp_display,struct dentry *dentry,bool is_edp);void msm_dp_display_atomic_post_disable (struct msm_dp *dp_display);void msm_dp_display_atomic_disable (struct msm_dp *dp_display); -void msm_dp_display_atomic_enable (struct msm_dp *dp_display, -struct drm_atomic_commit *state); +void msm_dp_display_atomic_prepare (struct msm_dp *dp_display, +struct drm_atomic_commit *state); +void msm_dp_display_atomic_enable (struct msm_dp *dp_display);enum drm_mode_status msm_dp_display_mode_valid (struct msm_dp *dp,const struct drm_display_info *info,const struct drm_display_mode *mode);
drivers/gpu/drm/msm/dp/dp_drm.c +4 -2
@@ -55,7 +55,8 @@ static void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,struct msm_dp_bridge *dp_bridge =to_dp_bridge (drm_bridge);struct msm_dp *dp = dp_bridge->msm_dp_display; -msm_dp_display_atomic_enable (dp, state); +msm_dp_display_atomic_prepare (dp, state); +msm_dp_display_atomic_enable (dp); } static void msm_dp_bridge_atomic_disable(struct drm_bridge *drm_bridge,
@@ -152,7 +153,8 @@ static void msm_edp_bridge_atomic_enable(struct drm_bridge *drm_bridge,return ; } -msm_dp_display_atomic_enable (dp, state); +msm_dp_display_atomic_prepare (dp, state); +msm_dp_display_atomic_enable (dp); } static void msm_edp_bridge_atomic_disable(struct drm_bridge *drm_bridge,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 14/15] drm/msm/dp: separate dp_display_prepare() into its own API
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Splitting `msm_dp_display_atomic_enable()` into `prepare` and `enable` drops the early return…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Splitting msm_dp_display_atomic_enable() into prepare and enable drops the early return protection on failure paths, causing the display stream to be unconditionally enabled even if link preparation fails, leading to unclocked/unpowered hardware access and crashes. --
--- Patch [14]: [PATCH v8 14/15] drm/msm/dp: separate dp_display_prepare() into its own API --- commit b0785b0b736b2b15642aeae00b1fdb850ab52d5c
Author: Abhinav Kumar <[email protected]>
drm/msm/dp: separate dp_display_prepare() into its own API
This commit splits the display enable sequence into separate link preparation and stream enable functions. This allows MST link setup to run once for multiple sinks, while the stream setup runs per-sink.
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_display.c +0
-0
[ ... ]
drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_display_atomic_enable(struct msm_dp *msm_dp_display, · line 1433
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +2
-3@@ -1428,10 +1428,16 @@ void msm_dp_display_atomic_enable(struct msm_dp *msm_dp_display, } rc =msm_dp_display_prepare_link (dp); -if (rc) { +if (rc)DRM_ERROR ("DP display prepare failed, rc=%d\n" , rc); -return ; - } +}
[Severity: High]
By splitting the function and removing this early return, the failure state is discarded. If crtc is NULL or hardware power/clocks fail to initialize in msm_dp_display_prepare_link() (for example, if pm_runtime_resume_and_get() fails), the caller will still proceed to the enable step.
Could this cause a crash (e.g., Synchronous External Abort) when accessing unpowered hardware registers in the enable path?
drivers/gpu/drm/msm/dp/dp_drm.c static void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 60
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_drm.c +2
-1@@ -55,7 +55,8 @@ static void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,struct msm_dp_bridge *dp_bridge =to_dp_bridge (drm_bridge);struct msm_dp *dp = dp_bridge->msm_dp_display; -msm_dp_display_atomic_enable (dp, state); +msm_dp_display_atomic_prepare (dp, state); +msm_dp_display_atomic_enable (dp); }
[Severity: High]
Since msm_dp_display_atomic_prepare() returns void, this function (and msm_edp_bridge_atomic_enable() below) unconditionally calls msm_dp_display_atomic_enable() regardless of preparation success.
Should msm_dp_display_atomic_prepare() return an error code so callers can skip enabling the stream if preparation fails?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
PATCH v8 15/15 drm/msm/dp: pass panel to display enable/disable helpers
In reply to Yongxing MouPass struct msm_dp_panel to the display enable/disable helpers to make them easier to reuse for MST stream handling.
--- drivers/gpu/drm/msm/dp/dp_display.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +12 -10
@@ -652,7 +652,8 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)return msm_dp_ctrl_prepare_stream_on (dp->ctrl, dp->panel, force_link_train); } -static int msm_dp_display_enable (struct msm_dp_display_private *dp) +static int msm_dp_display_enable (struct msm_dp_display_private *dp, +struct msm_dp_panel *msm_dp_panel) {int rc =0 ;struct msm_dp *msm_dp_display = &dp->msm_dp_display;
@@ -663,7 +664,7 @@ static int msm_dp_display_enable(struct msm_dp_display_private *dp)return 0 ; } - rc =msm_dp_ctrl_on_stream (dp->ctrl, dp->panel); + rc =msm_dp_ctrl_on_stream (dp->ctrl, msm_dp_panel);if (!rc) msm_dp_display->power_on = true;
@@ -709,22 +710,23 @@ static void msm_dp_display_audio_notify_disable(struct msm_dp_display_private *d msm_dp_display->audio_enabled = false; } -static int msm_dp_display_disable (struct msm_dp_display_private *dp) +static int msm_dp_display_disable (struct msm_dp_display_private *dp, +struct msm_dp_panel *msm_dp_panel) {struct msm_dp *msm_dp_display = &dp->msm_dp_display;if (!msm_dp_display->power_on)return 0 ; -msm_dp_panel_disable_vsc_sdp (dp->panel); +msm_dp_panel_disable_vsc_sdp (msm_dp_panel);msm_dp_ctrl_off_pixel_clk (dp->ctrl);/* 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); +msm_dp_link_psm_config (dp->link, &msm_dp_panel->link_info, true); -msm_dp_ctrl_off_link (dp->ctrl, dp->panel); +msm_dp_ctrl_off_link (dp->ctrl, msm_dp_panel);if (dp->link->sink_count ==0 )/* re-init the PHY so that we can listen to Dongle disconnect */
@@ -739,7 +741,7 @@ static int msm_dp_display_disable(struct msm_dp_display_private *dp) }/** -* msm_dp_bridge_mode_valid - callback to determine if specified mode is valid +* msm_dp_display_mode_valid - callback to determine if specified mode is valid * @dp: Pointer to dp display structure * @info: display info * @mode: Pointer to drm mode structure
@@ -1439,14 +1441,14 @@ void msm_dp_display_atomic_enable(struct msm_dp *msm_dp_display) dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); - rc =msm_dp_display_enable (dp); + rc =msm_dp_display_enable (dp, dp->panel);if (rc)DRM_ERROR ("DP display enable failed, rc=%d\n" , rc); rc =msm_dp_display_post_enable (msm_dp_display);if (rc) {DRM_ERROR ("DP display post enable failed, rc=%d\n" , rc); -msm_dp_display_disable (dp); +msm_dp_display_disable (dp, dp->panel); }drm_dbg_dp (msm_dp_display->drm_dev,"type=%d Done\n" , msm_dp_display->connector_type);
@@ -1481,7 +1483,7 @@ void msm_dp_display_atomic_post_disable(struct msm_dp *dp)msm_dp_display_audio_notify_disable (msm_dp_display); -msm_dp_display_disable (msm_dp_display); +msm_dp_display_disable (msm_dp_display, msm_dp_display->panel);msm_dp_display_unprepare (msm_dp_display); }
Signature · 1 line
2.43.0
Quoted 9 lines · Yongxing Mou
This series is the SST-only prerequisite portion of the MSM DP MST work. It refactors the existing DP code paths so that MST can plug in cleanly in a follow-up series, without bundling the cleanup with MST functionality in the same submission.
SST behaviour is preserved end-to-end; no new functionality is added here. The intent is to land these refactors first to keep the follow-up MST series focused, smaller, and easier to review.
Quoted 5 lines
Signed-off-by Yongxing Mou <[email protected]>---
Changes in v8:
- Rebase to next-20260717.
- Fix comments from sashiko-bot.
Which comments? In future please describe your changes. (and please update this entry if this gets reposted for any other reason).
Quoted 2 lines
- Link to v7: https://lore.kernel.org/r/[email protected]
Signature · 2 lines
With best wishes Dmitry