]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Stop storing the ring size in the ring pointer (v3)
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 8 Jul 2021 15:48:07 +0000 (10:48 -0500)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 8 Jul 2021 17:43:35 +0000 (19:43 +0200)
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: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210708154835.528166-3-jason@jlekstrand.net
drivers/gpu/drm/i915/gem/i915_gem_context.c
drivers/gpu/drm/i915/gt/intel_context.c
drivers/gpu/drm/i915/gt/intel_context.h
drivers/gpu/drm/i915/gt/intel_context_types.h
drivers/gpu/drm/i915/gt/intel_engine_cs.c
drivers/gpu/drm/i915/gt/intel_lrc.c
drivers/gpu/drm/i915/gt/intel_migrate.c
drivers/gpu/drm/i915/gt/selftest_execlists.c
drivers/gpu/drm/i915/gt/selftest_mocs.c
drivers/gpu/drm/i915/gt/selftest_timeline.c
drivers/gpu/drm/i915/gvt/scheduler.c

index ddc3cc3f8f092ded5626e59ea429deecd897546f..a4faf06022d5a280e26508260d06f3906674bb32 100644 (file)
@@ -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;
index 4033184f13b9fe9474443dd5f4bf30e3631a8330..bd63813c8a802537ca609f058bde00d3849a2b19 100644 (file)
@@ -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);
 
index f83a73a2b39fc239006413a2a90deac00247a3f6..b10cbe8fee9923f8e2a62572d2a4515d6936bb02 100644 (file)
@@ -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);
index ed8c447a7346ba433f7f947c3713cb27d1db5d36..90026c17710553ebee56cde9bd3fb0185c9324c2 100644 (file)
@@ -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;
 
index 5ca3d16643353b8cf7adb47865ec175fdcd7e91a..d561573ed98c25291b6fac512c4fd71d8bacd081 100644 (file)
@@ -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);
index a27bac0a4bfb8bdb3baef7f43279640ebd46e087..8ada1afe3d2292e9c53e03790f97c18cacee0922 100644 (file)
@@ -845,7 +845,7 @@ int lrc_alloc(struct intel_context *ce, struct intel_engine_cs *engine)
        if (IS_ERR(vma))
                return PTR_ERR(vma);
 
-       ring = intel_engine_create_ring(engine, (unsigned long)ce->ring);
+       ring = intel_engine_create_ring(engine, ce->ring_size);
        if (IS_ERR(ring)) {
                err = PTR_ERR(ring);
                goto err_vma;
index 14afa1974ea59e8e709156dbae8b61f6c8d8ceb0..d0a7c934fd3bbfa86c5289e4ffbbfdd8765bdf5b 100644 (file)
@@ -232,7 +232,8 @@ struct intel_context *intel_migrate_create_context(struct intel_migrate *m)
        if (IS_ERR(ce))
                return ce;
 
-       ce->ring = __intel_context_ring_size(SZ_256K);
+       ce->ring = NULL;
+       ce->ring_size = SZ_256K;
 
        i915_vm_put(ce->vm);
        ce->vm = i915_vm_get(m->context->vm);
index 08896ae027d5566f45c57c50341732f97f925c3a..d790b8b946ed914c8b75f8c9634c7536682fc260 100644 (file)
@@ -2810,7 +2810,7 @@ static int __live_preempt_ring(struct intel_engine_cs *engine,
                        goto err_ce;
                }
 
-               tmp->ring = __intel_context_ring_size(ring_sz);
+               tmp->ring_size = ring_sz;
 
                err = intel_context_pin(tmp);
                if (err) {
index b9bb0e6e97f7f9a9eac30ea9c4e06b5fe714902c..8763bbeca0f7779ade539f64ca4fd695054e8181 100644 (file)
@@ -28,7 +28,7 @@ static struct intel_context *mocs_context_create(struct intel_engine_cs *engine)
                return ce;
 
        /* We build large requests to read the registers from the ring */
-       ce->ring = __intel_context_ring_size(SZ_16K);
+       ce->ring_size = SZ_16K;
 
        return ce;
 }
index 64da0c91dec1d1d8754e20483571ec2c52b47890..d0b6a3afcf44e0c1028c780b9c4049359b4bced5 100644 (file)
@@ -874,7 +874,7 @@ static int create_watcher(struct hwsp_watcher *w,
        if (IS_ERR(ce))
                return PTR_ERR(ce);
 
-       ce->ring = __intel_context_ring_size(ringsz);
+       ce->ring_size = ringsz;
        w->rq = intel_context_create_request(ce);
        intel_context_put(ce);
        if (IS_ERR(w->rq))
index 734c37c5e34743752538d20493b6b090bd8e1403..b56a8e37a3cd6acc794f8e36bfb89337153b101a 100644 (file)
@@ -1409,11 +1409,8 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
                intel_context_set_single_submission(ce);
 
                /* Max ring buffer size */
-               if (!intel_uc_wants_guc_submission(&engine->gt->uc)) {
-                       const unsigned int ring_size = 512 * SZ_4K;
-
-                       ce->ring = __intel_context_ring_size(ring_size);
-               }
+               if (!intel_uc_wants_guc_submission(&engine->gt->uc))
+                       ce->ring_size = SZ_2M;
 
                s->shadow[i] = ce;
        }