intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 4/4] drm/i915: fewer warning patch (temporary)
Date: Mon, 11 Apr 2011 18:01:19 -0700	[thread overview]
Message-ID: <1302570079-17032-5-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1302570079-17032-1-git-send-email-ben@bwidawsk.net>

This patch may help mask some of the warnings. Because it's only a
requirement to hold struct_mutex to obtain a reference, it is acceptable
from a hardware perspective to not hold struct_mutex if there is already
a reference. However, it's still extremely dangerous since there is no
real synchronization with the reference count (it could change right
after our check). This should only be used by developers who want to
debug some of the warnings, but want to deal with a possibly smaller set
of warnings to start with. It should not go upstream.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_drv.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 0894e9f..d5748ba 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -290,7 +290,8 @@ void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv)
 	 * The other option is to introduce a new forcewake lock which must be
 	 * acquired prior to any register read.
 	 */
-	WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex));
+	WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex) &&
+		!dev_priv->forcewake_count);
 
 	if (dev_priv->forcewake_count++ == 0)
 		__gen6_gt_force_wake_get(dev_priv);
@@ -307,7 +308,8 @@ void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv)
 	/*
 	 * See gen6_gt_force_wake_get()
 	 */
-	WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex));
+	WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex) &&
+		!dev_priv->forcewake_count);
 
 	if (--dev_priv->forcewake_count == 0)
 		__gen6_gt_force_wake_put(dev_priv);
-- 
1.7.3.4

  parent reply	other threads:[~2011-04-12  1:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12  1:01 force wake reference counting (another try) Ben Widawsky
2011-04-12  1:01 ` [PATCH 1/4] drm/i915: proper use of forcewake Ben Widawsky
2011-04-12  1:01 ` [PATCH 2/4] drm/i915: refcounts for forcewake Ben Widawsky
2011-04-12  1:01 ` [PATCH 3/4] drm/i915: userspace interface to the forcewake refcount Ben Widawsky
2011-04-12  1:01 ` Ben Widawsky [this message]
2011-04-12  8:02 ` force wake reference counting (another try) Chris Wilson
2011-04-12 16:30   ` Ben Widawsky
2011-04-12 16:56     ` Keith Packard
2011-04-12 17:21       ` Chris Wilson
2011-04-12 17:41         ` Keith Packard
2011-04-13  1:31           ` Ben Widawsky
2011-04-13  5:31             ` Keith Packard
2011-04-13  5:52             ` Chris Wilson
2011-04-13  6:35               ` Ben Widawsky

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=1302570079-17032-5-git-send-email-ben@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=intel-gfx@lists.freedesktop.org \
    /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;
as well as URLs for NNTP newsgroup(s).