Skip to contentSkip to conversation

drm/amdgpu: Disable RPM helpers while reprobing connectors on resume

PATCH Applied Lyude 2 participants 2 messages Jul 8, 2016 – Jul 15, 2016

Subsystems (3)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

Lyude

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Disable RPM helpers while reprobing connectors on resume

Just about all of amdgpu's connector probing functions try to acquire runtime PM refs. If we try to do this in the context of amdgpu_resume_kms by calling drm_helper_hpd_irq_event(), we end up deadlocking the system.

Since we're guaranteed to be holding the spinlock for RPM in amdgpu_resume_kms, and we already know the GPU is in working order, we need to prevent the RPM helpers from trying to run during the initial connector reprobe on resume.

There's a couple of solutions I've explored for fixing this, but this one by far seems to be the simplest and most reliable (plus I'm pretty sure that's what disable_depth is there for anyway).

Reproduction recipe:
- Get any laptop dual GPUs using PRIME
- Make sure runtime PM is enabled for amdgpu
- Boot the machine
- If the machine managed to boot without hanging, switch out of X to another VT. This should definitely cause X to hang infinitely.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index 6e92008..46c1fee 100644
@@ -1841,7 +1841,19 @@ int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
 	}
 
 	drm_kms_helper_poll_enable(dev);
+
+	/*
+	 * 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.
+	 */
+	dev->dev->power.disable_depth++;
 	drm_helper_hpd_irq_event(dev);
+	dev->dev->power.disable_depth--;
 
 	if (fbcon) {
 		amdgpu_fbdev_set_suspend(adev, 0);
Signature · 1 line
2.7.4
Applied
#1 lore raw
Quoted 21 lines · Lyude

Just about all of amdgpu's connector probing functions try to acquire runtime PM refs. If we try to do this in the context of amdgpu_resume_kms by calling drm_helper_hpd_irq_event(), we end up deadlocking the system.

Since we're guaranteed to be holding the spinlock for RPM in amdgpu_resume_kms, and we already know the GPU is in working order, we need to prevent the RPM helpers from trying to run during the initial connector reprobe on resume.

There's a couple of solutions I've explored for fixing this, but this one by far seems to be the simplest and most reliable (plus I'm pretty sure that's what disable_depth is there for anyway).

Reproduction recipe:
- Get any laptop dual GPUs using PRIME
- Make sure runtime PM is enabled for amdgpu
- Boot the machine
- If the machine managed to boot without hanging, switch out of X to another VT. This should definitely cause X to hang infinitely.

Quoted 2 lines

Applied. thanks!

Alex

Quoted 35 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -1
index 6e92008..46c1fee 100644
@@ -1841,7 +1841,19 @@ int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
        }
 
        drm_kms_helper_poll_enable(dev);
+
+       /*
+        * 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.
+        */
+       dev->dev->power.disable_depth++;
        drm_helper_hpd_irq_event(dev);
+       dev->dev->power.disable_depth--;
 
        if (fbcon) {
                amdgpu_fbdev_set_suspend(adev, 0);
--

2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel