Commit 74e4b909 authored by Jason Ekstrand's avatar Jason Ekstrand Committed by Daniel Vetter
Browse files

drm/i915: Stop storing the ring size in the ring pointer (v3)



Previously, we were storing the ring size in the ring pointer before it
was actually allocated.  We would then guard setting the ring size on
checking for CONTEXT_ALLOC_BIT.  This is error-prone at best and really
only saves us a few bytes on something that already burns at least 4K.
Instead, this patch adds a new ring_size field and makes everything use
that.

v2 (Daniel Vetter):
 - Replace 512 * SZ_4K with SZ_2M

v2 (Jason Ekstrand):
 - Rebase on top of page migration code

Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210708154835.528166-3-jason@jlekstrand.net
parent fe4751c3
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -211,8 +211,7 @@ static void intel_context_set_gem(struct intel_context *ce,
	GEM_BUG_ON(rcu_access_pointer(ce->gem_context));
	RCU_INIT_POINTER(ce->gem_context, ctx);

	if (!test_bit(CONTEXT_ALLOC_BIT, &ce->flags))
		ce->ring = __intel_context_ring_size(SZ_16K);
	ce->ring_size = SZ_16K;

	if (rcu_access_pointer(ctx->vm)) {
		struct i915_address_space *vm;
+2 −1
Original line number Diff line number Diff line
@@ -371,7 +371,8 @@ intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine)
	ce->engine = engine;
	ce->ops = engine->cops;
	ce->sseu = engine->sseu;
	ce->ring = __intel_context_ring_size(SZ_4K);
	ce->ring = NULL;
	ce->ring_size = SZ_4K;

	ewma_runtime_init(&ce->runtime.avg);

+0 −5
Original line number Diff line number Diff line
@@ -175,11 +175,6 @@ int intel_context_prepare_remote_request(struct intel_context *ce,

struct i915_request *intel_context_create_request(struct intel_context *ce);

static inline struct intel_ring *__intel_context_ring_size(u64 sz)
{
	return u64_to_ptr(struct intel_ring, sz);
}

static inline bool intel_context_is_barrier(const struct intel_context *ce)
{
	return test_bit(CONTEXT_BARRIER_BIT, &ce->flags);
+1 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ struct intel_context {
	spinlock_t signal_lock; /* protects signals, the list of requests */

	struct i915_vma *state;
	u32 ring_size;
	struct intel_ring *ring;
	struct intel_timeline *timeline;

+2 −1
Original line number Diff line number Diff line
@@ -807,7 +807,8 @@ intel_engine_create_pinned_context(struct intel_engine_cs *engine,

	__set_bit(CONTEXT_BARRIER_BIT, &ce->flags);
	ce->timeline = page_pack_bits(NULL, hwsp);
	ce->ring = __intel_context_ring_size(ring_size);
	ce->ring = NULL;
	ce->ring_size = ring_size;

	i915_vm_put(ce->vm);
	ce->vm = i915_vm_get(vm);
Loading