From patchwork Mon Jun 30 19:54:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 4454231 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 916E8BEEAA for ; Mon, 30 Jun 2014 19:55:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8BFC2037E for ; Mon, 30 Jun 2014 19:55:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A58DE20254 for ; Mon, 30 Jun 2014 19:55:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF0FB6E1CD; Mon, 30 Jun 2014 12:55:13 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f41.google.com (mail-yh0-f41.google.com [209.85.213.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 765686E1CD for ; Mon, 30 Jun 2014 12:55:12 -0700 (PDT) Received: by mail-yh0-f41.google.com with SMTP id z6so5296465yhz.0 for ; Mon, 30 Jun 2014 12:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F5083LxUv9x6QA8x323aF8icstt/lLHtJ69Hg+MW4to=; b=Bvp7pRFFBJqs41Fza2kqZeDejewawiQlJe5tcTbY8piWB5HGZPNcpoEM3FUKvXToBF 3DVhkIo7os5pfnj7Wip/Wmto3ikjSpqs+PI97aJDUvSbmDgqSySHy3BLLmIWLkPQIGr7 HW0sBoBKIZCE2RyjTA2oJ/o2aIXmpQaASWJ0t2XddbCGpPTKzmHiHJu7UqSWyTqI1QLT xGMOWNZCXikgd9EfgO5nnPvK8Z33Vqe+6p2e/ZX5mkPiMbcc60s1I2tyol9/3f1rdAIo aTpwGLlk447fJgvzmmpAZcy/SMsS3MWwLgkTQ+vFZY+r26gUzh9KOcdfyVRTcgxrih6M Mh8Q== X-Received: by 10.236.158.129 with SMTP id q1mr14828672yhk.88.1404158111906; Mon, 30 Jun 2014 12:55:11 -0700 (PDT) Received: from localhost.localdomain ([186.212.33.98]) by mx.google.com with ESMTPSA id p1sm23638266yhk.40.2014.06.30.12.55.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jun 2014 12:55:11 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Mon, 30 Jun 2014 16:54:38 -0300 Message-Id: <1404158078-3748-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: References: Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH] drm/i915: cancel delayed_resume_work when suspending X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni 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 --- 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 =