From: Ben Widawsky <ben@bwidawsk.net>
To: Keith Packard <keithp@keithp.com>
Cc: intel-gfx@lists.freedesktop.org, Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 1/4] drm/i915: relative_constants_mode race fix
Date: Mon, 12 Dec 2011 19:21:57 -0800 [thread overview]
Message-ID: <1323746520-5592-2-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1323746520-5592-1-git-send-email-ben@bwidawsk.net>
dev_priv keeps track of the current addressing mode that gets set at
execbuffer time. Unfortunately the existing code was doing this before
acquiring struct_mutex which leaves a race with another thread also
doing an execbuffer. If that wasn't bad enough, relocate_slow drops
struct_mutex which opens a much more likely error where another thread
comes in and modifies the state while relocate_slow is being slow.
The solution here is to just defer setting this state until we
absolutely need it, and we know we'll have struct_mutex for the
remainder of our code path.
v2: Keith noticed a bug in the original patch.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 29 +++++++++++++++------------
1 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 3693e83..be0e3bc 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1016,19 +1016,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
if (INTEL_INFO(dev)->gen > 5 &&
mode == I915_EXEC_CONSTANTS_REL_SURFACE)
return -EINVAL;
-
- ret = intel_ring_begin(ring, 4);
- if (ret)
- return ret;
-
- intel_ring_emit(ring, MI_NOOP);
- intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
- intel_ring_emit(ring, INSTPM);
- intel_ring_emit(ring,
- I915_EXEC_CONSTANTS_MASK << 16 | mode);
- intel_ring_advance(ring);
-
- dev_priv->relative_constants_mode = mode;
}
break;
default:
@@ -1159,6 +1146,22 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
}
}
+ if (ring == &dev_priv->ring[RCS] &&
+ mode != dev_priv->relative_constants_mode) {
+ ret = intel_ring_begin(ring, 4);
+ if (ret)
+ goto err;
+
+ intel_ring_emit(ring, MI_NOOP);
+ intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
+ intel_ring_emit(ring, INSTPM);
+ intel_ring_emit(ring,
+ I915_EXEC_CONSTANTS_MASK << 16 | mode);
+ intel_ring_advance(ring);
+
+ dev_priv->relative_constants_mode = mode;
+ }
+
trace_i915_gem_ring_dispatch(ring, seqno);
exec_start = batch_obj->gtt_offset + args->batch_start_offset;
--
1.7.8
next prev parent reply other threads:[~2011-12-13 3:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-13 3:21 [PATCH 0/4] patches for -next Ben Widawsky
2011-12-13 3:21 ` Ben Widawsky [this message]
2011-12-13 3:21 ` [PATCH 2/4] drm/i915: Force sync command ordering (Gen6+) Ben Widawsky
2011-12-13 3:21 ` [PATCH 3/4] drm/i915: Update GEN6_RP_CONTROL definitions Ben Widawsky
2011-12-13 19:38 ` Jesse Barnes
2011-12-14 19:13 ` Eugeni Dodonov
2011-12-13 3:22 ` [PATCH 4/4] drm/i915: drpc debugfs update for gen6 Ben Widawsky
2011-12-13 3:36 ` Ben Widawsky
2011-12-13 19:37 ` Jesse Barnes
2011-12-14 19:13 ` Eugeni Dodonov
2011-12-13 3:34 ` [PATCH 4/4 v2] " Ben Widawsky
-- strict thread matches above, loose matches on Subject: below --
2011-10-12 4:43 [PATCH 0/5] execbuffer cleanups + fixes Ben Widawsky
2011-10-12 22:56 ` [PATCH 0/4] pre-v2 series Ben Widawsky
2011-10-12 22:56 ` [PATCH 1/4] drm/i915: relative_constants_mode race fix Ben Widawsky
2011-10-13 8:35 ` Daniel Vetter
2011-10-13 17:25 ` 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=1323746520-5592-2-git-send-email-ben@bwidawsk.net \
--to=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=keithp@keithp.com \
/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