Skip to contentSkip to conversation

drm/i915/display: Fix warning callstack for imbalance wakeref

PATCH In review Mitul Golani 3 participants 3 messages Aug 23, 2022 – Aug 24, 2022

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

PATCH 1/1 drm/i915/display: Fix warning callstack for imbalance wakeref

While executing i915_selftest, wakeref imbalance warning is seen with i915_selftest failure.

Currently when Driver is suspended, while doing unregister it is taking wakeref without resuming the device.
This patch is resuming the device, if driver is already suspended and doing unregister process. It will check the suspend state and if driver is not resumed before taking wakeref then resume before it.

---
 drivers/gpu/drm/i915/i915_driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_driver.c +9 -0
index deb8a8b76965..b3741bd49e2c 100644
@@ -948,6 +948,15 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 void i915_driver_remove(struct drm_i915_private *i915)
 {
+	int ret;
+	/*
+	 * Resuming Device if already suspended to complete driver unregistration
+	 */
+	if (i915->runtime_pm.suspended && !atomic_read(&i915->runtime_pm.wakeref_count)) {
+		ret = pm_runtime_get_sync(rpm->kdev);
+		drm_WARN_ONCE(&i915->drm, ret < 0, "pm_runtime_get_sync() failed: %d\n", ret);
+	}
+
 	disable_rpm_wakeref_asserts(&i915->runtime_pm);
 
 	i915_driver_unregister(i915);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 22 lines · Mitul Golani

While executing i915_selftest, wakeref imbalance warning is seen with i915_selftest failure.

Currently when Driver is suspended, while doing unregister it is taking wakeref without resuming the device.
This patch is resuming the device, if driver is already suspended and doing unregister process. It will check the suspend state and if driver is not resumed before taking wakeref then resume before it.

---
 drivers/gpu/drm/i915/i915_driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_driver.c +0 -0
index deb8a8b76965..b3741bd49e2c 100644
@@ -948,6 +948,15 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 void i915_driver_remove(struct drm_i915_private *i915)

drivers/gpu/drm/i915/i915_driver.c int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 959

Quoted 10 lines
drivers/gpu/drm/i915/i915_driver.c +9 -0
 {
+	int ret;
+	/*
+	 * Resuming Device if already suspended to complete driver unregistration
+	 */
+	if (i915->runtime_pm.suspended && !atomic_read(&i915->runtime_pm.wakeref_count)) {
+		ret = pm_runtime_get_sync(rpm->kdev);
+		drm_WARN_ONCE(&i915->drm, ret < 0, "pm_runtime_get_sync() failed: %d\n", ret);
+	}
+

I don't know what the right fix is, but under no circumstances are we adding detailed low level code into high level function like i915_driver_remove().

BR,
Jani.

Quoted 3 lines
drivers/gpu/drm/i915/i915_driver.c +0 -0
 	disable_rpm_wakeref_asserts(&i915->runtime_pm);
 
 	i915_driver_unregister(i915);
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#2 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915/display: Fix warning callstack for imbalance wakeref (rev4)

In reply to Mitul Golani
== Series Details ==

== Series Details ==

Series: drm/i915/display: Fix warning callstack for imbalance wakeref (rev4)
URL : https://patchwork.freedesktop.org/series/107211/
State : failure

== Summary ==

Error: make failed
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
CC [M] drivers/gpu/drm/i915/i915_driver.o
drivers/gpu/drm/i915/i915_driver.c: In function ‘i915_driver_remove’:
drivers/gpu/drm/i915/i915_driver.c:956:29: error: ‘rpm’ undeclared (first use in this function)

   ret = pm_runtime_get_sync(rpm->kdev);
                             ^~~

drivers/gpu/drm/i915/i915_driver.c:956:29: note: each undeclared identifier is reported only once for each function it appears in scripts/Makefile.build:249: recipe for target 'drivers/gpu/drm/i915/i915_driver.o' failed
make[4]: *** [drivers/gpu/drm/i915/i915_driver.o] Error 1
scripts/Makefile.build:465: recipe for target 'drivers/gpu/drm/i915' failed
make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:465: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:465: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1853: recipe for target 'drivers' failed
make: *** [drivers] Error 2