[Intel-gfx] [PATCH 19/33] drm/i915: Only clflush the context object when binding
Chris Wilson
chris at chris-wilson.co.uk
Sun Aug 7 14:45:27 UTC 2016
We know that the only access to the context object is via the GPU, and
the only time when it can be out of the GPU domain is when it is swapped
out and unbound. Therefore we only need to clflush the object when
binding.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem_context.c | 12 +++++++-----
drivers/gpu/drm/i915/intel_ringbuffer.c | 4 ++++
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index aa0419faeb34..5d42fee75464 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -771,6 +771,13 @@ static int do_rcs_switch(struct drm_i915_gem_request *req)
if (skip_rcs_switch(ppgtt, engine, to))
return 0;
+ if (!(to->engine[RCS].state->flags & I915_VMA_GLOBAL_BIND)) {
+ ret = i915_gem_object_set_to_gtt_domain(to->engine[RCS].state->obj,
+ false);
+ if (ret)
+ return ret;
+ }
+
/* Trying to pin first makes error handling easier. */
ret = i915_vma_pin(to->engine[RCS].state,
0, to->ggtt_alignment,
@@ -790,11 +797,6 @@ static int do_rcs_switch(struct drm_i915_gem_request *req)
/*
* Clear this page out of any CPU caches for coherent swap-in/out.
*/
- ret = i915_gem_object_set_to_gtt_domain(to->engine[RCS].state->obj,
- false);
- if (ret)
- goto unpin_vma;
-
if (needs_pd_load_pre(ppgtt, engine, to)) {
/* Older GENs and non render rings still want the load first,
* "PP_DCLV followed by PP_DIR_BASE register through Load
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 5a383430e91d..f24e4e83afd7 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2092,6 +2092,10 @@ static int intel_ring_context_pin(struct i915_gem_context *ctx,
return 0;
if (ce->state) {
+ ret = i915_gem_object_set_to_gtt_domain(ce->state->obj, false);
+ if (ret)
+ goto error;
+
ret = i915_vma_pin(ce->state, 0, ctx->ggtt_alignment,
PIN_GLOBAL | PIN_HIGH);
if (ret)
--
2.8.1
More information about the Intel-gfx
mailing list