drm/msm/dp: Drop the HPD state machine
v6 cover drm/msm/dp: Drop the HPD state machine
Currently, all HPD interrupt handling must go through the HPD state machine.
This has caused many issues where the DRM framework assumes that DP is in one state while the state machine is stuck in another state.
As discussed here [1], this series:
- Removes the state machine
- Moves link training to atomic_enable()
- Changes the detect() behavior to return true if a display is physically plugged in (as opposed to if the DP link is ready).
- Remove event queue and move internal HPD handling to hpd_notify()
To correctly detect the displays which are plugged on boot on the boards which use dp-connector devices, this series depends on [2]. USB-C and eDP panels are handled natively.
[1] https://patchwork.freedesktop.org/patch/656312/?series=142010&rev=2#comment_1201738
[2] https://lore.kernel.org/all/[email protected]/
---
Changes in v6:
- Corrected mismatch between Jessica's From and SoB emails
- Corrected documentation and fixed style comments for
msm_dp_bridge_detect() (Bjorn, Konrad)
- Changed msm_dp_bridge_atomic_enable() to bail out earlier in case of
link training failure (Konrad)
- Corrected commit message for the link training commit to stop
mentioning event-related changes (Konrad)
- Added kerneldoc to msm_dp_display_host_phy_init(), describing return
value (Konrad)
- Switched to guard() instead of raw mutex_lock() (Konrad)
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Fixed the EDID clearing on display unplug
- Fixed the initial HPD issue via the external series
- Tested on eDP devices
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Fixed PM runtime handling
- Fixed several cases where the HPD machine would loose its state
- Fixed the case where detection was ignoring the plugging in display.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Take over the series (thanks, Jessica, for the previous work!)
- Major rework of the series, squashed the set of patches touching the
HPD states and handling, it is easier to do it this way rather than
pulling the strings one by one.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Dropped event queue (Dmitry)
- Moved internal HPD handling to use hpd_notify() (Dmitry)
- Reworked bridge detect() to read DPCP and sink count (Dmitry)
- Moved setting of link_trained to plug/unplugged handling
- Dropped msm_dp::connected (Dmitry)
- Squashed all hpd state related patches (Dmitry)
- Link to v1: https://lore.kernel.org/r/[email protected]
To: Rob Clark <[email protected]>
To: Dmitry Baryshkov <[email protected]>
To: Abhinav Kumar <[email protected]>
To: Jessica Zhang <[email protected]>
To: Sean Paul <[email protected]>
To: Marijn Suijten <[email protected]>
To: David Airlie <[email protected]>
To: Simona Vetter <[email protected]>
To: Kuogee Hsieh <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Dmitry Baryshkov (3):
drm/msm/dp: drop event data
drm/msm/dp: turn link_ready into plugged
drm/msm/dp: clear EDID on display unplug
Jessica Zhang (7):
drm/msm/dp: fix HPD state status bit shift value drm/msm/dp: Fix the ISR_* enum values drm/msm/dp: Read DPCD and sink count in bridge detect() drm/msm/dp: Move link training to atomic_enable() drm/msm/dp: Drop EV_USER_NOTIFICATION drm/msm/dp: rework HPD handling
drm/msm/dp: Add sink_count to debug logs
drivers/gpu/drm/msm/dp/dp_ctrl.c | 16 - drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_display.c | 722 ++++++++++++------------------------ drivers/gpu/drm/msm/dp/dp_display.h | 3 +- drivers/gpu/drm/msm/dp/dp_drm.c | 63 +--- drivers/gpu/drm/msm/dp/dp_drm.h | 2 + drivers/gpu/drm/msm/dp/dp_panel.c | 8 + drivers/gpu/drm/msm/dp/dp_panel.h | 2 + drivers/gpu/drm/msm/dp/dp_reg.h | 4 +- 9 files changed, 255 insertions(+), 566 deletions(-)
---
base-commit: 687da68900cd1a46549f7d9430c7d40346cb86a0
change-id: 20250523-hpd-refactor-74e25b55620a
prerequisite-change-id: 20260314-dp-connector-hpd-f069e66bc6af:v2
prerequisite-patch-id: 90db75e3fb8bc9c81c67547db7bbd4eefd5d6c40
prerequisite-patch-id: 1c4d030b93a8cc6c98b3447a8685da24eb1f24d5
Best regards,
Signature · 2 lines
With best wishes Dmitry
PATCH v6 1/10 drm/msm/dp: fix HPD state status bit shift value
From: Jessica Zhang <[email protected]>
The HPD state status is the 3 most significant bits, not 4 bits of the HPD_INT_STATUS register.
Fix the bit shift macro so that the correct bits are returned in msm_dp_aux_is_link_connected().
--- drivers/gpu/drm/msm/dp/dp_reg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/dp/dp_reg.h +2 -2
@@ -68,8 +68,8 @@#define DP_DP_IRQ_HPD_INT_ACK (0x00000002)#define DP_DP_HPD_REPLUG_INT_ACK (0x00000004)#define DP_DP_HPD_UNPLUG_INT_ACK (0x00000008) -#define DP_DP_HPD_STATE_STATUS_BITS_MASK (0x0000000F) -#define DP_DP_HPD_STATE_STATUS_BITS_SHIFT (0x1C) +#define DP_DP_HPD_STATE_STATUS_BITS_MASK (0x00000007) +#define DP_DP_HPD_STATE_STATUS_BITS_SHIFT (0x1D)#define REG_DP_DP_HPD_INT_MASK (0x0000000C)#define DP_DP_HPD_PLUG_INT_MASK (0x00000001)
Signature · 1 line
2.47.3
PATCH v6 2/10 drm/msm/dp: Fix the ISR_* enum values
In reply to Dmitry BaryshkovFrom: Jessica Zhang <[email protected]>
The ISR_HPD_* enum should represent values that can be read from the REG_DP_DP_HPD_INT_STATUS register. Swap ISR_HPD_IO_GLITCH_COUNT and ISR_HPD_REPLUG_COUNT to map them correctly to register values.
While we are at it, correct the spelling for ISR_HPD_REPLUG_COUNT.
--- drivers/gpu/drm/msm/dp/dp_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +2 -2
@@ -38,9 +38,9 @@ enum {ISR_DISCONNECTED ,ISR_CONNECT_PENDING ,ISR_CONNECTED , -ISR_HPD_REPLUG_COUNT , +ISR_HPD_IO_GLITCH_COUNT ,ISR_IRQ_HPD_PULSE_COUNT , - ISR_HPD_LO_GLITH_COUNT, + ISR_HPD_REPLUG_COUNT, };/* event thread connection state */
Signature · 1 line
2.47.3
PATCH v6 3/10 drm/msm/dp: Read DPCD and sink count in bridge detect()
In reply to Dmitry BaryshkovFrom: Jessica Zhang <[email protected]>
Instead of relying on the link_ready flag to specify if DP is connected, read the DPCD bits and get the sink count to accurately detect if DP is connected.
--- drivers/gpu/drm/msm/dp/dp_display.c | 63 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_drm.c | 20 ------------ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 3 files changed, 65 insertions(+), 20 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +63 -0
@@ -1152,6 +1152,69 @@ static int msm_dp_hpd_event_thread_start(struct msm_dp_display_private *msm_dp_preturn 0 ; } +/** +* msm_dp_bridge_detect - callback to determine if connector is connected +* +* @bridge: Pointer to drm bridge structure +* @connector: Pointer to drm connector structure +* +* Returns: where there is a display connected to the DPTX (returning +* disconnected for branch devices without DP Sinks being connected). +*/ +enum drm_connector_status msm_dp_bridge_detect (struct drm_bridge *bridge, +struct drm_connector *connector) +{ +struct msm_dp_bridge *msm_dp_bridge =to_dp_bridge (bridge); +struct msm_dp *dp = msm_dp_bridge->msm_dp_display; +int status = connector_status_disconnected; +struct msm_dp_display_private *priv; +u8 dpcd[DP_RECEIVER_CAP_SIZE ]; +struct drm_dp_desc desc; +int ret; + + dp =to_dp_bridge (bridge)->msm_dp_display; + + priv = container_of(dp, struct msm_dp_display_private, msm_dp_display); + +if (!dp->link_ready) +return status; + +msm_dp_aux_enable_xfers (priv->aux, true); + + ret =pm_runtime_resume_and_get (&dp->pdev->dev); +if (ret) { +DRM_ERROR ("failed to pm_runtime_resume\n" ); +msm_dp_aux_enable_xfers (priv->aux, false); +return status; + } + + ret =msm_dp_aux_is_link_connected (priv->aux); +if (dp->internal_hpd && !ret) + goto end; + + ret =drm_dp_read_dpcd_caps (priv->aux, dpcd); +if (ret) + goto end; + + ret =drm_dp_read_desc (priv->aux, &desc,drm_dp_is_branch (dpcd)); +if (ret) + goto end; + + status = connector_status_connected; +if (drm_dp_read_sink_count_cap (connector, dpcd, &desc)) { +int sink_count =drm_dp_read_sink_count (priv->aux); + +drm_dbg_dp (dp->drm_dev,"sink_count = %d\n" , sink_count); + +if (sink_count <=0 ) + status = connector_status_disconnected; + } + +end: +pm_runtime_put_sync (&dp->pdev->dev); +return status; +} +static irqreturn_t msm_dp_display_irq_handler (int irq,void *dev_id) {struct msm_dp_display_private *dp = dev_id;
drivers/gpu/drm/msm/dp/dp_drm.c +0 -20
@@ -15,26 +15,6 @@#include "dp_audio.h" #include "dp_drm.h" -/** -* msm_dp_bridge_detect - callback to determine if connector is connected -* @bridge: Pointer to drm bridge structure -* @connector: Pointer to drm connector structure -* Returns: Bridge's 'is connected' status -*/ -static enum drm_connector_status -msm_dp_bridge_detect (struct drm_bridge *bridge,struct drm_connector *connector) -{ -struct msm_dp *dp; - - dp =to_dp_bridge (bridge)->msm_dp_display; - -drm_dbg_dp (dp->drm_dev,"link_ready = %s\n" , -str_true_false (dp->link_ready)); - -return (dp->link_ready) ? connector_status_connected : - connector_status_disconnected; -} - static int msm_dp_bridge_atomic_check(struct drm_bridge *bridge, struct drm_bridge_state *bridge_state, struct drm_crtc_state *crtc_state,
drivers/gpu/drm/msm/dp/dp_drm.h +2 -0
@@ -25,6 +25,8 @@ int msm_dp_bridge_init(struct msm_dp *msm_dp_display, struct drm_device *dev,struct drm_encoder *encoder, bool yuv_supported); +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,
Signature · 1 line
2.47.3
Re: [PATCH v6 03/10] drm/msm/dp: Read DPCD and sink count in bridge detect()
Quoted 21 lines · Dmitry Baryshkov
From: Jessica Zhang <[email protected]>
Instead of relying on the
link_readyflag to specify if DP is connected, read the DPCD bits and get the sink count to accurately detect if DP is connected.Signed-off-by Jessica Zhang <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/dp/dp_display.c | 63 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_drm.c | 20 ------------ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 3 files changed, 65 insertions(+), 20 deletions(-)drivers/gpu/drm/msm/dp/dp_display.c +0
-0
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_hpd_event_thread_start(struct msm_dp_display_private *msm_dp_p · line 1161
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +7
-0@@ -1152,6 +1152,69 @@ static int msm_dp_hpd_event_thread_start(struct msm_dp_display_private *msm_dp_preturn 0 ; } +/** +* msm_dp_bridge_detect - callback to determine if connector is connected +* +* @bridge: Pointer to drm bridge structure +* @connector: Pointer to drm connector structure +* +* Returns: where there is a display connected to the DPTX (returning
whether?
Otherwise, if keeping msm_dp_aux_enable_xfers(true) is intentional in bailout cases:
Konrad
Re: [PATCH v6 03/10] drm/msm/dp: Read DPCD and sink count in bridge detect()
Quoted 25 lines · Konrad Dybcio
Quoted 24 lines · Dmitry Baryshkov
From: Jessica Zhang <[email protected]>
Instead of relying on the
link_readyflag to specify if DP is connected, read the DPCD bits and get the sink count to accurately detect if DP is connected.Signed-off-by Jessica Zhang <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/dp/dp_display.c | 63 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_drm.c | 20 ------------ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 3 files changed, 65 insertions(+), 20 deletions(-)drivers/gpu/drm/msm/dp/dp_display.c +0
-0@@ -1152,6 +1152,69 @@ static int msm_dp_hpd_event_thread_start(struct msm_dp_display_private *msm_dp_preturn 0 ; }
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_hpd_event_thread_start(struct msm_dp_display_private *msm_dp_p · line 1161
Quoted 7 lines
drivers/gpu/drm/msm/dp/dp_display.c +7
-0+/** +* msm_dp_bridge_detect - callback to determine if connector is connected +* +* @bridge: Pointer to drm bridge structure +* @connector: Pointer to drm connector structure +* +* Returns: where there is a display connected to the DPTX (returning whether?
yep
Quoted 3 lines
Otherwise, if keeping
msm_dp_aux_enable_xfers(true)is intentional in bailout cases:
In the non-error bailouts, yes. I might want to change that later, but for now it's expected this way.
Quoted 4 lines
Reviewed-by Konrad Dybcio <[email protected]>Konrad
Signature · 2 lines
With best wishes Dmitry
PATCH v6 4/10 drm/msm/dp: Move link training to atomic_enable()
In reply to Dmitry BaryshkovFrom: Jessica Zhang <[email protected]>
Currently, the DP link training is being done during HPD. Move link training to atomic_enable() in accordance with the atomic_enable() documentation.
Link disabling is already done in atomic_post_disable() (as part of the dp_ctrl_off_link_stream() helper).
--- drivers/gpu/drm/msm/dp/dp_display.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +7 -5
@@ -437,11 +437,6 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)msm_dp_link_psm_config (dp->link, &dp->panel->link_info, false);msm_dp_link_reset_phy_params_vx_px (dp->link); - rc =msm_dp_ctrl_on_link (dp->ctrl); -if (rc) { -DRM_ERROR ("failed to complete DP link training\n" ); - goto end; - }msm_dp_add_event (dp,EV_USER_NOTIFICATION , true,0 );
@@ -1699,6 +1694,13 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, force_link_train = true; } + rc =msm_dp_ctrl_on_link (msm_dp_display->ctrl); +if (rc) { +DRM_ERROR ("Failed link training (rc=%d)\n" , rc); +// TODO: schedule drm_connector_set_link_status_property() +return ; + } +msm_dp_display_enable (msm_dp_display, force_link_train); rc =msm_dp_display_post_enable (dp);
Signature · 1 line
2.47.3
Re: [PATCH v6 04/10] drm/msm/dp: Move link training to atomic_enable()
Quoted 6 lines · Dmitry Baryshkov
From: Jessica Zhang <[email protected]>
Currently, the DP link training is being done during HPD. Move link training to
atomic_enable()in accordance with theatomic_enable()documentation.
Quoted 8 lines
Link disabling is already done in
atomic_post_disable()(as part of thedp_ctrl_off_link_stream()helper).Signed-off-by Jessica Zhang <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
PATCH v6 5/10 drm/msm/dp: Drop EV_USER_NOTIFICATION
In reply to Dmitry BaryshkovFrom: Jessica Zhang <[email protected]>
Currently, we queue an event for signalling HPD connect/disconnect. This can mean a delay in plug/unplug handling and notifying DRM core when a hotplug happens.
Drop EV_USER_NOTIFICATION and signal the IRQ event as part of hotplug handling.
--- drivers/gpu/drm/msm/dp/dp_display.c | 28 ++++++++-------------------- drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 2 ++ 3 files changed, 11 insertions(+), 20 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +8 -20
@@ -58,7 +58,6 @@ enum {EV_HPD_PLUG_INT ,EV_IRQ_HPD_INT , EV_HPD_UNPLUG_INT, - EV_USER_NOTIFICATION, };#define EVENT_TIMEOUT (HZ/10)/* 100ms */
@@ -344,17 +343,6 @@ static const struct component_ops msm_dp_display_comp_ops = { .unbind = msm_dp_display_unbind, }; -static void msm_dp_display_send_hpd_event (struct msm_dp *msm_dp_display) -{ -struct msm_dp_display_private *dp; -struct drm_connector *connector; - - dp = container_of(msm_dp_display, struct msm_dp_display_private, msm_dp_display); - - connector = dp->msm_dp_display.connector; -drm_helper_hpd_irq_event (connector->dev); -} -static int msm_dp_display_send_hpd_notification (struct msm_dp_display_private *dp,bool hpd) {
@@ -378,7 +366,11 @@ static int msm_dp_display_send_hpd_notification(struct msm_dp_display_private *ddrm_dbg_dp (dp->drm_dev,"type=%d hpd=%d\n" , dp->msm_dp_display.connector_type, hpd); -msm_dp_display_send_hpd_event (&dp->msm_dp_display); + +drm_bridge_hpd_notify (dp->msm_dp_display.bridge, + hpd ? + connector_status_connected : + connector_status_disconnected);return 0 ; }
@@ -438,7 +430,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); -msm_dp_add_event (dp,EV_USER_NOTIFICATION , true,0 ); +msm_dp_display_send_hpd_notification (dp, true); end:return rc;
@@ -507,7 +499,7 @@ static int msm_dp_display_notify_disconnect(struct device *dev) {struct msm_dp_display_private *dp =dev_get_dp_display_private (dev); -msm_dp_add_event (dp,EV_USER_NOTIFICATION , false,0 ); +msm_dp_display_send_hpd_notification (dp, false);return 0 ; }
@@ -528,7 +520,7 @@ static int msm_dp_display_handle_port_status_changed(struct msm_dp_display_privadrm_dbg_dp (dp->drm_dev,"sink count is zero, nothing to do\n" );if (dp->hpd_state !=ST_DISCONNECTED ) { dp->hpd_state =ST_DISCONNECT_PENDING ; -msm_dp_add_event (dp,EV_USER_NOTIFICATION , false,0 ); +msm_dp_display_send_hpd_notification (dp, false); } }else {if (dp->hpd_state ==ST_DISCONNECTED ) {
@@ -1122,10 +1114,6 @@ static int hpd_event_thread(void *data)case EV_IRQ_HPD_INT :msm_dp_irq_hpd_handle (msm_dp_priv, todo->data);break ; -case EV_USER_NOTIFICATION : -msm_dp_display_send_hpd_notification (msm_dp_priv, - todo->data); -break ;default :break ; }
drivers/gpu/drm/msm/dp/dp_display.h +1 -0
@@ -16,6 +16,7 @@ struct msm_dp {struct platform_device *pdev;struct drm_connector *connector;struct drm_bridge *next_bridge; +struct drm_bridge *bridge;bool link_ready;bool audio_enabled;bool power_on;
drivers/gpu/drm/msm/dp/dp_drm.c +2 -0
@@ -340,6 +340,8 @@ int msm_dp_bridge_init(struct msm_dp *msm_dp_display, struct drm_device *dev, } } + msm_dp_display->bridge = bridge; +return 0 ; }
Signature · 1 line
2.47.3
PATCH v6 6/10 drm/msm/dp: drop event data
In reply to Dmitry BaryshkovWith EV_USER_NOTIFICATION gone event's data is no longer useful. Drop it, removing also the argument from event handlers.
--- drivers/gpu/drm/msm/dp/dp_display.c | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +18 -21
@@ -69,7 +69,6 @@ enum {struct msm_dp_event {u32 event_id; -u32 data;u32 delay; };
@@ -219,7 +218,7 @@ static struct msm_dp_display_private *dev_get_dp_display_private(struct device * }static int msm_dp_add_event (struct msm_dp_display_private *msm_dp_priv,u32 event, -u32 data,u32 delay) +u32 delay) {unsigned long flag;struct msm_dp_event *todo;
@@ -237,7 +236,6 @@ static int msm_dp_add_event(struct msm_dp_display_private *msm_dp_priv, u32 even todo = &msm_dp_priv->event_list[msm_dp_priv->event_pndx++]; msm_dp_priv->event_pndx %=DP_EVENT_Q_MAX ; todo->event_id = event; - todo->data = data; todo->delay = delay;wake_up (&msm_dp_priv->event_q);spin_unlock_irqrestore (&msm_dp_priv->event_lock, flag);
@@ -577,7 +575,7 @@ static int msm_dp_display_usbpd_attention_cb(struct device *dev)return rc; } -static int msm_dp_hpd_plug_handle (struct msm_dp_display_private *dp,u32 data) +static int msm_dp_hpd_plug_handle (struct msm_dp_display_private *dp) {u32 state;int ret;
@@ -603,7 +601,7 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)if (state ==ST_DISCONNECT_PENDING ) {/* wait until ST_DISCONNECTED */ -msm_dp_add_event (dp,EV_HPD_PLUG_INT ,0 ,1 );/* delay = 1 */ +msm_dp_add_event (dp,EV_HPD_PLUG_INT ,1 );mutex_unlock (&dp->event_mutex);return 0 ; }
@@ -645,7 +643,7 @@ static void msm_dp_display_handle_plugged_change(struct msm_dp *msm_dp_display, plugged); } -static int msm_dp_hpd_unplug_handle (struct msm_dp_display_private *dp,u32 data) +static int msm_dp_hpd_unplug_handle (struct msm_dp_display_private *dp) {u32 state;struct platform_device *pdev = dp->msm_dp_display.pdev;
@@ -707,7 +705,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)return 0 ; } -static int msm_dp_irq_hpd_handle (struct msm_dp_display_private *dp,u32 data) +static int msm_dp_irq_hpd_handle (struct msm_dp_display_private *dp) {u32 state;
@@ -725,7 +723,7 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, u32 data)if (state ==ST_MAINLINK_READY || state ==ST_DISCONNECT_PENDING ) {/* wait until ST_CONNECTED */ -msm_dp_add_event (dp,EV_IRQ_HPD_INT ,0 ,1 );/* delay = 1 */ +msm_dp_add_event (dp,EV_IRQ_HPD_INT ,1 );mutex_unlock (&dp->event_mutex);return 0 ; }
@@ -1080,7 +1078,6 @@ static int hpd_event_thread(void *data) todo_next = &msm_dp_priv->event_list[msm_dp_priv->event_pndx++]; msm_dp_priv->event_pndx %=DP_EVENT_Q_MAX ; todo_next->event_id = todo->event_id; - todo_next->data = todo->data; todo_next->delay = todo->delay -1 ;/* clean up older event */
@@ -1106,13 +1103,13 @@ static int hpd_event_thread(void *data)switch (todo->event_id) {case EV_HPD_PLUG_INT : -msm_dp_hpd_plug_handle (msm_dp_priv, todo->data); +msm_dp_hpd_plug_handle (msm_dp_priv);break ;case EV_HPD_UNPLUG_INT : -msm_dp_hpd_unplug_handle (msm_dp_priv, todo->data); +msm_dp_hpd_unplug_handle (msm_dp_priv);break ;case EV_IRQ_HPD_INT : -msm_dp_irq_hpd_handle (msm_dp_priv, todo->data); +msm_dp_irq_hpd_handle (msm_dp_priv);break ;default :break ;
@@ -1216,19 +1213,19 @@ static irqreturn_t msm_dp_display_irq_handler(int irq, void *dev_id) dp->msm_dp_display.connector_type, hpd_isr_status);/* hpd related interrupts */ if (hpd_isr_status &DP_DP_HPD_PLUG_INT_MASK ) -msm_dp_add_event (dp,EV_HPD_PLUG_INT ,0 ,0 ); +msm_dp_add_event (dp,EV_HPD_PLUG_INT ,0 );if (hpd_isr_status &DP_DP_IRQ_HPD_INT_MASK ) { -msm_dp_add_event (dp,EV_IRQ_HPD_INT ,0 ,0 ); +msm_dp_add_event (dp,EV_IRQ_HPD_INT ,0 ); }if (hpd_isr_status &DP_DP_HPD_REPLUG_INT_MASK ) { -msm_dp_add_event (dp,EV_HPD_UNPLUG_INT ,0 ,0 ); -msm_dp_add_event (dp,EV_HPD_PLUG_INT ,0 ,3 ); +msm_dp_add_event (dp,EV_HPD_UNPLUG_INT ,0 ); +msm_dp_add_event (dp,EV_HPD_PLUG_INT ,3 ); }if (hpd_isr_status &DP_DP_HPD_UNPLUG_INT_MASK ) -msm_dp_add_event (dp,EV_HPD_UNPLUG_INT ,0 ,0 ); +msm_dp_add_event (dp,EV_HPD_UNPLUG_INT ,0 ); ret =IRQ_HANDLED ; }
@@ -1653,7 +1650,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, }if (dp->is_edp) -msm_dp_hpd_plug_handle (msm_dp_display,0 ); +msm_dp_hpd_plug_handle (msm_dp_display);mutex_lock (&msm_dp_display->event_mutex);if (pm_runtime_resume_and_get (&dp->pdev->dev)) {
@@ -1727,7 +1724,7 @@ void msm_dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge, msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display);if (dp->is_edp) -msm_dp_hpd_unplug_handle (msm_dp_display,0 ); +msm_dp_hpd_unplug_handle (msm_dp_display);mutex_lock (&msm_dp_display->event_mutex);
@@ -1849,7 +1846,7 @@ void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,return ;if (!msm_dp_display->link_ready && status == connector_status_connected) -msm_dp_add_event (dp,EV_HPD_PLUG_INT ,0 ,0 ); +msm_dp_add_event (dp,EV_HPD_PLUG_INT ,0 );else if (msm_dp_display->link_ready && status == connector_status_disconnected) -msm_dp_add_event (dp,EV_HPD_UNPLUG_INT ,0 ,0 ); +msm_dp_add_event (dp,EV_HPD_UNPLUG_INT ,0 ); }
Signature · 1 line
2.47.3
PATCH v6 7/10 drm/msm/dp: rework HPD handling
In reply to Dmitry BaryshkovFrom: Jessica Zhang <[email protected]>
Handling of the HPD events in the MSM DP driver is plagued with lots of problems. It tries to work aside of the main DRM framework, handling the HPD signals on its own. There are two separate paths, one for the HPD signals coming from the DP HPD pin and another path for signals coming from outside (e.g. from the Type-C AltMode). It lies about the connected state, returning the link established state instead. It is not easy to understand or modify it. Having a separate event machine doesn't add extra clarity.
Drop the whole event machine. When the DP receives a HPD event, send it to the DRM core. Then handle the events in the hpd_notify callback, unifying paths for HPD signals.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 16 - drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_display.c | 601 ++++++++---------------------------- drivers/gpu/drm/msm/dp/dp_display.h | 1 - 4 files changed, 134 insertions(+), 485 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +0 -16
@@ -2583,22 +2583,6 @@ void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl)phy_init (phy); } -void msm_dp_ctrl_off_link (struct msm_dp_ctrl *msm_dp_ctrl) -{ -struct msm_dp_ctrl_private *ctrl; -struct phy *phy; - - ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, msm_dp_ctrl); - phy = ctrl->phy; - -msm_dp_ctrl_mainlink_disable (ctrl); - -dev_pm_opp_set_rate (ctrl->dev,0 ); -msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl); - -phy_power_off (phy); -} -void msm_dp_ctrl_off (struct msm_dp_ctrl *msm_dp_ctrl) {struct msm_dp_ctrl_private *ctrl;
drivers/gpu/drm/msm/dp/dp_ctrl.h +0 -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,bool force_link_train);void msm_dp_ctrl_off_link_stream (struct msm_dp_ctrl *msm_dp_ctrl); -void msm_dp_ctrl_off_link (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);
drivers/gpu/drm/msm/dp/dp_display.c +134 -467
890 lines not on this page · raw message
drivers/gpu/drm/msm/dp/dp_display.h +0 -1
@@ -22,7 +22,6 @@ struct msm_dp {bool power_on;unsigned int connector_type;bool is_edp; -bool internal_hpd;struct msm_dp_audio *msm_dp_audio;bool psr_supported;
Signature · 1 line
2.47.3
Re: [PATCH v6 07/10] drm/msm/dp: rework HPD handling
Quoted 15 lines · Dmitry Baryshkov
From: Jessica Zhang <[email protected]>
Handling of the HPD events in the MSM DP driver is plagued with lots of problems. It tries to work aside of the main DRM framework, handling the HPD signals on its own. There are two separate paths, one for the HPD signals coming from the DP HPD pin and another path for signals coming from outside (e.g. from the Type-C AltMode). It lies about the connected state, returning the link established state instead. It is not easy to understand or modify it. Having a separate event machine doesn't add extra clarity.
Drop the whole event machine. When the DP receives a HPD event, send it to the DRM core. Then handle the events in the
hpd_notifycallback, unifying paths for HPD signals.
Quoted 6 lines
Signed-off-by Jessica Zhang <[email protected]>Co-developed-by Dmitry Baryshkov <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>---
This is way too complex for me to grasp at once, so I have a couple nits
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+ drm_dbg_dp(dp->drm_dev, "After, type=%d\n", + dp->msm_dp_display.connector_type);
Most debug prints added in this patch have odd indent and some have vague messages
[...]
drivers/gpu/drm/msm/dp/dp_display.c static irqreturn_t msm_dp_display_irq_handler(int irq, void *dev_id) · line 922
Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_display.c +8
-0+/* Send HPD as connected and distinguish it in the notifier */ +if (hpd_isr_status &DP_DP_IRQ_HPD_INT_MASK ) +drm_bridge_hpd_notify (dp->msm_dp_display.bridge, + connector_status_connected); + + ret =IRQ_HANDLED ; + +return ret;
Return directly
[...]
Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_display.c +2
-0+} +static int msm_dp_display_request_irq (struct msm_dp_display_private *dp) {int rc =0 ;@@ -1247,9 +933,13 @@ static int msm_dp_display_request_irq(struct msm_dp_display_private *dp)return dp->irq; }
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_display_request_irq(struct msm_dp_display_private *dp) · line 941
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +6
-3- rc =devm_request_irq (&pdev->dev, dp->irq, msm_dp_display_irq_handler, -IRQF_TRIGGER_HIGH |IRQF_NO_AUTOEN , -"dp_display_isr" , dp); +spin_lock_init (&dp->irq_thread_lock); +irq_set_status_flags (dp->irq,IRQ_NOAUTOEN ); + rc = devm_request_threaded_irq(&pdev->dev, dp->irq, + msm_dp_display_irq_handler, + msm_dp_display_irq_thread, + IRQ_TYPE_LEVEL_HIGH,
I think this field expects IRQF_-prefixed flags too
Konrad
Re: [PATCH v6 07/10] drm/msm/dp: rework HPD handling
Quoted 25 lines · Konrad Dybcio
Quoted 15 lines · Dmitry Baryshkov
From: Jessica Zhang <[email protected]>
Handling of the HPD events in the MSM DP driver is plagued with lots of problems. It tries to work aside of the main DRM framework, handling the HPD signals on its own. There are two separate paths, one for the HPD signals coming from the DP HPD pin and another path for signals coming from outside (e.g. from the Type-C AltMode). It lies about the connected state, returning the link established state instead. It is not easy to understand or modify it. Having a separate event machine doesn't add extra clarity.
Drop the whole event machine. When the DP receives a HPD event, send it to the DRM core. Then handle the events in the
hpd_notifycallback, unifying paths for HPD signals.Quoted 6 lines
Signed-off-by Jessica Zhang <[email protected]>Co-developed-by Dmitry Baryshkov <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>---
This is way too complex for me to grasp at once, so I have a couple nits
Quoted 7 lines
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+ drm_dbg_dp(dp->drm_dev, "After, type=%d\n", + dp->msm_dp_display.connector_type);Most debug prints added in this patch have odd indent and some have vague messages
Correcting the identation. I'm not sure, which messages are vague.
Signature · 2 lines
With best wishes Dmitry
PATCH v6 8/10 drm/msm/dp: Add sink_count to debug logs
In reply to Dmitry BaryshkovFrom: Jessica Zhang <[email protected]>
Add sink count to the debug logs for [un]plug and HPD IRQ handling.
--- drivers/gpu/drm/msm/dp/dp_display.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +18 -12
@@ -389,8 +389,9 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)int ret;struct platform_device *pdev = dp->msm_dp_display.pdev; -drm_dbg_dp (dp->drm_dev,"Before, type=%d\n" , - dp->msm_dp_display.connector_type); +drm_dbg_dp (dp->drm_dev,"Before, type=%d sink_count=%d\n" , + dp->msm_dp_display.connector_type, + dp->link->sink_count);if (dp->msm_dp_display.link_ready)return 0 ;
@@ -412,8 +413,9 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)pm_runtime_put_sync (&pdev->dev); } -drm_dbg_dp (dp->drm_dev,"After, type=%d\n" , - dp->msm_dp_display.connector_type); +drm_dbg_dp (dp->drm_dev,"After, type=%d sink_count=%d\n" , + dp->msm_dp_display.connector_type, + dp->link->sink_count);/* uevent will complete connection part */ return 0 ;
@@ -441,8 +443,9 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)msm_dp_aux_enable_xfers (dp->aux, false); -drm_dbg_dp (dp->drm_dev,"Before, type=%d\n" , - dp->msm_dp_display.connector_type); +drm_dbg_dp (dp->drm_dev,"Before, type=%d sink_count=%d\n" , + dp->msm_dp_display.connector_type, + dp->link->sink_count);if (!dp->msm_dp_display.link_ready)return 0 ;
@@ -466,8 +469,9 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)/* signal the disconnect event early to ensure proper teardown */ msm_dp_display_handle_plugged_change (&dp->msm_dp_display, false); -drm_dbg_dp (dp->drm_dev,"After, type=%d\n" , - dp->msm_dp_display.connector_type); +drm_dbg_dp (dp->drm_dev,"After, type=%d, sink_count=%d\n" , + dp->msm_dp_display.connector_type, + dp->link->sink_count);/* uevent will complete disconnection part */ pm_runtime_put_sync (&pdev->dev);
@@ -480,8 +484,9 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp)int rc =0 ;/* irq_hpd can happen at either connected or disconnected state */ -drm_dbg_dp (dp->drm_dev,"Before, type=%d\n" , - dp->msm_dp_display.connector_type); +drm_dbg_dp (dp->drm_dev,"Before, type=%d, sink_count=%d\n" , + dp->msm_dp_display.connector_type, + dp->link->sink_count);/* check for any test request issued by sink */ rc =msm_dp_link_process_request (dp->link);
@@ -494,8 +499,9 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp) rc =msm_dp_display_handle_irq_hpd (dp); } -drm_dbg_dp (dp->drm_dev,"After, type=%d\n" , - dp->msm_dp_display.connector_type); +drm_dbg_dp (dp->drm_dev,"After, type=%d, sink_count=%d\n" , + dp->msm_dp_display.connector_type, + dp->link->sink_count);return rc; }
Signature · 1 line
2.47.3
Re: [PATCH v6 08/10] drm/msm/dp: Add sink_count to debug logs
Quoted 10 lines · Dmitry Baryshkov
From: Jessica Zhang <[email protected]>
Add sink count to the debug logs for [un]plug and HPD IRQ handling.
Signed-off-by Jessica Zhang <[email protected]>[DB: dropped link_ready handling]Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
PATCH v6 9/10 drm/msm/dp: turn link_ready into plugged
In reply to Dmitry BaryshkovTracking when the DP link is ready isn't that useful from the driver point of view. It doesn't provide a direct information if the device should be suspended, etc. Replace it with the 'plugged' boolean, which is set when the driver knows that there is DPRX plugged.
--- drivers/gpu/drm/msm/dp/dp_display.c | 93 ++++++++++++++++++++++--------------- drivers/gpu/drm/msm/dp/dp_display.h | 1 - drivers/gpu/drm/msm/dp/dp_drm.c | 41 ++-------------- 3 files changed, 60 insertions(+), 75 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +56 -37
@@ -53,6 +53,9 @@ struct msm_dp_display_private {bool phy_initialized;bool audio_supported; +struct mutex plugged_lock; +bool plugged; +struct drm_device *drm_dev;struct drm_dp_aux *aux;
@@ -285,8 +288,6 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp) dp->panel->dpcd, dp->panel->downstream_ports); - dp->msm_dp_display.link_ready = true; - dp->msm_dp_display.psr_supported = dp->panel->psr_cap.version && psr_enabled; dp->audio_supported = info->has_audio;
@@ -304,7 +305,16 @@ static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp)return rc; } -static void msm_dp_display_host_phy_init (struct msm_dp_display_private *dp) +/** +* msm_dp_display_host_phy_init() - start up DP PHY +* @dp: main display data structure +* +* Prepare DP PHY for the AUX transactions to succeed. +* +* Returns: true if this call has initliazed the PHY and false if the PHY has +* already been setup beforehand. +*/ +static bool msm_dp_display_host_phy_init (struct msm_dp_display_private *dp) { drm_dbg_dp(dp->drm_dev, "type=%d core_init=%d phy_init=%d\n", dp->msm_dp_display.connector_type, dp->core_initialized,
@@ -313,7 +323,10 @@ static void msm_dp_display_host_phy_init(struct msm_dp_display_private *dp)if (!dp->phy_initialized) {msm_dp_ctrl_phy_init (dp->ctrl); dp->phy_initialized = true; +return true; } + +return false; }static void msm_dp_display_host_phy_exit (struct msm_dp_display_private *dp)
@@ -367,14 +380,6 @@ static int msm_dp_display_handle_irq_hpd(struct msm_dp_display_private *dp)u32 sink_request = dp->link->sink_request;drm_dbg_dp (dp->drm_dev,"%d\n" , sink_request); -if (!dp->msm_dp_display.link_ready) { -if (sink_request &DP_LINK_STATUS_UPDATED ) { -drm_dbg_dp (dp->drm_dev,"Disconnected sink_request: %d\n" , - sink_request); -DRM_ERROR ("Disconnected, no DP_LINK_STATUS_UPDATED\n" ); -return -EINVAL ; - } - }msm_dp_ctrl_handle_sink_request (dp->ctrl);
@@ -393,8 +398,7 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp) dp->msm_dp_display.connector_type, dp->link->sink_count); -if (dp->msm_dp_display.link_ready) -return 0 ; +guard (mutex)(&dp->plugged_lock); ret =pm_runtime_resume_and_get (&pdev->dev);if (ret) {
@@ -407,18 +411,14 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)msm_dp_display_host_phy_init (dp); ret =msm_dp_display_process_hpd_high (dp); -if (ret) {/* link train failed */ - dp->msm_dp_display.link_ready = false; -msm_dp_aux_enable_xfers (dp->aux, false); -pm_runtime_put_sync (&pdev->dev); - }drm_dbg_dp (dp->drm_dev,"After, type=%d sink_count=%d\n" , dp->msm_dp_display.connector_type, dp->link->sink_count); -/* uevent will complete connection part */ -return 0 ; + dp->plugged = true; + +return ret; }; static void msm_dp_display_handle_plugged_change(struct msm_dp *msm_dp_display,
@@ -447,7 +447,8 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp) dp->msm_dp_display.connector_type, dp->link->sink_count); -if (!dp->msm_dp_display.link_ready) +guard (mutex)(&dp->plugged_lock); +if (!dp->plugged)return 0 ;/* triggered by irq_hdp with sink_count = 0 */
@@ -464,8 +465,6 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp) dp->panel->dpcd, dp->panel->downstream_ports); - dp->msm_dp_display.link_ready = false; -/* signal the disconnect event early to ensure proper teardown */ msm_dp_display_handle_plugged_change (&dp->msm_dp_display, false);
@@ -473,8 +472,11 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp) dp->msm_dp_display.connector_type, dp->link->sink_count); -/* uevent will complete disconnection part */ -pm_runtime_put_sync (&pdev->dev); +if (dp->plugged) { +pm_runtime_put_sync (&pdev->dev); + dp->plugged = false; + } +return 0 ; }
@@ -823,42 +825,49 @@ enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge,struct msm_dp_display_private *priv;u8 dpcd[DP_RECEIVER_CAP_SIZE ];struct drm_dp_desc desc; +bool phy_deinit;int ret; dp =to_dp_bridge (bridge)->msm_dp_display; priv = container_of(dp, struct msm_dp_display_private, msm_dp_display); -if (!dp->link_ready) -return status; - +guard (mutex)(&priv->plugged_lock); ret =pm_runtime_resume_and_get (&dp->pdev->dev);if (ret) {DRM_ERROR ("failed to pm_runtime_resume\n" );return status; } + phy_deinit =msm_dp_display_host_phy_init (priv); +msm_dp_aux_enable_xfers (priv->aux, true); ret =msm_dp_aux_is_link_connected (priv->aux); -if (!ret) { +DRM_DEBUG_DP ("aux link status: %x\n" , ret); +if (!priv->plugged && !ret) {DRM_DEBUG_DP ("aux not connected\n" ); + priv->plugged = false; goto end; } ret =drm_dp_read_dpcd_caps (priv->aux, dpcd);if (ret) {DRM_DEBUG_DP ("failed to read caps\n" ); + priv->plugged = false; goto end; } ret =drm_dp_read_desc (priv->aux, &desc,drm_dp_is_branch (dpcd));if (ret) {DRM_DEBUG_DP ("failed to read desc\n" ); + priv->plugged = false; goto end; } status = connector_status_connected; + priv->plugged = true; +if (drm_dp_read_sink_count_cap (connector, dpcd, &desc)) {int sink_count =drm_dp_read_sink_count (priv->aux);
@@ -869,7 +878,19 @@ enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge, } end: -pm_runtime_put_sync (&dp->pdev->dev); +/* +* If we detected the DPRX, leave the controller on so that it doesn't +* loose the state. +*/ +if (!priv->plugged) { +if (phy_deinit) { +msm_dp_aux_enable_xfers (priv->aux, false); +msm_dp_display_host_phy_exit (priv); + } + +pm_runtime_put_sync (&dp->pdev->dev); + } +return status; }
@@ -1127,6 +1148,8 @@ static int msm_dp_display_probe(struct platform_device *pdev) (dp->msm_dp_display.connector_type == DRM_MODE_CONNECTOR_eDP); dp->hpd_isr_status =0 ; +mutex_init (&dp->plugged_lock); + rc =msm_dp_display_get_io (dp);if (rc)return rc;
@@ -1357,7 +1380,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,return ; } -if (dp->link_ready && !dp->power_on) { +if (!dp->power_on) {msm_dp_display_host_phy_init (msm_dp_display); force_link_train = true; }
@@ -1404,9 +1427,6 @@ void msm_dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge,if (dp->is_edp)msm_dp_hpd_unplug_handle (msm_dp_display); -if (!dp->link_ready) -drm_dbg_dp (dp->drm_dev,"type=%d is disconnected\n" , dp->connector_type); -msm_dp_display_disable (msm_dp_display);drm_dbg_dp (dp->drm_dev,"type=%d Done\n" , dp->connector_type);
@@ -1504,9 +1524,8 @@ void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge, hpd_link_status =msm_dp_aux_is_link_connected (dp->aux); -drm_dbg_dp (dp->drm_dev,"type=%d link hpd_link_status=0x%x, link_ready=%d, status=%d\n" , - msm_dp_display->connector_type, hpd_link_status, - msm_dp_display->link_ready, status); +drm_dbg_dp (dp->drm_dev,"type=%d link hpd_link_status=0x%x, status=%d\n" , + msm_dp_display->connector_type, hpd_link_status, status);if (status == connector_status_connected) {if (hpd_link_status ==ISR_HPD_REPLUG_COUNT ) {
drivers/gpu/drm/msm/dp/dp_display.h +0 -1
@@ -17,7 +17,6 @@ struct msm_dp {struct drm_connector *connector;struct drm_bridge *next_bridge;struct drm_bridge *bridge; -bool link_ready;bool audio_enabled;bool power_on;unsigned int connector_type;
drivers/gpu/drm/msm/dp/dp_drm.c +4 -37
59 lines not on this page · raw message
Signature · 1 line
2.47.3
Re: [PATCH v6 09/10] drm/msm/dp: turn link_ready into plugged
Quoted 9 lines · Dmitry Baryshkov
Tracking when the DP link is ready isn't that useful from the driver point of view. It doesn't provide a direct information if the device should be suspended, etc. Replace it with the 'plugged' boolean, which is set when the driver knows that there is DPRX plugged.
Signed-off-by Dmitry Baryshkov <[email protected]>---
[...]
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp) · line 315
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +8
-1-static void msm_dp_display_host_phy_init (struct msm_dp_display_private *dp) +/** +* msm_dp_display_host_phy_init() - start up DP PHY +* @dp: main display data structure +* +* Prepare DP PHY for the AUX transactions to succeed. +* +* Returns: true if this call has initliazed the PHY and false if the PHY has +* already been setup beforehand.
This assumes no failure. I hope adding various return-value checks across this driver is somewhere on the todolist..
[...]
drivers/gpu/drm/msm/dp/dp_display.c enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge, · line 883
Quoted 5 lines
end:
drivers/gpu/drm/msm/dp/dp_display.c +3
-1-pm_runtime_put_sync (&dp->pdev->dev); +/* +* If we detected the DPRX, leave the controller on so that it doesn't +* loose the state.
"lose"
That is done.. presumably so that one could correct a coredump or similar?
Konrad
Re: [PATCH v6 09/10] drm/msm/dp: turn link_ready into plugged
Quoted 36 lines · Konrad Dybcio
Quoted 9 lines · Dmitry Baryshkov
Tracking when the DP link is ready isn't that useful from the driver point of view. It doesn't provide a direct information if the device should be suspended, etc. Replace it with the 'plugged' boolean, which is set when the driver knows that there is DPRX plugged.
Signed-off-by Dmitry Baryshkov <[email protected]>---
[...]
drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_display_process_hpd_high(struct msm_dp_display_private *dp) · line 315
Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +8
-1-static void msm_dp_display_host_phy_init (struct msm_dp_display_private *dp) +/** +* msm_dp_display_host_phy_init() - start up DP PHY +* @dp: main display data structure +* +* Prepare DP PHY for the AUX transactions to succeed. +* +* Returns: true if this call has initliazed the PHY and false if the PHY has +* already been setup beforehand. This assumes no failure. I hope adding various return-value checks across this driver is somewhere on the todolist..
[...]
drivers/gpu/drm/msm/dp/dp_display.c enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge, · line 883
Quoted 5 lines
end:
drivers/gpu/drm/msm/dp/dp_display.c +3
-1-pm_runtime_put_sync (&dp->pdev->dev); +/* +* If we detected the DPRX, leave the controller on so that it doesn't +* loose the state. "lose"
Quoted 1 line
That is done.. presumably so that one could correct a coredump or similar?
No. It is exactly as written: to keep the DPTX state. Otherwise the HPD state machine will be reset, DPTX won't be able to respond to the HPD pulses from the branch device, when the anything gets plugged into it, etc.
Quoted 2 lines
Konrad
Signature · 2 lines
With best wishes Dmitry
PATCH v6 10/10 drm/msm/dp: clear EDID on display unplug
In reply to Dmitry BaryshkovCurrently the driver only updates the EDID when it detects a connected monitor, which results in the connector still listing outdated modes even after the display is unplugged. Set connector's EDID to NULL on unplug to clear the list of modes.
--- drivers/gpu/drm/msm/dp/dp_display.c | 4 ++++ drivers/gpu/drm/msm/dp/dp_panel.c | 8 ++++++++ drivers/gpu/drm/msm/dp/dp_panel.h | 2 ++ 3 files changed, 14 insertions(+)
drivers/gpu/drm/msm/dp/dp_display.c +4 -0
@@ -451,6 +451,10 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp)if (!dp->plugged)return 0 ; +/* Don't forget modes for eDP */ +if (!dp->msm_dp_display.is_edp) +msm_dp_panel_unplugged (dp->panel, dp->msm_dp_display.connector); +/* triggered by irq_hdp with sink_count = 0 */ if (dp->link->sink_count ==0 )msm_dp_display_host_phy_exit (dp);
drivers/gpu/drm/msm/dp/dp_panel.c +8 -0
@@ -293,6 +293,14 @@ int msm_dp_panel_read_sink_caps(struct msm_dp_panel *msm_dp_panel,return rc; } +void msm_dp_panel_unplugged (struct msm_dp_panel *msm_dp_panel, +struct drm_connector *connector) +{ +drm_edid_connector_update (connector,NULL ); +drm_edid_free (msm_dp_panel->drm_edid); + msm_dp_panel->drm_edid =NULL ; +} +u32 msm_dp_panel_get_mode_bpp (struct msm_dp_panel *msm_dp_panel,u32 mode_edid_bpp,u32 mode_pclk_khz) {
drivers/gpu/drm/msm/dp/dp_panel.h +2 -0
@@ -49,6 +49,8 @@ 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);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,
Signature · 1 line
2.47.3
Re: [PATCH v6 10/10] drm/msm/dp: clear EDID on display unplug
Quoted 9 lines · Dmitry Baryshkov
Currently the driver only updates the EDID when it detects a connected monitor, which results in the connector still listing outdated modes even after the display is unplugged. Set connector's EDID to NULL on unplug to clear the list of modes.
Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
Quoted 21 lines · Dmitry Baryshkov
Currently, all HPD interrupt handling must go through the HPD state machine.
This has caused many issues where the DRM framework assumes that DP is in one state while the state machine is stuck in another state.
As discussed here [1], this series:
- Removes the state machine
- Moves link training toatomic_enable()
- Changes thedetect()behavior to return true if a display is physically plugged in (as opposed to if the DP link is ready).
- Remove event queue and move internal HPD handling tohpd_notify()To correctly detect the displays which are plugged on boot on the boards which use dp-connector devices, this series depends on [2]. USB-C and eDP panels are handled natively.
[1] https://patchwork.freedesktop.org/patch/656312/?series=142010&rev=2#comment_1201738
[2] https://lore.kernel.org/all/[email protected]/
Quoted 13 lines
---
Changes in v6:
- Corrected mismatch between Jessica's From and SoB emails
- Corrected documentation and fixed style comments for
msm_dp_bridge_detect()(Bjorn, Konrad)
- Changedmsm_dp_bridge_atomic_enable()to bail out earlier in case of
link training failure (Konrad)
- Corrected commit message for the link training commit to stop
mentioning event-related changes (Konrad)
- Added kerneldoc tomsm_dp_display_host_phy_init(), describing return
value (Konrad)
- Switched toguard()instead of rawmutex_lock()(Konrad)
- Link to v5: https://lore.kernel.org/r/[email protected]
Looks like v5 is already in linux-next.. merged in:
~val
Quoted 37 lines · Val Packett
Quoted 21 lines · Dmitry Baryshkov
Currently, all HPD interrupt handling must go through the HPD state machine.
This has caused many issues where the DRM framework assumes that DP is in one state while the state machine is stuck in another state.
As discussed here [1], this series:
- Removes the state machine
- Moves link training toatomic_enable()
- Changes thedetect()behavior to return true if a display is physically plugged in (as opposed to if the DP link is ready).
- Remove event queue and move internal HPD handling tohpd_notify()To correctly detect the displays which are plugged on boot on the boards which use dp-connector devices, this series depends on [2]. USB-C and eDP panels are handled natively.
[1] https://patchwork.freedesktop.org/patch/656312/?series=142010&rev=2#comment_1201738
[2] https://lore.kernel.org/all/[email protected]/Quoted 13 lines
---
Changes in v6:
- Corrected mismatch between Jessica's From and SoB emails
- Corrected documentation and fixed style comments for
msm_dp_bridge_detect()(Bjorn, Konrad)
- Changedmsm_dp_bridge_atomic_enable()to bail out earlier in case of
link training failure (Konrad)
- Corrected commit message for the link training commit to stop
mentioning event-related changes (Konrad)
- Added kerneldoc tomsm_dp_display_host_phy_init(), describing return
value (Konrad)
- Switched toguard()instead of rawmutex_lock()(Konrad)
- Link to v5: https://lore.kernel.org/r/[email protected]
Quoted 3 lines
Looks like v5 is already in linux-next.. merged in:
To be replaced by v6 in the next linux-next buildup. There were comments (and r-b's) by Konrad, so it was worth replacing the series rather than forcing v5 through to msm-next and then drm-next and then landing changes on top of it.
Signature · 2 lines
With best wishes Dmitry