Skip to contentSkip to conversation

drm/msm/dp: Drop the HPD state machine

PATCH Superseded Jessica Zhang 2 participants 30 messages Jul 12, 2025 – Aug 2, 2025

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

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).

This has been validated on x1e80100-crd and sa8775p-ride. Any help testing on other platforms/use-cases would be appreciated!

[1] https://patchwork.freedesktop.org/patch/656312/?series=142010&rev=2#comment_1201738

---
Abhinav Kumar (4):
drm/msm/dp: remove redundant checks related to ST_DISPLAY_OFF in plug/irq_ipd handlers drm/msm/dp: replace ST_DISPLAY_OFF with power_on in msm_dp_hpd_unplug_handle() drm/msm/dp: Replace ST_DISPLAY_OFF with power_on in atomic_enable() drm/msm/dp: remove ST_DISPLAY_OFF as a hpd_state

Jessica Zhang (15):
drm/msm/dp: Track when DP is physically plugged in
drm/msm/dp: Return early from atomic_enable() if cable is not connected drm/msm/dp: Replace ST_MAINLINK_READY with link_ready in plug/hpd_irq handlers drm/msm/dp: Replace ST_DISCONNECTED with checks for connected drm/msm/dp: Rework unplug handling
drm/msm/dp: Don't delay plug-in handling when ST_DISCONNECT_PENDING drm/msm/dp: Check if DP is disconnected in atomic post_disable() drm/msm/dp: Drop ST_MAINLINK_READY hpd_state
drm/msm/dp: Drop ST_DISCONNECTED
drm/msm/dp: Drop ST_CONNECTED
drm/msm/dp: Drop ST_DISCONNECT_PENDING
drm/msm/dp: Drop hpd_state from msm_dp
drm/msm/dp: Use drm_bridge_hpd_notify()
drm/msm/dp: Move link training to atomic_enable()
drm/msm/dp: Log connected and link_ready for event handling

 drivers/gpu/drm/msm/dp/dp_ctrl.c    |  22 -----
 drivers/gpu/drm/msm/dp/dp_ctrl.h    |   1 -
 drivers/gpu/drm/msm/dp/dp_display.c | 190 ++++++++++++------------------------
 drivers/gpu/drm/msm/dp/dp_display.h |   2 +
 drivers/gpu/drm/msm/dp/dp_drm.c     |   8 +-
 5 files changed, 69 insertions(+), 154 deletions(-)

---
base-commit: 7a88d609b069b7d2f4d10113b18fea02921bedb1
change-id: 20250523-hpd-refactor-74e25b55620a

Best regards,

Signature · 1 line
Jessica Zhang <[email protected]>
#1 lore raw

PATCH 1/19 drm/msm/dp: Track when DP is physically plugged in

Add a boolean to track whether the DP cable is physically plugged in.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 11 ++++++++++-
 drivers/gpu/drm/msm/dp/dp_display.h |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +10 -1
index d87d47cc7ec3..6945df782f7b 100644
@@ -531,6 +531,7 @@ static int msm_dp_display_handle_port_status_changed(struct msm_dp_display_priva
 			rc = msm_dp_display_process_hpd_high(dp);
 			if (rc)
 				dp->hpd_state = ST_DISCONNECTED;
+			dp->msm_dp_display.connected = true;
 		}
 	}
 
@@ -604,6 +605,8 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 		return 0;
 	}
 
+	dp->msm_dp_display.connected = true;
+
 	if (state == ST_DISCONNECT_PENDING) {
 		/* wait until ST_DISCONNECTED */
 		msm_dp_add_event(dp, EV_HPD_PLUG_INT, 0, 1); /* delay = 1 */
@@ -621,6 +624,7 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 	ret = msm_dp_display_usbpd_configure_cb(&pdev->dev);
 	if (ret) {	/* link train failed */
 		dp->hpd_state = ST_DISCONNECTED;
+		dp->msm_dp_display.connected = false;
 		pm_runtime_put_sync(&pdev->dev);
 	} else {
 		dp->hpd_state = ST_MAINLINK_READY;
@@ -662,6 +666,8 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
 			dp->msm_dp_display.connector_type, state);
 
+	dp->msm_dp_display.connected = false;
+
 	/* unplugged, no more irq_hpd handle */
 	msm_dp_del_event(dp, EV_IRQ_HPD_INT);
 
@@ -680,6 +686,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 		msm_dp_ctrl_off_link(dp->ctrl);
 		msm_dp_display_host_phy_exit(dp);
 		dp->hpd_state = ST_DISCONNECTED;
+		dp->msm_dp_display.connected = false;
 		msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev);
 		pm_runtime_put_sync(&pdev->dev);
 		mutex_unlock(&dp->event_mutex);
@@ -1596,8 +1603,10 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 		return;
 	}
 
-	if (dp->is_edp)
+	if (dp->is_edp) {
 		msm_dp_hpd_plug_handle(msm_dp_display, 0);
+		dp->connected = true;
+	}
 
 	mutex_lock(&msm_dp_display->event_mutex);
 	if (pm_runtime_resume_and_get(&dp->pdev->dev)) {
drivers/gpu/drm/msm/dp/dp_display.h +1 -0
index cc6e2cab36e9..68bd8be19463 100644
@@ -16,6 +16,7 @@ struct msm_dp {
 	struct platform_device *pdev;
 	struct drm_connector *connector;
 	struct drm_bridge *next_bridge;
+	bool connected;
 	bool link_ready;
 	bool audio_enabled;
 	bool power_on;
Signature · 1 line
2.50.1
#2 lore raw

Re: [PATCH 01/19] drm/msm/dp: Track when DP is physically plugged in

Quoted 1 line · Jessica Zhang

Add a boolean to track whether the DP cable is physically plugged in.

I think there is more than that. Other drivers check that there is actually something connected (so checking the sink count, etc.). See Mediatek or IT6505 drivers, they have simple examples.

Quoted 53 lines
---
 drivers/gpu/drm/msm/dp/dp_display.c | 11 ++++++++++-
 drivers/gpu/drm/msm/dp/dp_display.h |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +7 -0
index d87d47cc7ec3..6945df782f7b 100644
@@ -531,6 +531,7 @@ static int msm_dp_display_handle_port_status_changed(struct msm_dp_display_priva
 			rc = msm_dp_display_process_hpd_high(dp);
 			if (rc)
 				dp->hpd_state = ST_DISCONNECTED;
+			dp->msm_dp_display.connected = true;
 		}
 	}
 
@@ -604,6 +605,8 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 		return 0;
 	}
 
+	dp->msm_dp_display.connected = true;
+
 	if (state == ST_DISCONNECT_PENDING) {
 		/* wait until ST_DISCONNECTED */
 		msm_dp_add_event(dp, EV_HPD_PLUG_INT, 0, 1); /* delay = 1 */
@@ -621,6 +624,7 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 	ret = msm_dp_display_usbpd_configure_cb(&pdev->dev);
 	if (ret) {	/* link train failed */
 		dp->hpd_state = ST_DISCONNECTED;
+		dp->msm_dp_display.connected = false;
 		pm_runtime_put_sync(&pdev->dev);
 	} else {
 		dp->hpd_state = ST_MAINLINK_READY;
@@ -662,6 +666,8 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
 			dp->msm_dp_display.connector_type, state);
 
+	dp->msm_dp_display.connected = false;
+
 	/* unplugged, no more irq_hpd handle */
 	msm_dp_del_event(dp, EV_IRQ_HPD_INT);
 
@@ -680,6 +686,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 		msm_dp_ctrl_off_link(dp->ctrl);
 		msm_dp_display_host_phy_exit(dp);
 		dp->hpd_state = ST_DISCONNECTED;
+		dp->msm_dp_display.connected = false;
 		msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev);
 		pm_runtime_put_sync(&pdev->dev);
 		mutex_unlock(&dp->event_mutex);

drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge, · line 1609

Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_display.c +3 -1
@@ -1596,8 +1603,10 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 		return;
 	}
 
-	if (dp->is_edp)
+	if (dp->is_edp) {
 		msm_dp_hpd_plug_handle(msm_dp_display, 0);
+		dp->connected = true;
+	}

So, are we returning 'disconnected' for eDP panels up to the atomic_enable() point? Then nobody will ever enable it.

Quoted 19 lines
drivers/gpu/drm/msm/dp/dp_display.c +0 -0
 	mutex_lock(&msm_dp_display->event_mutex);
 	if (pm_runtime_resume_and_get(&dp->pdev->dev)) {
drivers/gpu/drm/msm/dp/dp_display.h +1 -0
index cc6e2cab36e9..68bd8be19463 100644
@@ -16,6 +16,7 @@ struct msm_dp {
 	struct platform_device *pdev;
 	struct drm_connector *connector;
 	struct drm_bridge *next_bridge;
+	bool connected;
 	bool link_ready;
 	bool audio_enabled;
 	bool power_on;
Signature · 2 lines
-- 
2.50.1
Signature · 2 lines
With best wishes
Dmitry
#3 lore raw

PATCH 2/19 drm/msm/dp: remove redundant checks related to ST_DISPLAY_OFF in plug/irq_ipd handlers

In reply to Jessica Zhang

From: Abhinav Kumar <[email protected]>

In commit 8ede2ecc3e5ee ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets"), checks were introduced to avoid handling any plug or irq hpd events in ST_DISPLAY_OFF state.

Even if we do get hpd events, after the bridge was disabled, it should get handled. Moreover, its unclear under what circumstances these events will fire because ST_DISPLAY_OFF means that the link was still connected but only the bridge was disabled. If the link was untouched, then interrupts shouldn't fire.

Even in the case of the DP compliance equipment, it should be raising these interrupts during the start of the test which is usually accompanied with either a HPD pulse or a IRQ HPD but after the bridge is disabled it should be fine to handle these anyway. In the absence of a better reason to keep these checks, drop these and if any other issues do arise, it should be handled in a different way.

---
Note: Taken from https://patchwork.freedesktop.org/series/142010/

---
 drivers/gpu/drm/msm/dp/dp_display.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -10
index 6945df782f7b..1072b5fc00ae 100644
@@ -595,11 +595,6 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
 			dp->msm_dp_display.connector_type, state);
 
-	if (state == ST_DISPLAY_OFF) {
-		mutex_unlock(&dp->event_mutex);
-		return 0;
-	}
-
 	if (state == ST_MAINLINK_READY || state == ST_CONNECTED) {
 		mutex_unlock(&dp->event_mutex);
 		return 0;
@@ -728,11 +723,6 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, u32 data)
 	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
 			dp->msm_dp_display.connector_type, state);
 
-	if (state == ST_DISPLAY_OFF) {
-		mutex_unlock(&dp->event_mutex);
-		return 0;
-	}
-
 	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 */
Signature · 1 line
2.50.1
#4 lore raw

PATCH 3/19 drm/msm/dp: Return early from atomic_enable() if cable is not connected

In reply to Jessica Zhang

Replace the ST_MAINLINK_READY check here with a check for if the cable is not connected.

Since atomic_check() fails if the link isn't ready, we technically don't need a check against ST_MAINLINK_READY. The hpd_state should also never really hit ST_DISPLAY_OFF since atomic_enable() shouldn't be called twice in a row without an atomic_enable() in between.

That being said, it is possible for the cable to be disconnected after atomic_check() but before atomic_enable(). So let's change this check to guard against msm_dp::connected instead.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -1
index 1072b5fc00ae..fe38ea868eda 100644
@@ -1606,7 +1606,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 	}
 
 	hpd_state = msm_dp_display->hpd_state;
-	if (hpd_state != ST_DISPLAY_OFF && hpd_state != ST_MAINLINK_READY) {
+	if (!dp->connected) {
 		mutex_unlock(&msm_dp_display->event_mutex);
 		return;
 	}
Signature · 1 line
2.50.1
#5 lore raw

Re: [PATCH 03/19] drm/msm/dp: Return early from atomic_enable() if cable is not connected

Quoted 7 lines · Jessica Zhang

Replace the ST_MAINLINK_READY check here with a check for if the cable is not connected.

Since atomic_check() fails if the link isn't ready, we technically don't need a check against ST_MAINLINK_READY. The hpd_state should also never really hit ST_DISPLAY_OFF since atomic_enable() shouldn't be called twice in a row without an atomic_enable() in between.

There is something wrong in the last sentence.

Quoted 27 lines

That being said, it is possible for the cable to be disconnected after atomic_check() but before atomic_enable(). So let's change this check to guard against msm_dp::connected instead.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -1
index 1072b5fc00ae..fe38ea868eda 100644
@@ -1606,7 +1606,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 	}
 
 	hpd_state = msm_dp_display->hpd_state;
-	if (hpd_state != ST_DISPLAY_OFF && hpd_state != ST_MAINLINK_READY) {
+	if (!dp->connected) {
 		mutex_unlock(&msm_dp_display->event_mutex);
 		return;
 	}
Signature · 2 lines
-- 
2.50.1
Signature · 2 lines
With best wishes
Dmitry
#6 lore raw

PATCH 4/19 drm/msm/dp: replace ST_DISPLAY_OFF with power_on in msm_dp_hpd_unplug_handle()

In reply to Jessica Zhang

From: Abhinav Kumar <[email protected]>

msm_dp_hpd_unplug_handle() checks if the display was already disabled and if so does not transition to ST_DISCONNECT_PENDING state and goes directly to ST_DISCONNECTED. The same result can be achieved with the !power_on check.

Replace ST_DISPLAY_OFF with !power_on to achieve the same outcome.

---
Note: Taken from https://patchwork.freedesktop.org/series/142010/

---
 drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -1
index fe38ea868eda..f93fbcff2cda 100644
@@ -694,7 +694,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	 */
 	msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev);
 
-	if (state == ST_DISPLAY_OFF) {
+	if (!dp->msm_dp_display.power_on) {
 		dp->hpd_state = ST_DISCONNECTED;
 	} else {
 		dp->hpd_state = ST_DISCONNECT_PENDING;
Signature · 1 line
2.50.1
#7 lore raw

Re: [PATCH 04/19] drm/msm/dp: replace ST_DISPLAY_OFF with power_on in msm_dp_hpd_unplug_handle()

Quoted 9 lines · Jessica Zhang

From: Abhinav Kumar <[email protected]>

msm_dp_hpd_unplug_handle() checks if the display was already disabled and if so does not transition to ST_DISCONNECT_PENDING state and goes directly to ST_DISCONNECTED. The same result can be achieved with the !power_on check.

Replace ST_DISPLAY_OFF with !power_on to achieve the same outcome.

Quoted 7 lines

---
Note: Taken from https://patchwork.freedesktop.org/series/142010/

---
 drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Please squash all state-related patches into a single one. It would make it easier to review and more logical.

Signature · 2 lines
With best wishes
Dmitry
#8 lore raw

Re: [PATCH 04/19] drm/msm/dp: replace ST_DISPLAY_OFF with power_on in msm_dp_hpd_unplug_handle()

Quoted 18 lines · Dmitry Baryshkov
Quoted 9 lines · Jessica Zhang

From: Abhinav Kumar <[email protected]>

msm_dp_hpd_unplug_handle() checks if the display was already disabled and if so does not transition to ST_DISCONNECT_PENDING state and goes directly to ST_DISCONNECTED. The same result can be achieved with the !power_on check.

Replace ST_DISPLAY_OFF with !power_on to achieve the same outcome.

Quoted 7 lines

---
Note: Taken from https://patchwork.freedesktop.org/series/142010/

---
  drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 2 lines

Please squash all state-related patches into a single one. It would make it easier to review and more logical.

Hi Dmitry,

Ack -- I'd wanted to keep all the patches small, but I can squash patches 4-16 into 1 patch if that makes it easier for you.

Thanks,

Jessica Zhang

Quoted 1 line
#9 lore raw

Re: [PATCH 04/19] drm/msm/dp: replace ST_DISPLAY_OFF with power_on in msm_dp_hpd_unplug_handle()

Quoted 21 lines · Jessica Zhang
Quoted 18 lines · Dmitry Baryshkov
Quoted 16 lines · Jessica Zhang

From: Abhinav Kumar <[email protected]>

msm_dp_hpd_unplug_handle() checks if the display was already disabled and if so does not transition to ST_DISCONNECT_PENDING state and goes directly to ST_DISCONNECTED. The same result can be achieved with the !power_on check.

Replace ST_DISPLAY_OFF with !power_on to achieve the same outcome.

---
Note: Taken from https://patchwork.freedesktop.org/series/142010/

---
  drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines
Quoted 2 lines

Please squash all state-related patches into a single one. It would make it easier to review and more logical.

Hi Dmitry,

Ack -- I'd wanted to keep all the patches small, but I can squash patches 4-16 into 1 patch if that makes it easier for you.

I think it's easier this way: we get rid of the HPD state machine and use flags all over the place.

Signature · 2 lines
With best wishes
Dmitry
#10 lore raw

Re: [PATCH 04/19] drm/msm/dp: replace ST_DISPLAY_OFF with power_on in msm_dp_hpd_unplug_handle()

In reply to Dmitry Baryshkov
Quoted 18 lines · Dmitry Baryshkov
Quoted 9 lines · Jessica Zhang

From: Abhinav Kumar <[email protected]>

msm_dp_hpd_unplug_handle() checks if the display was already disabled and if so does not transition to ST_DISCONNECT_PENDING state and goes directly to ST_DISCONNECTED. The same result can be achieved with the !power_on check.

Replace ST_DISPLAY_OFF with !power_on to achieve the same outcome.

Quoted 7 lines

---
Note: Taken from https://patchwork.freedesktop.org/series/142010/

---
  drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 2 lines

Please squash all state-related patches into a single one. It would make it easier to review and more logical.

Hi Dmitry,

Ack -- I'd separated them to keep the patches small, but I can squash patches 4-16 into 1 patch if that makes it easier for you.

Thanks,

Jessica Zhang

Quoted 1 line
#11 lore raw

PATCH 5/19 drm/msm/dp: Replace ST_MAINLINK_READY with link_ready in plug/hpd_irq handlers

In reply to Jessica Zhang

The ST_MAINLINK_READY state and msm_dp::link_ready both indicate when link training has been successfully completed and the link is ready to be used.

Thus, replace ST_MAINLINK_READY checks with a check for msm_dp::link_ready.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +4 -4
index f93fbcff2cda..af3cc32aa123 100644
@@ -595,7 +595,7 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
 			dp->msm_dp_display.connector_type, state);
 
-	if (state == ST_MAINLINK_READY || state == ST_CONNECTED) {
+	if (dp->msm_dp_display.link_ready) {
 		mutex_unlock(&dp->event_mutex);
 		return 0;
 	}
@@ -677,7 +677,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	} else if (state == ST_DISCONNECT_PENDING) {
 		mutex_unlock(&dp->event_mutex);
 		return 0;
-	} else if (state == ST_MAINLINK_READY) {
+	} else if (state != ST_CONNECTED && dp->msm_dp_display.link_ready) {
 		msm_dp_ctrl_off_link(dp->ctrl);
 		msm_dp_display_host_phy_exit(dp);
 		dp->hpd_state = ST_DISCONNECTED;
@@ -723,8 +723,8 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, u32 data)
 	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
 			dp->msm_dp_display.connector_type, state);
 
-	if (state == ST_MAINLINK_READY || state == ST_DISCONNECT_PENDING) {
-		/* wait until ST_CONNECTED */
+	if (dp->msm_dp_display.link_ready != dp->msm_dp_display.connected) {
+		/* wait until connect/disconnect handling is completed */
 		msm_dp_add_event(dp, EV_IRQ_HPD_INT, 0, 1); /* delay = 1 */
 		mutex_unlock(&dp->event_mutex);
 		return 0;
Signature · 1 line
2.50.1
#12 lore raw

PATCH 6/19 drm/msm/dp: Replace ST_DISCONNECTED with checks for connected

In reply to Jessica Zhang

Replace ST_DISCONNECTED checks with checks for if !msm_dp::connected as they both represent the DP cable being disconnected

---
 drivers/gpu/drm/msm/dp/dp_display.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +4 -4
index af3cc32aa123..0f1c1fd2b1b7 100644
@@ -521,12 +521,12 @@ static int msm_dp_display_handle_port_status_changed(struct msm_dp_display_priva
 
 	if (drm_dp_is_branch(dp->panel->dpcd) && dp->link->sink_count == 0) {
 		drm_dbg_dp(dp->drm_dev, "sink count is zero, nothing to do\n");
-		if (dp->hpd_state != ST_DISCONNECTED) {
+		if (dp->msm_dp_display.connected) {
 			dp->hpd_state = ST_DISCONNECT_PENDING;
 			msm_dp_add_event(dp, EV_USER_NOTIFICATION, false, 0);
 		}
 	} else {
-		if (dp->hpd_state == ST_DISCONNECTED) {
+		if (!dp->msm_dp_display.connected) {
 			dp->hpd_state = ST_MAINLINK_READY;
 			rc = msm_dp_display_process_hpd_high(dp);
 			if (rc)
@@ -543,7 +543,7 @@ 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->hpd_state == ST_DISCONNECTED) {
+	if (!dp->msm_dp_display.connected) {
 		if (sink_request & DP_LINK_STATUS_UPDATED) {
 			drm_dbg_dp(dp->drm_dev, "Disconnected sink_request: %d\n",
 							sink_request);
@@ -666,7 +666,7 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	/* unplugged, no more irq_hpd handle */
 	msm_dp_del_event(dp, EV_IRQ_HPD_INT);
 
-	if (state == ST_DISCONNECTED) {
+	if (!dp->msm_dp_display.connected) {
 		/* triggered by irq_hdp with sink_count = 0 */
 		if (dp->link->sink_count == 0) {
 			msm_dp_display_host_phy_exit(dp);
Signature · 1 line
2.50.1
#13 lore raw

PATCH 7/19 drm/msm/dp: Rework unplug handling

In reply to Jessica Zhang

Simplify the unplug event handling by dropping the link teardown (as it is already handled as part of the atomic post_disable()).

With the link teardown removed, we can also drop hpd_state-specific handling to minimize redundant code

---
 drivers/gpu/drm/msm/dp/dp_ctrl.c    | 22 ----------------------
 drivers/gpu/drm/msm/dp/dp_ctrl.h    |  1 -
 drivers/gpu/drm/msm/dp/dp_display.c | 27 +++++++--------------------
 3 files changed, 7 insertions(+), 43 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +0 -22
index c42fd2c17a32..4cf269b98029 100644
@@ -2567,28 +2567,6 @@ void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl)
 			phy, phy->init_count, phy->power_count);
 }
 
-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);
-
-	DRM_DEBUG_DP("Before, phy=%p init_count=%d power_on=%d\n",
-		phy, phy->init_count, phy->power_count);
-
-	phy_power_off(phy);
-
-	DRM_DEBUG_DP("After, phy=%p init_count=%d power_on=%d\n",
-		phy, phy->init_count, phy->power_count);
-}
-
 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
index 124b9b21bb7f..f68bee62713f 100644
@@ -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 +7 -20
index 0f1c1fd2b1b7..1ce8051b116a 100644
@@ -661,32 +661,19 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
 			dp->msm_dp_display.connector_type, state);
 
+	if (!dp->msm_dp_display.link_ready) {
+		mutex_unlock(&dp->event_mutex);
+		return 0;
+	}
+
 	dp->msm_dp_display.connected = false;
 
 	/* unplugged, no more irq_hpd handle */
 	msm_dp_del_event(dp, EV_IRQ_HPD_INT);
 
-	if (!dp->msm_dp_display.connected) {
-		/* triggered by irq_hdp with sink_count = 0 */
-		if (dp->link->sink_count == 0) {
-			msm_dp_display_host_phy_exit(dp);
-		}
-		msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev);
-		mutex_unlock(&dp->event_mutex);
-		return 0;
-	} else if (state == ST_DISCONNECT_PENDING) {
-		mutex_unlock(&dp->event_mutex);
-		return 0;
-	} else if (state != ST_CONNECTED && dp->msm_dp_display.link_ready) {
-		msm_dp_ctrl_off_link(dp->ctrl);
+	/* triggered by irq_hdp with sink_count = 0 */
+	if (dp->link->sink_count == 0)
 		msm_dp_display_host_phy_exit(dp);
-		dp->hpd_state = ST_DISCONNECTED;
-		dp->msm_dp_display.connected = false;
-		msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev);
-		pm_runtime_put_sync(&pdev->dev);
-		mutex_unlock(&dp->event_mutex);
-		return 0;
-	}
 
 	/*
 	 * We don't need separate work for disconnect as
Signature · 1 line
2.50.1
#14 lore raw

PATCH 8/19 drm/msm/dp: Don't delay plug-in handling when ST_DISCONNECT_PENDING

In reply to Jessica Zhang

Since there is already a return early for when the DP link is ready and because link_ready is only set after the DP is connected and link training has completed, the DP will already be disconnect for plug-in handling to happen.

Thus, there is no need delay the plug-in handling until ST_DISCONNECTED and we can drop this ST_DISCONNECT_PENDING handling.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -7
index 1ce8051b116a..98f5274f123e 100644
@@ -602,13 +602,6 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 
 	dp->msm_dp_display.connected = true;
 
-	if (state == ST_DISCONNECT_PENDING) {
-		/* wait until ST_DISCONNECTED */
-		msm_dp_add_event(dp, EV_HPD_PLUG_INT, 0, 1); /* delay = 1 */
-		mutex_unlock(&dp->event_mutex);
-		return 0;
-	}
-
 	ret = pm_runtime_resume_and_get(&pdev->dev);
 	if (ret) {
 		DRM_ERROR("failed to pm_runtime_resume\n");
Signature · 1 line
2.50.1
#15 lore raw

PATCH 9/19 drm/msm/dp: Replace ST_DISPLAY_OFF with power_on in atomic_enable()

In reply to Jessica Zhang

From: Abhinav Kumar <[email protected]>

ST_DISPLAY_OFF check in msm_dp_bridge_atomic_enable() is used to check that if the display was disabled while still hotplugged, phy needs to be re-initialized.

This can be replaced with a different check as it just means the DP cable is connected but without display being powered on. Replace the ST_DISPLAY_OFF check with a combination of connected and power_on checks.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -5
index 98f5274f123e..6535c1cccf84 100644
@@ -1564,7 +1564,6 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 	struct msm_dp *dp = msm_dp_bridge->msm_dp_display;
 	int rc = 0;
 	struct msm_dp_display_private *msm_dp_display;
-	u32 hpd_state;
 	bool force_link_train = false;
 
 	msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display);
@@ -1585,7 +1584,6 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 		return;
 	}
 
-	hpd_state = msm_dp_display->hpd_state;
 	if (!dp->connected) {
 		mutex_unlock(&msm_dp_display->event_mutex);
 		return;
@@ -1598,9 +1596,7 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 		return;
 	}
 
-	hpd_state =  msm_dp_display->hpd_state;
-
-	if (hpd_state == ST_DISPLAY_OFF) {
+	if (dp->connected && !dp->power_on) {
 		msm_dp_display_host_phy_init(msm_dp_display);
 		force_link_train = true;
 	}
Signature · 1 line
2.50.1
#16 lore raw

PATCH 10/19 drm/msm/dp: Check if DP is disconnected in atomic post_disable()

In reply to Jessica Zhang

Since the hpd_state is unused, change the "wrong hpd_state" debug log in atomic post_disable() to log if the DP cable is disconnected.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +2 -4
index 6535c1cccf84..4c9a515648bc 100644
@@ -1643,10 +1643,8 @@ void msm_dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge,
 
 	mutex_lock(&msm_dp_display->event_mutex);
 
-	hpd_state = msm_dp_display->hpd_state;
-	if (hpd_state != ST_DISCONNECT_PENDING && hpd_state != ST_CONNECTED)
-		drm_dbg_dp(dp->drm_dev, "type=%d wrong hpd_state=%d\n",
-			   dp->connector_type, hpd_state);
+	if (!dp->connected)
+		drm_dbg_dp(dp->drm_dev, "type=%d is disconnected\n", dp->connector_type);
 
 	msm_dp_display_disable(msm_dp_display);
 
Signature · 1 line
2.50.1
#17 lore raw

PATCH 11/19 drm/msm/dp: remove ST_DISPLAY_OFF as a hpd_state

In reply to Jessica Zhang

From: Abhinav Kumar <[email protected]>

Since all consumers of ST_DISPLAY_OFF have now been removed, drop ST_DISPLAY_OFF from the list of hpd_states as technically this was never a 'hpd' state anyway.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -3
index 4c9a515648bc..17093b78900c 100644
@@ -49,7 +49,6 @@ enum {
 	ST_MAINLINK_READY,
 	ST_CONNECTED,
 	ST_DISCONNECT_PENDING,
-	ST_DISPLAY_OFF,
 };
 
 enum {
@@ -1652,8 +1651,6 @@ void msm_dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge,
 	if (hpd_state == ST_DISCONNECT_PENDING) {
 		/* completed disconnection */
 		msm_dp_display->hpd_state = ST_DISCONNECTED;
-	} else {
-		msm_dp_display->hpd_state = ST_DISPLAY_OFF;
 	}
 
 	drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type);
Signature · 1 line
2.50.1
#18 lore raw

PATCH 12/19 drm/msm/dp: Drop ST_MAINLINK_READY hpd_state

In reply to Jessica Zhang

Drop the now-unused ST_MAINLINK_READY hpd_state.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -4
index 17093b78900c..5efc8d4ecf54 100644
@@ -46,7 +46,6 @@ enum {
 /* event thread connection state */
 enum {
 	ST_DISCONNECTED,
-	ST_MAINLINK_READY,
 	ST_CONNECTED,
 	ST_DISCONNECT_PENDING,
 };
@@ -526,7 +525,6 @@ static int msm_dp_display_handle_port_status_changed(struct msm_dp_display_priva
 		}
 	} else {
 		if (!dp->msm_dp_display.connected) {
-			dp->hpd_state = ST_MAINLINK_READY;
 			rc = msm_dp_display_process_hpd_high(dp);
 			if (rc)
 				dp->hpd_state = ST_DISCONNECTED;
@@ -613,8 +611,6 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 		dp->hpd_state = ST_DISCONNECTED;
 		dp->msm_dp_display.connected = false;
 		pm_runtime_put_sync(&pdev->dev);
-	} else {
-		dp->hpd_state = ST_MAINLINK_READY;
 	}
 
 	drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n",
Signature · 1 line
2.50.1
#19 lore raw

PATCH 13/19 drm/msm/dp: Drop ST_DISCONNECTED

In reply to Jessica Zhang

Drop the now unused ST_DISCONNECTED state

---
 drivers/gpu/drm/msm/dp/dp_display.c | 17 -----------------
 1 file changed, 17 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -17
index 5efc8d4ecf54..dac5078a849d 100644
@@ -45,7 +45,6 @@ enum {
 
 /* event thread connection state */
 enum {
-	ST_DISCONNECTED,
 	ST_CONNECTED,
 	ST_DISCONNECT_PENDING,
 };
@@ -526,8 +525,6 @@ static int msm_dp_display_handle_port_status_changed(struct msm_dp_display_priva
 	} else {
 		if (!dp->msm_dp_display.connected) {
 			rc = msm_dp_display_process_hpd_high(dp);
-			if (rc)
-				dp->hpd_state = ST_DISCONNECTED;
 			dp->msm_dp_display.connected = true;
 		}
 	}
@@ -608,7 +605,6 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 
 	ret = msm_dp_display_usbpd_configure_cb(&pdev->dev);
 	if (ret) {	/* link train failed */
-		dp->hpd_state = ST_DISCONNECTED;
 		dp->msm_dp_display.connected = false;
 		pm_runtime_put_sync(&pdev->dev);
 	}
@@ -669,12 +665,6 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	 */
 	msm_dp_display_notify_disconnect(&dp->msm_dp_display.pdev->dev);
 
-	if (!dp->msm_dp_display.power_on) {
-		dp->hpd_state = ST_DISCONNECTED;
-	} else {
-		dp->hpd_state = ST_DISCONNECT_PENDING;
-	}
-
 	/* signal the disconnect event early to ensure proper teardown */
 	msm_dp_display_handle_plugged_change(&dp->msm_dp_display, false);
 
@@ -1628,7 +1618,6 @@ void msm_dp_bridge_atomic_post_disable(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;
-	u32 hpd_state;
 	struct msm_dp_display_private *msm_dp_display;
 
 	msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display);
@@ -1643,12 +1632,6 @@ void msm_dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge,
 
 	msm_dp_display_disable(msm_dp_display);
 
-	hpd_state =  msm_dp_display->hpd_state;
-	if (hpd_state == ST_DISCONNECT_PENDING) {
-		/* completed disconnection */
-		msm_dp_display->hpd_state = ST_DISCONNECTED;
-	}
-
 	drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type);
 
 	pm_runtime_put_sync(&dp->pdev->dev);
Signature · 1 line
2.50.1
#20 lore raw

PATCH 14/19 drm/msm/dp: Drop ST_CONNECTED

In reply to Jessica Zhang

Drop the now-unused ST_CONNECTED state

---
 drivers/gpu/drm/msm/dp/dp_display.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -4
index dac5078a849d..c7ad61e96b37 100644
@@ -45,7 +45,6 @@ enum {
 
 /* event thread connection state */
 enum {
-	ST_CONNECTED,
 	ST_DISCONNECT_PENDING,
 };
 
@@ -1594,9 +1593,6 @@ void msm_dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
 		msm_dp_display_disable(msm_dp_display);
 	}
 
-	/* completed connection */
-	msm_dp_display->hpd_state = ST_CONNECTED;
-
 	drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type);
 	mutex_unlock(&msm_dp_display->event_mutex);
 }
Signature · 1 line
2.50.1
#21 lore raw

PATCH 15/19 drm/msm/dp: Drop ST_DISCONNECT_PENDING

In reply to Jessica Zhang

Drop the now-unused ST_DISCONNECT_PENDING state. This will completely remove the hpd state enum.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -8
index c7ad61e96b37..529e30193168 100644
@@ -43,11 +43,6 @@ enum {
 	ISR_HPD_LO_GLITH_COUNT,
 };
 
-/* event thread connection state */
-enum {
-	ST_DISCONNECT_PENDING,
-};
-
 enum {
 	EV_NO_EVENT,
 	/* hpd events */
@@ -517,10 +512,8 @@ static int msm_dp_display_handle_port_status_changed(struct msm_dp_display_priva
 
 	if (drm_dp_is_branch(dp->panel->dpcd) && dp->link->sink_count == 0) {
 		drm_dbg_dp(dp->drm_dev, "sink count is zero, nothing to do\n");
-		if (dp->msm_dp_display.connected) {
-			dp->hpd_state = ST_DISCONNECT_PENDING;
+		if (dp->msm_dp_display.connected)
 			msm_dp_add_event(dp, EV_USER_NOTIFICATION, false, 0);
-		}
 	} else {
 		if (!dp->msm_dp_display.connected) {
 			rc = msm_dp_display_process_hpd_high(dp);
Signature · 1 line
2.50.1
#22 lore raw

PATCH 16/19 drm/msm/dp: Drop hpd_state from msm_dp

In reply to Jessica Zhang

Drop the now unused hpd_state field from msm_dp and adjust debug logs accordingly

---
 drivers/gpu/drm/msm/dp/dp_display.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +13 -23
index 529e30193168..3aaa603da4f9 100644
@@ -91,7 +91,6 @@ struct msm_dp_display_private {
 	/* event related only access by event thread */
 	struct mutex event_mutex;
 	wait_queue_head_t event_q;
-	u32 hpd_state;
 	u32 event_pndx;
 	u32 event_gndx;
 	struct task_struct *ev_tsk;
@@ -556,8 +555,7 @@ static int msm_dp_display_usbpd_attention_cb(struct device *dev)
 	rc = msm_dp_link_process_request(dp->link);
 	if (!rc) {
 		sink_request = dp->link->sink_request;
-		drm_dbg_dp(dp->drm_dev, "hpd_state=%d sink_request=%d\n",
-					dp->hpd_state, 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_handle_port_status_changed(dp);
 		else
@@ -569,7 +567,6 @@ static int msm_dp_display_usbpd_attention_cb(struct device *dev)
 
 static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 {
-	u32 state;
 	int ret;
 	struct platform_device *pdev = dp->msm_dp_display.pdev;
 
@@ -577,9 +574,8 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 
 	mutex_lock(&dp->event_mutex);
 
-	state =  dp->hpd_state;
-	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
-			dp->msm_dp_display.connector_type, state);
+	drm_dbg_dp(dp->drm_dev, "Before, type=%d\n",
+			dp->msm_dp_display.connector_type);
 
 	if (dp->msm_dp_display.link_ready) {
 		mutex_unlock(&dp->event_mutex);
@@ -601,8 +597,8 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 		pm_runtime_put_sync(&pdev->dev);
 	}
 
-	drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n",
-			dp->msm_dp_display.connector_type, state);
+	drm_dbg_dp(dp->drm_dev, "After, type=%d\n",
+			dp->msm_dp_display.connector_type);
 	mutex_unlock(&dp->event_mutex);
 
 	/* uevent will complete connection part */
@@ -625,17 +621,14 @@ static void msm_dp_display_handle_plugged_change(struct msm_dp *msm_dp_display,
 
 static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 {
-	u32 state;
 	struct platform_device *pdev = dp->msm_dp_display.pdev;
 
 	msm_dp_aux_enable_xfers(dp->aux, false);
 
 	mutex_lock(&dp->event_mutex);
 
-	state = dp->hpd_state;
-
-	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
-			dp->msm_dp_display.connector_type, state);
+	drm_dbg_dp(dp->drm_dev, "Before, type=%d\n",
+			dp->msm_dp_display.connector_type);
 
 	if (!dp->msm_dp_display.link_ready) {
 		mutex_unlock(&dp->event_mutex);
@@ -660,8 +653,8 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	/* 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 hpd_state=%d\n",
-			dp->msm_dp_display.connector_type, state);
+	drm_dbg_dp(dp->drm_dev, "After, type=%d\n",
+			dp->msm_dp_display.connector_type);
 
 	/* uevent will complete disconnection part */
 	pm_runtime_put_sync(&pdev->dev);
@@ -671,14 +664,11 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 
 static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, u32 data)
 {
-	u32 state;
-
 	mutex_lock(&dp->event_mutex);
 
 	/* irq_hpd can happen at either connected or disconnected state */
-	state =  dp->hpd_state;
-	drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
-			dp->msm_dp_display.connector_type, state);
+	drm_dbg_dp(dp->drm_dev, "Before, type=%d\n",
+			dp->msm_dp_display.connector_type);
 
 	if (dp->msm_dp_display.link_ready != dp->msm_dp_display.connected) {
 		/* wait until connect/disconnect handling is completed */
@@ -689,8 +679,8 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, u32 data)
 
 	msm_dp_display_usbpd_attention_cb(&dp->msm_dp_display.pdev->dev);
 
-	drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n",
-			dp->msm_dp_display.connector_type, state);
+	drm_dbg_dp(dp->drm_dev, "After, type=%d\n",
+			dp->msm_dp_display.connector_type);
 
 	mutex_unlock(&dp->event_mutex);
 
Signature · 1 line
2.50.1
#23 lore raw

PATCH 17/19 drm/msm/dp: Use drm_bridge_hpd_notify()

In reply to Jessica Zhang

Call drm_bridge_hpd_notify() instead of drm_helper_hpd_irq_event(). This way, we can directly call hpd_notify() via the bridge connector.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 17 +++++------------
 drivers/gpu/drm/msm/dp/dp_display.h |  1 +
 drivers/gpu/drm/msm/dp/dp_drm.c     |  2 ++
 3 files changed, 8 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +5 -12
index 3aaa603da4f9..87f2750a99ca 100644
@@ -324,17 +324,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)
 {
@@ -358,7 +347,11 @@ static int msm_dp_display_send_hpd_notification(struct msm_dp_display_private *d
 
 	drm_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);
+
+	if (hpd)
+		drm_bridge_hpd_notify(dp->msm_dp_display.bridge, connector_status_connected);
+	else
+		drm_bridge_hpd_notify(dp->msm_dp_display.bridge, connector_status_disconnected);
 
 	return 0;
 }
drivers/gpu/drm/msm/dp/dp_display.h +1 -0
index 68bd8be19463..6e12694d5a64 100644
@@ -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 connected;
 	bool link_ready;
 	bool audio_enabled;
drivers/gpu/drm/msm/dp/dp_drm.c +2 -0
index f222d7ccaa88..b12a43499c54 100644
@@ -358,6 +358,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.50.1
#24 lore raw

Re: [PATCH 17/19] drm/msm/dp: Use drm_bridge_hpd_notify()

Quoted 9 lines · Jessica Zhang

Call drm_bridge_hpd_notify() instead of drm_helper_hpd_irq_event(). This way, we can directly call hpd_notify() via the bridge connector.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 17 +++++------------
 drivers/gpu/drm/msm/dp/dp_display.h |  1 +
 drivers/gpu/drm/msm/dp/dp_drm.c     |  2 ++
 3 files changed, 8 insertions(+), 12 deletions(-)

This patch has some issues. Beforehand we were just stating that there was a HPD event, now we are explicitly stating the status. This might confuse DRM's status handling if the status here and status at the .detect() differ.

In my opinion, this should become patch #4 in the series (connected, link_training, EV_HPD_PLUG_INT / EV_HPD_UNPLUG_INT, then this one).

And the correct way would be to call drm_bridge_hpd_notify(bridge, msm_dp_display_detect()) from the IRQ thread. This way we should also be able to drop EV_USER_NOTIFICATION from all over the place.

Quoted 24 lines
drivers/gpu/drm/msm/dp/dp_display.c +0 -11
index 3aaa603da4f9..87f2750a99ca 100644
@@ -324,17 +324,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)
 {

drivers/gpu/drm/msm/dp/dp_display.c static int msm_dp_display_send_hpd_notification(struct msm_dp_display_private *d · line 354

Quoted 9 lines
drivers/gpu/drm/msm/dp/dp_display.c +5 -1
@@ -358,7 +347,11 @@ static int msm_dp_display_send_hpd_notification(struct msm_dp_display_private *d
 
 	drm_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);
+
+	if (hpd)
+		drm_bridge_hpd_notify(dp->msm_dp_display.bridge, connector_status_connected);
+	else
+		drm_bridge_hpd_notify(dp->msm_dp_display.bridge, connector_status_disconnected);

drm_bridge_hpd_notify(dp->msm_dp_display.bridge,

		      hpd ?
		      connector_status_connected : 
		      connector_status_disconnected);
Quoted 32 lines
drivers/gpu/drm/msm/dp/dp_display.c +0 -0
 	return 0;
 }
drivers/gpu/drm/msm/dp/dp_display.h +1 -0
index 68bd8be19463..6e12694d5a64 100644
@@ -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 connected;
 	bool link_ready;
 	bool audio_enabled;
drivers/gpu/drm/msm/dp/dp_drm.c +2 -0
index f222d7ccaa88..b12a43499c54 100644
@@ -358,6 +358,8 @@ int msm_dp_bridge_init(struct msm_dp *msm_dp_display, struct drm_device *dev,
 		}
 	}
 
+	msm_dp_display->bridge = bridge;
+
 	return 0;
 }
 
Signature · 2 lines
-- 
2.50.1
Signature · 2 lines
With best wishes
Dmitry
#25 lore raw

PATCH 18/19 drm/msm/dp: Move link training to atomic_enable()

In reply to Jessica Zhang

Currently, the DP link training is being done during HPD. Move link training to atomic_enable() in accordance with the atomic_enable() documentation.

In addition, don't disable the link until atomic_post_disable() (as part of the dp_ctrl_off[_link_stream]() helpers).

Since the link training is moved to a later part of the enable sequence, change the bridge detect() to return true when the display is physically connected instead of when the link is ready.

Finally, call the plug/unplug handlers directly in hpd_notify() instead of queueing them in the event thread so that they aren't preempted by other events.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 15 ++++++++-------
 drivers/gpu/drm/msm/dp/dp_drm.c     |  6 +++---
 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +8 -7
index 87f2750a99ca..32e1ee40c2c3 100644
@@ -410,11 +410,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);
 
@@ -1561,6 +1556,12 @@ 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);
+		dp->connector->state->link_status = DRM_LINK_STATUS_BAD;
+	}
+
 	msm_dp_display_enable(msm_dp_display, force_link_train);
 
 	rc = msm_dp_display_post_enable(dp);
@@ -1706,7 +1707,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_hpd_plug_handle(dp, 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_hpd_unplug_handle(dp, 0);
 }
drivers/gpu/drm/msm/dp/dp_drm.c +3 -3
index b12a43499c54..3bcdf00b2d95 100644
@@ -26,10 +26,10 @@ static enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge)
 
 	dp = to_dp_bridge(bridge)->msm_dp_display;
 
-	drm_dbg_dp(dp->drm_dev, "link_ready = %s\n",
-		str_true_false(dp->link_ready));
+	drm_dbg_dp(dp->drm_dev, "connected = %s\n",
+		str_true_false(dp->connected));
 
-	return (dp->link_ready) ? connector_status_connected :
+	return (dp->connected) ? connector_status_connected :
 					connector_status_disconnected;
 }
 
Signature · 1 line
2.50.1
#26 lore raw

Re: [PATCH 18/19] drm/msm/dp: Move link training to atomic_enable()

Quoted 10 lines · Jessica Zhang

Currently, the DP link training is being done during HPD. Move link training to atomic_enable() in accordance with the atomic_enable() documentation.

In addition, don't disable the link until atomic_post_disable() (as part of the dp_ctrl_off[_link_stream]() helpers).

Since the link training is moved to a later part of the enable sequence, change the bridge detect() to return true when the display is physically connected instead of when the link is ready.

These two parts should be patch #2 in the series.

Quoted 41 lines

Finally, call the plug/unplug handlers directly in hpd_notify() instead of queueing them in the event thread so that they aren't preempted by other events.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 15 ++++++++-------
 drivers/gpu/drm/msm/dp/dp_drm.c     |  6 +++---
 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +6 -5
index 87f2750a99ca..32e1ee40c2c3 100644
@@ -410,11 +410,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);
 
@@ -1561,6 +1556,12 @@ 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);
+		dp->connector->state->link_status = DRM_LINK_STATUS_BAD;
+	}
+
 	msm_dp_display_enable(msm_dp_display, force_link_train);
 
 	rc = msm_dp_display_post_enable(dp);

drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge, · line 1712

Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_display.c +2 -2
@@ -1706,7 +1707,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_hpd_plug_handle(dp, 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_hpd_unplug_handle(dp, 0);

This chunk should be separated from this patch. I'd ask to drop EV_HPD_PLUG_INT / EV_HPD_UNPLUG_INT completely and call DRM functions all over the place instead. You can do it in a single patch, which comes after this one.

Quoted 1 line
drivers/gpu/drm/msm/dp/dp_display.c +0 -0
 }
Signature · 2 lines
With best wishes
Dmitry
#27 lore raw

Re: [PATCH 18/19] drm/msm/dp: Move link training to atomic_enable()

Quoted 57 lines · Dmitry Baryshkov
Quoted 10 lines · Jessica Zhang

Currently, the DP link training is being done during HPD. Move link training to atomic_enable() in accordance with the atomic_enable() documentation.

In addition, don't disable the link until atomic_post_disable() (as part of the dp_ctrl_off[_link_stream]() helpers).

Since the link training is moved to a later part of the enable sequence, change the bridge detect() to return true when the display is physically connected instead of when the link is ready.

These two parts should be patch #2 in the series.

Quoted 43 lines

Finally, call the plug/unplug handlers directly in hpd_notify() instead of queueing them in the event thread so that they aren't preempted by other events.

---
  drivers/gpu/drm/msm/dp/dp_display.c | 15 ++++++++-------
  drivers/gpu/drm/msm/dp/dp_drm.c     |  6 +++---
  2 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +6 -5
index 87f2750a99ca..32e1ee40c2c3 100644
@@ -410,11 +410,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);
 
@@ -1561,6 +1556,12 @@ 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);
+		dp->connector->state->link_status = DRM_LINK_STATUS_BAD;
+	}
+
  	msm_dp_display_enable(msm_dp_display, force_link_train);
 
  	rc = msm_dp_display_post_enable(dp);
@@ -1706,7 +1707,7 @@ void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,
  		return;
 
Quoted 11 lines

drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge, · line 1712

Quoted 6 lines
drivers/gpu/drm/msm/dp/dp_display.c +2 -2
  	if (!msm_dp_display->link_ready && status == connector_status_connected)
-		msm_dp_add_event(dp, EV_HPD_PLUG_INT, 0, 0);
+		msm_dp_hpd_plug_handle(dp, 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_hpd_unplug_handle(dp, 0);

This chunk should be separated from this patch. I'd ask to drop EV_HPD_PLUG_INT / EV_HPD_UNPLUG_INT completely and call DRM functions all over the place instead. You can do it in a single patch, which comes after this one.

Hi Dmitry,

Sure I can split this into a separate patch.

Is the goal here to remove the event queue entirely?

I can drop EV_USER_NOTIFICATION, but I'm not sure if I can completely drop EV_HPD_[UN]PLUG_INT entirely without major refactor of the plug/unplug handlers since they are used for the HPD IRQ handling.

Thanks,

Jessica Zhang

Quoted 3 lines
Quoted 2 lines
drivers/gpu/drm/msm/dp/dp_display.c +0 -0
  }
#28 lore raw

Re: [PATCH 18/19] drm/msm/dp: Move link training to atomic_enable()

Quoted 66 lines · Jessica Zhang
Quoted 54 lines · Dmitry Baryshkov
Quoted 10 lines · Jessica Zhang

Currently, the DP link training is being done during HPD. Move link training to atomic_enable() in accordance with the atomic_enable() documentation.

In addition, don't disable the link until atomic_post_disable() (as part of the dp_ctrl_off[_link_stream]() helpers).

Since the link training is moved to a later part of the enable sequence, change the bridge detect() to return true when the display is physically connected instead of when the link is ready.

These two parts should be patch #2 in the series.

Quoted 40 lines

Finally, call the plug/unplug handlers directly in hpd_notify() instead of queueing them in the event thread so that they aren't preempted by other events.

---
  drivers/gpu/drm/msm/dp/dp_display.c | 15 ++++++++-------
  drivers/gpu/drm/msm/dp/dp_drm.c     |  6 +++---
  2 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +7 -6
index 87f2750a99ca..32e1ee40c2c3 100644
@@ -410,11 +410,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);
@@ -1561,6 +1556,12 @@ 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);
+		dp->connector->state->link_status = DRM_LINK_STATUS_BAD;
+	}
+
  	msm_dp_display_enable(msm_dp_display, force_link_train);
  	rc = msm_dp_display_post_enable(dp);
@@ -1706,7 +1707,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_hpd_plug_handle(dp, 0);
Quoted 8 lines

drivers/gpu/drm/msm/dp/dp_display.c void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge, · line 1712

Quoted 3 lines
drivers/gpu/drm/msm/dp/dp_display.c +1 -1
  	else if (msm_dp_display->link_ready && status == connector_status_disconnected)
-		msm_dp_add_event(dp, EV_HPD_UNPLUG_INT, 0, 0);
+		msm_dp_hpd_unplug_handle(dp, 0);

This chunk should be separated from this patch. I'd ask to drop EV_HPD_PLUG_INT / EV_HPD_UNPLUG_INT completely and call DRM functions all over the place instead. You can do it in a single patch, which comes after this one.

Quoted 5 lines

Hi Dmitry,

Sure I can split this into a separate patch.

Is the goal here to remove the event queue entirely?

I think so.

Quoted 2 lines

I can drop EV_USER_NOTIFICATION,

With the link training being moved to atomic_enable, there should be no need for an extra event here, I agree.

Quoted 3 lines

but I'm not sure if I can completely drop EV_HPD_[UN]PLUG_INT entirely without major refactor of the plug/unplug handlers since they are used for the HPD IRQ handling.

And one of the pieces of the problem is that it's not doing its job correctly.

The code flow should be:
- Inside the IRQ handler notify DRM core about HPD events from the bridge, don't do anything else.
- Inside detect() callback read DPCD bits and identify if there is a valid branch device.
- Inside hpd_notify() check if DPRX has sent IRQ_HPD pulse, handle the rest of the tasks: link events, etc.

Note: we might want to duplicate DPCD reading between detect() and hpd_notify() in order to relieve detect from updating the DP structures.

Signature · 2 lines
With best wishes
Dmitry
#29 lore raw

PATCH 19/19 drm/msm/dp: Log connected and link_ready for event handling

In reply to Jessica Zhang

Add the connected and link_ready states to the debug logs for [un]plug and HPD IRQ handling.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 38 ++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +25 -13
index 32e1ee40c2c3..6cff87e4ad9a 100644
@@ -543,7 +543,9 @@ static int msm_dp_display_usbpd_attention_cb(struct device *dev)
 	rc = msm_dp_link_process_request(dp->link);
 	if (!rc) {
 		sink_request = dp->link->sink_request;
-		drm_dbg_dp(dp->drm_dev, "sink_request=%d\n", sink_request);
+		drm_dbg_dp(dp->drm_dev, "sink_request=%d connected=%d\n",
+			   sink_request, dp->msm_dp_display.connected);
+
 		if (sink_request & DS_PORT_STATUS_CHANGED)
 			rc = msm_dp_display_handle_port_status_changed(dp);
 		else
@@ -562,8 +564,10 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 
 	mutex_lock(&dp->event_mutex);
 
-	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 connected=%d, link_ready=%d\n",
+			dp->msm_dp_display.connector_type,
+			dp->msm_dp_display.connected,
+			dp->msm_dp_display.link_ready);
 
 	if (dp->msm_dp_display.link_ready) {
 		mutex_unlock(&dp->event_mutex);
@@ -585,8 +589,9 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp, u32 data)
 		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 connected=%d\n",
+			dp->msm_dp_display.connector_type,
+			dp->msm_dp_display.connected);
 	mutex_unlock(&dp->event_mutex);
 
 	/* uevent will complete connection part */
@@ -615,8 +620,11 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 
 	mutex_lock(&dp->event_mutex);
 
-	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 connected=%d, link_ready=%d, sink_count=%d\n",
+			dp->msm_dp_display.connector_type,
+			dp->msm_dp_display.connected,
+			dp->msm_dp_display.link_ready,
+			dp->link->sink_count);
 
 	if (!dp->msm_dp_display.link_ready) {
 		mutex_unlock(&dp->event_mutex);
@@ -641,8 +649,9 @@ static int msm_dp_hpd_unplug_handle(struct msm_dp_display_private *dp, u32 data)
 	/* 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 connected=%d\n",
+			dp->msm_dp_display.connector_type,
+			dp->msm_dp_display.connected);
 
 	/* uevent will complete disconnection part */
 	pm_runtime_put_sync(&pdev->dev);
@@ -655,8 +664,10 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, u32 data)
 	mutex_lock(&dp->event_mutex);
 
 	/* 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 connected=%d, link_ready=%d\n",
+			dp->msm_dp_display.connector_type,
+			dp->msm_dp_display.connected,
+			dp->msm_dp_display.link_ready);
 
 	if (dp->msm_dp_display.link_ready != dp->msm_dp_display.connected) {
 		/* wait until connect/disconnect handling is completed */
@@ -667,8 +678,9 @@ static int msm_dp_irq_hpd_handle(struct msm_dp_display_private *dp, u32 data)
 
 	msm_dp_display_usbpd_attention_cb(&dp->msm_dp_display.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 connected=%d\n",
+			dp->msm_dp_display.connector_type,
+			dp->msm_dp_display.connected);
 
 	mutex_unlock(&dp->event_mutex);
 
Signature · 1 line
2.50.1