Skip to content

Commit 46470fc

Browse files
mikuintdanvet
authored andcommitted
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: Mika Kuoppala <mika.kuoppala@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent d3eaf88 commit 46470fc

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

drivers/gpu/drm/i915/i915_gem_context.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -700,21 +700,21 @@ static int do_switch(struct intel_ring_buffer *ring,
700700
/* obj is kept alive until the next request by its active ref */
701701
i915_gem_object_ggtt_unpin(from->obj);
702702
i915_gem_context_unreference(from);
703-
} else {
704-
if (to->is_initialized == false) {
705-
ret = i915_gem_render_state_init(ring);
706-
if (ret)
707-
DRM_ERROR("init render state: %d\n", ret);
708-
}
709703
}
710704

711-
to->is_initialized = true;
712-
713705
done:
714706
i915_gem_context_reference(to);
715707
ring->last_context = to;
716708
to->last_ring = ring;
717709

710+
if (ring->id == RCS && !to->is_initialized && from == NULL) {
711+
ret = i915_gem_render_state_init(ring);
712+
if (ret)
713+
DRM_ERROR("init render state: %d\n", ret);
714+
}
715+
716+
to->is_initialized = true;
717+
718718
return 0;
719719

720720
unpin_out:

drivers/gpu/drm/i915/i915_gem_render_state.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ int i915_gem_render_state_init(struct intel_ring_buffer *ring)
164164
const int gen = INTEL_INFO(ring->dev)->gen;
165165
struct i915_render_state *so;
166166
const struct intel_renderstate_rodata *rodata;
167-
u32 seqno;
168167
int ret;
169168

169+
if (WARN_ON(ring->id != RCS))
170+
return -ENOENT;
171+
170172
rodata = render_state_get_rodata(ring->dev, gen);
171173
if (rodata == NULL)
172174
return 0;
@@ -186,8 +188,10 @@ int i915_gem_render_state_init(struct intel_ring_buffer *ring)
186188
if (ret)
187189
goto out;
188190

189-
ret = i915_add_request(ring, &seqno);
191+
i915_vma_move_to_active(i915_gem_obj_to_ggtt(so->obj), ring);
190192

193+
ret = __i915_add_request(ring, NULL, so->obj, NULL);
194+
/* __i915_add_request moves object to inactive if it fails */
191195
out:
192196
render_state_free(so);
193197
return ret;

0 commit comments

Comments
 (0)