[PATCH] drm/amdgpu: disable hotplug events on runtime pm resume

Alex Deucher alexander.deucher at amd.com
Wed Dec 22 15:55:00 UTC 2021


When runtime pm kicks in and the device goes into runtime
suspend, we often see random calls (small rendering calls,
etc.) into the driver which cause the device to runtime
resume.  On resume we issue a hotplug event in case any
displays were changed during suspend, however, these events
cause the compositor to probe the displays and power then
back up leading to the user seeing the displays go off
followed by them coming back on again.

Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1840
Bug: https://bugzilla.kernel.org/show_bug.cgi?id=215203
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 36 +++++++++++++---------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 00b29ff414de..0970105ed03c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4070,25 +4070,33 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
 
 	amdgpu_ras_resume(adev);
 
-	/*
-	 * Most of the connector probing functions try to acquire runtime pm
-	 * refs to ensure that the GPU is powered on when connector polling is
-	 * performed. Since we're calling this from a runtime PM callback,
-	 * trying to acquire rpm refs will cause us to deadlock.
-	 *
-	 * Since we're guaranteed to be holding the rpm lock, it's safe to
-	 * temporarily disable the rpm helpers so this doesn't deadlock us.
+	/* Skip hotplug events in runtime pm.  Otherwise, we end up having the GPU
+	 * woken up periodically for random things which causes a hotplug event
+	 * that the desktop compostior to reacts to and re-enables the
+	 * displays.  This leads to displays turning back on soon after they go to
+	 * sleep in some cases if runtime pm kicks in.
 	 */
+	if (!adev->in_runpm) {
+		/*
+		 * Most of the connector probing functions try to acquire runtime pm
+		 * refs to ensure that the GPU is powered on when connector polling is
+		 * performed. Since we're calling this from a runtime PM callback,
+		 * trying to acquire rpm refs will cause us to deadlock.
+		 *
+		 * Since we're guaranteed to be holding the rpm lock, it's safe to
+		 * temporarily disable the rpm helpers so this doesn't deadlock us.
+		 */
 #ifdef CONFIG_PM
-	dev->dev->power.disable_depth++;
+		dev->dev->power.disable_depth++;
 #endif
-	if (!amdgpu_device_has_dc_support(adev))
-		drm_helper_hpd_irq_event(dev);
-	else
-		drm_kms_helper_hotplug_event(dev);
+		if (!amdgpu_device_has_dc_support(adev))
+			drm_helper_hpd_irq_event(dev);
+		else
+			drm_kms_helper_hotplug_event(dev);
 #ifdef CONFIG_PM
-	dev->dev->power.disable_depth--;
+		dev->dev->power.disable_depth--;
 #endif
+	}
 	adev->in_suspend = false;
 
 	if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D0))
-- 
2.33.1



More information about the amd-gfx mailing list