All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org, dri-devel@lists.sf.net,
	Eric Anholt <eric@anholt.net>
Subject: Re: [git pull] drm: previous pull req + 1.
Date: Tue, 30 Jun 2009 10:49:43 +0100	[thread overview]
Message-ID: <1246355383.25462.40.camel@tiger> (raw)
In-Reply-To: <1246262271.25462.32.camel@tiger>

Revised patch, unmap_mapping_range() on unbind and clear register.

>From 8f13b6389ee0c8a39a2073279928a3a228bd27dc Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon, 29 Jun 2009 08:45:31 +0100
Subject: [PATCH] drm/i915: Remove mappings on clearing fence register

As the fence register is not locked whilst the user has mmaped the buffer
through the GTT, in order for the buffer to reacquire a fence register we
need to cause a fresh page-fault on the next user access. In order to
cause the page fault, we zap the current mapping on clearing the register.
We also ensure that all potential outstanding access via the fence
register is flushed before release as well.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 685a876..7fb636b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1946,8 +1946,7 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
 		obj_priv->agp_mem = NULL;
 	}
 
-
-	/* blow away mappings if mapped through GTT */
+	/* Force the next mmap access to trigger a fault and rebind */
 	if (obj_priv->mmap_offset && dev->dev_mapping)
 		unmap_mapping_range(dev->dev_mapping,
 				    obj_priv->mmap_offset, obj->size, 1);
@@ -2350,8 +2349,7 @@ try_again:
 			if (old_obj_priv->pin_count)
 				continue;
 
-			/* i915 uses fences for GPU access to tiled buffers */
-			if (IS_I965G(dev) || !old_obj_priv->active)
+			if (!old_obj_priv->active)
 				break;
 
 			/* find the seqno of the first available fence */
@@ -2440,6 +2438,8 @@ i915_gem_clear_fence_reg(struct drm_gem_object *obj)
 		 obj_priv->gtt_offset, obj->size);
 #endif
 
+	BUG_ON(obj_priv->active);
+
 	if (IS_I965G(dev))
 		I915_WRITE64(FENCE_REG_965_0 + (obj_priv->fence_reg * 8), 0);
 	else {
@@ -2471,25 +2471,28 @@ i915_gem_object_put_fence_reg(struct drm_gem_object *obj)
 {
 	struct drm_device *dev = obj->dev;
 	struct drm_i915_gem_object *obj_priv = obj->driver_private;
+	int ret;
 
 	if (obj_priv->fence_reg == I915_FENCE_REG_NONE)
 		return 0;
 
-	/* On the i915, GPU access to tiled buffers is via a fence,
-	 * therefore we must wait for any outstanding access to complete
-	 * before clearing the fence.
+	/* If there is outstanding activity on the buffer whilst it holds
+	 * a fence register we must assume that it requires that fence for
+	 * correct operation. Therefore we must wait for any outstanding
+	 * access to complete before clearing the fence.
 	 */
-	if (!IS_I965G(dev)) {
-		int ret;
+	i915_gem_object_flush_gpu_write_domain(obj);
+	i915_gem_object_flush_gtt_write_domain(obj);
+	ret = i915_gem_object_wait_rendering(obj);
+	if (ret != 0)
+		return ret;
 
-		i915_gem_object_flush_gpu_write_domain(obj);
-		i915_gem_object_flush_gtt_write_domain(obj);
-		ret = i915_gem_object_wait_rendering(obj);
-		if (ret != 0)
-			return ret;
-	}
+	i915_gem_clear_fence_reg(obj);
 
-	i915_gem_clear_fence_reg (obj);
+	/* Reacquire fence register on next mmap access (via page fault) */
+	if (obj_priv->mmap_offset)
+		unmap_mapping_range(dev->dev_mapping,
+				    obj_priv->mmap_offset, obj->size, 1);
 
 	return 0;
 }
-- 
1.6.3.3




  reply	other threads:[~2009-06-30 10:09 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-20  5:23 [git pull] drm: previous pull req + 1 Dave Airlie
2009-06-21  0:04 ` Maxim Levitsky
2009-06-21  0:42   ` Linus Torvalds
2009-06-21 14:47     ` Maxim Levitsky
2009-06-21 21:24       ` Chris Wilson
2009-06-22 18:09         ` Maxim Levitsky
2009-06-29  7:57           ` Chris Wilson
2009-06-30  9:49             ` Chris Wilson [this message]
2009-07-09 23:11             ` Eric Anholt
2009-06-21  1:33   ` Dave Airlie
2009-06-21  3:41 ` Andy Lutomirski
2009-06-21  5:16   ` Dave Airlie
2009-06-21 12:06     ` Andrew Lutomirski
2009-06-21 16:46     ` Linus Torvalds
2009-06-21 17:13       ` Linus Torvalds
2009-06-21 18:50         ` Andrew Lutomirski
2009-06-21 19:47           ` Linus Torvalds
2009-06-21 21:14             ` Andrew Lutomirski
2009-06-22  0:05               ` Andrew Lutomirski
2009-06-22 19:20                 ` Arnaldo Carvalho de Melo
2009-06-21 22:40             ` Dave Airlie
2009-06-22  8:18               ` Thomas Hellström
2009-06-22  8:30                 ` Dave Airlie
2009-06-22 18:22                 ` Linus Torvalds
2009-06-22 18:59                   ` Andrew Lutomirski
2009-06-22 19:43                     ` Linus Torvalds
2009-06-23  0:01                   ` Benjamin Herrenschmidt
2009-06-23  0:00                 ` Benjamin Herrenschmidt
2009-06-23  0:24                   ` Linus Torvalds
2009-06-23  1:04                     ` Benjamin Herrenschmidt
2009-06-23  1:18                       ` Jesse Barnes
2009-06-23  1:58                         ` Benjamin Herrenschmidt
2009-06-23  2:07                           ` Jesse Barnes
2009-06-23  2:26                             ` Benjamin Herrenschmidt
2009-06-23 15:40                               ` Jesse Barnes
2009-06-23  7:48                         ` Michel Dänzer
2009-06-23 15:39                           ` Jesse Barnes
2009-06-23 16:28                             ` Jesse Barnes
2009-06-22 23:57             ` Benjamin Herrenschmidt
2009-06-21 22:41       ` Dave Airlie

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=1246355383.25462.40.camel@tiger \
    --to=chris@chris-wilson.co.uk \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.sf.net \
    --cc=eric@anholt.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maximlevitsky@gmail.com \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.