UBUNTU: SAUCE: drm/i915: Fix pipelined fencing
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 17 Mar 2011 22:12:05 +0000 (22:12 +0000)
committerLeann Ogasawara <leann.ogasawara@canonical.com>
Mon, 28 Mar 2011 13:54:43 +0000 (06:54 -0700)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34584
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

[We are expecting this to appear in upstream shortly, but the symptoms
are pretty serious corruption in gnome-terminal and other scrollable
text, and this is well understood and tested.]

BugLink: http://bugs.launchpad.net/bugs/717114
Signed-off-by: Andy Whitcroft <apw@canonical.com>

drivers/gpu/drm/i915/i915_gem.c

index 729c95a..07cd0a3 100644 (file)
@@ -2546,8 +2546,25 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj,
                reg = &dev_priv->fence_regs[obj->fence_reg];
                list_move_tail(&reg->lru_list, &dev_priv->mm.fence_list);
 
-               if (!obj->fenced_gpu_access && !obj->last_fenced_seqno)
-                       pipelined = NULL;
+               if (obj->tiling_changed) {
+                       ret = i915_gem_object_flush_fence(obj,
+                                                         pipelined,
+                                                         interruptible);
+                       if (ret)
+                               return ret;
+
+                       if (!obj->fenced_gpu_access && !obj->last_fenced_seqno)
+                               pipelined = NULL;
+
+                       if (pipelined) {
+                               reg->setup_seqno =
+                                       i915_gem_next_request_seqno(dev, pipelined);
+                               obj->last_fenced_seqno = reg->setup_seqno;
+                               obj->last_fenced_ring = pipelined;
+                       }
+
+                       goto update;
+               }
 
                if (!pipelined) {
                        if (reg->setup_seqno) {
@@ -2570,31 +2587,6 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj,
                                                          interruptible);
                        if (ret)
                                return ret;
-               } else if (obj->tiling_changed) {
-                       if (obj->fenced_gpu_access) {
-                               if (obj->base.write_domain & I915_GEM_GPU_DOMAINS) {
-                                       ret = i915_gem_flush_ring(obj->base.dev, obj->ring,
-                                                                 0, obj->base.write_domain);
-                                       if (ret)
-                                               return ret;
-                               }
-
-                               obj->fenced_gpu_access = false;
-                       }
-               }
-
-               if (!obj->fenced_gpu_access && !obj->last_fenced_seqno)
-                       pipelined = NULL;
-               BUG_ON(!pipelined && reg->setup_seqno);
-
-               if (obj->tiling_changed) {
-                       if (pipelined) {
-                               reg->setup_seqno =
-                                       i915_gem_next_request_seqno(dev, pipelined);
-                               obj->last_fenced_seqno = reg->setup_seqno;
-                               obj->last_fenced_ring = pipelined;
-                       }
-                       goto update;
                }
 
                return 0;