From patchwork Mon Apr 7 20:01:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 3946811 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 335939F371 for ; Mon, 7 Apr 2014 20:02:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70528201FE for ; Mon, 7 Apr 2014 20:02:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A0F3F201FD for ; Mon, 7 Apr 2014 20:02:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2200F6E7A0; Mon, 7 Apr 2014 13:02:18 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 869CB6E7A0 for ; Mon, 7 Apr 2014 13:02:17 -0700 (PDT) Received: by mail-pb0-f42.google.com with SMTP id rr13so7261451pbb.29 for ; Mon, 07 Apr 2014 13:02:17 -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=4HFi99A4e+eJ4SKRZYjuvABcVfxFrDUnkRHc1lKro24=; b=QofYZEUjwJcrqNTHeaUTiI4C78gI5l6Qs4hwy2Tt+hWJQrtfrPqcdwlFerYVRvwhQT z9LuTBRh6yS8adGQ6Kw8Hp6t2jo+CjUDzt13KCzMZoY0/Gh0XBHllvQo8bsybQy2i4sz axk9grTjPQiCBwhZj4Ti/StK21oJiJdPIb5bCbuXd5zK+jkfAEYrZaWSwGSpL/Y89gwR cMRtm5dm/5pLOrc8Ltr6KPXP7liN+tMKCGxkQw6GWRl2yJtje+CfQL0vy2sCwwVsveQl acbuMgdYEj4BA/YPuUUc3T906eEemrHnTbYshVMiQIhCNzgKKFNEUHrmkzqml/dqF39H 499w== X-Received: by 10.66.136.17 with SMTP id pw17mr33185492pab.86.1396900937407; Mon, 07 Apr 2014 13:02:17 -0700 (PDT) Received: from localhost (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by mx.google.com with ESMTPSA id nx12sm90312011pab.6.2014.04.07.13.02.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Apr 2014 13:02:16 -0700 (PDT) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Mon, 7 Apr 2014 17:01:50 -0300 Message-Id: <1396900911-12415-6-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1396900911-12415-1-git-send-email-rodrigo.vivi@gmail.com> References: <1396900911-12415-1-git-send-email-rodrigo.vivi@gmail.com> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 5/6] drm/i915: Do not allow a pending forcewake put to unbalance across reset 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Chris Wilson Across a device reset, we try to restore and user forcewake reference counts. This is complicated by our deferred forcewake put adding an extra reference, that may or may not be flushed when we call del_timer_sync. So we have to take that pending reference into account when restoring the forcewake. Reported-by: Daniel Vetter Signed-off-by: Chris Wilson Cc: Daniel Vetter Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/intel_uncore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index 2a72bab..c8969e3 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -317,8 +317,9 @@ static void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore) { struct drm_i915_private *dev_priv = dev->dev_private; unsigned long irqflags; + int pending; - del_timer_sync(&dev_priv->uncore.force_wake_timer); + pending = del_timer_sync(&dev_priv->uncore.force_wake_timer); /* Hold uncore.lock across reset to prevent any register access * with forcewake not set correctly @@ -336,6 +337,8 @@ static void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore) if (restore) { /* If reset with a user forcewake, try to restore */ unsigned fw = 0; + dev_priv->uncore.forcewake_count -= pending; + if (IS_VALLEYVIEW(dev)) { if (dev_priv->uncore.fw_rendercount) fw |= FORCEWAKE_RENDER;