Skip to contentSkip to conversation

drm/msm/dp: fix runtime PM leaks on hotplug

PATCH Applied Johan Hovold 2 participants 6 messages Mar 13, 2024 – Apr 5, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover drm/msm/dp: fix runtime PM leaks on hotplug

As I've reported elsewhere, I've been hitting runtime PM usage count leaks when investigated a DisplayPort hotplug regression on the Lenovo ThinkPad X13s. [1]

This series addresses two obvious leaks on disconnect and on connect failures, respectively.

Johan

[1] https://lore.kernel.org/lkml/[email protected]/

Johan Hovold (2):
drm/msm/dp: fix runtime PM leak on disconnect drm/msm/dp: fix runtime PM leak on connect failure

 drivers/gpu/drm/msm/dp/dp_display.c | 2 ++
 1 file changed, 2 insertions(+)
Signature · 1 line
2.43.2
#1 lore raw

PATCH 1/2 drm/msm/dp: fix runtime PM leak on disconnect

Make sure to put the runtime PM usage count (and suspend) also when receiving a disconnect event while in the ST_MAINLINK_READY state.

This specifically avoids leaking a runtime PM usage count on every disconnect with display servers that do not automatically enable external displays when receiving a hotplug notification.

Fixes 5814b8bf086a ("drm/msm/dp: incorporate pm_runtime framework into DP driver")
Cc Kuogee Hsieh <[email protected]>
---
 drivers/gpu/drm/msm/dp/dp_display.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/dp/dp_display.c +1 -0
index 4c72124ffb5d..8e8cf531da45 100644
@@ -655,6 +655,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
 		dp_display_host_phy_exit(dp);
 		dp->hpd_state = ST_DISCONNECTED;
 		dp_display_notify_disconnect(&dp->dp_display.pdev->dev);
+		pm_runtime_put_sync(&pdev->dev);
 		mutex_unlock(&dp->event_mutex);
 		return 0;
 	}
Signature · 1 line
2.43.2
#3 lore raw

PATCH 2/2 drm/msm/dp: fix runtime PM leak on connect failure

In reply to Johan Hovold

Make sure to balance the runtime PM usage counter (and suspend) before returning on connect failures (e.g. DPCD read failures after a spurious connect event or if link training fails).

Fixes 5814b8bf086a ("drm/msm/dp: incorporate pm_runtime framework into DP driver")
Cc Kuogee Hsieh <[email protected]>
---
 drivers/gpu/drm/msm/dp/dp_display.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/dp/dp_display.c +1 -0
index 8e8cf531da45..78464c395c3d 100644
@@ -598,6 +598,7 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data)
 	ret = dp_display_usbpd_configure_cb(&pdev->dev);
 	if (ret) {	/* link train failed */
 		dp->hpd_state = ST_DISCONNECTED;
+		pm_runtime_put_sync(&pdev->dev);
 	} else {
 		dp->hpd_state = ST_MAINLINK_READY;
 	}
Signature · 1 line
2.43.2
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] drm/msm/dp: fix runtime PM leak on connect failure

Quoted 8 lines · Johan Hovold

Make sure to balance the runtime PM usage counter (and suspend) before returning on connect failures (e.g. DPCD read failures after a spurious connect event or if link training fails).

Fixes 5814b8bf086a ("drm/msm/dp: incorporate pm_runtime framework into DP driver")
Cc Kuogee Hsieh <[email protected]>
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] drm/msm/dp: fix runtime PM leak on disconnect

In reply to Johan Hovold
Quoted 7 lines · Johan Hovold

Make sure to put the runtime PM usage count (and suspend) also when receiving a disconnect event while in the ST_MAINLINK_READY state.

This specifically avoids leaking a runtime PM usage count on every disconnect with display servers that do not automatically enable external displays when receiving a hotplug notification.

Thanks for the fixes. Both look right to me.

I will pick up both of them for -fixes

Quoted 20 lines
Fixes 5814b8bf086a ("drm/msm/dp: incorporate pm_runtime framework into DP driver")
Cc Kuogee Hsieh <[email protected]>
---
  drivers/gpu/drm/msm/dp/dp_display.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/dp/dp_display.c +1 -0
index 4c72124ffb5d..8e8cf531da45 100644
@@ -655,6 +655,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
  		dp_display_host_phy_exit(dp);
  		dp->hpd_state = ST_DISCONNECTED;
  		dp_display_notify_disconnect(&dp->dp_display.pdev->dev);
+		pm_runtime_put_sync(&pdev->dev);
  		mutex_unlock(&dp->event_mutex);
  		return 0;
  	}
#5 lore raw
In reply to Johan Hovold
Quoted 8 lines · Johan Hovold

As I've reported elsewhere, I've been hitting runtime PM usage count leaks when investigated a DisplayPort hotplug regression on the Lenovo ThinkPad X13s. [1]

This series addresses two obvious leaks on disconnect and on connect failures, respectively.

[...]

Applied, thanks!

[1/2] drm/msm/dp: fix runtime PM leak on disconnect

      https://gitlab.freedesktop.org/drm/msm/-/commit/0640f47b7426
[2/2] drm/msm/dp: fix runtime PM leak on connect failure
      https://gitlab.freedesktop.org/drm/msm/-/commit/e86750b01a15      

Best regards,

Signature · 1 line
Abhinav Kumar <[email protected]>