fix missing unplug interrupt problem
v2 cover fix missing unplug interrupt problem
Both AUX_SW_RESET and DP_SW_RESET clear pending HPD interrupts. Therefore irq_hpd handler should not issues either aux or sw reset to avoid following unplug interrupt be cleared accidentally.
Kuogee Hsieh (2):
drm/msm/dp: return fail when both link lane and rate are 0 at dpcd
read
drm/msm/dp: unplug interrupt missed after irq_hpd handler
drivers/gpu/drm/msm/dp/dp_aux.c | 7 ------- drivers/gpu/drm/msm/dp/dp_catalog.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_ctrl.c | 15 ++++++++++----- drivers/gpu/drm/msm/dp/dp_display.c | 7 +++++++ drivers/gpu/drm/msm/dp/dp_panel.c | 12 +++++++++--- 5 files changed, 50 insertions(+), 15 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/2 drm/msm/dp: return fail when both link lane and rate are 0 at dpcd read
Some dongle set both link lane and rate to 0 during dpcd receiver capability read if there is no monitor attache to this dongle. Therefore return fail to prevent driver from trying to populate monitor further.
Changes in V2:
-- split this patch into two. Move postpone irq_handle into next patch -- add Fixes tag
--- drivers/gpu/drm/msm/dp/dp_panel.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/dp/dp_panel.c +9 -3
@@ -167,12 +167,18 @@ int dp_panel_read_sink_caps(struct dp_panel *dp_panel, panel = container_of(dp_panel, struct dp_panel_private, dp_panel); rc =dp_panel_read_dpcd (dp_panel); +if (rc) { +DRM_ERROR ("read dpcd failed %d\n" , rc); +return rc; + } + bw_code =drm_dp_link_rate_to_bw_code (dp_panel->link_info.rate); -if (rc || !is_link_rate_valid (bw_code) || +if (!is_link_rate_valid (bw_code) || !is_lane_count_valid (dp_panel->link_info.num_lanes) || (bw_code > dp_panel->max_bw_code)) { -DRM_ERROR ("read dpcd failed %d\n" , rc); -return rc; +DRM_ERROR ("Illegal link rate=%d lane=%d\n" , dp_panel->link_info.rate, + dp_panel->link_info.num_lanes); +return -EINVAL ; }if (dp_panel->dfp_present) {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 2/2 drm/msm/dp: unplug interrupt missed after irq_hpd handler
In reply to Kuogee HsiehThere is HPD unplug interrupts missed at scenario of an irq_hpd followed by unplug interrupts with around 10 ms in between. Since both AUX_SW_RESET and DP_SW_RESET clear pending HPD interrupts, irq_hpd handler should not issues either aux or sw reset to avoid following unplug interrupt be cleared accidentally. This patch also postpone handling of irq_hpd until connected state if it happened at connection pending state.
Changes in V2:
-- add postpone handling of irq_hpd until connected state -- check DP_TRAINING_1 instead of DP_TRAINING_NONE
--- drivers/gpu/drm/msm/dp/dp_aux.c | 7 ------- drivers/gpu/drm/msm/dp/dp_catalog.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_ctrl.c | 15 ++++++++++----- drivers/gpu/drm/msm/dp/dp_display.c | 7 +++++++ 4 files changed, 41 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/dp/dp_aux.c +0 -7
@@ -336,7 +336,6 @@ static ssize_t dp_aux_transfer(struct drm_dp_aux *dp_aux,ssize_t ret;int const aux_cmd_native_max =16 ;int const aux_cmd_i2c_max =128 ; -int const retry_count =5 ;struct dp_aux_private *aux =container_of (dp_aux, struct dp_aux_private, dp_aux);
@@ -378,12 +377,6 @@ static ssize_t dp_aux_transfer(struct drm_dp_aux *dp_aux, ret =dp_aux_cmd_fifo_tx (aux, msg);if (ret <0 ) { -if (aux->native) { - aux->retry_cnt++; -if (!(aux->retry_cnt % retry_count)) -dp_catalog_aux_update_cfg (aux->catalog); -dp_catalog_aux_reset (aux->catalog); - }usleep_range (400 ,500 );/* at least 400us to next try */ goto unlock_exit; }
drivers/gpu/drm/msm/dp/dp_catalog.c +24 -0
@@ -190,6 +190,18 @@ int dp_catalog_aux_clear_hw_interrupts(struct dp_catalog *dp_catalog)return 0 ; } +/** +* dp_catalog_aux_reset() - reset AUX controller +* +* @aux: DP catalog structure +* +* return: void +* +* This function reset AUX controller +* +* NOTE: reset AUX controller will also clear any pending HPD related interrupts +* +*/ void dp_catalog_aux_reset (struct dp_catalog *dp_catalog) {u32 aux_ctrl;
@@ -483,6 +495,18 @@ int dp_catalog_ctrl_set_pattern(struct dp_catalog *dp_catalog,return 0 ; } +/** +* dp_catalog_ctrl_reset() - reset DP controller +* +* @dp_catalog: DP catalog structure +* +* return: void +* +* This function reset the DP controller +* +* NOTE: reset DP controller will also clear any pending HPD related interrupts +* +*/ void dp_catalog_ctrl_reset (struct dp_catalog *dp_catalog) {u32 sw_reset;
drivers/gpu/drm/msm/dp/dp_ctrl.c +10 -5
@@ -1296,7 +1296,8 @@ static int dp_ctrl_setup_main_link(struct dp_ctrl_private *ctrl,* transitioned to PUSH_IDLE. In order to start transmitting * a link training pattern, we have to first do soft reset. */ -dp_catalog_ctrl_reset (ctrl->catalog); +if (*training_step ==DP_TRAINING_1 ) +dp_catalog_ctrl_reset (ctrl->catalog); ret =dp_ctrl_link_train (ctrl, cr, training_step);
@@ -1491,15 +1492,18 @@ static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl)return 0 ; } +static void dp_ctrl_link_idle_reset (struct dp_ctrl_private *ctrl) +{ +dp_ctrl_push_idle (&ctrl->dp_ctrl); +dp_catalog_ctrl_reset (ctrl->catalog); +} +static int dp_ctrl_link_maintenance (struct dp_ctrl_private *ctrl) {int ret =0 ;struct dp_cr_status cr;int training_step =DP_TRAINING_NONE ; -dp_ctrl_push_idle (&ctrl->dp_ctrl); -dp_catalog_ctrl_reset (ctrl->catalog); - ctrl->dp_ctrl.pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; ret =dp_ctrl_setup_main_link (ctrl, &cr, &training_step);
@@ -1626,6 +1630,7 @@ void dp_ctrl_handle_sink_request(struct dp_ctrl *dp_ctrl)if (sink_request &DP_TEST_LINK_TRAINING ) {dp_link_send_test_response (ctrl->link); +dp_ctrl_link_idle_reset (ctrl);if (dp_ctrl_link_maintenance (ctrl)) {DRM_ERROR ("LM failed: TEST_LINK_TRAINING\n" );return ;
@@ -1679,7 +1684,7 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)break ; } - training_step =DP_TRAINING_NONE ; + training_step =DP_TRAINING_1 ; rc =dp_ctrl_setup_main_link (ctrl, &cr, &training_step);if (rc ==0 ) {/* training completed successfully */
drivers/gpu/drm/msm/dp/dp_display.c +7 -0
@@ -693,6 +693,13 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)return 0 ; } +if (state ==ST_CONNECT_PENDING ) { +/* wait until ST_CONNECTED */ +dp_add_event (dp,EV_IRQ_HPD_INT ,0 ,1 );/* delay = 1 */ +mutex_unlock (&dp->event_mutex); +return 0 ; + } + ret =dp_display_usbpd_attention_cb (&dp->pdev->dev);if (ret == -ECONNRESET ) {/* cable unplugged */ dp->core_initialized = false;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoting Kuogee Hsieh (2021-01-13 10:59:58)
Quoted 8 lines
Both
AUX_SW_RESETandDP_SW_RESETclear pending HPD interrupts. Thereforeirq_hpdhandler should not issues either aux or sw reset to avoid following unplug interrupt be cleared accidentally.Kuogee Hsieh (2):
drm/msm/dp: return fail when both link lane and rate are 0 at dpcd
read
drm/msm/dp: unplug interrupt missed afterirq_hpdhandler
It won't apply to the drm msm tree. Please rebase and resend.
Quoted 11 lines · Stephen Boyd
Quoting Kuogee Hsieh (2021-01-13 10:59:58)
Quoted 8 lines
Both
AUX_SW_RESETandDP_SW_RESETclear pending HPD interrupts. Thereforeirq_hpdhandler should not issues either aux or sw reset to avoid following unplug interrupt be cleared accidentally.Kuogee Hsieh (2):
drm/msm/dp: return fail when both link lane and rate are 0 at dpcd
read
drm/msm/dp: unplug interrupt missed afterirq_hpdhandlerIt won't apply to the drm msm tree. Please rebase and resend.
Both V1 two patches are picked by Rob already.
I will drop V2 patches.
Quoting [email protected] (2021-01-13 15:52:37)
Quoted 6 lines · Stephen Boyd
Quoted 5 lines
Quoting Kuogee Hsieh (2021-01-13 10:59:58)
Quoted 4 lines
Both
AUX_SW_RESETandDP_SW_RESETclear pending HPD interrupts. Thereforeirq_hpdhandler should not issues either aux or sw reset to avoid following unplug interrupt be cleared accidentally.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Kuogee Hsieh (2):
drm/msm/dp: return fail when both link lane and rate are 0 at dpcd
read
drm/msm/dp: unplug interrupt missed afterirq_hpdhandlerIt won't apply to the drm msm tree. Please rebase and resend.
Both V1 two patches are picked by Rob already.
I will drop V2 patches.
I only see the first patch, not the second one. Rob?