From patchwork Thu Feb 27 22:26:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 3736631 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 D4284BF13A for ; Thu, 27 Feb 2014 22:28:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06B9D2011E for ; Thu, 27 Feb 2014 22:28:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0DC8720237 for ; Thu, 27 Feb 2014 22:28:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AAD781058F2; Thu, 27 Feb 2014 14:27:51 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f50.google.com (mail-yh0-f50.google.com [209.85.213.50]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B3FE1058DA for ; Thu, 27 Feb 2014 14:27:10 -0800 (PST) Received: by mail-yh0-f50.google.com with SMTP id t59so1763534yho.23 for ; Thu, 27 Feb 2014 14:27:09 -0800 (PST) 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=eAzzsejNw71jfJadANUW7arUBKYj1g/+7I+qrH5vvl0=; b=chKm6QWnkoWvT5Zhkjk2ErmCf7ixvk1wW/wHMWw4Ls7YCSw6IMQcK8/F3Q8BlN2Xo5 RXjLfWUuQ5eU4b+feK3I7frKcOPKNIsoMzqyGqAwFOQHTcfd+a6TxFO9qbo0rRfSU0Hl 4/6EUcjIpWuMd0i5vZlUAkJOutJtsjZSLO/WnGt6bMVXnVOwFiqvJl7sJST6x/nsRP5R y3MIn9WHq5E4NJHM8CFA6lXku+FswwOwmNLGkSCwegRAeLsK4rdl0qNWNw3UsDA27fHL tAznjGzbJvpI0BW3W0Lmc7cemvtaRWJt8Zj8TP4eDpznI7OtKacsCc7vRH22UpXFbe2O IWBQ== X-Received: by 10.236.32.36 with SMTP id n24mr3401366yha.116.1393540029844; Thu, 27 Feb 2014 14:27:09 -0800 (PST) Received: from localhost.localdomain ([177.132.50.39]) by mx.google.com with ESMTPSA id t58sm18099538yho.20.2014.02.27.14.27.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Feb 2014 14:27:09 -0800 (PST) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 27 Feb 2014 19:26:30 -0300 Message-Id: <1393540010-1582-4-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1393540010-1582-1-git-send-email-przanoni@gmail.com> References: <1393540010-1582-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 03/23] drm/i915: put runtime PM only when we actually release force_wake X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org 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, 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: Paulo Zanoni When we call gen6_gt_force_wake_put we don't actually put force_wake, we just schedule gen6_force_wake_work through mod_delayed_work, and that will eventually release force_wake. The problem is that we call intel_runtime_pm_put directly at gen6_gt_force_wake_put, so most of the times we put our runtime PM reference before the delayed work happens, so we may runtime suspend while force_wake is still supposed to be enabled if the graphics autosuspend_delay_ms is too small. Now the nice thing about the current code is that after it triggers the delayed work function it gets a refcount, and it only triggers the delayed work function if refcount is zero. This guarantees that when we schedule the funciton, it will run before we try to schedule it again, which simplifies the problem and allows for the current solution to work properly (hopefully!). v2: - Keep the VLV refcounts balanced (Jesse) Reviewed-by: Jesse Barnes Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/intel_uncore.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index c628414..6a21f43 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -299,6 +299,8 @@ static void gen6_force_wake_work(struct work_struct *work) if (--dev_priv->uncore.forcewake_count == 0) dev_priv->uncore.funcs.force_wake_put(dev_priv, FORCEWAKE_ALL); spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); + + intel_runtime_pm_put(dev_priv); } static void intel_uncore_forcewake_reset(struct drm_device *dev) @@ -393,25 +395,31 @@ void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv, int fw_engine) void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine) { unsigned long irqflags; + bool delayed = false; if (!dev_priv->uncore.funcs.force_wake_put) return; /* Redirect to VLV specific routine */ - if (IS_VALLEYVIEW(dev_priv->dev)) - return vlv_force_wake_put(dev_priv, fw_engine); + if (IS_VALLEYVIEW(dev_priv->dev)) { + vlv_force_wake_put(dev_priv, fw_engine); + goto out; + } spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); if (--dev_priv->uncore.forcewake_count == 0) { dev_priv->uncore.forcewake_count++; + delayed = true; mod_delayed_work(dev_priv->wq, &dev_priv->uncore.force_wake_work, 1); } spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); - intel_runtime_pm_put(dev_priv); +out: + if (!delayed) + intel_runtime_pm_put(dev_priv); } /* We give fast paths for the really cool registers */