On Mon, 29 Aug 2022 14:01:24 +0530, Mitul Golani wrote: > 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@xxxxxxxxx> > --- > 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; Initing wakeref right before assigning to it is redundant. > + /* > + * Resuming Device if already suspended to complete driver unregistration > + */ No need for the above comment, which the function name makes clear already. > + 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); wakeref can't be 0, so the call can be unconditional. > } > > 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);