aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-07-09 04:22:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-04 04:51:09 -0400
commitc33535efc0e1a637a7dbad918e1a0bf5a692dcdd (patch)
tree2e51f1686efdb531d14b6f89db3d048d6f4862a1
parent5ac4dd137c34860870e0c0438180c2836053eadf (diff)
drm/i915: Fix write-read race with multiple rings
commit 02978ff57a5bdfbf703d2bc5a4d933a53ede3144 upstream. Daniel noticed a problem where is we wrote to an object with ring A in the middle of a very long running batch, then executed a quick batch on ring B before a batch that reads from the same object, its obj->ring would now point to ring B, but its last_write_seqno would be still relative to ring A. This would allow for the user to read from the object before the GPU had completed the write, as set_domain would only check that ring B had passed the last_write_seqno. To fix this simply (and inelegantly), we bump the last_write_seqno when switching rings so that the last_write_seqno is always relative to the current obj->ring. This fixes igt/tests/gem_write_read_ring_switch. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> [danvet: Add note about the newly created igt which exercises this bug.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 34118b0c02d1..890f5c11880b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1881,6 +1881,10 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
1881 u32 seqno = intel_ring_get_seqno(ring); 1881 u32 seqno = intel_ring_get_seqno(ring);
1882 1882
1883 BUG_ON(ring == NULL); 1883 BUG_ON(ring == NULL);
1884 if (obj->ring != ring && obj->last_write_seqno) {
1885 /* Keep the seqno relative to the current ring */
1886 obj->last_write_seqno = seqno;
1887 }
1884 obj->ring = ring; 1888 obj->ring = ring;
1885 1889
1886 /* Add a reference if we're newly entering the active list. */ 1890 /* Add a reference if we're newly entering the active list. */