Commit 62671d2e authored by Kuogee Hsieh's avatar Kuogee Hsieh Committed by Rob Clark

drm/msm/dp: fixes wrong connection state caused by failure of link train

Connection state is not set correctly happen when either failure of link
train due to cable unplugged in the middle of aux channel reading or
cable plugged in while in suspended state. This patch fixes these problems.
This patch also replace ST_SUSPEND_PENDING with ST_DISPLAY_OFF.

Changes in V2:
-- Add more information to commit message.

Changes in V3:
-- change base

Changes in V4:
-- add Fixes tag
Signed-off-by: default avatarKuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 19e52bcb
...@@ -45,7 +45,7 @@ enum { ...@@ -45,7 +45,7 @@ enum {
ST_CONNECT_PENDING, ST_CONNECT_PENDING,
ST_CONNECTED, ST_CONNECTED,
ST_DISCONNECT_PENDING, ST_DISCONNECT_PENDING,
ST_SUSPEND_PENDING, ST_DISPLAY_OFF,
ST_SUSPENDED, ST_SUSPENDED,
}; };
...@@ -504,7 +504,7 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) ...@@ -504,7 +504,7 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data)
mutex_lock(&dp->event_mutex); mutex_lock(&dp->event_mutex);
state = dp->hpd_state; state = dp->hpd_state;
if (state == ST_SUSPEND_PENDING) { if (state == ST_DISPLAY_OFF || state == ST_SUSPENDED) {
mutex_unlock(&dp->event_mutex); mutex_unlock(&dp->event_mutex);
return 0; return 0;
} }
...@@ -526,13 +526,13 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) ...@@ -526,13 +526,13 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data)
hpd->hpd_high = 1; hpd->hpd_high = 1;
ret = dp_display_usbpd_configure_cb(&dp->pdev->dev); ret = dp_display_usbpd_configure_cb(&dp->pdev->dev);
if (ret) { /* failed */ if (ret) { /* link train failed */
hpd->hpd_high = 0; hpd->hpd_high = 0;
dp->hpd_state = ST_DISCONNECTED; dp->hpd_state = ST_DISCONNECTED;
} } else {
/* start sentinel checking in case of missing uevent */
/* start sanity checking */
dp_add_event(dp, EV_CONNECT_PENDING_TIMEOUT, 0, tout); dp_add_event(dp, EV_CONNECT_PENDING_TIMEOUT, 0, tout);
}
mutex_unlock(&dp->event_mutex); mutex_unlock(&dp->event_mutex);
...@@ -578,11 +578,6 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) ...@@ -578,11 +578,6 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
mutex_lock(&dp->event_mutex); mutex_lock(&dp->event_mutex);
state = dp->hpd_state; state = dp->hpd_state;
if (state == ST_SUSPEND_PENDING) {
mutex_unlock(&dp->event_mutex);
return 0;
}
if (state == ST_DISCONNECT_PENDING || state == ST_DISCONNECTED) { if (state == ST_DISCONNECT_PENDING || state == ST_DISCONNECTED) {
mutex_unlock(&dp->event_mutex); mutex_unlock(&dp->event_mutex);
return 0; return 0;
...@@ -609,7 +604,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) ...@@ -609,7 +604,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
*/ */
dp_display_usbpd_disconnect_cb(&dp->pdev->dev); dp_display_usbpd_disconnect_cb(&dp->pdev->dev);
/* start sanity checking */ /* start sentinel checking in case of missing uevent */
dp_add_event(dp, EV_DISCONNECT_PENDING_TIMEOUT, 0, DP_TIMEOUT_5_SECOND); dp_add_event(dp, EV_DISCONNECT_PENDING_TIMEOUT, 0, DP_TIMEOUT_5_SECOND);
/* signal the disconnect event early to ensure proper teardown */ /* signal the disconnect event early to ensure proper teardown */
...@@ -649,7 +644,7 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data) ...@@ -649,7 +644,7 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)
/* irq_hpd can happen at either connected or disconnected state */ /* irq_hpd can happen at either connected or disconnected state */
state = dp->hpd_state; state = dp->hpd_state;
if (state == ST_SUSPEND_PENDING) { if (state == ST_DISPLAY_OFF) {
mutex_unlock(&dp->event_mutex); mutex_unlock(&dp->event_mutex);
return 0; return 0;
} }
...@@ -1074,7 +1069,7 @@ static irqreturn_t dp_display_irq_handler(int irq, void *dev_id) ...@@ -1074,7 +1069,7 @@ static irqreturn_t dp_display_irq_handler(int irq, void *dev_id)
} }
if (hpd_isr_status & DP_DP_IRQ_HPD_INT_MASK) { if (hpd_isr_status & DP_DP_IRQ_HPD_INT_MASK) {
/* delete connect pending event first */ /* stop sentinel connect pending checking */
dp_del_event(dp, EV_CONNECT_PENDING_TIMEOUT); dp_del_event(dp, EV_CONNECT_PENDING_TIMEOUT);
dp_add_event(dp, EV_IRQ_HPD_INT, 0, 0); dp_add_event(dp, EV_IRQ_HPD_INT, 0, 0);
} }
...@@ -1205,13 +1200,10 @@ static int dp_pm_resume(struct device *dev) ...@@ -1205,13 +1200,10 @@ static int dp_pm_resume(struct device *dev)
status = dp_catalog_hpd_get_state_status(dp->catalog); status = dp_catalog_hpd_get_state_status(dp->catalog);
if (status) { if (status)
dp->dp_display.is_connected = true; dp->dp_display.is_connected = true;
} else { else
dp->dp_display.is_connected = false; dp->dp_display.is_connected = false;
/* make sure next resume host_init be called */
dp->core_initialized = false;
}
mutex_unlock(&dp->event_mutex); mutex_unlock(&dp->event_mutex);
...@@ -1233,6 +1225,9 @@ static int dp_pm_suspend(struct device *dev) ...@@ -1233,6 +1225,9 @@ static int dp_pm_suspend(struct device *dev)
dp->hpd_state = ST_SUSPENDED; dp->hpd_state = ST_SUSPENDED;
/* host_init will be called at pm_resume */
dp->core_initialized = false;
mutex_unlock(&dp->event_mutex); mutex_unlock(&dp->event_mutex);
return 0; return 0;
...@@ -1362,6 +1357,7 @@ int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder) ...@@ -1362,6 +1357,7 @@ int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder)
mutex_lock(&dp_display->event_mutex); mutex_lock(&dp_display->event_mutex);
/* stop sentinel checking */
dp_del_event(dp_display, EV_CONNECT_PENDING_TIMEOUT); dp_del_event(dp_display, EV_CONNECT_PENDING_TIMEOUT);
rc = dp_display_set_mode(dp, &dp_display->dp_mode); rc = dp_display_set_mode(dp, &dp_display->dp_mode);
...@@ -1380,7 +1376,7 @@ int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder) ...@@ -1380,7 +1376,7 @@ int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder)
state = dp_display->hpd_state; state = dp_display->hpd_state;
if (state == ST_SUSPEND_PENDING) if (state == ST_DISPLAY_OFF)
dp_display_host_init(dp_display); dp_display_host_init(dp_display);
dp_display_enable(dp_display, 0); dp_display_enable(dp_display, 0);
...@@ -1392,7 +1388,8 @@ int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder) ...@@ -1392,7 +1388,8 @@ int msm_dp_display_enable(struct msm_dp *dp, struct drm_encoder *encoder)
dp_display_unprepare(dp); dp_display_unprepare(dp);
} }
if (state == ST_SUSPEND_PENDING) /* manual kick off plug event to train link */
if (state == ST_DISPLAY_OFF)
dp_add_event(dp_display, EV_IRQ_HPD_INT, 0, 0); dp_add_event(dp_display, EV_IRQ_HPD_INT, 0, 0);
/* completed connection */ /* completed connection */
...@@ -1424,6 +1421,7 @@ int msm_dp_display_disable(struct msm_dp *dp, struct drm_encoder *encoder) ...@@ -1424,6 +1421,7 @@ int msm_dp_display_disable(struct msm_dp *dp, struct drm_encoder *encoder)
mutex_lock(&dp_display->event_mutex); mutex_lock(&dp_display->event_mutex);
/* stop sentinel checking */
dp_del_event(dp_display, EV_DISCONNECT_PENDING_TIMEOUT); dp_del_event(dp_display, EV_DISCONNECT_PENDING_TIMEOUT);
dp_display_disable(dp_display, 0); dp_display_disable(dp_display, 0);
...@@ -1437,7 +1435,7 @@ int msm_dp_display_disable(struct msm_dp *dp, struct drm_encoder *encoder) ...@@ -1437,7 +1435,7 @@ int msm_dp_display_disable(struct msm_dp *dp, struct drm_encoder *encoder)
/* completed disconnection */ /* completed disconnection */
dp_display->hpd_state = ST_DISCONNECTED; dp_display->hpd_state = ST_DISCONNECTED;
} else { } else {
dp_display->hpd_state = ST_SUSPEND_PENDING; dp_display->hpd_state = ST_DISPLAY_OFF;
} }
mutex_unlock(&dp_display->event_mutex); mutex_unlock(&dp_display->event_mutex);
......
...@@ -196,6 +196,11 @@ int dp_panel_read_sink_caps(struct dp_panel *dp_panel, ...@@ -196,6 +196,11 @@ int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
&panel->aux->ddc); &panel->aux->ddc);
if (!dp_panel->edid) { if (!dp_panel->edid) {
DRM_ERROR("panel edid read failed\n"); DRM_ERROR("panel edid read failed\n");
/* check edid read fail is due to unplug */
if (!dp_catalog_hpd_get_state_status(panel->catalog)) {
rc = -ETIMEDOUT;
goto end;
}
/* fail safe edid */ /* fail safe edid */
mutex_lock(&connector->dev->mode_config.mutex); mutex_lock(&connector->dev->mode_config.mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment