Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Strip out internal priorities

Since we are not using any internal priority levels, and in the next few
patches will introduce a new index for which the optimisation is not so
lear cut, discard the small table within the priolist.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Andi Shyti <andi.shyti@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210120121439.17600-1-chris@chris-wilson.co.uk
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

authored by

Chris Wilson and committed by
Daniel Vetter
2867ff6c 06debd6e

+20 -87
+1 -1
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c
··· 125 125 * low latency and no jitter] the chance to naturally 126 126 * complete before being preempted. 127 127 */ 128 - attr.priority = I915_PRIORITY_MASK; 128 + attr.priority = 0; 129 129 if (rq->sched.attr.priority >= attr.priority) 130 130 attr.priority |= I915_USER_PRIORITY(I915_PRIORITY_HEARTBEAT); 131 131 if (rq->sched.attr.priority >= attr.priority)
+5 -17
drivers/gpu/drm/i915/gt/intel_execlists_submission.c
··· 274 274 275 275 static int queue_prio(const struct intel_engine_execlists *execlists) 276 276 { 277 - struct i915_priolist *p; 278 277 struct rb_node *rb; 279 278 280 279 rb = rb_first_cached(&execlists->queue); 281 280 if (!rb) 282 281 return INT_MIN; 283 282 284 - /* 285 - * As the priolist[] are inverted, with the highest priority in [0], 286 - * we have to flip the index value to become priority. 287 - */ 288 - p = to_priolist(rb); 289 - if (!I915_USER_PRIORITY_SHIFT) 290 - return p->priority; 291 - 292 - return ((p->priority + 1) << I915_USER_PRIORITY_SHIFT) - ffs(p->used); 283 + return to_priolist(rb)->priority; 293 284 } 294 285 295 286 static int virtual_prio(const struct intel_engine_execlists *el) ··· 1443 1452 while ((rb = rb_first_cached(&execlists->queue))) { 1444 1453 struct i915_priolist *p = to_priolist(rb); 1445 1454 struct i915_request *rq, *rn; 1446 - int i; 1447 1455 1448 - priolist_for_each_request_consume(rq, rn, p, i) { 1456 + priolist_for_each_request_consume(rq, rn, p) { 1449 1457 bool merge = true; 1450 1458 1451 1459 /* ··· 2958 2968 /* Flush the queued requests to the timeline list (for retiring). */ 2959 2969 while ((rb = rb_first_cached(&execlists->queue))) { 2960 2970 struct i915_priolist *p = to_priolist(rb); 2961 - int i; 2962 2971 2963 - priolist_for_each_request_consume(rq, rn, p, i) { 2972 + priolist_for_each_request_consume(rq, rn, p) { 2964 2973 i915_request_mark_eio(rq); 2965 2974 __i915_request_submit(rq); 2966 2975 } ··· 3233 3244 3234 3245 static struct list_head *virtual_queue(struct virtual_engine *ve) 3235 3246 { 3236 - return &ve->base.execlists.default_priolist.requests[0]; 3247 + return &ve->base.execlists.default_priolist.requests; 3237 3248 } 3238 3249 3239 3250 static void rcu_virtual_context_destroy(struct work_struct *wrk) ··· 3829 3840 count = 0; 3830 3841 for (rb = rb_first_cached(&execlists->queue); rb; rb = rb_next(rb)) { 3831 3842 struct i915_priolist *p = rb_entry(rb, typeof(*p), node); 3832 - int i; 3833 3843 3834 - priolist_for_each_request(rq, p, i) { 3844 + priolist_for_each_request(rq, p) { 3835 3845 if (count++ < max - 1) 3836 3846 show_request(m, rq, "\t\t", 0); 3837 3847 else
-1
drivers/gpu/drm/i915/gt/selftest_execlists.c
··· 1081 1081 1082 1082 intel_ring_advance(rq, cs); 1083 1083 1084 - rq->sched.attr.priority = I915_PRIORITY_MASK; 1085 1084 err = 0; 1086 1085 err: 1087 1086 i915_request_get(rq);
-1
drivers/gpu/drm/i915/gt/selftest_lrc.c
··· 733 733 734 734 intel_ring_advance(rq, cs); 735 735 736 - rq->sched.attr.priority = I915_PRIORITY_MASK; 737 736 err = 0; 738 737 err: 739 738 i915_request_get(rq);
+2 -4
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
··· 206 206 while ((rb = rb_first_cached(&execlists->queue))) { 207 207 struct i915_priolist *p = to_priolist(rb); 208 208 struct i915_request *rq, *rn; 209 - int i; 210 209 211 - priolist_for_each_request_consume(rq, rn, p, i) { 210 + priolist_for_each_request_consume(rq, rn, p) { 212 211 if (last && rq->context != last->context) { 213 212 if (port == last_port) 214 213 goto done; ··· 360 361 /* Flush the queued requests to the timeline list (for retiring). */ 361 362 while ((rb = rb_first_cached(&execlists->queue))) { 362 363 struct i915_priolist *p = to_priolist(rb); 363 - int i; 364 364 365 - priolist_for_each_request_consume(rq, rn, p, i) { 365 + priolist_for_each_request_consume(rq, rn, p) { 366 366 list_del_init(&rq->sched.link); 367 367 __i915_request_submit(rq); 368 368 dma_fence_set_error(&rq->fence, -EIO);
+2 -6
drivers/gpu/drm/i915/i915_priolist_types.h
··· 27 27 #define I915_USER_PRIORITY_SHIFT 0 28 28 #define I915_USER_PRIORITY(x) ((x) << I915_USER_PRIORITY_SHIFT) 29 29 30 - #define I915_PRIORITY_COUNT BIT(I915_USER_PRIORITY_SHIFT) 31 - #define I915_PRIORITY_MASK (I915_PRIORITY_COUNT - 1) 32 - 33 30 /* Smallest priority value that cannot be bumped. */ 34 - #define I915_PRIORITY_INVALID (INT_MIN | (u8)I915_PRIORITY_MASK) 31 + #define I915_PRIORITY_INVALID (INT_MIN) 35 32 36 33 /* 37 34 * Requests containing performance queries must not be preempted by ··· 42 45 #define I915_PRIORITY_BARRIER (I915_PRIORITY_UNPREEMPTABLE - 1) 43 46 44 47 struct i915_priolist { 45 - struct list_head requests[I915_PRIORITY_COUNT]; 48 + struct list_head requests; 46 49 struct rb_node node; 47 - unsigned long used; 48 50 int priority; 49 51 }; 50 52
+6 -45
drivers/gpu/drm/i915/i915_scheduler.c
··· 43 43 static void assert_priolists(struct intel_engine_execlists * const execlists) 44 44 { 45 45 struct rb_node *rb; 46 - long last_prio, i; 46 + long last_prio; 47 47 48 48 if (!IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)) 49 49 return; ··· 57 57 58 58 GEM_BUG_ON(p->priority > last_prio); 59 59 last_prio = p->priority; 60 - 61 - GEM_BUG_ON(!p->used); 62 - for (i = 0; i < ARRAY_SIZE(p->requests); i++) { 63 - if (list_empty(&p->requests[i])) 64 - continue; 65 - 66 - GEM_BUG_ON(!(p->used & BIT(i))); 67 - } 68 60 } 69 61 } 70 62 ··· 67 75 struct i915_priolist *p; 68 76 struct rb_node **parent, *rb; 69 77 bool first = true; 70 - int idx, i; 71 78 72 79 lockdep_assert_held(&engine->active.lock); 73 80 assert_priolists(execlists); 74 81 75 - /* buckets sorted from highest [in slot 0] to lowest priority */ 76 - idx = I915_PRIORITY_COUNT - (prio & I915_PRIORITY_MASK) - 1; 77 82 prio >>= I915_USER_PRIORITY_SHIFT; 78 83 if (unlikely(execlists->no_priolist)) 79 84 prio = I915_PRIORITY_NORMAL; ··· 88 99 parent = &rb->rb_right; 89 100 first = false; 90 101 } else { 91 - goto out; 102 + return &p->requests; 92 103 } 93 104 } 94 105 ··· 114 125 } 115 126 116 127 p->priority = prio; 117 - for (i = 0; i < ARRAY_SIZE(p->requests); i++) 118 - INIT_LIST_HEAD(&p->requests[i]); 128 + INIT_LIST_HEAD(&p->requests); 129 + 119 130 rb_link_node(&p->node, rb, parent); 120 131 rb_insert_color_cached(&p->node, &execlists->queue, first); 121 - p->used = 0; 122 132 123 - out: 124 - p->used |= BIT(idx); 125 - return &p->requests[idx]; 133 + return &p->requests; 126 134 } 127 135 128 136 void __i915_priolist_free(struct i915_priolist *p) ··· 349 363 spin_unlock_irq(&schedule_lock); 350 364 } 351 365 352 - static void __bump_priority(struct i915_sched_node *node, unsigned int bump) 353 - { 354 - struct i915_sched_attr attr = node->attr; 355 - 356 - if (attr.priority & bump) 357 - return; 358 - 359 - attr.priority |= bump; 360 - __i915_schedule(node, &attr); 361 - } 362 - 363 - void i915_schedule_bump_priority(struct i915_request *rq, unsigned int bump) 364 - { 365 - unsigned long flags; 366 - 367 - GEM_BUG_ON(bump & ~I915_PRIORITY_MASK); 368 - if (READ_ONCE(rq->sched.attr.priority) & bump) 369 - return; 370 - 371 - spin_lock_irqsave(&schedule_lock, flags); 372 - __bump_priority(&rq->sched, bump); 373 - spin_unlock_irqrestore(&schedule_lock, flags); 374 - } 375 - 376 366 void i915_sched_node_init(struct i915_sched_node *node) 377 367 { 378 368 INIT_LIST_HEAD(&node->signalers_list); ··· 515 553 if (!global.slab_dependencies) 516 554 return -ENOMEM; 517 555 518 - global.slab_priorities = KMEM_CACHE(i915_priolist, 519 - SLAB_HWCACHE_ALIGN); 556 + global.slab_priorities = KMEM_CACHE(i915_priolist, 0); 520 557 if (!global.slab_priorities) 521 558 goto err_priorities; 522 559
+4 -12
drivers/gpu/drm/i915/i915_scheduler.h
··· 15 15 16 16 struct drm_printer; 17 17 18 - #define priolist_for_each_request(it, plist, idx) \ 19 - for (idx = 0; idx < ARRAY_SIZE((plist)->requests); idx++) \ 20 - list_for_each_entry(it, &(plist)->requests[idx], sched.link) 18 + #define priolist_for_each_request(it, plist) \ 19 + list_for_each_entry(it, &(plist)->requests, sched.link) 21 20 22 - #define priolist_for_each_request_consume(it, n, plist, idx) \ 23 - for (; \ 24 - (plist)->used ? (idx = __ffs((plist)->used)), 1 : 0; \ 25 - (plist)->used &= ~BIT(idx)) \ 26 - list_for_each_entry_safe(it, n, \ 27 - &(plist)->requests[idx], \ 28 - sched.link) 21 + #define priolist_for_each_request_consume(it, n, plist) \ 22 + list_for_each_entry_safe(it, n, &(plist)->requests, sched.link) 29 23 30 24 void i915_sched_node_init(struct i915_sched_node *node); 31 25 void i915_sched_node_reinit(struct i915_sched_node *node); ··· 37 43 38 44 void i915_schedule(struct i915_request *request, 39 45 const struct i915_sched_attr *attr); 40 - 41 - void i915_schedule_bump_priority(struct i915_request *rq, unsigned int bump); 42 46 43 47 struct list_head * 44 48 i915_sched_lookup_priolist(struct intel_engine_cs *engine, int prio);