Commit 46470fc9 authored by Mika Kuoppala's avatar Mika Kuoppala Committed by Daniel Vetter

drm/i915: Add null state batch to active list

for proper refcounting to take place as we use
i915_add_request() for it.

i915_add_request() also takes the context for the request
from ring->last_context so move the null state batch
submission after the ring context has been set.

v2: we need to check for correct ring now (Ville Syrjälä)
v3: no need to expose i915_gem_move_object_to_active (Chris Wilson)
v4: cargoculted vma/active/inactive error handling removed (Chris Wilson)

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: default avatarMika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent d3eaf884
...@@ -700,21 +700,21 @@ static int do_switch(struct intel_ring_buffer *ring, ...@@ -700,21 +700,21 @@ static int do_switch(struct intel_ring_buffer *ring,
/* obj is kept alive until the next request by its active ref */ /* obj is kept alive until the next request by its active ref */
i915_gem_object_ggtt_unpin(from->obj); i915_gem_object_ggtt_unpin(from->obj);
i915_gem_context_unreference(from); i915_gem_context_unreference(from);
} else {
if (to->is_initialized == false) {
ret = i915_gem_render_state_init(ring);
if (ret)
DRM_ERROR("init render state: %d\n", ret);
} }
}
to->is_initialized = true;
done: done:
i915_gem_context_reference(to); i915_gem_context_reference(to);
ring->last_context = to; ring->last_context = to;
to->last_ring = ring; to->last_ring = ring;
if (ring->id == RCS && !to->is_initialized && from == NULL) {
ret = i915_gem_render_state_init(ring);
if (ret)
DRM_ERROR("init render state: %d\n", ret);
}
to->is_initialized = true;
return 0; return 0;
unpin_out: unpin_out:
......
...@@ -164,9 +164,11 @@ int i915_gem_render_state_init(struct intel_ring_buffer *ring) ...@@ -164,9 +164,11 @@ int i915_gem_render_state_init(struct intel_ring_buffer *ring)
const int gen = INTEL_INFO(ring->dev)->gen; const int gen = INTEL_INFO(ring->dev)->gen;
struct i915_render_state *so; struct i915_render_state *so;
const struct intel_renderstate_rodata *rodata; const struct intel_renderstate_rodata *rodata;
u32 seqno;
int ret; int ret;
if (WARN_ON(ring->id != RCS))
return -ENOENT;
rodata = render_state_get_rodata(ring->dev, gen); rodata = render_state_get_rodata(ring->dev, gen);
if (rodata == NULL) if (rodata == NULL)
return 0; return 0;
...@@ -186,8 +188,10 @@ int i915_gem_render_state_init(struct intel_ring_buffer *ring) ...@@ -186,8 +188,10 @@ int i915_gem_render_state_init(struct intel_ring_buffer *ring)
if (ret) if (ret)
goto out; goto out;
ret = i915_add_request(ring, &seqno); i915_vma_move_to_active(i915_gem_obj_to_ggtt(so->obj), ring);
ret = __i915_add_request(ring, NULL, so->obj, NULL);
/* __i915_add_request moves object to inactive if it fails */
out: out:
render_state_free(so); render_state_free(so);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment