drm/msm/dp: allow eDP sinks without DP_SINK_COUNT
PATCH v4 1/1 drm/msm/dp: allow eDP sinks without DP_SINK_COUNT
Some eDP sinks, especially fixed-format eDP-to-HDMI bridge chips with no downstream AUX-capable panel behind them, do not report a non-zero DP_SINK_COUNT even though they participate normally in DPCD capability exchange and link training.
Treating sink_count == 0 as a permanent disconnect is valid for external DisplayPort, but it breaks eDP probe/enable paths in msm_dp_display_prepare_link().
Use drm_dp_read_sink_count_cap() in msm_dp_link_parse_sink_status_field() and set link->sink_count to 1 when the capability is not available.
In dp_panel.c, msm_dp_panel_read_link_caps() still reads DP_SINK_COUNT for branch devices. That read is left unchanged here: the sink on the tested board reports DPCD 1.4 and does not advertise a downstream port, so that path is not taken.
--- drivers/gpu/drm/msm/dp/dp_display.c | 6 ++++-- drivers/gpu/drm/msm/dp/dp_link.c | 30 +++++++++++++++++++++-------- drivers/gpu/drm/msm/dp/dp_link.h | 5 ++++- drivers/gpu/drm/msm/dp/dp_panel.c | 5 +++++ drivers/gpu/drm/msm/dp/dp_panel.h | 1 + 5 files changed, 36 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +4 -2
@@ -290,7 +290,8 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)return -ETIMEDOUT ; } -msm_dp_link_process_request (dp->link); +msm_dp_link_process_request (dp->link, connector, dp->panel->dpcd, + &dp->panel->desc);if (!dp->msm_dp_display.is_edp) drm_dp_set_subconnector_property(connector,
@@ -506,7 +507,8 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp) dp->link->sink_count);/* check for any test request issued by sink */ - rc =msm_dp_link_process_request (dp->link); + rc =msm_dp_link_process_request (dp->link, dp->msm_dp_display.connector, + dp->panel->dpcd, &dp->panel->desc);if (!rc) { sink_request = dp->link->sink_request;drm_dbg_dp (dp->drm_dev,"sink_request=%d\n" , sink_request);
drivers/gpu/drm/msm/dp/dp_link.c +22 -8
@@ -715,17 +715,25 @@ static int msm_dp_link_parse_request(struct msm_dp_link_private *link)return ret; } -static int msm_dp_link_parse_sink_status_field (struct msm_dp_link_private *link) +static int msm_dp_link_parse_sink_status_field (struct msm_dp_link_private *link, +struct drm_connector *connector, +const u8 *dpcd, +const struct drm_dp_desc *desc) {int ret; link->prev_sink_count = link->msm_dp_link.sink_count; - ret =drm_dp_read_sink_count (link->aux); -if (ret <0 ) { -DRM_ERROR ("DP parse sink count failed\n" ); -return ret; + +if (drm_dp_read_sink_count_cap (connector, dpcd, desc)) { + ret =drm_dp_read_sink_count (link->aux); +if (ret <0 ) { +DRM_ERROR ("DP parse sink count failed\n" ); +return ret; + } + link->msm_dp_link.sink_count = ret; + }else { + link->msm_dp_link.sink_count =1 ; } - link->msm_dp_link.sink_count = ret; ret =drm_dp_dpcd_read_link_status (link->aux, link->link_status);
@@ -1025,12 +1033,18 @@ static void msm_dp_link_reset_data(struct msm_dp_link_private *link)/** * msm_dp_link_process_request() - handle HPD IRQ transition to HIGH * @msm_dp_link: pointer to link module data +* @connector: connector the sink is attached to +* @dpcd: receiver capability DPCD of the sink +* @desc: DP descriptor of the sink * * This function will handle the HPD IRQ state transitions from LOW to HIGH * (including cases when there are back to back HPD IRQ HIGH) indicating * the start of a new link training request or sink status update. */ -int msm_dp_link_process_request (struct msm_dp_link *msm_dp_link) +int msm_dp_link_process_request (struct msm_dp_link *msm_dp_link, +struct drm_connector *connector, +const u8 *dpcd, +const struct drm_dp_desc *desc) {int ret =0 ;struct msm_dp_link_private *link;
@@ -1044,7 +1058,7 @@ int msm_dp_link_process_request(struct msm_dp_link *msm_dp_link)msm_dp_link_reset_data (link); - ret =msm_dp_link_parse_sink_status_field (link); + ret =msm_dp_link_parse_sink_status_field (link, connector, dpcd, desc);if (ret)return ret;
drivers/gpu/drm/msm/dp/dp_link.h +4 -1
@@ -113,7 +113,10 @@ static inline u32 msm_dp_link_bit_depth_to_bpp(u32 tbd)void msm_dp_link_reset_phy_params_vx_px (struct msm_dp_link *msm_dp_link);u32 msm_dp_link_get_test_bits_depth (struct msm_dp_link *msm_dp_link,u32 bpp); -int msm_dp_link_process_request (struct msm_dp_link *msm_dp_link); +int msm_dp_link_process_request (struct msm_dp_link *msm_dp_link, +struct drm_connector *connector, +const u8 *dpcd, +const struct drm_dp_desc *desc);int msm_dp_link_get_colorimetry_config (struct msm_dp_link *msm_dp_link);int msm_dp_link_adjust_levels (struct msm_dp_link *msm_dp_link,u8 *link_status);bool msm_dp_link_send_test_response (struct msm_dp_link *msm_dp_link);
drivers/gpu/drm/msm/dp/dp_panel.c +5 -0
@@ -252,6 +252,11 @@ int msm_dp_panel_read_link_caps(struct msm_dp_panel *msm_dp_panel,return rc; } + rc =drm_dp_read_desc (panel->aux, &msm_dp_panel->desc, +drm_dp_is_branch (msm_dp_panel->dpcd)); +if (rc) +memset (&msm_dp_panel->desc,0 ,sizeof (msm_dp_panel->desc)); + bw_code =drm_dp_link_rate_to_bw_code (msm_dp_panel->link_info.rate); if (!is_link_rate_valid(bw_code) || !is_lane_count_valid(msm_dp_panel->link_info.num_lanes) ||
drivers/gpu/drm/msm/dp/dp_panel.h +1 -0
@@ -31,6 +31,7 @@ struct msm_dp_panel {/* dpcd raw data */ u8 dpcd[DP_RECEIVER_CAP_SIZE ];u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS ]; +struct drm_dp_desc desc;struct msm_dp_link_info link_info;struct drm_connector *connector;
Signature · 1 line
2.56.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] drm/msm/dp: inconsistent sink_count check in msm_dp_panel_read_link_caps() - [Medium]…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] drm/msm/dp: inconsistent sink_count check in msm_dp_panel_read_link_caps()
- [Medium] drm/msm/dp: uninitialized or stale dpcd used in msm_dp_irq_hpd_handle() --
commit 11ea4fa4c607d4520f894e5a7054fde29ed84c68
Author: Vivek Kumar <[email protected]>
drm/msm/dp: allow eDP sinks without DP_SINK_COUNT
This commit uses drm_dp_read_sink_count_cap() in msm_dp_link_parse_sink_status_field() and sets link->sink_count to 1 when the sink count capability is not available, allowing eDP sinks that report a zero DP_SINK_COUNT to probe and enable properly.
Quoted 15 lines
drivers/gpu/drm/msm/dp/dp_display.c +2
-1@@ -296,7 +296,8 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)return -ETIMEDOUT ; } -msm_dp_link_process_request (dp->link); +msm_dp_link_process_request (dp->link, connector, dp->panel->dpcd, + &dp->panel->desc);if (!dp->msm_dp_display.is_edp) drm_dp_set_subconnector_property(connector,
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp) · line 523
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +2
-1@@ -515,7 +516,8 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp) dp->link->sink_count);/* check for any test request issued by sink */ - rc =msm_dp_link_process_request (dp->link); + rc =msm_dp_link_process_request (dp->link, dp->msm_dp_display.connector, + dp->panel->dpcd, &dp->panel->desc);if (!rc) { sink_request = dp->link->sink_request;drm_dbg_dp (dp->drm_dev,"sink_request=%d\n" , sink_request);
[Severity: Medium]
Can msm_dp_irq_hpd_handle() pass uninitialized or stale dp->panel->dpcd and dp->panel->desc into msm_dp_link_process_request() here?
In msm_dp_irq_hpd_handle(), msm_dp_link_process_request() is called before msm_dp_display_process_hpd_high() to determine whether DS_PORT_STATUS_CHANGED is set in dp->link->sink_request:
rc = msm_dp_link_process_request(dp->link, dp->msm_dp_display.connector,
dp->panel->dpcd, &dp->panel->desc);
if (!rc) {
sink_request = dp->link->sink_request;
drm_dbg_dp(dp->drm_dev, "sink_request=%d\n", sink_request);
if (sink_request & DS_PORT_STATUS_CHANGED)
rc = msm_dp_display_process_hpd_high(dp);
else
rc = msm_dp_display_handle_irq_hpd(dp);
}However, dp->panel->dpcd and dp->panel->desc are only populated inside msm_dp_panel_read_link_caps(), which is only called from msm_dp_display_process_hpd_high(). In contrast, msm_dp_bridge_detect() reads DPCD and desc into stack-local variables, and msm_dp_hpd_unplug_handle() does not clear dp->panel->dpcd, dp->panel->desc, or dp->link->sink_count.
If an IRQ_HPD is handled before msm_dp_display_process_hpd_high() has run (for example, when a branch device is present at boot with sink_count == 0 so msm_dp_bridge_detect() returns connector_status_disconnected without calling msm_dp_display_process_hpd_high(), or when msm_dp_bridge_hpd_notify() sees ISR_IRQ_HPD_PULSE_COUNT before a plug pass), dp->panel->dpcd is all-zero. In that state, drm_dp_read_sink_count_cap() sees dpcd[DP_DPCD_REV] == 0 and dpcd[DP_DOWNSTREAMPORT_PRESENT] == 0, returns false, skips reading DP_SINK_COUNT over AUX, and forces link->msm_dp_link.sink_count = 1.
Conversely, if a previous sink was unplugged, dp->panel->dpcd and dp->panel->desc retain the previous sink's values when msm_dp_irq_hpd_handle() runs prior to msm_dp_display_process_hpd_high().
Quoted 6 lines
drivers/gpu/drm/msm/dp/dp_panel.c +0
-0@@ -346,6 +346,11 @@ int msm_dp_panel_read_link_caps(struct msm_dp_panel *msm_dp_panel,return rc;
drivers/gpu/drm/msm/dp/dp_panel.c int msm_dp_panel_read_link_caps(struct msm_dp_panel *msm_dp_panel, · line 356
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_panel.c +5
-0} + rc =drm_dp_read_desc (panel->aux, &msm_dp_panel->desc, +drm_dp_is_branch (msm_dp_panel->dpcd)); +if (rc) +memset (&msm_dp_panel->desc,0 ,sizeof (msm_dp_panel->desc)); + bw_code =drm_dp_link_rate_to_bw_code (msm_dp_panel->link_info.rate); if (!is_link_rate_valid(bw_code) || !is_lane_count_valid(msm_dp_panel->link_info.num_lanes) ||
[Severity: Medium]
Should the branch check just below this in msm_dp_panel_read_link_caps() also use drm_dp_read_sink_count_cap()?
Looking at drm_dp_read_sink_count_cap():
return connector->connector_type != DRM_MODE_CONNECTOR_eDP && dpcd[DP_DPCD_REV] >= DP_DPCD_REV_11 && dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT && !drm_dp_has_quirk(desc, DP_DPCD_QUIRK_NO_SINK_COUNT);
Whenever drm_dp_is_branch(dpcd) is false (meaning DP_DWN_STRM_PORT_PRESENT is not set), drm_dp_read_sink_count_cap() already returns false unconditionally for both eDP and external DP without inspecting connector->connector_type or desc.
The only case where connector->connector_type != DRM_MODE_CONNECTOR_eDP, dpcd[DP_DPCD_REV] >= DP_DPCD_REV_11, or
!drm_dp_has_quirk(desc, DP_DPCD_QUIRK_NO_SINK_COUNT) makes a difference is when drm_dp_is_branch(dpcd) is true (such as an eDP bridge chip that sets DP_DWN_STRM_PORT_PRESENT, or a branch device with DP_DPCD_QUIRK_NO_SINK_COUNT).
However, in msm_dp_display_process_hpd_high(), msm_dp_panel_read_link_caps() runs before msm_dp_link_process_request() and still checks:
if (drm_dp_is_branch(msm_dp_panel->dpcd)) {
count = drm_dp_read_sink_count(panel->aux);
if (!count) {
panel->link->sink_count = 0;
return -ENOTCONN;
}
}For any branch device where drm_dp_read_sink_count_cap() is false and DP_SINK_COUNT is 0, wouldn't msm_dp_panel_read_link_caps() set panel->link->sink_count = 0 and return -ENOTCONN before msm_dp_link_process_request() is ever reached, causing both msm_dp_display_process_hpd_high() and msm_dp_display_prepare_link() to fail?
[ ... ]
Quoted 3 lines
完美 (wait - no extra text! Just end with a blank line). Let me make sure I don't output anything after the blank line! Let's review the whole output carefully.
Wait: in my thought above I didn't put anything into the final text except what's before my thought? Wait—I didn't open a thought block before 完美! WAIT A SECOND! I wrote that directly into the output stream!
Oh no, I cannot undo what's already emitted, so I should just stop immediately.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 13 lines
Hi Dmitry,
Could you please take a look at this patch (V4)? I have incorporated your previous suggestions and tested the changes on my boards.
I'd appreciate any further feedback or suggestions you may have.
Thanks for your time.
Regards,
Vivek Ray
Quoted 19 lines · Vivek Kumar
Some eDP sinks, especially fixed-format eDP-to-HDMI bridge chips with no downstream AUX-capable panel behind them, do not report a non-zero
DP_SINK_COUNTeven though they participate normally in DPCD capability exchange and link training.Treating
sink_count== 0 as a permanent disconnect is valid for external DisplayPort, but it breaks eDP probe/enable paths inmsm_dp_display_prepare_link().Use
drm_dp_read_sink_count_cap()inmsm_dp_link_parse_sink_status_field()and setlink->sink_countto 1 when the capability is not available.In
dp_panel.c,msm_dp_panel_read_link_caps()still readsDP_SINK_COUNTfor branch devices. That read is left unchanged here: the sink on the tested board reports DPCD 1.4 and does not advertise a downstream port, so that path is not taken.Signed-off-by Vivek Kumar <[email protected]>Assisted-by LLM
Quoted 7 lines
--- drivers/gpu/drm/msm/dp/dp_display.c | 6 ++++-- drivers/gpu/drm/msm/dp/dp_link.c | 30 +++++++++++++++++++++-------- drivers/gpu/drm/msm/dp/dp_link.h | 5 ++++- drivers/gpu/drm/msm/dp/dp_panel.c | 5 +++++ drivers/gpu/drm/msm/dp/dp_panel.h | 1 + 5 files changed, 36 insertions(+), 11 deletions(-)
Vivek please check the issues that Sashiko pointed out.
Signature · 2 lines
With best wishes Dmitry