From patchwork Fri Apr 18 21:04:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 4018501 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 B6946BFF02 for ; Fri, 18 Apr 2014 21:04:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECF982038D for ; Fri, 18 Apr 2014 21:04:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E9877202E6 for ; Fri, 18 Apr 2014 21:04:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8515A6E47C; Fri, 18 Apr 2014 14:04:38 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 810956ECEE for ; Fri, 18 Apr 2014 14:04:36 -0700 (PDT) Received: by mail-pd0-f181.google.com with SMTP id p10so1762924pdj.12 for ; Fri, 18 Apr 2014 14:04:36 -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=tE5LPfp3PlmBxfeMH7P8Wev+kOzskFBjmTCUnFy5y/A=; b=GR+OYWgXUQXnGkMWPoYWg3xadT+C3E3gP6KO7tmg++8PRBFcUuXk9JXFnT1gw4h3OS eLFnWMUo2mI8l5iN3OukvikBrBvDWWfPde9D/ANzsGsEZWtzRV8CqzOrA1B6EJJwcsK4 vuK+G8qJlWuPE14sA4R2uvCgNaWcBOz8q9lIFMLMhhLVCsZCNE31pdrxcQFhQHvxtyoe 9FN7/gQ1A8bjW7ZG5yhFc/u4uWuyGS4+T8rzJmAM1KkGAiCIOTp+NCpjiLwIv2Bh0RhO 0VEbVIph+XEY95sMHb370Vum5DfdKXWdUIhZJ1v06c3mIFpMwmLrZkQGAYbTzSav2HUw lKhg== X-Received: by 10.68.102.34 with SMTP id fl2mr24196202pbb.2.1397855076341; Fri, 18 Apr 2014 14:04:36 -0700 (PDT) Received: from localhost (jfdmzpr03-ext.jf.intel.com. [134.134.139.72]) by mx.google.com with ESMTPSA id hw8sm61773463pbc.62.2014.04.18.14.04.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Apr 2014 14:04:35 -0700 (PDT) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Fri, 18 Apr 2014 18:04:19 -0300 Message-Id: <1397855070-4480-4-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1397855070-4480-1-git-send-email-rodrigo.vivi@gmail.com> References: <1397855070-4480-1-git-send-email-rodrigo.vivi@gmail.com> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 03/14] 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.7 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=ham 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;