public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref
@ 2022-08-12  4:47 Mitul Golani
  2022-08-12 12:45 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: Mitul Golani @ 2022-08-12  4:47 UTC (permalink / raw)
  To: intel-gfx; +Cc: Mitul Golani

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

When device is already suspended, wakeref is acquired by
disable_rpm_wakeref_asserts and rpm ownership is transferred back
to core. During this case wakeref_count will not be zero.
Once driver is unregistered, this wakeref is released with
enable_rpm_wakeref_asserts and balancing wakeref_count acquired
by driver.

This patch will fix the warning callstack by adding check if device
is already suspended and rpm ownership transfer is going on.

Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index deb8a8b76965..6530a8680cfd 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1670,7 +1670,13 @@ static int intel_runtime_resume(struct device *kdev)
 
 	drm_dbg(&dev_priv->drm, "Resuming device\n");
 
-	drm_WARN_ON_ONCE(&dev_priv->drm, atomic_read(&rpm->wakeref_count));
+	/*
+	 * When device is already suspended, Wakeref is acquired by disable_rpm_wakeref_asserts
+	 * and rpm ownership is transferred back to core. During this case wakeref_count will
+	 * not be zero. Once driver is unregistered, this wakeref is released with
+	 * enable_rpm_wakeref_asserts and balancing wakeref_count acquired by driver.
+	 */
+	drm_WARN_ON_ONCE(&dev_priv->drm, atomic_read(&rpm->wakeref_count) && !rpm->suspended);
 	disable_rpm_wakeref_asserts(rpm);
 
 	intel_opregion_notify_adapter(dev_priv, PCI_D0);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread
* [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref
@ 2022-08-23  2:35 Mitul Golani
  2022-08-23 11:00 ` Jani Nikula
  0 siblings, 1 reply; 24+ messages in thread
From: Mitul Golani @ 2022-08-23  2:35 UTC (permalink / raw)
  To: intel-gfx

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.

Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index deb8a8b76965..b3741bd49e2c 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread
* [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref
@ 2022-08-23  5:20 Mitul Golani
  2022-08-23 14:31 ` Jani Nikula
  0 siblings, 1 reply; 24+ messages in thread
From: Mitul Golani @ 2022-08-23  5:20 UTC (permalink / raw)
  To: intel-gfx

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.

Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index deb8a8b76965..99d6df02dc67 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -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(i915->runtime_pm.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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread
* [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref
@ 2022-08-29  8:31 Mitul Golani
  0 siblings, 0 replies; 24+ messages in thread
From: Mitul Golani @ 2022-08-29  8:31 UTC (permalink / raw)
  To: intel-gfx

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.

Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 1332c70370a6..281bf6cd5e4c 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -953,7 +953,11 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 void i915_driver_remove(struct drm_i915_private *i915)
 {
-	disable_rpm_wakeref_asserts(&i915->runtime_pm);
+	intel_wakeref_t wakeref = 0;
+	/*
+	 * Resuming Device if already suspended to complete driver unregistration
+	 */
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	i915_driver_unregister(i915);
 
@@ -977,18 +981,20 @@ void i915_driver_remove(struct drm_i915_private *i915)
 
 	i915_driver_hw_remove(i915);
 
-	enable_rpm_wakeref_asserts(&i915->runtime_pm);
+	if (wakeref)
+		intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 }
 
 static void i915_driver_release(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
+	intel_wakeref_t wakeref = 0;
 
 	if (!dev_priv->do_release)
 		return;
 
-	disable_rpm_wakeref_asserts(rpm);
+	wakeref = intel_runtime_pm_get(rpm);
 
 	i915_gem_driver_release(dev_priv);
 
@@ -999,7 +1005,9 @@ static void i915_driver_release(struct drm_device *dev)
 
 	i915_driver_mmio_release(dev_priv);
 
-	enable_rpm_wakeref_asserts(rpm);
+	if (wakeref)
+		intel_runtime_pm_put(rpm, wakeref);
+
 	intel_runtime_pm_driver_release(rpm);
 
 	i915_driver_late_release(dev_priv);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread
* [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref
@ 2022-08-30  8:51 Mitul Golani
  2022-08-31 11:54 ` Imre Deak
  2022-08-31 15:28 ` Andrzej Hajda
  0 siblings, 2 replies; 24+ messages in thread
From: Mitul Golani @ 2022-08-30  8:51 UTC (permalink / raw)
  To: intel-gfx

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.

Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 1332c70370a6..be0d51c04cc5 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -953,7 +953,9 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 void i915_driver_remove(struct drm_i915_private *i915)
 {
-	disable_rpm_wakeref_asserts(&i915->runtime_pm);
+	intel_wakeref_t wakeref;
+
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	i915_driver_unregister(i915);
 
@@ -977,18 +979,19 @@ void i915_driver_remove(struct drm_i915_private *i915)
 
 	i915_driver_hw_remove(i915);
 
-	enable_rpm_wakeref_asserts(&i915->runtime_pm);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 }
 
 static void i915_driver_release(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
+	intel_wakeref_t wakeref;
 
 	if (!dev_priv->do_release)
 		return;
 
-	disable_rpm_wakeref_asserts(rpm);
+	wakeref = intel_runtime_pm_get(rpm);
 
 	i915_gem_driver_release(dev_priv);
 
@@ -999,7 +1002,8 @@ static void i915_driver_release(struct drm_device *dev)
 
 	i915_driver_mmio_release(dev_priv);
 
-	enable_rpm_wakeref_asserts(rpm);
+	intel_runtime_pm_put(rpm, wakeref);
+
 	intel_runtime_pm_driver_release(rpm);
 
 	i915_driver_late_release(dev_priv);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-08-31 15:28 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12  4:47 [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref Mitul Golani
2022-08-12 12:45 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2022-08-12 19:32 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-08-16 20:03 ` Patchwork
2022-08-16 20:47 ` [Intel-gfx] ✓ Fi.CI.IGT: success " Patchwork
2022-08-17  7:15 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/display: Fix warning callstack for imbalance wakeref (rev2) Patchwork
2022-08-17  9:12 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/display: Fix warning callstack for imbalance wakeref (rev3) Patchwork
2022-08-17 12:12 ` [Intel-gfx] ✗ Fi.CI.IGT: failure for drm/i915/display: Fix warning callstack for imbalance wakeref (rev2) Patchwork
2022-08-17 12:49 ` [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref Imre Deak
2022-08-23 12:39   ` Golani, Mitulkumar Ajitkumar
2022-08-23 12:56     ` Golani, Mitulkumar Ajitkumar
2022-08-25 10:51       ` Imre Deak
2022-08-29  6:45         ` Golani, Mitulkumar Ajitkumar
2022-08-29 14:46           ` Imre Deak
2022-08-29 16:59             ` Golani, Mitulkumar Ajitkumar
2022-08-17 13:24 ` [Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915/display: Fix warning callstack for imbalance wakeref (rev3) Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2022-08-23  2:35 [Intel-gfx] [PATCH] drm/i915/display: Fix warning callstack for imbalance wakeref Mitul Golani
2022-08-23 11:00 ` Jani Nikula
2022-08-23  5:20 Mitul Golani
2022-08-23 14:31 ` Jani Nikula
2022-08-29  8:31 Mitul Golani
2022-08-30  8:51 Mitul Golani
2022-08-31 11:54 ` Imre Deak
2022-08-31 15:28 ` Andrzej Hajda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox