public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Paulo Zanoni <przanoni@gmail.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH] drm/i915: cancel delayed_resume_work when suspending
Date: Mon, 30 Jun 2014 16:54:38 -0300	[thread overview]
Message-ID: <1404158078-3748-1-git-send-email-przanoni@gmail.com> (raw)
In-Reply-To: <CA+gsUGQ-Ftyxeb=qOm_7W=GjUJQSe_vrR8HRDazf=25kLkbfjg@mail.gmail.com>

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

It is possible that, by the time we run i915_drm_freeze(),
delayed_resume_work was already queued but did not run yet. If it
still didn't run after intel_runtime_pm_disable_interrupts(), by the
time it runs it will try to change the interrupt registers with the
interrupts already disabled, which will trigger a WARN. We can
reliably reproduce this with the pm_rpm system-suspend test case.

In order to avoid the probelm, we flush the work and put the necessary
resources in case the work was already scheduled.

Another thing I tried was to move the intel_suspend_gt_powersave()
call to before intel_runtime_pm_disable_interrupts(), but since that
function needs to be called after the interrupts are already disabled,
due to dev_priv->rps.work, this strategy didn't work.

Testcase: igt/pm_rpm/system-suspend
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80517
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c  | 2 ++
 drivers/gpu/drm/i915/intel_drv.h | 1 +
 drivers/gpu/drm/i915/intel_pm.c  | 8 ++++++++
 3 files changed, 11 insertions(+)

Now the maintainers and reviewers can choose if they prefer the "cancel" or the
"flush" version of the patch.

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 6eb45ac..dad7e8b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -520,6 +520,8 @@ static int i915_drm_freeze(struct drm_device *dev)
 			return error;
 		}
 
+		intel_cancel_rps_resume_work(dev_priv);
+
 		intel_runtime_pm_disable_interrupts(dev);
 		dev_priv->enable_hotplug_processing = false;
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 5f7c7bd..b122b12 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -993,6 +993,7 @@ void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
 void intel_suspend_gt_powersave(struct drm_device *dev);
 void intel_reset_gt_powersave(struct drm_device *dev);
+void intel_cancel_rps_resume_work(struct drm_i915_private *dev_priv);
 void ironlake_teardown_rc6(struct drm_device *dev);
 void gen6_update_ring_freq(struct drm_device *dev);
 void gen6_rps_idle(struct drm_i915_private *dev_priv);
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index a90fdbd..664099f 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -4911,6 +4911,14 @@ void intel_disable_gt_powersave(struct drm_device *dev)
 	}
 }
 
+/* This function needs to put/clear any resources that the
+ * rps.delayed_resume_work function puts/clears. */
+void intel_cancel_rps_resume_work(struct drm_i915_private *dev_priv)
+{
+	if (cancel_delayed_work_sync(&dev_priv->rps.delayed_resume_work))
+		intel_runtime_pm_put(dev_priv);
+}
+
 static void intel_gen6_powersave_work(struct work_struct *work)
 {
 	struct drm_i915_private *dev_priv =
-- 
2.0.0

  reply	other threads:[~2014-06-30 19:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27 21:51 [PATCH] drm/i915: flush delayed_resume_work when suspending Paulo Zanoni
2014-06-27 22:30 ` Rodrigo Vivi
2014-06-30 19:22   ` Paulo Zanoni
2014-06-30 19:54     ` Paulo Zanoni [this message]
2014-06-30 20:10     ` Rodrigo Vivi
2014-07-01 14:49 ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1404158078-3748-1-git-send-email-przanoni@gmail.com \
    --to=przanoni@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox