drm/i915/gt: Cancel submitted requests upon context reset
Subsystems (3)
PATCH 1/54 drm/i915/gt: Cancel submitted requests upon context reset
Since we process schedule-in of a context after submitting the request, if we decide to reset the context at that time, we also have to cancel the requets we have marked for submission.
--- .../drm/i915/gt/intel_execlists_submission.c | 22 ++++++++++++++----- drivers/gpu/drm/i915/i915_request.c | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +16 -6
@@ -215,22 +215,32 @@ static void mark_eio(struct i915_request *rq) }static struct i915_request * -active_request (const struct intel_timeline *const tl,struct i915_request *rq) +__active_request (const struct intel_timeline *const tl, +struct i915_request *rq, +int error) {struct i915_request *active = rq; -rcu_read_lock (); -list_for_each_entry_continue_reverse (rq, &tl->requests, link) { +list_for_each_entry_from_reverse (rq, &tl->requests, link) {if (__i915_request_is_complete (rq))break ; +if (error) { +i915_request_set_error_once (rq, error); +__i915_request_skip (rq); + } active = rq; } -rcu_read_unlock ();return active; } +static struct i915_request * +active_request (const struct intel_timeline *const tl,struct i915_request *rq) +{ +return __active_request (tl, rq,0 ); +} +static inline void ring_set_paused (const struct intel_engine_cs *engine,int state) {
@@ -487,14 +497,14 @@ static void reset_active(struct i915_request *rq,* remain correctly ordered. And we defer to __i915_request_submit() * so that all asynchronous waits are correctly handled. */ -ENGINE_TRACE (engine,"{ rq=%llx:%lld }\n" , +ENGINE_TRACE (engine,"{ reset rq=%llx:%lld }\n" , rq->fence.context, rq->fence.seqno);/* On resubmission of the active request, payload will be scrubbed */ if (__i915_request_is_complete (rq)) head = rq->tail;else - head =active_request (ce->timeline, rq)->head; + head =__active_request (ce->timeline, rq, -EIO )->head; head =intel_ring_wrap (ce->ring, head);/* Scrub the context image to prevent replaying the previous batch */
drivers/gpu/drm/i915/i915_request.c +2 -0
@@ -490,6 +490,8 @@ void __i915_request_skip(struct i915_request *rq)if (rq->infix == rq->postfix)return ; +RQ_TRACE (rq,"error: %d\n" , rq->fence.error); +/* * As this request likely depends on state from the lost * context, clear out all the user operations leaving the
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/54 drm/i915/gt: Pull context closure check from request submit to schedule-in
We only need to evaluate the current status of the context when it is scheduled in, we will force a reschedule when the context is closed propagating the change to inflight contexts.
--- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 4 ++++ drivers/gpu/drm/i915/i915_request.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +4 -0
@@ -522,6 +522,10 @@ __execlists_schedule_in(struct i915_request *rq)intel_context_get (ce); +if (unlikely (intel_context_is_closed (ce) && + !intel_engine_has_heartbeat (engine))) +intel_context_set_banned (ce); +if (unlikely (intel_context_is_banned (ce)))reset_active (rq, engine);
drivers/gpu/drm/i915/i915_request.c +0 -4
@@ -546,10 +546,6 @@ bool __i915_request_submit(struct i915_request *request)if (i915_request_completed (request)) goto xfer; -if (unlikely (intel_context_is_closed (request->context) && - !intel_engine_has_heartbeat (engine))) -intel_context_set_banned (request->context); -if (unlikely (intel_context_is_banned (request->context)))i915_request_set_error_once (request, -EIO );
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/54 drm/i915/gem: Peek at the inflight context
In reply to Chris WilsonIf supported by the backend, we can quickly look at the context's inflight engine rather than search along the active list to confirm.
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 3 +++ drivers/gpu/drm/i915/gt/intel_context.h | 10 ++++++++++ drivers/gpu/drm/i915/gt/intel_context_types.h | 9 +++++---- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 1 + 4 files changed, 19 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +3 -0
@@ -423,6 +423,9 @@ static struct intel_engine_cs *active_engine(struct intel_context *ce)struct intel_engine_cs *engine =NULL ;struct i915_request *rq; +if (intel_context_has_inflight (ce)) +return intel_context_inflight (ce); +if (!ce->timeline)return NULL ;
drivers/gpu/drm/i915/gt/intel_context.h +10 -0
@@ -191,6 +191,16 @@ static inline bool intel_context_is_closed(const struct intel_context *ce)return test_bit (CONTEXT_CLOSED_BIT , &ce->flags); } +static inline void intel_context_set_inflight (struct intel_context *ce) +{ +return __set_bit (CONTEXT_HAS_INFLIGHT , &ce->flags); +} + +static inline bool intel_context_has_inflight (const struct intel_context *ce) +{ +return test_bit (CONTEXT_HAS_INFLIGHT , &ce->flags); +} +static inline bool intel_context_use_semaphores (const struct intel_context *ce) {return test_bit (CONTEXT_USE_SEMAPHORES , &ce->flags);
drivers/gpu/drm/i915/gt/intel_context_types.h +5 -4
@@ -87,10 +87,11 @@ struct intel_context {#define CONTEXT_ALLOC_BIT 1#define CONTEXT_VALID_BIT 2#define CONTEXT_CLOSED_BIT 3 -#define CONTEXT_USE_SEMAPHORES 4 -#define CONTEXT_BANNED 5 -#define CONTEXT_FORCE_SINGLE_SUBMISSION 6 -#define CONTEXT_NOPREEMPT 7 +#define CONTEXT_HAS_INFLIGHT 4 +#define CONTEXT_USE_SEMAPHORES 5 +#define CONTEXT_BANNED 6 +#define CONTEXT_FORCE_SINGLE_SUBMISSION 7 +#define CONTEXT_NOPREEMPT 8u32 *lrc_reg_state;union {
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +1 -0
@@ -2532,6 +2532,7 @@ static int __execlists_context_alloc(struct intel_context *ce,if (err) goto err_lrc; +intel_context_set_inflight (ce);return 0 ; err_lrc:
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 03/54] drm/i915/gem: Peek at the inflight context
Hi Chris,
Quoted 4 lines · Chris Wilson
If supported by the backend, we can quickly look at the context's inflight engine rather than search along the active list to confirm.
Signed-off-by Chris Wilson <[email protected]>
Thanks,
Andi
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/54 drm/i915: Mark up protected uses of 'i915_request_completed'
In reply to Chris WilsonWhen we know that we are inside the timeline mutex, or inside the submission flow (under active.lock or the holder's rcu lock), we know that the rq->hwsp is stable and we can use the simpler direct version.
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 4 ++-- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/intel_reset.c | 3 +-- drivers/gpu/drm/i915/gt/intel_ring_submission.c | 4 +++- drivers/gpu/drm/i915/gt/intel_timeline.c | 4 ++-- drivers/gpu/drm/i915/i915_request.c | 15 +++++++-------- 7 files changed, 17 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +1 -1
@@ -408,7 +408,7 @@ __active_engine(struct i915_request *rq, struct intel_engine_cs **active) }if (i915_request_is_active (rq)) { -if (!i915_request_completed (rq)) +if (!__i915_request_is_complete (rq)) *active = locked; ret = true; }
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c +2 -2
@@ -484,8 +484,8 @@ static void print_signals(struct intel_breadcrumbs *b, struct drm_printer *p)list_for_each_entry_rcu (rq, &ce->signals, signal_link)drm_printf (p,"\t[%llx:%llx%s] @ %dms\n" , rq->fence.context, rq->fence.seqno, -i915_request_completed (rq) ?"!" : -i915_request_started (rq) ?"*" : +__i915_request_is_complete (rq) ?"!" : +__i915_request_has_started (rq) ?"*" :"" ,jiffies_to_msecs (jiffies - rq->emitted_jiffies)); }
drivers/gpu/drm/i915/gt/intel_engine_cs.c +1 -1
@@ -1792,7 +1792,7 @@ intel_engine_find_active_request(struct intel_engine_cs *engine)struct intel_timeline *tl = request->context->timeline;list_for_each_entry_from_reverse (request, &tl->requests, link) { -if (i915_request_completed (request)) +if (__i915_request_is_complete (request))break ; active = request;
drivers/gpu/drm/i915/gt/intel_reset.c +1 -2
@@ -151,8 +151,7 @@ static void mark_innocent(struct i915_request *rq)void __i915_request_reset (struct i915_request *rq,bool guilty) {RQ_TRACE (rq,"guilty? %s\n" ,yesno (guilty)); - -GEM_BUG_ON (i915_request_completed (rq)); +GEM_BUG_ON (__i915_request_is_complete (rq));rcu_read_lock ();/* protect the GEM context */ if (guilty) {
drivers/gpu/drm/i915/gt/intel_ring_submission.c +3 -1
@@ -404,12 +404,14 @@ static void reset_rewind(struct intel_engine_cs *engine, bool stalled) rq =NULL ;spin_lock_irqsave (&engine->active.lock, flags); +rcu_read_lock ();list_for_each_entry (pos, &engine->active.requests, sched.link) { -if (!i915_request_completed (pos)) { +if (!__i915_request_is_complete (pos)) { rq = pos;break ; } } +rcu_read_unlock ();/* * The guilty request will get skipped on a hung engine.
drivers/gpu/drm/i915/gt/intel_timeline.c +2 -2
@@ -582,11 +582,11 @@ int intel_timeline_read_hwsp(struct i915_request *from,rcu_read_lock (); cl =rcu_dereference (from->hwsp_cacheline); -if (i915_request_completed (from))/* confirm cacheline is valid */ +if (i915_request_signaled (from))/* confirm cacheline is valid */ goto unlock;if (unlikely (!i915_active_acquire_if_busy (&cl->active))) goto unlock;/* seqno wrapped and completed! */ -if (unlikely (i915_request_completed (from))) +if (unlikely (__i915_request_is_complete (from))) goto release;rcu_read_unlock ();
drivers/gpu/drm/i915/i915_request.c +7 -8
@@ -276,7 +276,7 @@ static void remove_from_engine(struct i915_request *rq)bool i915_request_retire (struct i915_request *rq) { -if (!i915_request_completed (rq)) +if (!__i915_request_is_complete (rq))return false;RQ_TRACE (rq,"\n" );
@@ -344,8 +344,7 @@ void i915_request_retire_upto(struct i915_request *rq)struct i915_request *tmp;RQ_TRACE (rq,"\n" ); - -GEM_BUG_ON (!i915_request_completed (rq)); +GEM_BUG_ON (!__i915_request_is_complete (rq)); do { tmp = list_first_entry(&tl->requests, typeof(*tmp), link);
@@ -543,7 +542,7 @@ bool __i915_request_submit(struct i915_request *request)* dropped upon retiring. (Otherwise if resubmit a *retired* * request, this would be a horrible use-after-free.) */ -if (i915_request_completed (request)) +if (__i915_request_is_complete (request)) goto xfer;if (unlikely (intel_context_is_banned (request->context)))
@@ -643,7 +642,7 @@ void __i915_request_unsubmit(struct i915_request *request)i915_request_cancel_breadcrumb (request);/* We've already spun, don't charge on resubmitting. */ -if (request->sched.semaphores &&i915_request_started (request)) +if (request->sched.semaphores &&__i915_request_has_started (request)) request->sched.semaphores =0 ;/*
@@ -855,7 +854,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)RCU_INIT_POINTER (rq->timeline, tl);RCU_INIT_POINTER (rq->hwsp_cacheline, tl->hwsp_cacheline); rq->hwsp_seqno = tl->hwsp_seqno; -GEM_BUG_ON (i915_request_completed (rq)); +GEM_BUG_ON (__i915_request_is_complete (rq)); rq->rcustate =get_state_synchronize_rcu ();/* acts as smp_mb() */
@@ -969,7 +968,7 @@ i915_request_await_start(struct i915_request *rq, struct i915_request *signal)struct i915_request *prev;/* Confirm signal has not been retired, the link is valid */ -if (unlikely (i915_request_started (signal))) +if (unlikely (__i915_request_has_started (signal)))break ;/* Is signal the earliest request on its timeline? */
@@ -1511,7 +1510,7 @@ __i915_request_add_to_timeline(struct i915_request *rq)*/ prev =to_request (__i915_active_fence_set (&timeline->last_request, &rq->fence)); -if (prev && !i915_request_completed (prev)) { +if (prev && !__i915_request_is_complete (prev)) {/* * The requests are supposed to be kept in order. However, * we need to be wary in case the timeline->last_request
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 04/54] drm/i915: Mark up protected uses of 'i915_request_completed'
Hi Chris,
Quoted 5 lines
When we know that we are inside the timeline mutex, or inside the submission flow (under active.lock or the holder's rcu lock), we know that the
rq->hwspis stable and we can use the simpler direct version.Signed-off-by Chris Wilson <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 4 ++-- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/intel_reset.c | 3 +-- drivers/gpu/drm/i915/gt/intel_ring_submission.c | 4 +++- drivers/gpu/drm/i915/gt/intel_timeline.c | 4 ++-- drivers/gpu/drm/i915/i915_request.c | 15 +++++++-------- 7 files changed, 17 insertions(+), 17 deletions(-)
have you also missed a couple of cases in intel_execlists_submission.c and i915_scheduler.c?
[...]
drivers/gpu/drm/i915/gt/intel_reset.c static void mark_innocent(struct i915_request *rq) · line 154
Quoted 11 lines
drivers/gpu/drm/i915/gt/intel_reset.c +1
-2@@ -151,8 +151,7 @@ static void mark_innocent(struct i915_request *rq)void __i915_request_reset (struct i915_request *rq,bool guilty) {RQ_TRACE (rq,"guilty? %s\n" ,yesno (guilty)); - -GEM_BUG_ON (i915_request_completed (rq)); +GEM_BUG_ON (__i915_request_is_complete (rq));
aren't you outside the lock here?
Andi
drivers/gpu/drm/i915/gt/intel_reset.c static void mark_innocent(struct i915_request *rq) · line 157
Quoted 3 lines
drivers/gpu/drm/i915/gt/intel_reset.c +0
-0rcu_read_lock ();/* protect the GEM context */ if (guilty) {
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 04/54] drm/i915: Mark up protected uses of 'i915_request_completed'
Quoting Andi Shyti (2020-12-29 12:17:08)
Quoted 17 lines
Hi Chris,
Quoted 5 lines
When we know that we are inside the timeline mutex, or inside the submission flow (under active.lock or the holder's rcu lock), we know that the
rq->hwspis stable and we can use the simpler direct version.Signed-off-by Chris Wilson <[email protected]>Quoted 9 lines
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 4 ++-- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/intel_reset.c | 3 +-- drivers/gpu/drm/i915/gt/intel_ring_submission.c | 4 +++- drivers/gpu/drm/i915/gt/intel_timeline.c | 4 ++-- drivers/gpu/drm/i915/i915_request.c | 15 +++++++-------- 7 files changed, 17 insertions(+), 17 deletions(-)
Quoted 2 lines
have you also missed a couple of cases in
intel_execlists_submission.candi915_scheduler.c?
Yes. I dealt with those while updating those files. This patch was originally the fixup of the mainly protected request flow.
Quoted 15 lines
[...]
drivers/gpu/drm/i915/gt/intel_reset.c static void mark_innocent(struct i915_request *rq) · line 154
Quoted 11 lines
drivers/gpu/drm/i915/gt/intel_reset.c +1
-2@@ -151,8 +151,7 @@ static void mark_innocent(struct i915_request *rq)void __i915_request_reset (struct i915_request *rq,bool guilty) {RQ_TRACE (rq,"guilty? %s\n" ,yesno (guilty)); - -GEM_BUG_ON (i915_request_completed (rq)); +GEM_BUG_ON (__i915_request_is_complete (rq));aren't you outside the lock here?
This is inside the rcu read lock for the reset.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/54 drm/i915: Drop i915_request.lock serialisation around await_start
In reply to Chris WilsonOriginally, we used the signal->lock as a means of following the previous link in its timeline and peeking at the previous fence. However, we have replaced the explicit serialisation with a series of very careful probes that anticipate the links being deleted and the fences recycled before we are able to acquire a strong reference to it. We do not need the signal->lock crutch anymore, nor want the contention.
--- drivers/gpu/drm/i915/i915_request.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_request.c +8 -2
@@ -960,9 +960,16 @@ i915_request_await_start(struct i915_request *rq, struct i915_request *signal)if (i915_request_started (signal))return 0 ; +/* +* The caller holds a reference on @signal, but we do not serialise +* against it being retired and removed from the lists. +* +* We do not hold a reference to the request before @signal, and +* so must be very careful to ensure that it is not _recycled_ as +* we follow the link backwards. +*/ fence =NULL ;rcu_read_lock (); -spin_lock_irq (&signal->lock); do { struct list_head *pos = READ_ONCE(signal->link.prev); struct i915_request *prev;
@@ -993,7 +1000,6 @@ i915_request_await_start(struct i915_request *rq, struct i915_request *signal) fence = &prev->fence; }while (0 ); -spin_unlock_irq (&signal->lock);rcu_read_unlock ();if (!fence)return 0 ;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/54 drm/i915: Drop i915_request.lock requirement for intel_rps_boost()
In reply to Chris WilsonSince we use a flag within i915_request.flags to indicate when we have boosted the request (so that we only apply the boost) once, this can be used as the serialisation with i915_request_retire() to avoid having to explicitly take the i915_request.lock which is more heavily contended.
--- drivers/gpu/drm/i915/gt/intel_rps.c | 15 ++++++--------- drivers/gpu/drm/i915/i915_request.c | 4 +--- 2 files changed, 7 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gt/intel_rps.c +6 -9
@@ -917,17 +917,15 @@ void intel_rps_park(struct intel_rps *rps)void intel_rps_boost (struct i915_request *rq) { -struct intel_rps *rps = &READ_ONCE (rq->engine)->gt->rps; -unsigned long flags; - -if (i915_request_signaled (rq) || !intel_rps_is_active (rps)) +if (i915_request_signaled (rq) ||i915_request_has_waitboost (rq))return ;/* Serializes with i915_request_retire() */ -spin_lock_irqsave (&rq->lock, flags); -if (!i915_request_has_waitboost (rq) && - !dma_fence_is_signaled_locked (&rq->fence)) { -set_bit (I915_FENCE_FLAG_BOOST , &rq->fence.flags); +if (!test_and_set_bit (I915_FENCE_FLAG_BOOST , &rq->fence.flags)) { +struct intel_rps *rps = &READ_ONCE (rq->engine)->gt->rps; + +if (!intel_rps_is_active (rps)) +return ;GT_TRACE (rps_to_gt (rps),"boost fence:%llx:%llx\n" , rq->fence.context, rq->fence.seqno);
@@ -938,7 +936,6 @@ void intel_rps_boost(struct i915_request *rq)atomic_inc (&rps->boosts); } -spin_unlock_irqrestore (&rq->lock, flags); }int intel_rps_set (struct intel_rps *rps,u8 val)
drivers/gpu/drm/i915/i915_request.c +1 -3
@@ -307,10 +307,8 @@ bool i915_request_retire(struct i915_request *rq)spin_unlock_irq (&rq->lock); } -if (i915_request_has_waitboost (rq)) { -GEM_BUG_ON (!atomic_read (&rq->engine->gt->rps.num_waiters)); +if (test_and_set_bit (I915_FENCE_FLAG_BOOST , &rq->fence.flags))atomic_dec (&rq->engine->gt->rps.num_waiters); - }/* * We only loosely track inflight requests across preemption,
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 06/54] drm/i915: Drop i915_request.lock requirement for intel_rps_boost()
Quoted 40 lines · Chris Wilson
Since we use a flag within i915_request.flags to indicate when we have boosted the request (so that we only apply the boost) once, this can be used as the serialisation with
i915_request_retire()to avoid having to explicitly take the i915_request.lock which is more heavily contended.Signed-off-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/gt/intel_rps.c | 15 ++++++--------- drivers/gpu/drm/i915/i915_request.c | 4 +--- 2 files changed, 7 insertions(+), 12 deletions(-)drivers/gpu/drm/i915/gt/intel_rps.c +6
-8@@ -917,17 +917,15 @@ void intel_rps_park(struct intel_rps *rps)void intel_rps_boost (struct i915_request *rq) { -struct intel_rps *rps = &READ_ONCE (rq->engine)->gt->rps; -unsigned long flags; - -if (i915_request_signaled (rq) || !intel_rps_is_active (rps)) +if (i915_request_signaled (rq) ||i915_request_has_waitboost (rq))return ;/* Serializes with i915_request_retire() */ -spin_lock_irqsave (&rq->lock, flags); -if (!i915_request_has_waitboost (rq) && - !dma_fence_is_signaled_locked (&rq->fence)) { -set_bit (I915_FENCE_FLAG_BOOST , &rq->fence.flags); +if (!test_and_set_bit (I915_FENCE_FLAG_BOOST , &rq->fence.flags)) { +struct intel_rps *rps = &READ_ONCE (rq->engine)->gt->rps; + +if (!intel_rps_is_active (rps)) +return ;GT_TRACE (rps_to_gt (rps),"boost fence:%llx:%llx\n" , rq->fence.context, rq->fence.seqno);
drivers/gpu/drm/i915/gt/intel_rps.c void intel_rps_boost(struct i915_request *rq) · line 937
Quoted 2 lines
drivers/gpu/drm/i915/gt/intel_rps.c +0
-0@@ -938,7 +936,6 @@ void intel_rps_boost(struct i915_request *rq)atomic_inc (&rps->boosts);
Looks of it, this does not need to be atomic. But topic for another patch.
Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_rps.c +0
-1} -spin_unlock_irqrestore (&rq->lock, flags); }int intel_rps_set (struct intel_rps *rps,u8 val)drivers/gpu/drm/i915/i915_request.c +0
-0
drivers/gpu/drm/i915/i915_request.c bool i915_request_retire(struct i915_request *rq) · line 311
Quoted 7 lines
drivers/gpu/drm/i915/i915_request.c +1
-2@@ -307,10 +307,8 @@ bool i915_request_retire(struct i915_request *rq)spin_unlock_irq (&rq->lock); } -if (i915_request_has_waitboost (rq)) { -GEM_BUG_ON (!atomic_read (&rq->engine->gt->rps.num_waiters)); +if (test_and_set_bit (I915_FENCE_FLAG_BOOST , &rq->fence.flags))atomic_dec (&rq->engine->gt->rps.num_waiters);
This should keep the num_waiters in sync.
Quoted 11 lines
drivers/gpu/drm/i915/i915_request.c +0
-1- }/* * We only loosely track inflight requests across preemption, Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/54 drm/i915/gem: Reduce ctx->engine_mutex for reading the clone source
In reply to Chris WilsonWhen cloning the engines from the source context, we need to ensure that the engines are not freed as we copy them, and that the flags we clone from the source correspond with the engines we copy across. To do this we need only take a reference to the src->engines, rather than hold the src->engine_mutex, so long as we verify that nothing changed under the read.
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +15 -9
@@ -717,7 +717,8 @@ __create_context(struct drm_i915_private *i915) }static inline struct i915_gem_engines * -__context_engines_await (const struct i915_gem_context *ctx) +__context_engines_await (const struct i915_gem_context *ctx, +bool *user_engines) {struct i915_gem_engines *engines;
@@ -726,6 +727,10 @@ __context_engines_await(const struct i915_gem_context *ctx) engines =rcu_dereference (ctx->engines);GEM_BUG_ON (!engines); +if (user_engines) + *user_engines =i915_gem_context_user_engines (ctx); + +/* successful await => strong mb */ if (unlikely (!i915_sw_fence_await (&engines->fence)))continue ;
@@ -749,7 +754,7 @@ context_apply_all(struct i915_gem_context *ctx,struct intel_context *ce;int err =0 ; - e =__context_engines_await (ctx); + e =__context_engines_await (ctx,NULL );for_each_gem_engine (ce, e, it) { err =fn (ce, data);if (err)
@@ -1075,7 +1080,7 @@ static int context_barrier_task(struct i915_gem_context *ctx,return err; } - e =__context_engines_await (ctx); + e =__context_engines_await (ctx,NULL );if (!e) {i915_active_release (&cb->base);return -ENOENT ;
@@ -2095,11 +2100,14 @@ static int copy_ring_size(struct intel_context *dst,static int clone_engines (struct i915_gem_context *dst,struct i915_gem_context *src) { -struct i915_gem_engines *e =i915_gem_context_lock_engines (src); -struct i915_gem_engines *clone; +struct i915_gem_engines *clone, *e;bool user_engines;unsigned long n; + e =__context_engines_await (src, &user_engines); +if (!e) +return -ENOENT ; + clone =alloc_engines (e->num_engines);if (!clone) goto err_unlock;
@@ -2141,9 +2149,7 @@ static int clone_engines(struct i915_gem_context *dst, } } clone->num_engines = n; - - user_engines =i915_gem_context_user_engines (src); -i915_gem_context_unlock_engines (src); +i915_sw_fence_complete (&e->fence);/* Serialised by constructor */ engines_idle_release (dst,rcu_replace_pointer (dst->engines, clone,1 ));
@@ -2154,7 +2160,7 @@ static int clone_engines(struct i915_gem_context *dst,return 0 ; err_unlock: -i915_gem_context_unlock_engines (src); +i915_sw_fence_complete (&e->fence);return -ENOMEM ; }
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/54 drm/i915/gem: Reduce ctx->engines_mutex for get_engines()
In reply to Chris WilsonTake a snapshot of the ctx->engines, so we can avoid taking the ctx->engines_mutex for a mere read in get_engines().
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 39 +++++---------------- 1 file changed, 8 insertions(+), 31 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +8 -31
@@ -1843,27 +1843,6 @@ set_engines(struct i915_gem_context *ctx,return 0 ; } -static struct i915_gem_engines * -__copy_engines (struct i915_gem_engines *e) -{ -struct i915_gem_engines *copy; -unsigned int n; - - copy =alloc_engines (e->num_engines); -if (!copy) -return ERR_PTR (-ENOMEM ); - -for (n =0 ; n < e->num_engines; n++) { -if (e->engines[n]) - copy->engines[n] =intel_context_get (e->engines[n]); -else - copy->engines[n] =NULL ; - } - copy->num_engines = n; - -return copy; -} -static int get_engines (struct i915_gem_context *ctx,struct drm_i915_gem_context_param *args)
@@ -1871,19 +1850,17 @@ get_engines(struct i915_gem_context *ctx,struct i915_context_param_engines __user *user;struct i915_gem_engines *e;size_t n, count, size; +bool user_engines;int err =0 ; - err =mutex_lock_interruptible (&ctx->engines_mutex); -if (err) -return err; + e =__context_engines_await (ctx, &user_engines); +if (!e) +return -ENOENT ; - e =NULL ; -if (i915_gem_context_user_engines (ctx)) - e =__copy_engines (i915_gem_context_engines (ctx)); -mutex_unlock (&ctx->engines_mutex); -if (IS_ERR_OR_NULL (e)) { +if (!user_engines) { +i915_sw_fence_complete (&e->fence); args->size =0 ; -return PTR_ERR_OR_ZERO (e); +return 0 ; } count = e->num_engines;
@@ -1934,7 +1911,7 @@ get_engines(struct i915_gem_context *ctx, args->size = size; err_free: -free_engines (e); +i915_sw_fence_complete (&e->fence);return err; }
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/54 drm/i915: Reduce test_and_set_bit to set_bit in i915_request_submit()
In reply to Chris WilsonAvoid the full blown memory barrier of test_and_set_bit() by noting the completed request and removing it from the lists.
--- drivers/gpu/drm/i915/i915_request.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_request.c +9 -7
@@ -540,8 +540,10 @@ bool __i915_request_submit(struct i915_request *request)* dropped upon retiring. (Otherwise if resubmit a *retired* * request, this would be a horrible use-after-free.) */ -if (__i915_request_is_complete (request)) - goto xfer; +if (__i915_request_is_complete (request)) { +list_del_init (&request->sched.link); + goto active; + }if (unlikely (intel_context_is_banned (request->context)))i915_request_set_error_once (request, -EIO );
@@ -576,11 +578,11 @@ bool __i915_request_submit(struct i915_request *request) engine->serial++; result = true; -xfer: -if (!test_and_set_bit (I915_FENCE_FLAG_ACTIVE , &request->fence.flags)) { -list_move_tail (&request->sched.link, &engine->active.requests); -clear_bit (I915_FENCE_FLAG_PQUEUE , &request->fence.flags); - } +GEM_BUG_ON (test_bit (I915_FENCE_FLAG_ACTIVE , &request->fence.flags)); +list_move_tail (&request->sched.link, &engine->active.requests); +active: +clear_bit (I915_FENCE_FLAG_PQUEUE , &request->fence.flags); +set_bit (I915_FENCE_FLAG_ACTIVE , &request->fence.flags);/* * XXX Rollback bonded-execution on __i915_request_unsubmit()?
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/54 drm/i915/gt: Drop atomic for engine->fw_active tracking
In reply to Chris WilsonSince schedule-in/out is now entirely serialised by the tasklet bitlock, we do not need to worry about concurrent in/out operations and so reduce the atomic operations to plain instructions.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/intel_engine_types.h | 2 +- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +1 -1
@@ -1657,7 +1657,7 @@ void intel_engine_dump(struct intel_engine_cs *engine,ktime_to_ms (intel_engine_get_busy_time (engine, &dummy)));drm_printf (m,"\tForcewake: %x domains, %d active\n" , - engine->fw_domain,atomic_read (&engine->fw_active)); + engine->fw_domain,READ_ONCE (engine->fw_active));rcu_read_lock (); rq =READ_ONCE (engine->heartbeat.systole);
drivers/gpu/drm/i915/gt/intel_engine_types.h +1 -1
@@ -329,7 +329,7 @@ struct intel_engine_cs {* as possible. */ enum forcewake_domains fw_domain; -atomic_t fw_active; +unsigned int fw_active;unsigned long context_tag;
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +2 -2
@@ -550,7 +550,7 @@ __execlists_schedule_in(struct i915_request *rq) ce->lrc.ccid |= engine->execlists.ccid;__intel_gt_pm_get (engine->gt); -if (engine->fw_domain && !atomic_fetch_inc (&engine->fw_active)) +if (engine->fw_domain && !engine->fw_active++)intel_uncore_forcewake_get (engine->uncore, engine->fw_domain);execlists_context_status_change (rq,INTEL_CONTEXT_SCHEDULE_IN );intel_engine_context_in (engine);
@@ -661,7 +661,7 @@ static inline void __execlists_schedule_out(struct i915_request *rq)lrc_update_runtime (ce);intel_engine_context_out (engine);execlists_context_status_change (rq,INTEL_CONTEXT_SCHEDULE_OUT ); -if (engine->fw_domain && !atomic_dec_return (&engine->fw_active)) +if (engine->fw_domain && !--engine->fw_active)intel_uncore_forcewake_put (engine->uncore, engine->fw_domain);intel_gt_pm_put_async (engine->gt);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/54 drm/i915/gt: Extract busy-stats for ring-scheduler
In reply to Chris WilsonLift the busy-stats context-in/out implementation out of intel_lrc, so that we can reuse it for other scheduler implementations.
--- drivers/gpu/drm/i915/gt/intel_engine_stats.h | 49 +++++++++++++++++++ .../drm/i915/gt/intel_execlists_submission.c | 34 +------------ 2 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/intel_engine_stats.h
drivers/gpu/drm/i915/gt/intel_engine_stats.h new file +49 -0
@@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2020 Intel Corporation +*/ + +#ifndef __INTEL_ENGINE_STATS_H__ +#define __INTEL_ENGINE_STATS_H__ + +#include <linux/atomic.h> +#include <linux/ktime.h> +#include <linux/seqlock.h> + +#include "i915_gem.h" /* GEM_BUG_ON */ +#include "intel_engine.h" + +static inline void intel_engine_context_in (struct intel_engine_cs *engine) +{ +unsigned long flags; + +if (atomic_add_unless (&engine->stats.active,1 ,0 )) +return ; + +write_seqlock_irqsave (&engine->stats.lock, flags); +if (!atomic_add_unless (&engine->stats.active,1 ,0 )) { + engine->stats.start =ktime_get (); +atomic_inc (&engine->stats.active); + } +write_sequnlock_irqrestore (&engine->stats.lock, flags); +} + +static inline void intel_engine_context_out (struct intel_engine_cs *engine) +{ +unsigned long flags; + +GEM_BUG_ON (!atomic_read (&engine->stats.active)); + +if (atomic_add_unless (&engine->stats.active,-1 ,1 )) +return ; + +write_seqlock_irqsave (&engine->stats.lock, flags); +if (atomic_dec_and_test (&engine->stats.active)) { + engine->stats.total = +ktime_add (engine->stats.total, +ktime_sub (ktime_get (), engine->stats.start)); + } +write_sequnlock_irqrestore (&engine->stats.lock, flags); +} + +#endif /* __INTEL_ENGINE_STATS_H__ */
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +1 -33
@@ -115,6 +115,7 @@#include "intel_breadcrumbs.h" #include "intel_context.h" #include "intel_engine_pm.h" +#include "intel_engine_stats.h" #include "intel_execlists_submission.h" #include "intel_gt.h" #include "intel_gt_pm.h"
@@ -443,39 +444,6 @@ execlists_context_status_change(struct i915_request *rq, unsigned long status) status, rq); } -static void intel_engine_context_in (struct intel_engine_cs *engine) -{ -unsigned long flags; - -if (atomic_add_unless (&engine->stats.active,1 ,0 )) -return ; - -write_seqlock_irqsave (&engine->stats.lock, flags); -if (!atomic_add_unless (&engine->stats.active,1 ,0 )) { - engine->stats.start =ktime_get (); -atomic_inc (&engine->stats.active); - } -write_sequnlock_irqrestore (&engine->stats.lock, flags); -} - -static void intel_engine_context_out (struct intel_engine_cs *engine) -{ -unsigned long flags; - -GEM_BUG_ON (!atomic_read (&engine->stats.active)); - -if (atomic_add_unless (&engine->stats.active,-1 ,1 )) -return ; - -write_seqlock_irqsave (&engine->stats.lock, flags); -if (atomic_dec_and_test (&engine->stats.active)) { - engine->stats.total = -ktime_add (engine->stats.total, -ktime_sub (ktime_get (), engine->stats.start)); - } -write_sequnlock_irqrestore (&engine->stats.lock, flags); -} -static void reset_active (struct i915_request *rq,struct intel_engine_cs *engine) {
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/54 drm/i915/gt: Convert stats.active to plain unsigned int
In reply to Chris WilsonAs context-in/out is now always serialised, we do not have to worry about concurrent enabling/disable of the busy-stats and can reduce the atomic_t active to a plain unsigned int, and the seqlock to a seqcount.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 8 ++-- drivers/gpu/drm/i915/gt/intel_engine_stats.h | 45 ++++++++++++-------- drivers/gpu/drm/i915/gt/intel_engine_types.h | 4 +- 3 files changed, 34 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +4 -4
@@ -341,7 +341,7 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id) engine->schedule =NULL ;ewma__engine_latency_init (&engine->latency); -seqlock_init (&engine->stats.lock); +seqcount_init (&engine->stats.lock);ATOMIC_INIT_NOTIFIER_HEAD (&engine->context_status_notifier);
@@ -1735,7 +1735,7 @@ static ktime_t __intel_engine_get_busy_time(struct intel_engine_cs *engine,* add it to the total. */ *now =ktime_get (); -if (atomic_read (&engine->stats.active)) +if (READ_ONCE (engine->stats.active)) total =ktime_add (total,ktime_sub (*now, engine->stats.start));return total;
@@ -1754,9 +1754,9 @@ ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine, ktime_t *now)ktime_t total;do { - seq =read_seqbegin (&engine->stats.lock); + seq =read_seqcount_begin (&engine->stats.lock); total =__intel_engine_get_busy_time (engine, now); - }while (read_seqretry (&engine->stats.lock, seq)); + }while (read_seqcount_retry (&engine->stats.lock, seq));return total; }
drivers/gpu/drm/i915/gt/intel_engine_stats.h +28 -17
61 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_engine_types.h +2 -2
@@ -526,12 +526,12 @@ struct intel_engine_cs {/** * @active: Number of contexts currently scheduled in. */ -atomic_t active; +unsigned int active;/** * @lock: Lock protecting the below fields. */ -seqlock_t lock; +seqcount_t lock;/** * @total: Total time this engine was busy.
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 13/54 drm/i915/gt: Do not suspend bonded requests if one hangs
In reply to Chris WilsonTreat the dependency between bonded requests as weak and leave the remainder of the pair on the GPU if one hangs.
--- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +6 -0
@@ -1995,6 +1995,9 @@ static void __execlists_hold(struct i915_request *rq)struct i915_request *w =container_of (p->waiter,typeof (*w), sched); +if (p->flags &I915_DEPENDENCY_WEAK ) +continue ; +/* Leave semaphores spinning on the other engines */ if (w->engine != rq->engine)continue ;
@@ -2093,6 +2096,9 @@ static void __execlists_unhold(struct i915_request *rq)struct i915_request *w =container_of (p->waiter,typeof (*w), sched); +if (p->flags &I915_DEPENDENCY_WEAK ) +continue ; +/* Propagate any change in error status */ if (rq->fence.error)i915_request_set_error_once (w, rq->fence.error);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 14/54 drm/i915/gt: Remove timeslice suppression
In reply to Chris WilsonIn the next patch, we remove the strict priority system and continuously re-evaluate the relative priority of tasks. As such we need to enable the timeslice whenever there is more than one context in the pipeline. This simplifies the decision and removes some of the tweaks to suppress timeslicing, allowing us to lift the timeslice enabling to a common spot at the end of running the submission tasklet.
--- drivers/gpu/drm/i915/gt/intel_engine_types.h | 10 -- .../drm/i915/gt/intel_execlists_submission.c | 159 +++++++----------- 2 files changed, 61 insertions(+), 108 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_types.h +0 -10
@@ -238,16 +238,6 @@ struct intel_engine_execlists {*/ unsigned int port_mask; -/** -* @switch_priority_hint: Second context priority. -* -* We submit multiple contexts to the HW simultaneously and would -* like to occasionally switch between them to emulate timeslicing. -* To know when timeslicing is suitable, we track the priority of -* the context submitted second. -*/ -int switch_priority_hint; -/** * @queue_priority_hint: Highest pending priority. *
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +61 -98
252 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 15/54 drm/i915/gt: Skip over completed active execlists, again
In reply to Chris WilsonNow that we are careful to always force-restore contexts upon rewinding (where necessary), we can restore our optimisation to skip over completed active execlists when dequeuing.
Referenecs: 35f3fd8182ba ("drm/i915/execlists: Workaround switching back to a completed context")
References: 8ab3a3812aa9 ("drm/i915/gt: Incrementally check for rewinding")
--- .../drm/i915/gt/intel_execlists_submission.c | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +17 -16
@@ -1224,12 +1224,20 @@ static void set_preempt_timeout(struct intel_engine_cs *engine, active_preempt_timeout(engine, rq)); } +static bool completed (const struct i915_request *rq) +{ +if (i915_request_has_sentinel (rq)) +return false; + +return __i915_request_is_complete (rq); +} +static void execlists_dequeue (struct intel_engine_cs *engine) {struct intel_engine_execlists *const execlists = &engine->execlists;struct i915_request **port = execlists->pending;struct i915_request **const last_port = port + execlists->port_mask; -struct i915_request *last = *execlists->active; +struct i915_request *last, *const *active;struct virtual_engine *ve;struct rb_node *rb;bool submit = false;
@@ -1266,21 +1274,15 @@ static void execlists_dequeue(struct intel_engine_cs *engine)* i.e. we will retrigger preemption following the ack in case * of trouble. * -* In theory we can skip over completed contexts that have not -* yet been processed by events (as those events are in flight): -* -* while ((last = *active) && i915_request_completed(last)) -* active++; -* -* However, the GPU cannot handle this as it will ultimately -* find itself trying to jump back into a context it has just -* completed and barf. */ + active = execlists->active; +while ((last = *active) &&completed (last)) + active++;if (last) { -if (__i915_request_is_complete (last)) { - goto check_secondary; - }else if (need_preempt (engine, last)) { +GEM_BUG_ON (!i915_request_is_active (last)); + +if (need_preempt (engine, last)) { ENGINE_TRACE(engine, "preempting last=%llx:%lld, prio=%d, hint=%d\n", last->fence.context,
@@ -1343,7 +1345,6 @@ static void execlists_dequeue(struct intel_engine_cs *engine)* we hopefully coalesce several updates into a single * submission. */ -check_secondary:if (!list_is_last (&last->sched.link, &engine->active.requests)) {/*
@@ -1548,7 +1549,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)* of ordered contexts. */ if (submit && -memcmp (execlists->active, +memcmp (active, execlists->pending, (port - execlists->pending) *sizeof (*port))) { *port =NULL ;
@@ -1556,7 +1557,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)execlists_schedule_in (*port, port - execlists->pending);WRITE_ONCE (execlists->yield,-1 ); -set_preempt_timeout (engine, *execlists->active); +set_preempt_timeout (engine, *active);execlists_submit_ports (engine); }else {ring_set_paused (engine,0 );
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 16/54 drm/i915: Strip out internal priorities
In reply to Chris WilsonSince 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.
--- .../gpu/drm/i915/gt/intel_engine_heartbeat.c | 2 +- .../drm/i915/gt/intel_execlists_submission.c | 22 ++------ drivers/gpu/drm/i915/gt/selftest_execlists.c | 1 - drivers/gpu/drm/i915/gt/selftest_lrc.c | 1 - .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 6 +-- drivers/gpu/drm/i915/i915_priolist_types.h | 8 +-- drivers/gpu/drm/i915/i915_scheduler.c | 51 +++---------------- drivers/gpu/drm/i915/i915_scheduler.h | 16 ++---- 8 files changed, 20 insertions(+), 87 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c +1 -1
@@ -125,7 +125,7 @@ static void heartbeat(struct work_struct *wrk)* low latency and no jitter] the chance to naturally * complete before being preempted. */ - attr.priority =I915_PRIORITY_MASK ; + attr.priority =0 ;if (rq->sched.attr.priority >= attr.priority) attr.priority |=I915_USER_PRIORITY (I915_PRIORITY_HEARTBEAT );if (rq->sched.attr.priority >= attr.priority)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +5 -17
@@ -286,22 +286,13 @@ static int effective_prio(const struct i915_request *rq)static int queue_prio (const struct intel_engine_execlists *execlists) { -struct i915_priolist *p;struct rb_node *rb; rb =rb_first_cached (&execlists->queue);if (!rb)return INT_MIN ; -/* -* As the priolist[] are inverted, with the highest priority in [0], -* we have to flip the index value to become priority. -*/ - p =to_priolist (rb); -if (!I915_USER_PRIORITY_SHIFT ) -return p->priority; - -return ((p->priority +1 ) <<I915_USER_PRIORITY_SHIFT ) -ffs (p->used); +return to_priolist (rb)->priority; }static int virtual_prio (const struct intel_engine_execlists *el)
@@ -1441,9 +1432,8 @@ static void execlists_dequeue(struct intel_engine_cs *engine)while ((rb =rb_first_cached (&execlists->queue))) {struct i915_priolist *p =to_priolist (rb);struct i915_request *rq, *rn; -int i; -priolist_for_each_request_consume (rq, rn, p, i) { +priolist_for_each_request_consume (rq, rn, p) {bool merge = true;/*
@@ -2969,9 +2959,8 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)/* Flush the queued requests to the timeline list (for retiring). */ while ((rb =rb_first_cached (&execlists->queue))) {struct i915_priolist *p =to_priolist (rb); -int i; -priolist_for_each_request_consume (rq, rn, p, i) { +priolist_for_each_request_consume (rq, rn, p) {mark_eio (rq);__i915_request_submit (rq); }
@@ -3242,7 +3231,7 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine)static struct list_head *virtual_queue (struct virtual_engine *ve) { -return &ve->base.execlists.default_priolist.requests[0 ]; +return &ve->base.execlists.default_priolist.requests; }static void rcu_virtual_context_destroy (struct work_struct *wrk)
@@ -3836,9 +3825,8 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine, count =0 ;for (rb =rb_first_cached (&execlists->queue); rb; rb =rb_next (rb)) {struct i915_priolist *p =rb_entry (rb,typeof (*p), node); -int i; -priolist_for_each_request (rq, p, i) { +priolist_for_each_request (rq, p) {if (count++ < max -1 )show_request (m, rq,"\t\t" ,0 );else
drivers/gpu/drm/i915/gt/selftest_execlists.c +0 -1
@@ -1078,7 +1078,6 @@ create_rewinder(struct intel_context *ce,intel_ring_advance (rq, cs); - rq->sched.attr.priority =I915_PRIORITY_MASK ; err =0 ; err:i915_request_get (rq);
drivers/gpu/drm/i915/gt/selftest_lrc.c +0 -1
@@ -730,7 +730,6 @@ create_timestamp(struct intel_context *ce, void *slot, int idx)intel_ring_advance (rq, cs); - rq->sched.attr.priority =I915_PRIORITY_MASK ; err =0 ; err:i915_request_get (rq);
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +2 -4
@@ -313,9 +313,8 @@ static void __guc_dequeue(struct intel_engine_cs *engine)while ((rb =rb_first_cached (&execlists->queue))) {struct i915_priolist *p =to_priolist (rb);struct i915_request *rq, *rn; -int i; -priolist_for_each_request_consume (rq, rn, p, i) { +priolist_for_each_request_consume (rq, rn, p) {if (last && rq->context != last->context) {if (port == last_port) goto done;
@@ -486,9 +485,8 @@ static void guc_reset_cancel(struct intel_engine_cs *engine)/* Flush the queued requests to the timeline list (for retiring). */ while ((rb =rb_first_cached (&execlists->queue))) {struct i915_priolist *p =to_priolist (rb); -int i; -priolist_for_each_request_consume (rq, rn, p, i) { +priolist_for_each_request_consume (rq, rn, p) {list_del_init (&rq->sched.link);__i915_request_submit (rq);dma_fence_set_error (&rq->fence, -EIO );
drivers/gpu/drm/i915/i915_priolist_types.h +2 -6
@@ -27,11 +27,8 @@ enum {#define I915_USER_PRIORITY_SHIFT 0#define I915_USER_PRIORITY (x) ((x) << I915_USER_PRIORITY_SHIFT) -#define I915_PRIORITY_COUNT BIT(I915_USER_PRIORITY_SHIFT) -#define I915_PRIORITY_MASK (I915_PRIORITY_COUNT - 1) -/* Smallest priority value that cannot be bumped. */ -#define I915_PRIORITY_INVALID (INT_MIN | (u8)I915_PRIORITY_MASK) +#define I915_PRIORITY_INVALID (INT_MIN)/* * Requests containing performance queries must not be preempted by
@@ -45,9 +42,8 @@ enum {#define I915_PRIORITY_BARRIER (I915_PRIORITY_UNPREEMPTABLE - 1)struct i915_priolist { -struct list_head requests[I915_PRIORITY_COUNT ]; +struct list_head requests;struct rb_node node; -unsigned long used;int priority; };
drivers/gpu/drm/i915/i915_scheduler.c +6 -45
100 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +4 -12
@@ -15,17 +15,11 @@struct drm_printer ; -#define priolist_for_each_request (it, plist, idx) \ - for (idx = 0; idx < ARRAY_SIZE((plist)->requests); idx++) \ - list_for_each_entry(it, &(plist)->requests[idx], sched.link) +#define priolist_for_each_request (it, plist) \ + list_for_each_entry(it, &(plist)->requests, sched.link) -#define priolist_for_each_request_consume (it, n, plist, idx) \ - for (; \ - (plist)->used ? (idx = __ffs((plist)->used)), 1 : 0; \ - (plist)->used &= ~BIT(idx)) \ - list_for_each_entry_safe(it, n, \ - &(plist)->requests[idx], \ - sched.link) +#define priolist_for_each_request_consume (it, n, plist) \ + list_for_each_entry_safe(it, n, &(plist)->requests, sched.link)void i915_sched_node_init (struct i915_sched_node *node);void i915_sched_node_reinit (struct i915_sched_node *node);
@@ -44,8 +38,6 @@ void i915_sched_node_fini(struct i915_sched_node *node);void i915_schedule (struct i915_request *request,const struct i915_sched_attr *attr); -void i915_schedule_bump_priority (struct i915_request *rq,unsigned int bump); -struct list_head *i915_sched_lookup_priolist (struct intel_engine_cs *engine,int prio);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 17/54 drm/i915: Remove I915_USER_PRIORITY_SHIFT
In reply to Chris WilsonAs we do not have any internal priority levels, the priority can be set directed from the user values.
--- drivers/gpu/drm/i915/display/intel_display.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 +-- .../i915/gem/selftests/i915_gem_object_blt.c | 4 +- .../gpu/drm/i915/gt/intel_engine_heartbeat.c | 10 ++--- drivers/gpu/drm/i915/gt/selftest_execlists.c | 44 +++++++------------ drivers/gpu/drm/i915/i915_priolist_types.h | 3 -- drivers/gpu/drm/i915/i915_scheduler.c | 1 - 7 files changed, 24 insertions(+), 48 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +1 -3
@@ -15613,9 +15613,7 @@ void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)static void fb_obj_bump_render_priority (struct drm_i915_gem_object *obj) { -struct i915_sched_attr attr = { - .priority =I915_USER_PRIORITY (I915_PRIORITY_DISPLAY ), - }; +struct i915_sched_attr attr = { .priority =I915_PRIORITY_DISPLAY };i915_gem_object_wait_priority (obj,0 , &attr); }
drivers/gpu/drm/i915/gem/i915_gem_context.c +3 -3
@@ -679,7 +679,7 @@ __create_context(struct drm_i915_private *i915)kref_init (&ctx->ref); ctx->i915 = i915; - ctx->sched.priority =I915_USER_PRIORITY (I915_PRIORITY_NORMAL ); + ctx->sched.priority =I915_PRIORITY_NORMAL ;mutex_init (&ctx->mutex);INIT_LIST_HEAD (&ctx->link);
@@ -1959,7 +1959,7 @@ static int set_priority(struct i915_gem_context *ctx, !capable(CAP_SYS_NICE))return -EPERM ; - ctx->sched.priority =I915_USER_PRIORITY (priority); + ctx->sched.priority = priority;context_apply_all (ctx, __apply_priority, ctx);return 0 ;
@@ -2463,7 +2463,7 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,case I915_CONTEXT_PARAM_PRIORITY : args->size =0 ; - args->value = ctx->sched.priority >>I915_USER_PRIORITY_SHIFT ; + args->value = ctx->sched.priority;break ;case I915_CONTEXT_PARAM_SSEU :
drivers/gpu/drm/i915/gem/selftests/i915_gem_object_blt.c +2 -2
@@ -220,7 +220,7 @@ static int igt_fill_blt_thread(void *arg)return PTR_ERR (ctx); prio =i915_prandom_u32_max_state (I915_PRIORITY_MAX , prng); - ctx->sched.priority =I915_USER_PRIORITY (prio); + ctx->sched.priority = prio; } ce =i915_gem_context_get_engine (ctx,0 );
@@ -338,7 +338,7 @@ static int igt_copy_blt_thread(void *arg)return PTR_ERR (ctx); prio =i915_prandom_u32_max_state (I915_PRIORITY_MAX , prng); - ctx->sched.priority =I915_USER_PRIORITY (prio); + ctx->sched.priority = prio; } ce =i915_gem_context_get_engine (ctx,0 );
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c +3 -7
@@ -81,9 +81,7 @@ static void show_heartbeat(const struct i915_request *rq,static void heartbeat (struct work_struct *wrk) { -struct i915_sched_attr attr = { - .priority =I915_USER_PRIORITY (I915_PRIORITY_MIN ), - }; +struct i915_sched_attr attr = { .priority =I915_PRIORITY_MIN };struct intel_engine_cs *engine =container_of (wrk,typeof (*engine), heartbeat.work.work);struct intel_context *ce = engine->kernel_context;
@@ -127,7 +125,7 @@ static void heartbeat(struct work_struct *wrk)*/ attr.priority =0 ;if (rq->sched.attr.priority >= attr.priority) - attr.priority |=I915_USER_PRIORITY (I915_PRIORITY_HEARTBEAT ); + attr.priority =I915_PRIORITY_HEARTBEAT ;if (rq->sched.attr.priority >= attr.priority) attr.priority =I915_PRIORITY_BARRIER ;
@@ -285,9 +283,7 @@ int intel_engine_pulse(struct intel_engine_cs *engine)int intel_engine_flush_barriers (struct intel_engine_cs *engine) { -struct i915_sched_attr attr = { - .priority =I915_USER_PRIORITY (I915_PRIORITY_MIN ), - }; +struct i915_sched_attr attr = { .priority =I915_PRIORITY_MIN };struct intel_context *ce = engine->kernel_context;struct i915_request *rq;int err;
drivers/gpu/drm/i915/gt/selftest_execlists.c +15 -29
130 lines not on this page · raw message
drivers/gpu/drm/i915/i915_priolist_types.h +0 -3
@@ -24,9 +24,6 @@ enum { I915_PRIORITY_DISPLAY, }; -#define I915_USER_PRIORITY_SHIFT 0 -#define I915_USER_PRIORITY (x) ((x) << I915_USER_PRIORITY_SHIFT) -/* Smallest priority value that cannot be bumped. */ #define I915_PRIORITY_INVALID (INT_MIN)
drivers/gpu/drm/i915/i915_scheduler.c +0 -1
@@ -71,7 +71,6 @@ i915_sched_lookup_priolist(struct intel_engine_cs *engine, int prio)lockdep_assert_held (&engine->active.lock);assert_priolists (execlists); - prio >>=I915_USER_PRIORITY_SHIFT ;if (unlikely (execlists->no_priolist)) prio =I915_PRIORITY_NORMAL ;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 18/54 drm/i915: Replace engine->schedule() with a known request operation
In reply to Chris WilsonLooking to the future, we want to set the scheduling attributes explicitly and so replace the generic engine->schedule() with the more direct i915_request_set_priority()
What it loses in removing the 'schedule' name from the function, it gains in having an explicit entry point with a stated goal.
--- drivers/gpu/drm/i915/display/intel_display.c | 9 +---- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 - drivers/gpu/drm/i915/gem/i915_gem_object.h | 2 +- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 27 +++++---------- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 3 -- .../gpu/drm/i915/gt/intel_engine_heartbeat.c | 4 +-- drivers/gpu/drm/i915/gt/intel_engine_types.h | 29 ++++++++-------- drivers/gpu/drm/i915/gt/intel_engine_user.c | 2 +- .../drm/i915/gt/intel_execlists_submission.c | 3 +- drivers/gpu/drm/i915/gt/selftest_execlists.c | 33 +++++-------------- drivers/gpu/drm/i915/gt/selftest_hangcheck.c | 11 +++---- drivers/gpu/drm/i915/i915_request.c | 10 +++--- drivers/gpu/drm/i915/i915_scheduler.c | 15 +++++---- drivers/gpu/drm/i915/i915_scheduler.h | 3 +- 14 files changed, 56 insertions(+), 96 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +1 -8
@@ -15611,13 +15611,6 @@ void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)intel_unpin_fb_vma (vma, old_plane_state->flags); } -static void fb_obj_bump_render_priority (struct drm_i915_gem_object *obj) -{ -struct i915_sched_attr attr = { .priority =I915_PRIORITY_DISPLAY }; - -i915_gem_object_wait_priority (obj,0 , &attr); -} -/** * intel_prepare_plane_fb - Prepare fb for usage on plane * @_plane: drm plane to prepare for
@@ -15694,7 +15687,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,if (ret)return ret; -fb_obj_bump_render_priority (obj); +i915_gem_object_wait_priority (obj,0 ,I915_PRIORITY_DISPLAY );i915_gem_object_flush_frontbuffer (obj,ORIGIN_DIRTYFB );if (!new_plane_state->uapi.fence) {/* implicit fencing */
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +0 -1
@@ -2653,7 +2653,6 @@ static struct i915_request *eb_pin_engine(struct i915_execbuffer *eb, bool throtint err;GEM_BUG_ON (eb->args->flags & __EXEC_ENGINE_PINNED); -if (unlikely (intel_context_is_banned (ce)))return ERR_PTR (-EIO );
drivers/gpu/drm/i915/gem/i915_gem_object.h +1 -1
@@ -517,7 +517,7 @@ int i915_gem_object_wait(struct drm_i915_gem_object *obj, long timeout);int i915_gem_object_wait_priority (struct drm_i915_gem_object *obj,unsigned int flags, -const struct i915_sched_attr *attr); +int prio);void __i915_gem_object_flush_frontbuffer (struct drm_i915_gem_object *obj,enum fb_op_origin origin);
drivers/gpu/drm/i915/gem/i915_gem_wait.c +8 -19
@@ -91,28 +91,17 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,return timeout; } -static void __fence_set_priority (struct dma_fence *fence, -const struct i915_sched_attr *attr) +static void __fence_set_priority (struct dma_fence *fence,int prio) { -struct i915_request *rq; -struct intel_engine_cs *engine; -if (dma_fence_is_signaled (fence) || !dma_fence_is_i915 (fence))return ; - rq =to_request (fence); - engine = rq->engine; -local_bh_disable (); -rcu_read_lock ();/* RCU serialisation for set-wedged protection */ -if (engine->schedule) - engine->schedule (rq, attr); -rcu_read_unlock (); +i915_request_set_priority (to_request (fence), prio);local_bh_enable ();/* kick the tasklets if queues were reprioritised */ } -static void fence_set_priority (struct dma_fence *fence, -const struct i915_sched_attr *attr) +static void fence_set_priority (struct dma_fence *fence,int prio) {/* Recurse once into a fence-array */ if (dma_fence_is_array (fence)) {
@@ -120,16 +109,16 @@ static void fence_set_priority(struct dma_fence *fence,int i;for (i =0 ; i < array->num_fences; i++) -__fence_set_priority (array->fences[i], attr); +__fence_set_priority (array->fences[i], prio); }else { -__fence_set_priority (fence, attr); +__fence_set_priority (fence, prio); } }int i915_gem_object_wait_priority (struct drm_i915_gem_object *obj,unsigned int flags, -const struct i915_sched_attr *attr) +int prio) {struct dma_fence *excl;
@@ -144,7 +133,7 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj,return ret;for (i =0 ; i < count; i++) { -fence_set_priority (shared[i], attr); +fence_set_priority (shared[i], prio);dma_fence_put (shared[i]); }
@@ -154,7 +143,7 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, }if (excl) { -fence_set_priority (excl, attr); +fence_set_priority (excl, prio);dma_fence_put (excl); }return 0 ;
drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -3
@@ -337,9 +337,6 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)if (engine->context_size)DRIVER_CAPS (i915)->has_logical_contexts = true; -/* Nothing to do here, execute in order of dependencies */ - engine->schedule =NULL ; -ewma__engine_latency_init (&engine->latency);seqcount_init (&engine->stats.lock);
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c +2 -2
@@ -115,7 +115,7 @@ static void heartbeat(struct work_struct *wrk)* but all other contexts, including the kernel * context are stuck waiting for the signal. */ - }else if (engine->schedule && + }else if (intel_engine_has_scheduler (engine) && rq->sched.attr.priority <I915_PRIORITY_BARRIER ) {/* * Gradually raise the priority of the heartbeat to
@@ -130,7 +130,7 @@ static void heartbeat(struct work_struct *wrk) attr.priority =I915_PRIORITY_BARRIER ;local_bh_disable (); - engine->schedule (rq, &attr); +i915_request_set_priority (rq, attr.priority);local_bh_enable (); }else {if (IS_ENABLED (CONFIG_DRM_I915_DEBUG_GEM ))
drivers/gpu/drm/i915/gt/intel_engine_types.h +14 -15
@@ -454,14 +454,6 @@ struct intel_engine_cs {void (*bond_execute)(struct i915_request *rq,struct dma_fence *signal); -/* -* Call when the priority on a request has changed and it and its -* dependencies may need rescheduling. Note the request itself may -* not be ready to run! -*/ -void (*schedule)(struct i915_request *request, -const struct i915_sched_attr *attr); -void (*release)(struct intel_engine_cs *engine);struct intel_engine_execlists execlists;
@@ -479,13 +471,14 @@ struct intel_engine_cs {#define I915_ENGINE_USING_CMD_PARSER BIT(0)#define I915_ENGINE_SUPPORTS_STATS BIT(1) -#define I915_ENGINE_HAS_PREEMPTION BIT(2) -#define I915_ENGINE_HAS_SEMAPHORES BIT(3) -#define I915_ENGINE_HAS_TIMESLICES BIT(4) -#define I915_ENGINE_NEEDS_BREADCRUMB_TASKLET BIT(5) -#define I915_ENGINE_IS_VIRTUAL BIT(6) -#define I915_ENGINE_HAS_RELATIVE_MMIO BIT(7) -#define I915_ENGINE_REQUIRES_CMD_PARSER BIT(8) +#define I915_ENGINE_HAS_SCHEDULER BIT(2) +#define I915_ENGINE_HAS_PREEMPTION BIT(3) +#define I915_ENGINE_HAS_SEMAPHORES BIT(4) +#define I915_ENGINE_HAS_TIMESLICES BIT(5) +#define I915_ENGINE_NEEDS_BREADCRUMB_TASKLET BIT(6) +#define I915_ENGINE_IS_VIRTUAL BIT(7) +#define I915_ENGINE_HAS_RELATIVE_MMIO BIT(8) +#define I915_ENGINE_REQUIRES_CMD_PARSER BIT(9)unsigned int flags;/*
@@ -571,6 +564,12 @@ intel_engine_supports_stats(const struct intel_engine_cs *engine)return engine->flags &I915_ENGINE_SUPPORTS_STATS ; } +static inline bool +intel_engine_has_scheduler (const struct intel_engine_cs *engine) +{ +return engine->flags &I915_ENGINE_HAS_SCHEDULER ; +} +static inline bool intel_engine_has_preemption (const struct intel_engine_cs *engine) {
drivers/gpu/drm/i915/gt/intel_engine_user.c +1 -1
@@ -108,7 +108,7 @@ static void set_scheduler_caps(struct drm_i915_private *i915)for_each_uabi_engine (engine, i915) {/* all engines must agree! */ int i; -if (engine->schedule) +if (intel_engine_has_scheduler (engine)) enabled |= (I915_SCHEDULER_CAP_ENABLED |I915_SCHEDULER_CAP_PRIORITY );else
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +1 -2
@@ -3048,7 +3048,6 @@ static void execlists_park(struct intel_engine_cs *engine)void intel_execlists_set_default_submission (struct intel_engine_cs *engine) { engine->submit_request = execlists_submit_request; - engine->schedule = i915_schedule; engine->execlists.tasklet.func = execlists_submission_tasklet; engine->reset.prepare = execlists_reset_prepare;
@@ -3059,6 +3058,7 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine) engine->park = execlists_park; engine->unpark =NULL ; + engine->flags |=I915_ENGINE_HAS_SCHEDULER ; engine->flags |=I915_ENGINE_SUPPORTS_STATS ;if (!intel_vgpu_active (engine->i915)) { engine->flags |=I915_ENGINE_HAS_SEMAPHORES ;
@@ -3629,7 +3629,6 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings, ve->base.cops = &virtual_context_ops; ve->base.request_alloc = execlists_request_alloc; - ve->base.schedule = i915_schedule; ve->base.submit_request = virtual_submit_request; ve->base.bond_execute = virtual_bond_execute;
drivers/gpu/drm/i915/gt/selftest_execlists.c +8 -25
@@ -269,12 +269,8 @@ static int live_unlite_restore(struct intel_gt *gt, int prio)i915_request_put (rq[0 ]);if (prio) { -struct i915_sched_attr attr = { - .priority = prio, - }; -/* Alternatively preempt the spinner with ce[1] */ - engine->schedule (rq[1 ], &attr); +i915_request_set_priority (rq[1 ], prio); }/* And switch back to ce[0] for good measure */
@@ -874,9 +870,6 @@ release_queue(struct intel_engine_cs *engine,struct i915_vma *vma, int idx, int prio) { - struct i915_sched_attr attr = { - .priority = prio, - }; struct i915_request *rq;u32 *cs;
@@ -901,7 +894,7 @@ release_queue(struct intel_engine_cs *engine,i915_request_add (rq);local_bh_disable (); - engine->schedule (rq, &attr); +i915_request_set_priority (rq, prio);local_bh_enable ();/* kick tasklet */ i915_request_put (rq);
@@ -1308,7 +1301,6 @@ static int live_timeslice_queue(void *arg) goto err_pin;for_each_engine (engine, gt, id) { -struct i915_sched_attr attr = { .priority =I915_PRIORITY_MAX };struct i915_request *rq, *nop;if (!intel_engine_has_preemption (engine))
@@ -1323,7 +1315,7 @@ static int live_timeslice_queue(void *arg) err =PTR_ERR (rq); goto err_heartbeat; } - engine->schedule (rq, &attr); +i915_request_set_priority (rq,I915_PRIORITY_MAX ); err =wait_for_submit (engine, rq,HZ /2 );if (err) { pr_err("%s: Timed out trying to submit semaphores\n",
@@ -1810,7 +1802,6 @@ static int live_late_preempt(void *arg)struct i915_gem_context *ctx_hi, *ctx_lo;struct igt_spinner spin_hi, spin_lo;struct intel_engine_cs *engine; -struct i915_sched_attr attr = {};enum intel_engine_id id;int err = -ENOMEM ;
@@ -1873,8 +1864,7 @@ static int live_late_preempt(void *arg) goto err_wedged; } - attr.priority =I915_PRIORITY_MAX ; - engine->schedule (rq, &attr); +i915_request_set_priority (rq,I915_PRIORITY_MAX );if (!igt_wait_for_spinner (&spin_hi, rq)) {pr_err ("High priority context failed to preempt the low priority context\n" );
@@ -2350,7 +2340,6 @@ static int live_preempt_cancel(void *arg)static int live_suppress_self_preempt (void *arg) { -struct i915_sched_attr attr = { .priority =I915_PRIORITY_MAX };struct intel_gt *gt = arg;struct intel_engine_cs *engine;struct preempt_client a, b;
@@ -2421,7 +2410,7 @@ static int live_suppress_self_preempt(void *arg)i915_request_add (rq_b);GEM_BUG_ON (i915_request_completed (rq_a)); - engine->schedule (rq_a, &attr); +i915_request_set_priority (rq_a,I915_PRIORITY_MAX );igt_spinner_end (&a.spin);if (!igt_wait_for_spinner (&b.spin, rq_b)) {
@@ -2489,7 +2478,6 @@ static int live_chain_preempt(void *arg) goto err_client_hi;for_each_engine (engine, gt, id) { -struct i915_sched_attr attr = { .priority =I915_PRIORITY_MAX };struct igt_live_test t;struct i915_request *rq;int ring_size, count, i;
@@ -2556,7 +2544,7 @@ static int live_chain_preempt(void *arg)i915_request_get (rq);i915_request_add (rq); - engine->schedule (rq, &attr); +i915_request_set_priority (rq,I915_PRIORITY_MAX );igt_spinner_end (&hi.spin);if (i915_request_wait (rq,0 ,HZ /5 ) <0 ) {
@@ -2907,14 +2895,12 @@ static int live_preempt_gang(void *arg)return -EIO ;do { -struct i915_sched_attr attr = { .priority = prio++ }; - err =create_gang (engine, &rq);if (err)break ;/* Submit each spinner at increasing priority */ - engine->schedule (rq, &attr); +i915_request_set_priority (rq, prio++); }while (prio <=I915_PRIORITY_MAX && !__igt_timeout (end_time,NULL )); pr_debug("%s: Preempt chain of %d requests\n",
@@ -3135,9 +3121,6 @@ static int preempt_user(struct intel_engine_cs *engine, struct i915_vma *global, int id) { -struct i915_sched_attr attr = { - .priority =I915_PRIORITY_MAX - };struct i915_request *rq;int err =0 ;u32 *cs;
@@ -3162,7 +3145,7 @@ static int preempt_user(struct intel_engine_cs *engine,i915_request_get (rq);i915_request_add (rq); - engine->schedule (rq, &attr); +i915_request_set_priority (rq,I915_PRIORITY_MAX );if (i915_request_wait (rq,0 ,HZ /2 ) <0 ) err = -ETIME ;
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +5 -6
@@ -726,12 +726,11 @@ static int active_engine(void *data) rq[idx] =i915_request_get (new);i915_request_add (new); -if (engine->schedule && arg->flags &TEST_PRIORITY ) { -struct i915_sched_attr attr = { - .priority = -i915_prandom_u32_max_state (512 , &prng), - }; - engine->schedule (rq[idx], &attr); +if (intel_engine_has_scheduler (engine) && + arg->flags &TEST_PRIORITY ) { +int prio =i915_prandom_u32_max_state (512 , &prng); + +i915_request_set_priority (rq[idx], prio); } err =active_request_put (old);
drivers/gpu/drm/i915/i915_request.c +5 -5
@@ -1207,7 +1207,7 @@ __i915_request_await_execution(struct i915_request *to, }/* Couple the dependency tree for PI on this exposed to->fence */ -if (to->engine->schedule) { +if (intel_engine_has_scheduler (to->engine)) { err =i915_sched_node_add_dependency (&to->sched, &from->sched,I915_DEPENDENCY_WEAK );
@@ -1348,7 +1348,7 @@ i915_request_await_request(struct i915_request *to, struct i915_request *from)return 0 ; } -if (to->engine->schedule) { +if (intel_engine_has_scheduler (to->engine)) { ret =i915_sched_node_add_dependency (&to->sched, &from->sched,I915_DEPENDENCY_EXTERNAL );
@@ -1535,7 +1535,7 @@ __i915_request_add_to_timeline(struct i915_request *rq)__i915_sw_fence_await_dma_fence (&rq->submit, &prev->fence, &rq->dmaq); -if (rq->engine->schedule) +if (intel_engine_has_scheduler (rq->engine)) __i915_sched_node_add_dependency(&rq->sched, &prev->sched, &rq->dep,
@@ -1607,8 +1607,8 @@ void __i915_request_queue(struct i915_request *rq,* decide whether to preempt the entire chain so that it is ready to * run at the earliest possible convenience. */ -if (attr && rq->engine->schedule) - rq->engine->schedule (rq, attr); +if (attr) +i915_request_set_priority (rq, attr->priority);local_bh_disable ();__i915_request_queue_bh (rq);
drivers/gpu/drm/i915/i915_scheduler.c +9 -6
@@ -216,10 +216,8 @@ static void kick_submission(struct intel_engine_cs *engine,rcu_read_unlock (); } -static void __i915_schedule (struct i915_sched_node *node, -const struct i915_sched_attr *attr) +static void __i915_schedule (struct i915_sched_node *node,int prio) { -const int prio =max (attr->priority, node->attr.priority);struct intel_engine_cs *engine;struct i915_dependency *dep, *p;struct i915_dependency stack;
@@ -233,6 +231,8 @@ static void __i915_schedule(struct i915_sched_node *node,if (node_signaled (node))return ; + prio =max (prio, node->attr.priority); + stack.signaler = node;list_add (&stack.dfs_link, &dfs);
@@ -286,7 +286,7 @@ static void __i915_schedule(struct i915_sched_node *node,*/ if (node->attr.priority ==I915_PRIORITY_INVALID ) {GEM_BUG_ON (!list_empty (&node->link)); - node->attr = *attr; + node->attr.priority = prio;if (stack.dfs_link.next == stack.dfs_link.prev)return ;
@@ -341,10 +341,13 @@ static void __i915_schedule(struct i915_sched_node *node,spin_unlock (&engine->active.lock); } -void i915_schedule (struct i915_request *rq,const struct i915_sched_attr *attr) +void i915_request_set_priority (struct i915_request *rq,int prio) { +if (!intel_engine_has_scheduler (rq->engine)) +return ; +spin_lock_irq (&schedule_lock); -__i915_schedule (&rq->sched, attr); +__i915_schedule (&rq->sched, prio);spin_unlock_irq (&schedule_lock); }
drivers/gpu/drm/i915/i915_scheduler.h +1 -2
@@ -35,8 +35,7 @@ int i915_sched_node_add_dependency(struct i915_sched_node *node,void i915_sched_node_fini (struct i915_sched_node *node); -void i915_schedule (struct i915_request *request, -const struct i915_sched_attr *attr); +void i915_request_set_priority (struct i915_request *request,int prio);struct list_head *i915_sched_lookup_priolist (struct intel_engine_cs *engine,int prio);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 19/54 drm/i915: Teach the i915_dependency to use a double-lock
In reply to Chris WilsonCurrently, we construct and teardown the i915_dependency chains using a global spinlock. As the lists are entirely local, it should be possible to use an double-lock with an explicit nesting [signaler -> waiter, always] and so avoid the costly convenience of a global spinlock.
--- drivers/gpu/drm/i915/i915_request.c | 2 +- drivers/gpu/drm/i915/i915_scheduler.c | 63 ++++++++++++++------- drivers/gpu/drm/i915/i915_scheduler.h | 2 +- drivers/gpu/drm/i915/i915_scheduler_types.h | 2 + 4 files changed, 45 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_request.c +1 -1
@@ -330,7 +330,7 @@ bool i915_request_retire(struct i915_request *rq)intel_context_unpin (rq->context);free_capture_list (rq); -i915_sched_node_fini (&rq->sched); +i915_sched_node_retire (&rq->sched);i915_request_put (rq);return true;
drivers/gpu/drm/i915/i915_scheduler.c +41 -22
134 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +1 -1
@@ -33,7 +33,7 @@ int i915_sched_node_add_dependency(struct i915_sched_node *node,struct i915_sched_node *signal, unsigned long flags); -void i915_sched_node_fini (struct i915_sched_node *node); +void i915_sched_node_retire (struct i915_sched_node *node);void i915_request_set_priority (struct i915_request *request,int prio);
drivers/gpu/drm/i915/i915_scheduler_types.h +2 -0
@@ -60,6 +60,7 @@ struct i915_sched_attr {* others. */ struct i915_sched_node { +spinlock_t lock;/* protect the lists */ struct list_head signalers_list;/* those before us, we depend upon */ struct list_head waiters_list;/* those after us, they depend upon us */ struct list_head link;
@@ -75,6 +76,7 @@ struct i915_dependency {struct list_head signal_link;struct list_head wait_link;struct list_head dfs_link; +struct rcu_head rcu;unsigned long flags;#define I915_DEPENDENCY_ALLOC BIT(0)#define I915_DEPENDENCY_EXTERNAL BIT(1)
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 20/54 drm/i915: Restructure priority inheritance
In reply to Chris WilsonIn anticipation of wanting to be able to call pi from underneath an engine's active.lock, rework the priority inheritance to primarily work along an engine's priority queue, delegating any other engine that the chain may traverse to a worker. This reduces the global spinlock from governing the multi-entire priority inheritance depth-first search, to a smaller lock on each engine around a single list on that engine.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 + drivers/gpu/drm/i915/gt/intel_engine_types.h | 3 + drivers/gpu/drm/i915/i915_scheduler.c | 340 ++++++++++++------- drivers/gpu/drm/i915/i915_scheduler.h | 2 + drivers/gpu/drm/i915/i915_scheduler_types.h | 19 +- 5 files changed, 230 insertions(+), 136 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -0
@@ -594,6 +594,8 @@ void intel_engine_init_execlists(struct intel_engine_cs *engine) execlists->queue_priority_hint =INT_MIN ; execlists->queue =RB_ROOT_CACHED ; + +i915_sched_init_ipi (&execlists->ipi); }static void cleanup_status_page (struct intel_engine_cs *engine)
drivers/gpu/drm/i915/gt/intel_engine_types.h +3 -0
@@ -21,6 +21,7 @@#include "i915_gem.h" #include "i915_pmu.h" #include "i915_priolist_types.h" +#include "i915_scheduler_types.h" #include "i915_selftest.h" #include "intel_breadcrumbs_types.h" #include "intel_sseu.h"
@@ -258,6 +259,8 @@ struct intel_engine_execlists {struct rb_root_cached queue;struct rb_root_cached virtual; +struct i915_sched_ipi ipi; +/** * @csb_write: control register for Context Switch buffer *
drivers/gpu/drm/i915/i915_scheduler.c +209 -131
447 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +2 -0
@@ -35,6 +35,8 @@ int i915_sched_node_add_dependency(struct i915_sched_node *node,void i915_sched_node_retire (struct i915_sched_node *node); +void i915_sched_init_ipi (struct i915_sched_ipi *ipi); +void i915_request_set_priority (struct i915_request *request,int prio); struct list_head *
drivers/gpu/drm/i915/i915_scheduler_types.h +14 -5
@@ -8,8 +8,8 @@#define _I915_SCHEDULER_TYPES_H_#include <linux/list.h> +#include <linux/workqueue.h> -#include "gt/intel_engine_types.h" #include "i915_priolist_types.h" struct drm_i915_private ;
@@ -61,13 +61,23 @@ struct i915_sched_attr {*/ struct i915_sched_node {spinlock_t lock;/* protect the lists */ +struct list_head signalers_list;/* those before us, we depend upon */ struct list_head waiters_list;/* those after us, they depend upon us */ -struct list_head link; +struct list_head link;/* guarded by engine->active.lock */ +struct list_head dfs;/* guarded by engine->active.lock */ struct i915_sched_attr attr; -unsigned int flags; +unsigned long flags;#define I915_SCHED_HAS_EXTERNAL_CHAIN BIT(0) -intel_engine_mask_t semaphores; +unsigned long semaphores; + +struct i915_request *ipi_link; +int ipi_priority; +}; + +struct i915_sched_ipi { +struct i915_request *list; +struct work_struct work; };struct i915_dependency {
@@ -75,7 +85,6 @@ struct i915_dependency {struct i915_sched_node *waiter;struct list_head signal_link;struct list_head wait_link; -struct list_head dfs_link;struct rcu_head rcu;unsigned long flags;#define I915_DEPENDENCY_ALLOC BIT(0)
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 21/54 drm/i915/selftests: Measure set-priority duration
In reply to Chris WilsonAs a topological sort, we expect it to run in linear graph time, O(V+E). In removing the recursion, it is no longer a DFS but rather a BFS, and performs as O(VE). Let's demonstrate how bad this is with a few examples, and build a few test cases to verify a potential fix.
--- drivers/gpu/drm/i915/i915_scheduler.c | 4 + .../drm/i915/selftests/i915_live_selftests.h | 1 + .../drm/i915/selftests/i915_perf_selftests.h | 1 + .../gpu/drm/i915/selftests/i915_scheduler.c | 679 ++++++++++++++++++ 4 files changed, 685 insertions(+) create mode 100644 drivers/gpu/drm/i915/selftests/i915_scheduler.c
drivers/gpu/drm/i915/i915_scheduler.c +4 -0
@@ -590,6 +590,10 @@ void i915_request_show_with_schedule(struct drm_printer *m,rcu_read_unlock (); } +#if IS_ENABLED (CONFIG_DRM_I915_SELFTEST ) +#include "selftests/i915_scheduler.c" +#endif +static void i915_global_scheduler_shrink (void ) {kmem_cache_shrink (global.slab_dependencies);
drivers/gpu/drm/i915/selftests/i915_live_selftests.h +1 -0
@@ -26,6 +26,7 @@ selftest(gt_mocs, intel_mocs_live_selftests) selftest(gt_pm, intel_gt_pm_live_selftests) selftest(gt_heartbeat, intel_heartbeat_live_selftests) selftest(requests, i915_request_live_selftests) +selftest(scheduler, i915_scheduler_live_selftests) selftest(active, i915_active_live_selftests) selftest(objects, i915_gem_object_live_selftests)selftest (mman, i915_gem_mman_live_selftests)
drivers/gpu/drm/i915/selftests/i915_perf_selftests.h +1 -0
@@ -17,5 +17,6 @@*/ selftest(engine_cs, intel_engine_cs_perf_selftests) selftest(request, i915_request_perf_selftests) +selftest(scheduler, i915_scheduler_perf_selftests) selftest(blt, i915_gem_object_blt_perf_selftests)selftest (region, intel_memory_region_perf_selftests)
drivers/gpu/drm/i915/selftests/i915_scheduler.c new file +679 -0
679 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 22/54 drm/i915/selftests: Exercise priority inheritance around an engine loop
In reply to Chris WilsonExercise rescheduling priority inheritance around a sequence of requests that wrap around all the engines.
--- .../gpu/drm/i915/selftests/i915_scheduler.c | 219 ++++++++++++++++++ 1 file changed, 219 insertions(+)
drivers/gpu/drm/i915/selftests/i915_scheduler.c +219 -0
@@ -7,6 +7,7 @@#include "gt/intel_context.h" #include "gt/intel_gpu_commands.h" +#include "gt/intel_ring.h" #include "gt/selftest_engine_heartbeat.h" #include "selftests/igt_spinner.h" #include "selftests/i915_random.h"
@@ -512,10 +513,228 @@ static int igt_priority_chains(void *arg)return igt_schedule_chains (arg, igt_priority); } +static struct i915_request * +__write_timestamp (struct intel_engine_cs *engine, +struct drm_i915_gem_object *obj, +int slot, +struct i915_request *prev) +{ +struct i915_request *rq =ERR_PTR (-EINVAL ); +struct intel_context *ce; +struct i915_vma *vma; +int err =0 ; +u32 *cs; + + ce =intel_context_create (engine); +if (IS_ERR (ce)) +return ERR_CAST (ce); + + vma =i915_vma_instance (obj, ce->vm,NULL ); +if (IS_ERR (vma)) { + err =PTR_ERR (vma); + goto out_ce; + } + + err =i915_vma_pin (vma,0 ,0 ,PIN_USER ); +if (err) + goto out_ce; + + rq =intel_context_create_request (ce); +if (IS_ERR (rq)) { + err =PTR_ERR (rq); + goto out_unpin; + } + +i915_vma_lock (vma); + err =i915_vma_move_to_active (vma, rq,EXEC_OBJECT_WRITE ); +i915_vma_unlock (vma); +if (err) + goto out_request; + +if (prev) { + err =i915_request_await_dma_fence (rq, &prev->fence); +if (err) + goto out_request; + } + +if (engine->emit_init_breadcrumb) { + err = engine->emit_init_breadcrumb (rq); +if (err) + goto out_request; + } + + cs =intel_ring_begin (rq,4 ); +if (IS_ERR (cs)) { + err =PTR_ERR (cs); + goto out_request; + } + + *cs++ =MI_STORE_REGISTER_MEM_GEN8 ; + *cs++ =i915_mmio_reg_offset (RING_TIMESTAMP (engine->mmio_base)); + *cs++ =lower_32_bits (vma->node.start) +sizeof (u32) * slot; + *cs++ =upper_32_bits (vma->node.start); +intel_ring_advance (rq, cs); + +i915_request_get (rq); +out_request: +i915_request_add (rq); +out_unpin: +i915_vma_unpin (vma); +out_ce: +intel_context_put (ce); +i915_request_put (prev); +return err ?ERR_PTR (err) : rq; +} + +static struct i915_request *create_spinner (struct drm_i915_private *i915, +struct igt_spinner *spin) +{ +struct intel_engine_cs *engine; + +for_each_uabi_engine (engine, i915) { +struct intel_context *ce; +struct i915_request *rq; + +if (igt_spinner_init (spin, engine->gt)) +return ERR_PTR (-ENOMEM ); + + ce =intel_context_create (engine); +if (IS_ERR (ce)) +return ERR_CAST (ce); + + rq =igt_spinner_create_request (spin, ce,MI_NOOP ); +intel_context_put (ce); +if (rq ==ERR_PTR (-ENODEV )) +continue ; +if (IS_ERR (rq)) +return rq; + +i915_request_get (rq); +i915_request_add (rq); +return rq; + } + +return ERR_PTR (-ENODEV ); +} + +static int __igt_schedule_cycle (struct drm_i915_private *i915, +bool (*fn)(struct i915_request *rq, +unsigned long v,unsigned long e)) +{ +struct intel_engine_cs *engine; +struct drm_i915_gem_object *obj; +struct igt_spinner spin; +struct i915_request *rq; +unsigned long count, n; +u32 *time, last; +int err; + +/* +* Queue a bunch of ordered requests (each waiting on the previous) +* around the engines a couple of times. Each request will write +* the timestamp it executes at into the scratch, with the expectation +* that the timestamp will be in our desired execution order. +*/ + +if (INTEL_GEN (i915) <8 ) +return 0 ; + + obj =i915_gem_object_create_internal (i915,SZ_64K ); +if (IS_ERR (obj)) +return PTR_ERR (obj); + + time =i915_gem_object_pin_map (obj,I915_MAP_WC ); +if (IS_ERR (time)) { + err =PTR_ERR (time); + goto out_obj; + } + + rq =create_spinner (i915, &spin); +if (IS_ERR (rq)) { + err =PTR_ERR (rq); + goto out_obj; + } + + err =0 ; + count =0 ; +for_each_uabi_engine (engine, i915) { +if (!intel_engine_has_scheduler (engine)) +continue ; + + rq =__write_timestamp (engine, obj, count, rq); +if (IS_ERR (rq)) { + err =PTR_ERR (rq); +break ; + } + + count++; + } +for_each_uabi_engine (engine, i915) { +if (!intel_engine_has_scheduler (engine)) +continue ; + + rq =__write_timestamp (engine, obj, count, rq); +if (IS_ERR (rq)) { + err =PTR_ERR (rq); +break ; + } + + count++; + } +GEM_BUG_ON (count *sizeof (u32) > obj->base.size); +if (err || !count) + goto out_spin; + +fn (rq, count +1 , count); +igt_spinner_end (&spin); + +if (i915_request_wait (rq,0 ,HZ /2 ) <0 ) { + err = -ETIME ; + goto out_request; + } + + last = time[0 ]; +for (n =1 ; n < count; n++) { +if (i915_seqno_passed (last, time[n])) { +pr_err ("Timestamp[%lu] %x before previous %x\n" , + n, time[n], last); + err = -EINVAL ; +break ; + } + last = time[n]; + } + +out_request: +i915_request_put (rq); +out_spin: +igt_spinner_fini (&spin); +out_obj: +i915_gem_object_put (obj); +return 0 ; +} + +static bool noop (struct i915_request *rq,unsigned long v,unsigned long e) +{ +return true; +} + +static int igt_schedule_cycle (void *arg) +{ +return __igt_schedule_cycle (arg, noop); +} + +static int igt_priority_cycle (void *arg) +{ +return __igt_schedule_cycle (arg, igt_priority); +} +int i915_scheduler_live_selftests (struct drm_i915_private *i915) {static const struct i915_subtest tests[] = {SUBTEST (igt_priority_chains), + +SUBTEST (igt_schedule_cycle), +SUBTEST (igt_priority_cycle), };return i915_subtests (tests, i915);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 23/54 drm/i915: Improve DFS for priority inheritance
In reply to Chris WilsonThe core of the scheduling algorithm is that we compute the topological order of the fence DAG. Knowing that we have a DAG, we should be able to use a DFS to compute the topological sort in linear time. However, during the conversion of the recursive algorithm into an iterative one, the memorization of how far we had progressed down a branch was forgotten.
--- drivers/gpu/drm/i915/i915_scheduler.c | 58 ++++++++++++++++----------- 1 file changed, 34 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_scheduler.c +34 -24
@@ -234,6 +234,26 @@ void __i915_priolist_free(struct i915_priolist *p)kmem_cache_free (global.slab_priorities, p); } +static struct i915_request * +stack_push (struct i915_request *rq, +struct i915_request *stack, +struct list_head *pos) +{ + stack->sched.dfs.prev = pos; + rq->sched.dfs.next = (struct list_head *)stack; +return rq; +} + +static struct i915_request * +stack_pop (struct i915_request *rq, +struct list_head **pos) +{ + rq = (struct i915_request *)rq->sched.dfs.next; +if (rq) + *pos = rq->sched.dfs.prev; +return rq; +} +static inline bool need_preempt (int prio,int active) {/*
@@ -298,11 +318,10 @@ static void ipi_priority(struct i915_request *rq, int prio)static void __i915_request_set_priority (struct i915_request *rq,int prio) {struct intel_engine_cs *engine = rq->engine; -struct i915_request *rn; +struct list_head *pos = &rq->sched.signalers_list;struct list_head *plist; -LIST_HEAD (dfs); -list_add (&rq->sched.dfs, &dfs); + plist =i915_sched_lookup_priolist (engine, prio);/* * Recursively bump all dependent priorities to match the new request.
@@ -322,40 +341,31 @@ static void __i915_request_set_priority(struct i915_request *rq, int prio)* end result is a topological list of requests in reverse order, the * last element in the list is the request we must execute first. */ -list_for_each_entry (rq, &dfs, sched.dfs) { -struct i915_dependency *p; - -/* Also release any children on this engine that are ready */ -GEM_BUG_ON (rq->engine != engine); - -for_each_signaler (p, rq) { + rq->sched.dfs.next =NULL ; + do { + list_for_each_continue(pos, &rq->sched.signalers_list) { + struct i915_dependency *p = + list_entry(pos, typeof(*p), signal_link); struct i915_request *s = container_of(p->signaler, typeof(*s), sched); -GEM_BUG_ON (s == rq); - if (rq_prio(s) >= prio) continue; if (__i915_request_is_complete(s)) continue; -if (s->engine != rq->engine) { + if (s->engine != engine) { ipi_priority(s, prio); continue; } -list_move_tail (&s->sched.dfs, &dfs); + /* Remember our position along this branch */ + rq = stack_push(s, rq, pos); + pos = &rq->sched.signalers_list; } - } - - plist =i915_sched_lookup_priolist (engine, prio); - -/* Fifo and depth-first replacement ensure our deps execute first */ -list_for_each_entry_safe_reverse (rq, rn, &dfs, sched.dfs) { -GEM_BUG_ON (rq->engine != engine); -INIT_LIST_HEAD (&rq->sched.dfs); + RQ_TRACE(rq, "set-priority:%d\n", prio); WRITE_ONCE(rq->sched.attr.priority, prio); /*
@@ -369,12 +379,13 @@ static void __i915_request_set_priority(struct i915_request *rq, int prio)if (!i915_request_is_ready (rq))continue ; +GEM_BUG_ON (rq->engine != engine);if (i915_request_in_priority_queue (rq))list_move_tail (&rq->sched.link, plist);/* Defer (tasklet) submission until after all updates. */ kick_submission (engine, rq, prio); - } + }while ((rq =stack_pop (rq, &pos))); }void i915_request_set_priority (struct i915_request *rq,int prio)
@@ -442,7 +453,6 @@ void i915_sched_node_init(struct i915_sched_node *node)INIT_LIST_HEAD (&node->signalers_list);INIT_LIST_HEAD (&node->waiters_list);INIT_LIST_HEAD (&node->link); -INIT_LIST_HEAD (&node->dfs); node->ipi_link =NULL ;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 24/54 drm/i915: Extract request submission from execlists
In reply to Chris WilsonIn the process of preparing to reuse the request submission logic for other backends, lift it out of the execlists backend. It already operates on the common structs, so just a matter of moving and renaming.
--- .../drm/i915/gt/intel_execlists_submission.c | 55 +------------ drivers/gpu/drm/i915/i915_scheduler.c | 82 +++++++++++++++++++ drivers/gpu/drm/i915/i915_scheduler.h | 2 + 3 files changed, 85 insertions(+), 54 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +1 -54
@@ -2366,59 +2366,6 @@ static void execlists_preempt(struct timer_list *timer)execlists_kick (timer, preempt); } -static void queue_request (struct intel_engine_cs *engine, -struct i915_request *rq) -{ -GEM_BUG_ON (!list_empty (&rq->sched.link)); -list_add_tail (&rq->sched.link, -i915_sched_lookup_priolist (engine,rq_prio (rq))); -set_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags); -} - -static bool submit_queue (struct intel_engine_cs *engine, -const struct i915_request *rq) -{ -struct intel_engine_execlists *execlists = &engine->execlists; - -if (rq_prio (rq) <= execlists->queue_priority_hint) -return false; - - execlists->queue_priority_hint =rq_prio (rq); -return true; -} - -static bool ancestor_on_hold (const struct intel_engine_cs *engine, -const struct i915_request *rq) -{ -GEM_BUG_ON (i915_request_on_hold (rq)); -return !list_empty (&engine->active.hold) &&hold_request (rq); -} - -static void execlists_submit_request (struct i915_request *request) -{ -struct intel_engine_cs *engine = request->engine; -unsigned long flags; - -/* Will be called from irq-context when using foreign fences. */ -spin_lock_irqsave (&engine->active.lock, flags); - -if (unlikely (ancestor_on_hold (engine, request))) { -RQ_TRACE (request,"ancestor on hold\n" ); -list_add_tail (&request->sched.link, &engine->active.hold); -i915_request_set_hold (request); - }else { -queue_request (engine, request); - -GEM_BUG_ON (RB_EMPTY_ROOT (&engine->execlists.queue.rb_root)); -GEM_BUG_ON (list_empty (&request->sched.link)); - -if (submit_queue (engine, request)) -__execlists_kick (&engine->execlists); - } - -spin_unlock_irqrestore (&engine->active.lock, flags); -} -static int execlists_context_pre_pin (struct intel_context *ce,struct i915_gem_ww_ctx *ww,void **vaddr)
@@ -3047,7 +2994,7 @@ static void execlists_park(struct intel_engine_cs *engine)void intel_execlists_set_default_submission (struct intel_engine_cs *engine) { - engine->submit_request = execlists_submit_request; + engine->submit_request = i915_request_enqueue; engine->execlists.tasklet.func = execlists_submission_tasklet; engine->reset.prepare = execlists_reset_prepare;
drivers/gpu/drm/i915/i915_scheduler.c +82 -0
88 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +2 -0
@@ -39,6 +39,8 @@ void i915_sched_init_ipi(struct i915_sched_ipi *ipi);void i915_request_set_priority (struct i915_request *request,int prio); +void i915_request_enqueue (struct i915_request *request); +struct list_head *i915_sched_lookup_priolist (struct intel_engine_cs *engine,int prio);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 25/54 drm/i915: Extract request rewinding from execlists
In reply to Chris WilsonIn the process of preparing to reuse the request submission logic for other backends, lift it out of the execlists backend.
While this operates on the common structs, we do have a bit of backend knowledge, which is harmless for !lrc but still unsightly.
--- drivers/gpu/drm/i915/gt/intel_engine.h | 3 - .../drm/i915/gt/intel_execlists_submission.c | 58 ++----------------- drivers/gpu/drm/i915/gt/intel_lrc_reg.h | 3 + drivers/gpu/drm/i915/gt/selftest_execlists.c | 2 +- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 2 +- drivers/gpu/drm/i915/i915_scheduler.c | 44 ++++++++++++++ drivers/gpu/drm/i915/i915_scheduler.h | 3 + 7 files changed, 56 insertions(+), 59 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +0 -3
@@ -136,9 +136,6 @@ execlists_active_unlock_bh(struct intel_engine_execlists *execlists)local_bh_enable ();/* restore softirq, and kick ksoftirqd! */ } -struct i915_request * -execlists_unwind_incomplete_requests (struct intel_engine_execlists *execlists); -static inline u32 intel_read_status_page (const struct intel_engine_cs *engine,int reg) {
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +4 -54
88 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_lrc_reg.h +3 -0
@@ -93,4 +93,7 @@/* in Gen12 ID 0x7FF is reserved to indicate idle */ #define GEN12_MAX_CONTEXT_HW_ID (GEN11_MAX_CONTEXT_HW_ID - 1) +#define CTX_DESC_RELOAD_PD BIT_ULL(1) +#define CTX_DESC_FORCE_RESTORE BIT_ULL(2) +#endif /* _INTEL_LRC_REG_H_ */
drivers/gpu/drm/i915/gt/selftest_execlists.c +1 -1
@@ -4532,7 +4532,7 @@ static int reset_virtual_engine(struct intel_gt *gt,/* Fake a preemption event; failed of course */ spin_lock_irq (&engine->active.lock); -__unwind_incomplete_requests (engine); +__intel_engine_rewind_requests (engine);spin_unlock_irq (&engine->active.lock);GEM_BUG_ON (rq->engine != engine);
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +1 -1
@@ -434,7 +434,7 @@ static void guc_reset_rewind(struct intel_engine_cs *engine, bool stalled)cancel_port_requests (execlists);/* Push back any incomplete requests for replay after the reset. */ - rq =execlists_unwind_incomplete_requests (execlists); + rq =__intel_engine_rewind_requests (engine);if (!rq) goto out_unlock;
drivers/gpu/drm/i915/i915_scheduler.c +44 -0
56 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +3 -0
@@ -41,6 +41,9 @@ void i915_request_set_priority(struct i915_request *request, int prio);void i915_request_enqueue (struct i915_request *request); +struct i915_request * +__intel_engine_rewind_requests (struct intel_engine_cs *engine); +struct list_head *i915_sched_lookup_priolist (struct intel_engine_cs *engine,int prio);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 26/54 drm/i915: Extract request suspension from the execlists backend
In reply to Chris WilsonMake the ability to suspend and resume a request and its dependents generic.
--- .../drm/i915/gt/intel_execlists_submission.c | 148 +----------------- drivers/gpu/drm/i915/i915_scheduler.c | 120 ++++++++++++++ drivers/gpu/drm/i915/i915_scheduler.h | 5 + 3 files changed, 129 insertions(+), 144 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +4 -144
@@ -1881,166 +1881,26 @@ static void post_process_csb(struct i915_request **port,execlists_schedule_out (*port++); } -static void __execlists_hold (struct i915_request *rq) -{ -LIST_HEAD (list); - -do { -struct i915_dependency *p; - -if (i915_request_is_active (rq)) -__i915_request_unsubmit (rq); - -clear_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags); -list_move_tail (&rq->sched.link, &rq->engine->active.hold); -i915_request_set_hold (rq); -RQ_TRACE (rq,"on hold\n" ); - -for_each_waiter (p, rq) { -struct i915_request *w = -container_of (p->waiter,typeof (*w), sched); - -if (p->flags &I915_DEPENDENCY_WEAK ) -continue ; - -/* Leave semaphores spinning on the other engines */ -if (w->engine != rq->engine) -continue ; - -if (!i915_request_is_ready (w)) -continue ; - -if (__i915_request_is_complete (w)) -continue ; - -if (i915_request_on_hold (w)) -continue ; - -list_move_tail (&w->sched.link, &list); - } - - rq =list_first_entry_or_null (&list,typeof (*rq), sched.link); - }while (rq); -} -static bool execlists_hold (struct intel_engine_cs *engine,struct i915_request *rq) { +bool result; +if (i915_request_on_hold (rq))return false;spin_lock_irq (&engine->active.lock); - -if (__i915_request_is_complete (rq)) {/* too late! */ - rq =NULL ; - goto unlock; - } - -/* -* Transfer this request onto the hold queue to prevent it -* being resumbitted to HW (and potentially completed) before we have -* released it. Since we may have already submitted following -* requests, we need to remove those as well. -*/ -GEM_BUG_ON (i915_request_on_hold (rq)); -GEM_BUG_ON (rq->engine != engine); -__execlists_hold (rq); -GEM_BUG_ON (list_empty (&engine->active.hold)); - -unlock: + result =__intel_engine_hold_request (engine, rq);spin_unlock_irq (&engine->active.lock); -return rq; -} - -static bool hold_request (const struct i915_request *rq) -{ -struct i915_dependency *p; -bool result = false; - -/* -* If one of our ancestors is on hold, we must also be on hold, -* otherwise we will bypass it and execute before it. -*/ -rcu_read_lock (); -for_each_signaler (p, rq) { -const struct i915_request *s = -container_of (p->signaler,typeof (*s), sched); - -if (s->engine != rq->engine) -continue ; - - result =i915_request_on_hold (s); -if (result) -break ; - } -rcu_read_unlock ();return result; } -static void __execlists_unhold (struct i915_request *rq) -{ -LIST_HEAD (list); - -do { -struct i915_dependency *p; - -RQ_TRACE (rq,"hold release\n" ); - -GEM_BUG_ON (!i915_request_on_hold (rq)); -GEM_BUG_ON (!i915_sw_fence_signaled (&rq->submit)); - -i915_request_clear_hold (rq); -list_move_tail (&rq->sched.link, -i915_sched_lookup_priolist (rq->engine, -rq_prio (rq))); -set_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags); - -/* Also release any children on this engine that are ready */ -for_each_waiter (p, rq) { -struct i915_request *w = -container_of (p->waiter,typeof (*w), sched); - -if (p->flags &I915_DEPENDENCY_WEAK ) -continue ; - -/* Propagate any change in error status */ -if (rq->fence.error) -i915_request_set_error_once (w, rq->fence.error); - -if (w->engine != rq->engine) -continue ; - -if (!i915_request_on_hold (w)) -continue ; - -/* Check that no other parents are also on hold */ -if (hold_request (w)) -continue ; - -list_move_tail (&w->sched.link, &list); - } - - rq =list_first_entry_or_null (&list,typeof (*rq), sched.link); - }while (rq); -} -static void execlists_unhold (struct intel_engine_cs *engine,struct i915_request *rq) {spin_lock_irq (&engine->active.lock); - -/* -* Move this request back to the priority queue, and all of its -* children and grandchildren that were suspended along with it. -*/ -__execlists_unhold (rq); - -if (rq_prio (rq) > engine->execlists.queue_priority_hint) { - engine->execlists.queue_priority_hint =rq_prio (rq); -tasklet_hi_schedule (&engine->execlists.tasklet); - } - +__intel_engine_unhold_request (engine, rq);spin_unlock_irq (&engine->active.lock); }
drivers/gpu/drm/i915/i915_scheduler.c +120 -0
126 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +5 -0
@@ -44,6 +44,11 @@ void i915_request_enqueue(struct i915_request *request);struct i915_request *__intel_engine_rewind_requests (struct intel_engine_cs *engine); +bool __intel_engine_hold_request (struct intel_engine_cs *engine, +struct i915_request *request); +void __intel_engine_unhold_request (struct intel_engine_cs *engine, +struct i915_request *request); +struct list_head *i915_sched_lookup_priolist (struct intel_engine_cs *engine,int prio);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 27/54 drm/i915: Extract the ability to defer and rerun a request later
In reply to Chris WilsonLift the ability to defer a request until later from execlists into the common layer.
--- .../drm/i915/gt/intel_execlists_submission.c | 55 ++-------------- drivers/gpu/drm/i915/i915_scheduler.c | 66 ++++++++++++++++--- drivers/gpu/drm/i915/i915_scheduler.h | 5 +- 3 files changed, 67 insertions(+), 59 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +7 -48
@@ -995,9 +995,13 @@ static void virtual_xfer_context(struct virtual_engine *ve, } } -static void defer_request (struct i915_request *rq,struct list_head *const pl) +static void defer_active (struct intel_engine_cs *engine) { -LIST_HEAD (list); +struct i915_request *rq; + + rq =__intel_engine_rewind_requests (engine); +if (!rq) +return ;/* * We want to move the interrupted request to the back of
@@ -1006,52 +1010,7 @@ static void defer_request(struct i915_request *rq, struct list_head * const pl)* flight and were waiting for the interrupted request to * be run after it again. */ -do { -struct i915_dependency *p; - -GEM_BUG_ON (i915_request_is_active (rq)); -list_move_tail (&rq->sched.link, pl); - -for_each_waiter (p, rq) { -struct i915_request *w = -container_of (p->waiter,typeof (*w), sched); - -if (p->flags &I915_DEPENDENCY_WEAK ) -continue ; - -/* Leave semaphores spinning on the other engines */ -if (w->engine != rq->engine) -continue ; - -/* No waiter should start before its signaler */ -GEM_BUG_ON (i915_request_has_initial_breadcrumb (w) && -__i915_request_has_started (w) && - !__i915_request_is_complete (rq)); - -GEM_BUG_ON (i915_request_is_active (w)); -if (!i915_request_is_ready (w)) -continue ; - -if (rq_prio (w) <rq_prio (rq)) -continue ; - -GEM_BUG_ON (rq_prio (w) >rq_prio (rq)); -list_move_tail (&w->sched.link, &list); - } - - rq =list_first_entry_or_null (&list,typeof (*rq), sched.link); - }while (rq); -} - -static void defer_active (struct intel_engine_cs *engine) -{ -struct i915_request *rq; - - rq =__intel_engine_rewind_requests (engine); -if (!rq) -return ; - -defer_request (rq,i915_sched_lookup_priolist (engine,rq_prio (rq))); +__intel_engine_defer_request (engine, rq); } static bool
drivers/gpu/drm/i915/i915_scheduler.c +58 -8
100 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +2 -3
@@ -43,15 +43,14 @@ void i915_request_enqueue(struct i915_request *request);struct i915_request *__intel_engine_rewind_requests (struct intel_engine_cs *engine); +void __intel_engine_defer_request (struct intel_engine_cs *engine, +struct i915_request *request);bool __intel_engine_hold_request (struct intel_engine_cs *engine,struct i915_request *request);void __intel_engine_unhold_request (struct intel_engine_cs *engine,struct i915_request *request); -struct list_head * -i915_sched_lookup_priolist (struct intel_engine_cs *engine,int prio); -void __i915_priolist_free (struct i915_priolist *p);static inline void i915_priolist_free (struct i915_priolist *p) {
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 28/54 drm/i915: Fix the iterative dfs for defering requests
In reply to Chris WilsonThe current implementation of walking the children of a deferred requests lacks the backtracking required to reduce the dfs to linear. Having pulled it from execlists into the common layer, we can reuse the dfs code for priority inheritance.
--- drivers/gpu/drm/i915/i915_scheduler.c | 58 +++++++++++++++++++-------- 1 file changed, 42 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_scheduler.c +42 -16
@@ -452,25 +452,26 @@ void i915_request_set_priority(struct i915_request *rq, int prio)void __intel_engine_defer_request (struct intel_engine_cs *engine,struct i915_request *rq) { -struct list_head *pl; -LIST_HEAD (list); +struct list_head *pos = &rq->sched.waiters_list; +struct i915_request *rn; +LIST_HEAD (dfs); +int prio;lockdep_assert_held (&engine->active.lock);GEM_BUG_ON (!test_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags)); + prio =rq_prio (rq); +/* * When we defer a request, we must maintain its order with respect * to those that are waiting upon it. So we traverse its chain of * waiters and move any that are earlier than the request to after it. */ - pl =lookup_priolist (engine,rq_prio (rq)); + rq->sched.dfs.next =NULL ; do { - struct i915_dependency *p; - - GEM_BUG_ON(i915_request_is_active(rq)); - list_move_tail(&rq->sched.link, pl); - - for_each_waiter(p, rq) { + list_for_each_continue(pos, &rq->sched.waiters_list) { + struct i915_dependency *p = + list_entry(pos, typeof(*p), wait_link); struct i915_request *w = container_of(p->waiter, typeof(*w), sched);
@@ -486,19 +487,44 @@ void __intel_engine_defer_request(struct intel_engine_cs *engine,__i915_request_has_started (w) && !__i915_request_is_complete(rq)); -GEM_BUG_ON (i915_request_is_active (w)); -if (!i915_request_is_ready (w)) +if (!i915_request_in_priority_queue (w))continue ; -if (rq_prio (w) <rq_prio (rq)) +/* +* We also need to reorder within the same priority. +* +* This is unlike priority-inheritance, where if the +* signaler already has a higher priority [earlier +* deadline] than us, we can ignore as it will be +* scheduled first. If a waiter already has the +* same priority, we still have to push it to the end +* of the list. This unfortunately means we cannot +* use the rq_deadline() itself as a 'visited' bit. +*/ +if (rq_prio (w) < prio)continue ; -GEM_BUG_ON (rq_prio (w) >rq_prio (rq)); -list_move_tail (&w->sched.link, &list); +GEM_BUG_ON (rq_prio (w) != prio); + +/* Remember our position along this branch */ + rq =stack_push (w, rq, pos); + pos = &rq->sched.waiters_list; } - rq =list_first_entry_or_null (&list,typeof (*rq), sched.link); - }while (rq); +/* Note list is reversed for waiters wrt signal hierarchy */ +GEM_BUG_ON (rq->engine != engine); +GEM_BUG_ON (!i915_request_in_priority_queue (rq)); +list_move (&rq->sched.link, &dfs); + +/* Track our visit, and prevent duplicate processing */ +clear_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags); + }while ((rq =stack_pop (rq, &pos))); + + pos =lookup_priolist (engine, prio); +list_for_each_entry_safe (rq, rn, &dfs, sched.link) { +set_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags); +list_add_tail (&rq->sched.link, pos); + } } static void queue_request(struct intel_engine_cs *engine,
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 29/54 drm/i915: Move common active lists from engine to i915_scheduler
In reply to Chris WilsonExtract the scheduler lists into a related structure, stop sprawling over struct intel_engine_cs
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 26 +------------- drivers/gpu/drm/i915/gt/intel_engine_types.h | 8 +---- .../drm/i915/gt/intel_execlists_submission.c | 2 +- drivers/gpu/drm/i915/gt/mock_engine.c | 2 +- drivers/gpu/drm/i915/i915_scheduler.c | 34 ++++++++++++++++--- drivers/gpu/drm/i915/i915_scheduler.h | 3 +- drivers/gpu/drm/i915/i915_scheduler_types.h | 8 +++++ 7 files changed, 43 insertions(+), 40 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +1 -25
@@ -594,8 +594,6 @@ void intel_engine_init_execlists(struct intel_engine_cs *engine) execlists->queue_priority_hint =INT_MIN ; execlists->queue =RB_ROOT_CACHED ; - -i915_sched_init_ipi (&execlists->ipi); }static void cleanup_status_page (struct intel_engine_cs *engine)
@@ -711,7 +709,7 @@ static int engine_setup_common(struct intel_engine_cs *engine) goto err_status; } -intel_engine_init_active (engine,ENGINE_PHYSICAL ); +i915_sched_init_engine (&engine->active,ENGINE_PHYSICAL );intel_engine_init_execlists (engine);intel_engine_init_cmd_parser (engine);intel_engine_init__pm (engine);
@@ -776,28 +774,6 @@ static int measure_breadcrumb_dw(struct intel_context *ce)return dw; } -void -intel_engine_init_active (struct intel_engine_cs *engine,unsigned int subclass) -{ -INIT_LIST_HEAD (&engine->active.requests); -INIT_LIST_HEAD (&engine->active.hold); - -spin_lock_init (&engine->active.lock); -lockdep_set_subclass (&engine->active.lock, subclass); - -/* -* Due to an interesting quirk in lockdep's internal debug tracking, -* after setting a subclass we must ensure the lock is used. Otherwise, -* nr_unused_locks is incremented once too often. -*/ -#ifdef CONFIG_DEBUG_LOCK_ALLOC -local_irq_disable (); -lock_map_acquire (&engine->active.lock.dep_map); -lock_map_release (&engine->active.lock.dep_map); -local_irq_enable (); -#endif -} -static struct intel_context * create_pinned_context(struct intel_engine_cs *engine, unsigned int hwsp,
drivers/gpu/drm/i915/gt/intel_engine_types.h +1 -7
@@ -259,8 +259,6 @@ struct intel_engine_execlists {struct rb_root_cached queue;struct rb_root_cached virtual; -struct i915_sched_ipi ipi; -/** * @csb_write: control register for Context Switch buffer *
@@ -330,11 +328,7 @@ struct intel_engine_cs {struct intel_sseu sseu; -struct { -spinlock_t lock; -struct list_head requests; -struct list_head hold;/* ready requests, but on hold */ - } active; +struct i915_sched_engine active;/* keep a request in reserve for a [pm] barrier under oom */ struct i915_request *request_pool;
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +1 -1
@@ -3339,7 +3339,7 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings,snprintf (ve->base.name,sizeof (ve->base.name),"virtual" ); -intel_engine_init_active (&ve->base,ENGINE_VIRTUAL ); +i915_sched_init_engine (&ve->base.active,ENGINE_VIRTUAL );intel_engine_init_execlists (&ve->base); ve->base.cops = &virtual_context_ops;
drivers/gpu/drm/i915/gt/mock_engine.c +1 -1
@@ -355,7 +355,7 @@ int mock_engine_init(struct intel_engine_cs *engine) {struct intel_context *ce; -intel_engine_init_active (engine,ENGINE_MOCK ); +i915_sched_init_engine (&engine->active,ENGINE_MOCK );intel_engine_init_execlists (engine);intel_engine_init__pm (engine);intel_engine_init_retire (engine);
drivers/gpu/drm/i915/i915_scheduler.c +29 -5
@@ -85,12 +85,36 @@ static void ipi_schedule(struct work_struct *wrk) }while (rq); } -void i915_sched_init_ipi (struct i915_sched_ipi *ipi) +static void i915_sched_init_ipi (struct i915_sched_ipi *ipi) {INIT_WORK (&ipi->work, ipi_schedule); ipi->list =NULL ; } +void i915_sched_init_engine (struct i915_sched_engine *se, +unsigned int subclass) +{ +spin_lock_init (&se->lock); +lockdep_set_subclass (&se->lock, subclass); + +INIT_LIST_HEAD (&se->requests); +INIT_LIST_HEAD (&se->hold); + +i915_sched_init_ipi (&se->ipi); + +/* +* Due to an interesting quirk in lockdep's internal debug tracking, +* after setting a subclass we must ensure the lock is used. Otherwise, +* nr_unused_locks is incremented once too often. +*/ +#ifdef CONFIG_DEBUG_LOCK_ALLOC +local_irq_disable (); +lock_map_acquire (&se->lock.dep_map); +lock_map_release (&se->lock.dep_map); +local_irq_enable (); +#endif +} +static void __ipi_add (struct i915_request *rq) {#define STUB ((struct i915_request *)1)
@@ -106,13 +130,13 @@ static void __ipi_add(struct i915_request *rq)return ; } - first =READ_ONCE (engine->execlists.ipi.list); -do + first =READ_ONCE (engine->active.ipi.list); +do { rq->sched.ipi_link =ptr_pack_bits (first,1 ,1 ); -while (!try_cmpxchg (&engine->execlists.ipi.list, &first, rq)); + }while (!try_cmpxchg (&engine->active.ipi.list, &first, rq));if (!first) -queue_work (system_unbound_wq, &engine->execlists.ipi.work); +queue_work (system_unbound_wq, &engine->active.ipi.work); }/*
drivers/gpu/drm/i915/i915_scheduler.h +2 -1
@@ -35,7 +35,8 @@ int i915_sched_node_add_dependency(struct i915_sched_node *node,void i915_sched_node_retire (struct i915_sched_node *node); -void i915_sched_init_ipi (struct i915_sched_ipi *ipi); +void i915_sched_init_engine (struct i915_sched_engine *se, +unsigned int subclass);void i915_request_set_priority (struct i915_request *request,int prio);
drivers/gpu/drm/i915/i915_scheduler_types.h +8 -0
@@ -80,6 +80,14 @@ struct i915_sched_ipi {struct work_struct work; }; +struct i915_sched_engine { +spinlock_t lock; +struct list_head requests; +struct list_head hold;/* ready requests, but on hold */ + +struct i915_sched_ipi ipi; +}; +struct i915_dependency {struct i915_sched_node *signaler;struct i915_sched_node *waiter;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 30/54 drm/i915: Move scheduler queue
In reply to Chris WilsonExtract the scheduling queue from "execlists" into the per-engine scheduling structs, for reuse by other backends.
--- .../gpu/drm/i915/gem/i915_gem_context_types.h | 2 +- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 1 + drivers/gpu/drm/i915/gt/intel_engine_cs.c | 5 +-- drivers/gpu/drm/i915/gt/intel_engine_pm.c | 3 +- drivers/gpu/drm/i915/gt/intel_engine_types.h | 14 ------- .../drm/i915/gt/intel_execlists_submission.c | 29 +++++++------- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 11 +++--- drivers/gpu/drm/i915/i915_drv.h | 1 - drivers/gpu/drm/i915/i915_request.h | 2 +- drivers/gpu/drm/i915/i915_scheduler.c | 38 ++++++++++++------- drivers/gpu/drm/i915/i915_scheduler.h | 15 ++++++++ drivers/gpu/drm/i915/i915_scheduler_types.h | 15 ++++++++ .../gpu/drm/i915/selftests/i915_scheduler.c | 2 +- 13 files changed, 84 insertions(+), 54 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context_types.h +1 -1
@@ -19,7 +19,7 @@#include "gt/intel_context_types.h" -#include "i915_scheduler.h" +#include "i915_scheduler_types.h" #include "i915_sw_fence.h" struct pid ;
drivers/gpu/drm/i915/gem/i915_gem_wait.c +1 -0
@@ -12,6 +12,7 @@#include "dma_resv_utils.h" #include "i915_gem_ioctls.h" #include "i915_gem_object.h" +#include "i915_scheduler.h" static long i915_gem_object_wait_fence(struct dma_fence *fence,
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -3
@@ -593,7 +593,6 @@ void intel_engine_init_execlists(struct intel_engine_cs *engine)memset (execlists->inflight,0 ,sizeof (execlists->inflight)); execlists->queue_priority_hint =INT_MIN ; - execlists->queue =RB_ROOT_CACHED ; }static void cleanup_status_page (struct intel_engine_cs *engine)
@@ -915,7 +914,7 @@ int intel_engines_init(struct intel_gt *gt)*/ void intel_engine_cleanup_common (struct intel_engine_cs *engine) { -GEM_BUG_ON (!list_empty (&engine->active.requests)); +i915_sched_fini_engine (&engine->active);tasklet_kill (&engine->execlists.tasklet);/* flush the callback */ intel_breadcrumbs_free (engine->breadcrumbs);
@@ -1236,7 +1235,7 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine) }/* ELSP is empty, but there are ready requests? E.g. after reset */ -if (!RB_EMPTY_ROOT (&engine->execlists.queue.rb_root)) +if (!i915_sched_is_idle (&engine->active))return false;/* Ring stopped? */
drivers/gpu/drm/i915/gt/intel_engine_pm.c +2 -1
@@ -5,6 +5,7 @@*/ #include "i915_drv.h" +#include "i915_scheduler.h" #include "intel_breadcrumbs.h" #include "intel_context.h"
@@ -277,7 +278,7 @@ static int __engine_park(struct intel_wakeref *wf)if (engine->park) engine->park (engine); - engine->execlists.no_priolist = false; +i915_sched_park_engine (&engine->active);/* While gt calls i915_vma_parked(), we have to break the lock cycle */ intel_gt_pm_put_async (engine->gt);
drivers/gpu/drm/i915/gt/intel_engine_types.h +0 -14
@@ -154,11 +154,6 @@ struct intel_engine_execlists {*/ struct timer_list preempt; -/** -* @default_priolist: priority list for I915_PRIORITY_NORMAL -*/ -struct i915_priolist default_priolist; -/** * @ccid: identifier for contexts submitted to this engine */
@@ -193,11 +188,6 @@ struct intel_engine_execlists {*/ u32 reset_ccid; -/** -* @no_priolist: priority lists disabled -*/ -bool no_priolist; -/** * @submit_reg: gen-specific execlist submission register * set to the ExecList Submission Port (elsp) register pre-Gen11 and to
@@ -253,10 +243,6 @@ struct intel_engine_execlists {*/ int queue_priority_hint; -/** -* @queue: queue of requests, in priority lists -*/ -struct rb_root_cached queue;struct rb_root_cached virtual;/**
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +15 -14
@@ -284,11 +284,11 @@ static int effective_prio(const struct i915_request *rq)return prio; } -static int queue_prio (const struct intel_engine_execlists *execlists) +static int queue_prio (const struct i915_sched_engine *se) {struct rb_node *rb; - rb =rb_first_cached (&execlists->queue); + rb =rb_first_cached (&se->queue);if (!rb)return INT_MIN ;
@@ -351,7 +351,7 @@ static inline bool need_preempt(const struct intel_engine_cs *engine,* context, it's priority would not exceed ELSP[0] aka last_prio. */ return max (virtual_prio (&engine->execlists), -queue_prio (&engine->execlists)) > last_prio; +queue_prio (&engine->active)) > last_prio; } __maybe_unused static inline bool
@@ -1047,11 +1047,11 @@ static bool needs_timeslice(const struct intel_engine_cs *engine,return false;/* If ELSP[1] is occupied, always check to see if worth slicing */ -if (!list_is_last_rcu (&rq->sched.link, &engine->active.requests)) +if (!i915_sched_is_last_request (&engine->active, rq))return true;/* Otherwise, ELSP[0] is by itself, but may be waiting in the queue */ -if (!RB_EMPTY_ROOT (&engine->execlists.queue.rb_root)) +if (!i915_sched_is_idle (&engine->active))return true;return !RB_EMPTY_ROOT (&engine->execlists.virtual.rb_root);
@@ -1270,7 +1270,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)GEM_BUG_ON (rq->engine != &ve->base);GEM_BUG_ON (rq->context != &ve->context); -if (unlikely (rq_prio (rq) <queue_prio (execlists))) { +if (unlikely (rq_prio (rq) <queue_prio (&engine->active))) {spin_unlock (&ve->base.active.lock);break ; }
@@ -1338,7 +1338,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)break ; } -while ((rb =rb_first_cached (&execlists->queue))) { +while ((rb =rb_first_cached (&engine->active.queue))) {struct i915_priolist *p =to_priolist (rb);struct i915_request *rq, *rn;
@@ -1417,7 +1417,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine) } } -rb_erase_cached (&p->node, &execlists->queue); +rb_erase_cached (&p->node, &engine->active.queue);i915_priolist_free (p); } done:
@@ -1439,7 +1439,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)* request triggering preemption on the next dequeue (or subsequent * interrupt for secondary ports). */ - execlists->queue_priority_hint =queue_prio (execlists); + execlists->queue_priority_hint =queue_prio (&engine->active);spin_unlock (&engine->active.lock);/*
@@ -2673,7 +2673,7 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)intel_engine_signal_breadcrumbs (engine);/* Flush the queued requests to the timeline list (for retiring). */ -while ((rb =rb_first_cached (&execlists->queue))) { +while ((rb =rb_first_cached (&engine->active.queue))) {struct i915_priolist *p =to_priolist (rb);priolist_for_each_request_consume (rq, rn, p) {
@@ -2681,9 +2681,10 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)__i915_request_submit (rq); } -rb_erase_cached (&p->node, &execlists->queue); +rb_erase_cached (&p->node, &engine->active.queue);i915_priolist_free (p); } +GEM_BUG_ON (!i915_sched_is_idle (&engine->active));/* On-hold requests will be flushed to timeline upon their release */ list_for_each_entry (rq, &engine->active.hold, sched.link)
@@ -2714,7 +2715,7 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)/* Remaining _unready_ requests will be nop'ed when submitted */ execlists->queue_priority_hint =INT_MIN ; - execlists->queue =RB_ROOT_CACHED ; + engine->active.queue =RB_ROOT_CACHED ;GEM_BUG_ON (__tasklet_is_enabled (&execlists->tasklet)); execlists->tasklet.func = nop_submission_tasklet;
@@ -2947,7 +2948,7 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine)static struct list_head *virtual_queue (struct virtual_engine *ve) { -return &ve->base.execlists.default_priolist.requests; +return &ve->base.active.default_priolist.requests; }static void rcu_virtual_context_destroy (struct work_struct *wrk)
@@ -3538,7 +3539,7 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine, last =NULL ; count =0 ; -for (rb =rb_first_cached (&execlists->queue); rb; rb =rb_next (rb)) { +for (rb =rb_first_cached (&engine->active.queue); rb; rb =rb_next (rb)) {struct i915_priolist *p =rb_entry (rb,typeof (*p), node);priolist_for_each_request (rq, p) {
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +6 -5
@@ -310,7 +310,7 @@ static void __guc_dequeue(struct intel_engine_cs *engine)* event. */ port = first; -while ((rb =rb_first_cached (&execlists->queue))) { +while ((rb =rb_first_cached (&engine->active.queue))) {struct i915_priolist *p =to_priolist (rb);struct i915_request *rq, *rn;
@@ -330,7 +330,7 @@ static void __guc_dequeue(struct intel_engine_cs *engine) last = rq; } -rb_erase_cached (&p->node, &execlists->queue); +rb_erase_cached (&p->node, &engine->active.queue);i915_priolist_free (p); } done:
@@ -483,7 +483,7 @@ static void guc_reset_cancel(struct intel_engine_cs *engine) }/* Flush the queued requests to the timeline list (for retiring). */ -while ((rb =rb_first_cached (&execlists->queue))) { +while ((rb =rb_first_cached (&engine->active.queue))) {struct i915_priolist *p =to_priolist (rb);priolist_for_each_request_consume (rq, rn, p) {
@@ -493,14 +493,15 @@ static void guc_reset_cancel(struct intel_engine_cs *engine)i915_request_mark_complete (rq); } -rb_erase_cached (&p->node, &execlists->queue); +rb_erase_cached (&p->node, &engine->active.queue);i915_priolist_free (p); } +GEM_BUG_ON (!i915_sched_is_idle (&engine->active));/* Remaining _unready_ requests will be nop'ed when submitted */ execlists->queue_priority_hint =INT_MIN ; - execlists->queue =RB_ROOT_CACHED ; + engine->active.queue =RB_ROOT_CACHED ;spin_unlock_irqrestore (&engine->active.lock, flags); }
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -97,7 +97,6 @@#include "i915_gpu_error.h" #include "i915_perf_types.h" #include "i915_request.h" -#include "i915_scheduler.h" #include "gt/intel_timeline.h" #include "i915_vma.h" #include "i915_irq.h"
drivers/gpu/drm/i915/i915_request.h +1 -1
@@ -35,7 +35,7 @@#include "gt/intel_timeline_types.h" #include "i915_gem.h" -#include "i915_scheduler.h" +#include "i915_scheduler_types.h" #include "i915_selftest.h" #include "i915_sw_fence.h"
drivers/gpu/drm/i915/i915_scheduler.c +25 -13
@@ -99,6 +99,7 @@ void i915_sched_init_engine(struct i915_sched_engine *se,INIT_LIST_HEAD (&se->requests);INIT_LIST_HEAD (&se->hold); + se->queue =RB_ROOT_CACHED ;i915_sched_init_ipi (&se->ipi);
@@ -115,6 +116,17 @@ void i915_sched_init_engine(struct i915_sched_engine *se,#endif } +void i915_sched_park_engine (struct i915_sched_engine *se) +{ +GEM_BUG_ON (!i915_sched_is_idle (se)); + se->no_priolist = false; +} + +void i915_sched_fini_engine (struct i915_sched_engine *se) +{ +GEM_BUG_ON (!list_empty (&se->requests)); +} +static void __ipi_add (struct i915_request *rq) {#define STUB ((struct i915_request *)1)
@@ -175,7 +187,7 @@ static inline struct i915_priolist *to_priolist(struct rb_node *rb) return rb_entry(rb, struct i915_priolist, node); } -static void assert_priolists (struct intel_engine_execlists *const execlists) +static void assert_priolists (struct i915_sched_engine *const se) {struct rb_node *rb;long last_prio;
@@ -183,11 +195,11 @@ static void assert_priolists(struct intel_engine_execlists * const execlists)if (!IS_ENABLED (CONFIG_DRM_I915_DEBUG_GEM ))return ; -GEM_BUG_ON (rb_first_cached (&execlists->queue) != -rb_first (&execlists->queue.rb_root)); +GEM_BUG_ON (rb_first_cached (&se->queue) != +rb_first (&se->queue.rb_root)); last_prio =INT_MAX ; -for (rb =rb_first_cached (&execlists->queue); rb; rb =rb_next (rb)) { +for (rb =rb_first_cached (&se->queue); rb; rb =rb_next (rb)) {const struct i915_priolist *p =to_priolist (rb);GEM_BUG_ON (p->priority > last_prio);
@@ -198,21 +210,21 @@ static void assert_priolists(struct intel_engine_execlists * const execlists)static struct list_head *lookup_priolist (struct intel_engine_cs *engine,int prio) { -struct intel_engine_execlists *const execlists = &engine->execlists; +struct i915_sched_engine *const se = &engine->active;struct i915_priolist *p;struct rb_node **parent, *rb;bool first = true;lockdep_assert_held (&engine->active.lock); -assert_priolists (execlists); +assert_priolists (se); -if (unlikely (execlists->no_priolist)) +if (unlikely (se->no_priolist)) prio =I915_PRIORITY_NORMAL ; find_priolist:/* most positive priority is scheduled first, equal priorities fifo */ rb =NULL ; - parent = &execlists->queue.rb_root.rb_node; + parent = &se->queue.rb_root.rb_node;while (*parent) { rb = *parent; p =to_priolist (rb);
@@ -227,7 +239,7 @@ lookup_priolist(struct intel_engine_cs *engine, int prio) }if (prio ==I915_PRIORITY_NORMAL ) { - p = &execlists->default_priolist; + p = &se->default_priolist; }else { p =kmem_cache_alloc (global.slab_priorities,GFP_ATOMIC );/* Convert an allocation failure to a priority bump */
@@ -242,7 +254,7 @@ lookup_priolist(struct intel_engine_cs *engine, int prio)* requests, so if userspace lied about their * dependencies that reordering may be visible. */ - execlists->no_priolist = true; + se->no_priolist = true; goto find_priolist; } }
@@ -251,7 +263,7 @@ lookup_priolist(struct intel_engine_cs *engine, int prio)INIT_LIST_HEAD (&p->requests);rb_link_node (&p->node, rb, parent); -rb_insert_color_cached (&p->node, &execlists->queue, first); +rb_insert_color_cached (&p->node, &se->queue, first);return &p->requests; }
@@ -621,7 +633,7 @@ void i915_request_enqueue(struct i915_request *rq) }else {queue_request (engine, rq); -GEM_BUG_ON (RB_EMPTY_ROOT (&engine->execlists.queue.rb_root)); +GEM_BUG_ON (i915_sched_is_idle (&engine->active)); kick =submit_queue (engine, rq); }
@@ -656,7 +668,7 @@ __intel_engine_rewind_requests(struct intel_engine_cs *engine) prio =rq_prio (rq); pl =lookup_priolist (engine, prio); } -GEM_BUG_ON (RB_EMPTY_ROOT (&engine->execlists.queue.rb_root)); +GEM_BUG_ON (i915_sched_is_idle (&engine->active));list_move (&rq->sched.link, pl);set_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags);
drivers/gpu/drm/i915/i915_scheduler.h +15 -0
@@ -12,6 +12,7 @@#include <linux/kernel.h> #include "i915_scheduler_types.h" +#include "i915_request.h" struct drm_printer ;
@@ -37,6 +38,8 @@ void i915_sched_node_retire(struct i915_sched_node *node);void i915_sched_init_engine (struct i915_sched_engine *se,unsigned int subclass); +void i915_sched_park_engine (struct i915_sched_engine *se); +void i915_sched_fini_engine (struct i915_sched_engine *se);void i915_request_set_priority (struct i915_request *request,int prio);
@@ -59,6 +62,18 @@ static inline void i915_priolist_free(struct i915_priolist *p)__i915_priolist_free (p); } +static inline bool i915_sched_is_idle (const struct i915_sched_engine *se) +{ +return RB_EMPTY_ROOT (&se->queue.rb_root); +} + +static inline bool +i915_sched_is_last_request (const struct i915_sched_engine *se, +const struct i915_request *rq) +{ +return list_is_last_rcu (&rq->sched.link, &se->requests); +} + void i915_request_show_with_schedule(struct drm_printer *m, const struct i915_request *rq, const char *prefix,
drivers/gpu/drm/i915/i915_scheduler_types.h +15 -0
@@ -82,10 +82,25 @@ struct i915_sched_ipi {struct i915_sched_engine {spinlock_t lock; +struct list_head requests;struct list_head hold;/* ready requests, but on hold */ +/** +* @queue: queue of requests, in priority lists +*/ +struct rb_root_cached queue;struct i915_sched_ipi ipi; + +/** +* @default_priolist: priority list for I915_PRIORITY_NORMAL +*/ +struct i915_priolist default_priolist; + +/** +* @no_priolist: priority lists disabled +*/ +bool no_priolist; };struct i915_dependency {
drivers/gpu/drm/i915/selftests/i915_scheduler.c +1 -1
@@ -92,7 +92,7 @@ static bool check_context_order(struct intel_engine_cs *engine) last_context =0 ; last_seqno =0 ; last_prio =0 ; -for (rb =rb_first_cached (&engine->execlists.queue); rb; rb =rb_next (rb)) { +for (rb =rb_first_cached (&engine->active.queue); rb; rb =rb_next (rb)) {struct i915_priolist *p =rb_entry (rb,typeof (*p), node);struct i915_request *rq;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 31/54 drm/i915: Move tasklet from execlists to sched
In reply to Chris WilsonMove the scheduling tasklists out of the execlists backend into the per-engine scheduling bookkeeping.
--- drivers/gpu/drm/i915/gt/intel_engine.h | 14 ---- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 11 ++-- drivers/gpu/drm/i915/gt/intel_engine_types.h | 5 -- .../drm/i915/gt/intel_execlists_submission.c | 64 +++++++++---------- drivers/gpu/drm/i915/gt/intel_gt_irq.c | 2 +- drivers/gpu/drm/i915/gt/selftest_execlists.c | 16 ++--- drivers/gpu/drm/i915/gt/selftest_hangcheck.c | 2 +- drivers/gpu/drm/i915/gt/selftest_lrc.c | 6 +- drivers/gpu/drm/i915/gt/selftest_reset.c | 6 +- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 14 ++-- drivers/gpu/drm/i915/i915_scheduler.c | 14 ++-- drivers/gpu/drm/i915/i915_scheduler.h | 20 ++++++ drivers/gpu/drm/i915/i915_scheduler_types.h | 6 ++ .../gpu/drm/i915/selftests/i915_scheduler.c | 16 ++--- 14 files changed, 99 insertions(+), 97 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +0 -14
@@ -122,20 +122,6 @@ execlists_active(const struct intel_engine_execlists *execlists)return active; } -static inline void -execlists_active_lock_bh (struct intel_engine_execlists *execlists) -{ -local_bh_disable ();/* prevent local softirq and lock recursion */ -tasklet_lock (&execlists->tasklet); -} - -static inline void -execlists_active_unlock_bh (struct intel_engine_execlists *execlists) -{ -tasklet_unlock (&execlists->tasklet); -local_bh_enable ();/* restore softirq, and kick ksoftirqd! */ -} -static inline u32 intel_read_status_page (const struct intel_engine_cs *engine,int reg) {
drivers/gpu/drm/i915/gt/intel_engine_cs.c +5 -6
@@ -915,7 +915,6 @@ int intel_engines_init(struct intel_gt *gt)void intel_engine_cleanup_common (struct intel_engine_cs *engine) {i915_sched_fini_engine (&engine->active); -tasklet_kill (&engine->execlists.tasklet);/* flush the callback */ intel_breadcrumbs_free (engine->breadcrumbs);
@@ -1189,7 +1188,7 @@ static bool ring_is_idle(struct intel_engine_cs *engine)void __intel_engine_flush_submission (struct intel_engine_cs *engine,bool sync) { -struct tasklet_struct *t = &engine->execlists.tasklet; +struct tasklet_struct *t = &engine->active.tasklet;if (!t->func)return ;
@@ -1454,8 +1453,8 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine,drm_printf (m,"\tExeclist tasklet queued? %s (%s), preempt? %s, timeslice? %s\n" ,yesno (test_bit (TASKLET_STATE_SCHED , - &engine->execlists.tasklet.state)), -enableddisabled (!atomic_read (&engine->execlists.tasklet.count)), + &engine->active.tasklet.state)), +enableddisabled (!atomic_read (&engine->active.tasklet.count)),repr_timer (&engine->execlists.preempt),repr_timer (&engine->execlists.timer));
@@ -1479,7 +1478,7 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine, idx, hws[idx * 2], hws[idx * 2 + 1]); } -execlists_active_lock_bh (execlists); +i915_sched_lock_bh (&engine->active);rcu_read_lock ();for (port = execlists->active; (rq = *port); port++) {char hdr[160 ];
@@ -1510,7 +1509,7 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine,i915_request_show (m, rq, hdr,0 ); }rcu_read_unlock (); -execlists_active_unlock_bh (execlists); +i915_sched_unlock_bh (&engine->active); }else if (INTEL_GEN (dev_priv) >6 ) {drm_printf (m,"\tPP_DIR_BASE: 0x%08x\n" ,ENGINE_READ (engine,RING_PP_DIR_BASE ));
drivers/gpu/drm/i915/gt/intel_engine_types.h +0 -5
@@ -139,11 +139,6 @@ struct st_preempt_hang {* driver and the hardware state for execlist mode of submission. */ struct intel_engine_execlists { -/** -* @tasklet: softirq tasklet for bottom handler -*/ -struct tasklet_struct tasklet; -/** * @timer: kick the current context if its timeslice expires */
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +31 -33
201 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_gt_irq.c +1 -1
@@ -60,7 +60,7 @@ cs_irq_handler(struct intel_engine_cs *engine, u32 iir) }if (tasklet) -tasklet_hi_schedule (&engine->execlists.tasklet); +i915_sched_kick (&engine->active); } static u32
drivers/gpu/drm/i915/gt/selftest_execlists.c +8 -8
@@ -44,7 +44,7 @@ static int wait_for_submit(struct intel_engine_cs *engine, unsigned long timeout) {/* Ignore our own attempts to suppress excess tasklets */ -tasklet_hi_schedule (&engine->execlists.tasklet); +i915_sched_kick (&engine->active); timeout += jiffies; do {
@@ -603,9 +603,9 @@ static int live_hold_reset(void *arg) err = -EBUSY ; goto out; } -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet); - engine->execlists.tasklet.func (engine->execlists.tasklet.data); + engine->active.tasklet.func (engine->active.tasklet.data);GEM_BUG_ON (execlists_active (&engine->execlists) != rq);i915_request_get (rq);
@@ -615,7 +615,7 @@ static int live_hold_reset(void *arg)__intel_engine_reset_bh (engine,NULL );GEM_BUG_ON (rq->fence.error != -EIO ); -tasklet_enable (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet);clear_and_wake_up_bit (I915_RESET_ENGINE + id, >->reset.flags);local_bh_enable ();
@@ -1174,7 +1174,7 @@ static int live_timeslice_rewind(void *arg)while (i915_request_is_active (rq[A2 ])) {/* semaphore yield! */ /* Wait for the timeslice to kick in */ del_timer (&engine->execlists.timer); -tasklet_hi_schedule (&engine->execlists.tasklet); +i915_sched_kick (&engine->active);intel_engine_flush_submission (engine); }/* -> ELSP[] = { { A:rq1 }, { B:rq1 } } */
@@ -4525,9 +4525,9 @@ static int reset_virtual_engine(struct intel_gt *gt, err = -EBUSY ; goto out_heartbeat; } -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet); - engine->execlists.tasklet.func (engine->execlists.tasklet.data); + engine->active.tasklet.func (engine->active.tasklet.data);GEM_BUG_ON (execlists_active (&engine->execlists) != rq);/* Fake a preemption event; failed of course */
@@ -4544,7 +4544,7 @@ static int reset_virtual_engine(struct intel_gt *gt,GEM_BUG_ON (rq->fence.error != -EIO );/* Release our grasp on the engine, letting CS flow again */ -tasklet_enable (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet);clear_and_wake_up_bit (I915_RESET_ENGINE + engine->id, >->reset.flags);local_bh_enable ();
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +1 -1
@@ -1568,7 +1568,7 @@ static int __igt_atomic_reset_engine(struct intel_engine_cs *engine,const struct igt_atomic_section *p, const char *mode) { - struct tasklet_struct * const t = &engine->execlists.tasklet; + struct tasklet_struct * const t = &engine->active.tasklet;int err; GEM_TRACE("i915_reset_engine(%s:%s) under %s\n",
drivers/gpu/drm/i915/gt/selftest_lrc.c +3 -3
@@ -49,7 +49,7 @@ static int wait_for_submit(struct intel_engine_cs *engine, unsigned long timeout) {/* Ignore our own attempts to suppress excess tasklets */ -tasklet_hi_schedule (&engine->execlists.tasklet); +i915_sched_kick (&engine->active); timeout += jiffies; do {
@@ -1608,12 +1608,12 @@ static void garbage_reset(struct intel_engine_cs *engine,local_bh_disable ();if (!test_and_set_bit (bit, lock)) { -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet);if (!rq->fence.error)__intel_engine_reset_bh (engine,NULL ); -tasklet_enable (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet);clear_and_wake_up_bit (bit, lock); }local_bh_enable ();
drivers/gpu/drm/i915/gt/selftest_reset.c +3 -3
@@ -321,7 +321,7 @@ static int igt_atomic_engine_reset(void *arg) goto out_unlock;for_each_engine (engine, gt, id) { -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet);intel_engine_pm_get (engine);for (p = igt_atomic_phases; p->name; p++) {
@@ -345,8 +345,8 @@ static int igt_atomic_engine_reset(void *arg) }intel_engine_pm_put (engine); -tasklet_enable (&engine->execlists.tasklet); -tasklet_hi_schedule (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet); +tasklet_hi_schedule (&engine->active.tasklet);if (err)break ; }
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +5 -9
@@ -372,8 +372,6 @@ static void guc_submission_tasklet(unsigned long data)static void guc_reset_prepare (struct intel_engine_cs *engine) { -struct intel_engine_execlists *const execlists = &engine->execlists; -ENGINE_TRACE (engine,"\n" );/*
@@ -385,7 +383,7 @@ static void guc_reset_prepare(struct intel_engine_cs *engine)* Turning off the execlists->tasklet until the reset is over * prevents the race. */ -__tasklet_disable_sync_once (&execlists->tasklet); +__tasklet_disable_sync_once (&engine->active.tasklet); } static void
@@ -508,14 +506,12 @@ static void guc_reset_cancel(struct intel_engine_cs *engine)static void guc_reset_finish (struct intel_engine_cs *engine) { -struct intel_engine_execlists *const execlists = &engine->execlists; - -if (__tasklet_enable (&execlists->tasklet)) +if (__tasklet_enable (&engine->active.tasklet))/* And kick in case we missed a new request submission. */ -tasklet_hi_schedule (&execlists->tasklet); +tasklet_hi_schedule (&engine->active.tasklet);ENGINE_TRACE (engine,"depth->%d\n" , -atomic_read (&execlists->tasklet.count)); +atomic_read (&engine->active.tasklet.count)); }/*
@@ -613,7 +609,7 @@ static void guc_set_default_submission(struct intel_engine_cs *engine)*/ intel_execlists_set_default_submission (engine); - engine->execlists.tasklet.func = guc_submission_tasklet; + engine->active.tasklet.func = guc_submission_tasklet;/* do not use execlists park/unpark */ engine->park = engine->unpark =NULL ;
drivers/gpu/drm/i915/i915_scheduler.c +8 -6
@@ -125,6 +125,7 @@ void i915_sched_park_engine(struct i915_sched_engine *se)void i915_sched_fini_engine (struct i915_sched_engine *se) {GEM_BUG_ON (!list_empty (&se->requests)); +tasklet_kill (&se->tasklet);/* flush the callback */ }static void __ipi_add (struct i915_request *rq)
@@ -339,7 +340,7 @@ static void kick_submission(struct intel_engine_cs *engine, engine->execlists.queue_priority_hint = prio;if (need_preempt (prio,rq_prio (inflight))) -tasklet_hi_schedule (&engine->execlists.tasklet); +i915_sched_kick (&engine->active); }static void ipi_priority (struct i915_request *rq,int prio)
@@ -619,16 +620,17 @@ static bool ancestor_on_hold(const struct intel_engine_cs *engine,void i915_request_enqueue (struct i915_request *rq) {struct intel_engine_cs *engine = rq->engine; +struct i915_sched_engine *se = &engine->active;unsigned long flags;bool kick = false;/* Will be called from irq-context when using foreign fences. */ -spin_lock_irqsave (&engine->active.lock, flags); +spin_lock_irqsave (&se->lock, flags);GEM_BUG_ON (test_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags));if (unlikely (ancestor_on_hold (engine, rq))) {RQ_TRACE (rq,"ancestor on hold\n" ); -list_add_tail (&rq->sched.link, &engine->active.hold); +list_add_tail (&rq->sched.link, &se->hold);i915_request_set_hold (rq); }else {queue_request (engine, rq);
@@ -639,9 +641,9 @@ void i915_request_enqueue(struct i915_request *rq) }GEM_BUG_ON (list_empty (&rq->sched.link)); -spin_unlock_irqrestore (&engine->active.lock, flags); +spin_unlock_irqrestore (&se->lock, flags);if (kick) -tasklet_hi_schedule (&engine->execlists.tasklet); +i915_sched_kick (se); } struct i915_request *
@@ -754,7 +756,7 @@ void __intel_engine_unhold_request(struct intel_engine_cs *engine,if (rq_prio (rq) > engine->execlists.queue_priority_hint) { engine->execlists.queue_priority_hint =rq_prio (rq); -tasklet_hi_schedule (&engine->execlists.tasklet); +i915_sched_kick (&engine->active); }/*
drivers/gpu/drm/i915/i915_scheduler.h +20 -0
@@ -74,6 +74,26 @@ i915_sched_is_last_request(const struct i915_sched_engine *se,return list_is_last_rcu (&rq->sched.link, &se->requests); } +static inline void +i915_sched_lock_bh (struct i915_sched_engine *se) +{ +local_bh_disable ();/* prevent local softirq and lock recursion */ +tasklet_lock (&se->tasklet); +} + +static inline void +i915_sched_unlock_bh (struct i915_sched_engine *se) +{ +tasklet_unlock (&se->tasklet); +local_bh_enable ();/* restore softirq, and kick ksoftirqd! */ +} + +static inline void i915_sched_kick (struct i915_sched_engine *se) +{ +/* Kick the tasklet for some interrupt coalescing and reset handling */ +tasklet_hi_schedule (&se->tasklet); +} + void i915_request_show_with_schedule(struct drm_printer *m, const struct i915_request *rq, const char *prefix,
drivers/gpu/drm/i915/i915_scheduler_types.h +6 -0
@@ -7,6 +7,7 @@#ifndef _I915_SCHEDULER_TYPES_H_#define _I915_SCHEDULER_TYPES_H_ +#include <linux/interrupt.h> #include <linux/list.h> #include <linux/workqueue.h>
@@ -101,6 +102,11 @@ struct i915_sched_engine {* @no_priolist: priority lists disabled */ bool no_priolist; + +/** +* @tasklet: softirq tasklet for bottom half +*/ +struct tasklet_struct tasklet; };struct i915_dependency {
drivers/gpu/drm/i915/selftests/i915_scheduler.c +8 -8
@@ -172,12 +172,12 @@ static int __single_chain(struct intel_engine_cs *engine, unsigned long length, }intel_engine_flush_submission (engine); -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet);local_bh_disable ();if (fn (rq, count, count -1 ) && !check_context_order (engine)) err = -EINVAL ;local_bh_enable (); -tasklet_enable (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet);igt_spinner_end (&spin); err_context:
@@ -258,12 +258,12 @@ static int __wide_chain(struct intel_engine_cs *engine, unsigned long width, }intel_engine_flush_submission (engine); -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet);local_bh_disable ();if (fn (rq[i -1 ], i, count) && !check_context_order (engine)) err = -EINVAL ;local_bh_enable (); -tasklet_enable (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet);igt_spinner_end (&spin); err_free:
@@ -348,12 +348,12 @@ static int __inv_chain(struct intel_engine_cs *engine, unsigned long width, }intel_engine_flush_submission (engine); -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet);local_bh_disable ();if (fn (rq[i -1 ], i, count) && !check_context_order (engine)) err = -EINVAL ;local_bh_enable (); -tasklet_enable (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet);igt_spinner_end (&spin); err_free:
@@ -455,12 +455,12 @@ static int __sparse_chain(struct intel_engine_cs *engine, unsigned long width, }intel_engine_flush_submission (engine); -tasklet_disable (&engine->execlists.tasklet); +tasklet_disable (&engine->active.tasklet);local_bh_disable ();if (fn (rq[i -1 ], i, count) && !check_context_order (engine)) err = -EINVAL ;local_bh_enable (); -tasklet_enable (&engine->execlists.tasklet); +tasklet_enable (&engine->active.tasklet);igt_spinner_end (&spin); err_free:
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 32/54 drm/i915: Replace priolist rbtree with a skiplist
In reply to Chris WilsonReplace the priolist rbtree with a skiplist. The crucial difference is that walking and removing the first element of a skiplist is O(1), but O(lgN) for an rbtree, as we need to rebalance on remove. This is a hindrance for submission latency as it occurs between picking a request for the priolist and submitting it to hardware, as well effectively trippling the number of O(lgN) operations required under the irqoff lock. This is critical to reducing the latency jitter with multiple clients.
The downsides to skiplists are that lookup/insertion is only probablistically O(lgN) and there is a significant memory penalty to as each skip node is larger than the rbtree equivalent. Furthermore, we don't use dynamic arrays for the skiplist, so the allocation is fixed, and imposes an upper bound on the scalability wrt to the number of inflight requests.
--- .../drm/i915/gt/intel_execlists_submission.c | 63 ++--- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 30 +-- drivers/gpu/drm/i915/i915_priolist_types.h | 29 ++- drivers/gpu/drm/i915/i915_scheduler.c | 233 +++++++++++++----- drivers/gpu/drm/i915/i915_scheduler.h | 11 +- drivers/gpu/drm/i915/i915_scheduler_types.h | 2 +- .../drm/i915/selftests/i915_mock_selftests.h | 1 + .../gpu/drm/i915/selftests/i915_scheduler.c | 42 +++- 8 files changed, 294 insertions(+), 117 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +35 -28
@@ -256,11 +256,6 @@ ring_set_paused(const struct intel_engine_cs *engine, int state)wmb (); } -static inline struct i915_priolist *to_priolist (struct rb_node *rb) -{ - return rb_entry(rb, struct i915_priolist, node); -} -static inline int rq_prio (const struct i915_request *rq) {return READ_ONCE (rq->sched.attr.priority);
@@ -284,15 +279,31 @@ static int effective_prio(const struct i915_request *rq)return prio; } -static int queue_prio (const struct i915_sched_engine *se) +static struct i915_request *first_request (struct i915_sched_engine *se) { -struct rb_node *rb; +struct i915_priolist *pl; + +for_each_priolist (pl, &se->queue) { +if (likely (!list_empty (&pl->requests))) +return list_first_entry (&pl->requests, + struct i915_request, + sched.link); + +i915_priolist_advance (&se->queue, pl); + } + +return NULL ; +} - rb =rb_first_cached (&se->queue); -if (!rb) +static int queue_prio (struct i915_sched_engine *se) +{ +struct i915_request *rq; + + rq =first_request (se); +if (!rq)return INT_MIN ; -return to_priolist (rb)->priority; +return rq_prio (rq); }static int virtual_prio (const struct intel_engine_execlists *el)
@@ -302,7 +313,7 @@ static int virtual_prio(const struct intel_engine_execlists *el) return rb ? rb_entry(rb, struct ve_node, rb)->prio : INT_MIN; } -static inline bool need_preempt (const struct intel_engine_cs *engine, +static inline bool need_preempt (struct intel_engine_cs *engine,const struct i915_request *rq) {int last_prio;
@@ -1139,6 +1150,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)struct i915_request **const last_port = port + execlists->port_mask;struct i915_request *last, *const *active;struct virtual_engine *ve; +struct i915_priolist *pl;struct rb_node *rb;bool submit = false;
@@ -1338,11 +1350,10 @@ static void execlists_dequeue(struct intel_engine_cs *engine)break ; } -while ((rb =rb_first_cached (&engine->active.queue))) { -struct i915_priolist *p =to_priolist (rb); +for_each_priolist (pl, &engine->active.queue) {struct i915_request *rq, *rn; -priolist_for_each_request_consume (rq, rn, p) { +priolist_for_each_request_safe (rq, rn, pl) {bool merge = true;/*
@@ -1417,8 +1428,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine) } } -rb_erase_cached (&p->node, &engine->active.queue); -i915_priolist_free (p); +i915_priolist_advance (&engine->active.queue, pl); } done: *port++ =i915_request_get (last);
@@ -2643,6 +2653,7 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine) {struct intel_engine_execlists *const execlists = &engine->execlists;struct i915_request *rq, *rn; +struct i915_priolist *pl;struct rb_node *rb;unsigned long flags;
@@ -2673,16 +2684,12 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)intel_engine_signal_breadcrumbs (engine);/* Flush the queued requests to the timeline list (for retiring). */ -while ((rb =rb_first_cached (&engine->active.queue))) { -struct i915_priolist *p =to_priolist (rb); - -priolist_for_each_request_consume (rq, rn, p) { +for_each_priolist (pl, &engine->active.queue) { +priolist_for_each_request_safe (rq, rn, pl) {mark_eio (rq);__i915_request_submit (rq); } - -rb_erase_cached (&p->node, &engine->active.queue); -i915_priolist_free (p); +i915_priolist_advance (&engine->active.queue, pl); }GEM_BUG_ON (!i915_sched_is_idle (&engine->active));
@@ -2715,7 +2722,6 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)/* Remaining _unready_ requests will be nop'ed when submitted */ execlists->queue_priority_hint =INT_MIN ; - engine->active.queue =RB_ROOT_CACHED ;GEM_BUG_ON (__tasklet_is_enabled (&engine->active.tasklet)); engine->active.tasklet.func = nop_submission_tasklet;
@@ -3098,6 +3104,8 @@ static void virtual_context_exit(struct intel_context *ce)for (n =0 ; n < ve->num_siblings; n++)intel_engine_pm_put (ve->siblings[n]); + +i915_sched_park_engine (&ve->base.active); }static const struct intel_context_ops virtual_context_ops = {
@@ -3508,6 +3516,7 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine, {const struct intel_engine_execlists *execlists = &engine->execlists;struct i915_request *rq, *last; +struct i915_priolist *pl;unsigned long flags;unsigned int count;struct rb_node *rb;
@@ -3537,10 +3546,8 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine, last =NULL ; count =0 ; -for (rb =rb_first_cached (&engine->active.queue); rb; rb =rb_next (rb)) { -struct i915_priolist *p =rb_entry (rb,typeof (*p), node); - -priolist_for_each_request (rq, p) { +for_each_priolist (pl, &engine->active.queue) { +priolist_for_each_request (rq, pl) {if (count++ < max -1 )show_request (m, rq,"\t\t" ,0 );else
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +9 -21
@@ -55,11 +55,6 @@* */ -static inline struct i915_priolist *to_priolist (struct rb_node *rb) -{ - return rb_entry(rb, struct i915_priolist, node); -} -static struct guc_stage_desc *__get_stage_desc (struct intel_guc *guc,u32 id) {struct guc_stage_desc *base = guc->stage_desc_pool_vaddr;
@@ -292,8 +287,8 @@ static void __guc_dequeue(struct intel_engine_cs *engine)struct i915_request **const last_port = first + execlists->port_mask;struct i915_request *last = first[0 ];struct i915_request **port; +struct i915_priolist *pl;bool submit = false; -struct rb_node *rb;lockdep_assert_held (&engine->active.lock);
@@ -310,11 +305,10 @@ static void __guc_dequeue(struct intel_engine_cs *engine)* event. */ port = first; -while ((rb =rb_first_cached (&engine->active.queue))) { -struct i915_priolist *p =to_priolist (rb); +for_each_priolist (pl, &engine->active.queue) {struct i915_request *rq, *rn; -priolist_for_each_request_consume (rq, rn, p) { +priolist_for_each_request_safe (rq, rn, pl) {if (last && rq->context != last->context) {if (port == last_port) goto done;
@@ -330,12 +324,11 @@ static void __guc_dequeue(struct intel_engine_cs *engine) last = rq; } -rb_erase_cached (&p->node, &engine->active.queue); -i915_priolist_free (p); +i915_priolist_advance (&engine->active.queue, pl); } done: execlists->queue_priority_hint = - rb ?to_priolist (rb)->priority :INT_MIN ; + pl != &engine->active.queue.sentinel ? pl->priority :INT_MIN ;if (submit) { *port =schedule_in (last, port - execlists->inflight); *++port =NULL ;
@@ -450,7 +443,7 @@ static void guc_reset_cancel(struct intel_engine_cs *engine) {struct intel_engine_execlists *const execlists = &engine->execlists;struct i915_request *rq, *rn; -struct rb_node *rb; +struct i915_priolist *p;unsigned long flags;ENGINE_TRACE (engine,"\n" );
@@ -481,25 +474,20 @@ static void guc_reset_cancel(struct intel_engine_cs *engine) }/* Flush the queued requests to the timeline list (for retiring). */ -while ((rb =rb_first_cached (&engine->active.queue))) { -struct i915_priolist *p =to_priolist (rb); - -priolist_for_each_request_consume (rq, rn, p) { +for_each_priolist (p, &engine->active.queue) { +priolist_for_each_request_safe (rq, rn, p) {list_del_init (&rq->sched.link);__i915_request_submit (rq);dma_fence_set_error (&rq->fence, -EIO );i915_request_mark_complete (rq); } - -rb_erase_cached (&p->node, &engine->active.queue); -i915_priolist_free (p); +i915_priolist_advance (&engine->active.queue, p); }GEM_BUG_ON (!i915_sched_is_idle (&engine->active));/* Remaining _unready_ requests will be nop'ed when submitted */ execlists->queue_priority_hint =INT_MIN ; - engine->active.queue =RB_ROOT_CACHED ;spin_unlock_irqrestore (&engine->active.lock, flags); }
drivers/gpu/drm/i915/i915_priolist_types.h +28 -1
@@ -38,10 +38,37 @@ enum {#define I915_PRIORITY_UNPREEMPTABLE INT_MAX#define I915_PRIORITY_BARRIER (I915_PRIORITY_UNPREEMPTABLE - 1) +#ifdef CONFIG_64BIT +#define I915_PRIOLIST_HEIGHT 12 +#else +#define I915_PRIOLIST_HEIGHT 11 +#endif +struct i915_priolist {struct list_head requests; -struct rb_node node;int priority; + +int level; +struct i915_priolist *next[I915_PRIOLIST_HEIGHT ]; +}; + +struct i915_priolist_root { +struct i915_priolist sentinel; +u32 prng; }; +#define priolist_first (root) ((root)->sentinel.next[0]) +#define i915_priolist_is_empty (root) (priolist_first(root) == &(root)->sentinel) + +#define for_each_priolist (p, root) \ + for ((p) = priolist_first(root); \ + (p) != &(root)->sentinel; \ + (p) = (p)->next[0]) + +#define priolist_for_each_request (it, plist) \ + list_for_each_entry(it, &(plist)->requests, sched.link) + +#define priolist_for_each_request_safe (it, n, plist) \ + list_for_each_entry_safe(it, n, &(plist)->requests, sched.link) +#endif /* _I915_PRIOLIST_TYPES_H_ */
drivers/gpu/drm/i915/i915_scheduler.c +177 -56
304 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +4 -7
@@ -16,12 +16,6 @@struct drm_printer ; -#define priolist_for_each_request (it, plist) \ - list_for_each_entry(it, &(plist)->requests, sched.link) - -#define priolist_for_each_request_consume (it, n, plist) \ - list_for_each_entry_safe(it, n, &(plist)->requests, sched.link) -void i915_sched_node_init (struct i915_sched_node *node);void i915_sched_node_reinit (struct i915_sched_node *node);
@@ -64,7 +58,7 @@ static inline void i915_priolist_free(struct i915_priolist *p)static inline bool i915_sched_is_idle (const struct i915_sched_engine *se) { -return RB_EMPTY_ROOT (&se->queue.rb_root); +return i915_priolist_is_empty (&se->queue); } static inline bool
@@ -94,6 +88,9 @@ static inline void i915_sched_kick(struct i915_sched_engine *se)tasklet_hi_schedule (&se->tasklet); } +void i915_priolist_advance (struct i915_priolist_root *root, +struct i915_priolist *old); + void i915_request_show_with_schedule(struct drm_printer *m, const struct i915_request *rq, const char *prefix,
drivers/gpu/drm/i915/i915_scheduler_types.h +1 -1
@@ -89,7 +89,7 @@ struct i915_sched_engine {/** * @queue: queue of requests, in priority lists */ -struct rb_root_cached queue; +struct i915_priolist_root queue;struct i915_sched_ipi ipi;
drivers/gpu/drm/i915/selftests/i915_mock_selftests.h +1 -0
@@ -25,6 +25,7 @@ selftest(ring, intel_ring_mock_selftests) selftest(engine, intel_engine_cs_mock_selftests) selftest(timelines, intel_timeline_mock_selftests) selftest(requests, i915_request_mock_selftests) +selftest(scheduler, i915_scheduler_mock_selftests) selftest(objects, i915_gem_object_mock_selftests) selftest(phys, i915_gem_phys_mock_selftests)selftest (dmabuf, i915_gem_dmabuf_mock_selftests)
drivers/gpu/drm/i915/selftests/i915_scheduler.c +39 -3
62 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 33/54 drm/i915: Wrap cmpxchg64 with try_cmpxchg64() helper
In reply to Chris WilsonWrap cmpxchg64 with a try_cmpxchg()-esque helper. Hiding the old-value dance in the helper allows for cleaner code.
--- drivers/gpu/drm/i915/i915_utils.h | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/gpu/drm/i915/i915_utils.h +32 -0
@@ -456,4 +456,36 @@ static inline bool timer_expired(const struct timer_list *t)*/ #define IS_ACTIVE (config) ((config) != 0) +#ifndef try_cmpxchg64 +#if IS_ENABLED (CONFIG_64BIT ) +#define try_cmpxchg64 (_ptr, _pold, _new) try_cmpxchg(_ptr, _pold, _new) +#else +#define try_cmpxchg64 (_ptr, _pold, _new) \ +({ \ + __typeof__(_ptr) _old = (__typeof__(_ptr))(_pold); \ + __typeof__(*(_ptr)) __old = *_old; \ + __typeof__(*(_ptr)) __cur = cmpxchg64(_ptr, __old, _new); \ + bool success = __cur == __old; \ + if (unlikely(!success)) \ + *_old = __cur; \ + likely(success); \ +}) +#endif +#endif + +#ifndef xchg64 +#if IS_ENABLED (CONFIG_64BIT ) +#define xchg64 (_ptr, _new) xchg(_ptr, _new) +#else +#define xchg64 (_ptr, _new) \ +({ \ + __typeof__(_ptr) __ptr = (_ptr); \ + __typeof__(*(_ptr)) __old = *__ptr; \ + while (!try_cmpxchg64(__ptr, &__old, (_new))) \ + ; \ + __old; \ +}) +#endif +#endif +#endif /* !__I915_UTILS_H */
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 34/54 drm/i915: Fair low-latency scheduling
In reply to Chris WilsonThe first "scheduler" was a topographical sorting of requests into priority order. The execution order was deterministic, the earliest submitted, highest priority request would be executed first. Priority inheritance ensured that inversions were kept at bay, and allowed us to dynamically boost priorities (e.g. for interactive pageflips).
The minimalistic timeslicing scheme was an attempt to introduce fairness between long running requests, by evicting the active request at the end of a timeslice and moving it to the back of its priority queue (while ensuring that dependencies were kept in order). For short running requests from many clients of equal priority, the scheme is still very much FIFO submission ordering, and as unfair as before.
To impose fairness, we need an external metric that ensures that clients are interpersed, so we don't execute one long chain from client A before executing any of client B. This could be imposed by the clients themselves by using fences based on an external clock, that is they only submit work for a "frame" at frame-intervals, instead of submitting as much work as they are able to. The standard SwapBuffers approach is akin to double bufferring, where as one frame is being executed, the next is being submitted, such that there is always a maximum of two frames per client in the pipeline and so ideally maintains consistent input-output latency. Even this scheme exhibits unfairness under load as a single client will execute two frames back to back before the next, and with enough clients, deadlines will be missed.
The idea introduced by BFS/MuQSS is that fairness is introduced by metering with an external clock. Every request, when it becomes ready to execute is assigned a virtual deadline, and execution order is then determined by earliest deadline. Priority is used as a hint, rather than strict ordering, where high priority requests have earlier deadlines, but not necessarily earlier than outstanding work. Thus work is executed in order of 'readiness', with timeslicing to demote long running work.
The Achille's heel of this scheduler is its strong preference for low-latency and favouring of new queues. Whereas it was easy to dominate the old scheduler by flooding it with many requests over a short period of time, the new scheduler can be dominated by a 'synchronous' client that waits for each of its requests to complete before submitting the next. As such a client has no history, it is always considered ready-to-run and receives an earlier deadline than the long running requests. This is compensated for by refreshing the current execution's deadline and by disallowing preemption for timeslice shuffling.
To check the impact on throughput (often the downfall of latency sensitive schedulers), we used gem_wsim to simulate various transcode workloads with different load balancers, and varying the number of competing [heterogenous] clients.
+delta%------------------------------------------------------------------+
| a | | a | | aa | | aa | | aa | | aa | | aaa | | aaaa | | a aaaaa | | a aaaaaa | |a aa a aaaaaaaaaa aa a a| | A_| | +------------------------------------------------------------------------+ N Min Max Median Avg Stddev 108 -23.982194 28.421527 -0.077474828 -0.072650418 0.16179718
The impact was on average 0.1% under contention due to the change in context execution order and number of context switches. The biggest swings are due to the execution ordering favouring one client or another, and maybe room for improvement.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 - .../gpu/drm/i915/gt/intel_engine_heartbeat.c | 1 + drivers/gpu/drm/i915/gt/intel_engine_pm.c | 4 +- drivers/gpu/drm/i915/gt/intel_engine_types.h | 14 - .../drm/i915/gt/intel_execlists_submission.c | 205 ++++----- drivers/gpu/drm/i915/gt/selftest_execlists.c | 30 +- drivers/gpu/drm/i915/gt/selftest_hangcheck.c | 5 +- drivers/gpu/drm/i915/gt/selftest_lrc.c | 1 + .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 4 - drivers/gpu/drm/i915/i915_priolist_types.h | 7 +- drivers/gpu/drm/i915/i915_request.c | 14 +- drivers/gpu/drm/i915/i915_scheduler.c | 429 +++++++++++++----- drivers/gpu/drm/i915/i915_scheduler.h | 18 +- drivers/gpu/drm/i915/i915_scheduler_types.h | 23 + drivers/gpu/drm/i915/selftests/i915_request.c | 1 + .../gpu/drm/i915/selftests/i915_scheduler.c | 136 ++++++ 16 files changed, 632 insertions(+), 262 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -2
@@ -591,8 +591,6 @@ void intel_engine_init_execlists(struct intel_engine_cs *engine)memset (execlists->pending,0 ,sizeof (execlists->pending)); execlists->active =memset (execlists->inflight,0 ,sizeof (execlists->inflight)); - - execlists->queue_priority_hint =INT_MIN ; }static void cleanup_status_page (struct intel_engine_cs *engine)
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c +1 -0
@@ -205,6 +205,7 @@ static int __intel_engine_pulse(struct intel_engine_cs *engine)if (IS_ERR (rq))return PTR_ERR (rq); + rq->sched.deadline =0 ;__set_bit (I915_FENCE_FLAG_SENTINEL , &rq->fence.flags);heartbeat_commit (rq, &attr);
drivers/gpu/drm/i915/gt/intel_engine_pm.c +1 -3
@@ -212,6 +212,7 @@ static bool switch_to_kernel_context(struct intel_engine_cs *engine)i915_request_add_active_barriers (rq);/* Install ourselves as a preemption barrier */ + rq->sched.deadline =0 ; rq->sched.attr.priority =I915_PRIORITY_BARRIER ;if (likely (!__i915_request_commit (rq))) {/* engine should be idle! */ /*
@@ -272,9 +273,6 @@ static int __engine_park(struct intel_wakeref *wf)intel_engine_park_heartbeat (engine);intel_breadcrumbs_park (engine->breadcrumbs); -/* Must be reset upon idling, or we may miss the busy wakeup. */ -GEM_BUG_ON (engine->execlists.queue_priority_hint !=INT_MIN ); -if (engine->park) engine->park (engine);
drivers/gpu/drm/i915/gt/intel_engine_types.h +0 -14
@@ -224,20 +224,6 @@ struct intel_engine_execlists {*/ unsigned int port_mask; -/** -* @queue_priority_hint: Highest pending priority. -* -* When we add requests into the queue, or adjust the priority of -* executing requests, we compute the maximum priority of those -* pending requests. We can then use this value to determine if -* we need to preempt the executing requests to service the queue. -* However, since the we may have recorded the priority of an inflight -* request we wanted to preempt but since completed, at the time of -* dequeuing the priority hint may no longer may match the highest -* available request priority. -*/ -int queue_priority_hint; -struct rb_root_cached virtual;/**
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +98 -107
404 lines not on this page · raw message
drivers/gpu/drm/i915/gt/selftest_execlists.c +20 -10
@@ -868,7 +868,7 @@ semaphore_queue(struct intel_engine_cs *engine, struct i915_vma *vma, int idx)static int release_queue (struct intel_engine_cs *engine,struct i915_vma *vma, -int idx,int prio) +int idx,u64 deadline) {struct i915_request *rq;u32 *cs;
@@ -893,10 +893,7 @@ release_queue(struct intel_engine_cs *engine,i915_request_get (rq);i915_request_add (rq); -local_bh_disable (); -i915_request_set_priority (rq, prio); -local_bh_enable ();/* kick tasklet */ - +i915_request_set_deadline (rq, deadline);i915_request_put (rq);return 0 ;
@@ -910,6 +907,7 @@ slice_semaphore_queue(struct intel_engine_cs *outer,struct intel_engine_cs *engine;struct i915_request *head;enum intel_engine_id id; +long timeout;int err, i, n =0 ; head =semaphore_queue (outer, vma, n++);
@@ -930,12 +928,16 @@ slice_semaphore_queue(struct intel_engine_cs *outer, } } - err =release_queue (outer, vma, n,I915_PRIORITY_BARRIER ); + err =release_queue (outer, vma, n,0 );if (err) goto out; -if (i915_request_wait (head,0 , -2 * outer->gt->info.num_engines * (count +2 ) * (count +3 )) <0 ) { +/* Expected number of pessimal slices required */ + timeout = outer->gt->info.num_engines * (count +2 ) * (count +3 ); + timeout *=4 ;/* safety factor, including bucketing */ + timeout +=HZ /2 ;/* and include the request completion */ + +if (i915_request_wait (head,0 , timeout) <0 ) {pr_err ("Failed to slice along semaphore chain of length (%d, %d)!\n" , count, n);GEM_TRACE_DUMP ();
@@ -1040,6 +1042,8 @@ create_rewinder(struct intel_context *ce, err =i915_request_await_dma_fence (rq, &wait->fence);if (err) goto err; + +i915_request_set_deadline (rq,rq_deadline (wait)); } cs =intel_ring_begin (rq,14 );
@@ -1316,6 +1320,7 @@ static int live_timeslice_queue(void *arg) goto err_heartbeat; }i915_request_set_priority (rq,I915_PRIORITY_MAX ); +i915_request_set_deadline (rq,0 ); err =wait_for_submit (engine, rq,HZ /2 );if (err) { pr_err("%s: Timed out trying to submit semaphores\n",
@@ -1338,10 +1343,9 @@ static int live_timeslice_queue(void *arg) }GEM_BUG_ON (i915_request_completed (rq)); -GEM_BUG_ON (execlists_active (&engine->execlists) != rq);/* Queue: semaphore signal, matching priority as semaphore */ - err =release_queue (engine, vma,1 ,effective_prio (rq)); + err =release_queue (engine, vma,1 ,rq_deadline (rq));if (err) goto err_rq;
@@ -1452,6 +1456,7 @@ static int live_timeslice_nopreempt(void *arg) goto out_spin; } + rq->sched.deadline =0 ; rq->sched.attr.priority =I915_PRIORITY_BARRIER ;i915_request_get (rq);i915_request_add (rq);
@@ -1824,6 +1829,7 @@ static int live_late_preempt(void *arg)/* Make sure ctx_lo stays before ctx_hi until we trigger preemption. */ ctx_lo->sched.priority =1 ; + ctx_hi->sched.priority =I915_PRIORITY_MIN ;for_each_engine (engine, gt, id) {struct igt_live_test t;
@@ -2924,6 +2930,9 @@ static int live_preempt_gang(void *arg)while (rq) {/* wait for each rq from highest to lowest prio */ struct i915_request *n =list_next_entry (rq, mock.link); +/* With deadlines, no strict priority ordering */ +i915_request_set_deadline (rq,0 ); +if (err ==0 &&i915_request_wait (rq,0 ,HZ /5 ) <0 ) {struct drm_printer p =drm_info_printer (engine->i915->drm.dev);
@@ -3146,6 +3155,7 @@ static int preempt_user(struct intel_engine_cs *engine,i915_request_add (rq);i915_request_set_priority (rq,I915_PRIORITY_MAX ); +i915_request_set_deadline (rq,0 );if (i915_request_wait (rq,0 ,HZ /2 ) <0 ) err = -ETIME ;
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +4 -1
@@ -878,7 +878,10 @@ static int __igt_reset_engines(struct intel_gt *gt,break ; } -if (i915_request_wait (rq,0 ,HZ /5 ) <0 ) { +/* With deadlines, no strict priority */ +i915_request_set_deadline (rq,0 ); + +if (i915_request_wait (rq,0 ,HZ /2 ) <0 ) {struct drm_printer p =drm_info_printer (gt->i915->drm.dev);
drivers/gpu/drm/i915/gt/selftest_lrc.c +1 -0
@@ -1171,6 +1171,7 @@ static int poison_registers(struct intel_context *ce, u32 poison, u32 *sema)intel_ring_advance (rq, cs); + rq->sched.deadline =0 ; rq->sched.attr.priority =I915_PRIORITY_BARRIER ; err_rq:i915_request_add (rq);
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +0 -4
@@ -327,8 +327,6 @@ static void __guc_dequeue(struct intel_engine_cs *engine)i915_priolist_advance (&engine->active.queue, pl); } done: - execlists->queue_priority_hint = - pl != &engine->active.queue.sentinel ? pl->priority :INT_MIN ;if (submit) { *port =schedule_in (last, port - execlists->inflight); *++port =NULL ;
@@ -487,8 +485,6 @@ static void guc_reset_cancel(struct intel_engine_cs *engine)/* Remaining _unready_ requests will be nop'ed when submitted */ - execlists->queue_priority_hint =INT_MIN ; -spin_unlock_irqrestore (&engine->active.lock, flags); }
drivers/gpu/drm/i915/i915_priolist_types.h +4 -3
@@ -22,6 +22,8 @@ enum {/* Interactive workload, scheduled for immediate pageflipping */ I915_PRIORITY_DISPLAY , + + __I915_PRIORITY_KERNEL__ };/* Smallest priority value that cannot be bumped. */
@@ -35,8 +37,7 @@ enum {* i.e. nothing can have higher priority and force us to usurp the * active request. */ -#define I915_PRIORITY_UNPREEMPTABLE INT_MAX -#define I915_PRIORITY_BARRIER (I915_PRIORITY_UNPREEMPTABLE - 1) +#define I915_PRIORITY_BARRIER INT_MAX#ifdef CONFIG_64BIT #define I915_PRIOLIST_HEIGHT 12
@@ -46,7 +47,7 @@ enum {struct i915_priolist {struct list_head requests; -int priority; +u64 deadline;int level;struct i915_priolist *next[I915_PRIOLIST_HEIGHT ];
drivers/gpu/drm/i915/i915_request.c +8 -6
@@ -519,7 +519,7 @@ bool __i915_request_submit(struct i915_request *request)struct intel_engine_cs *engine = request->engine;bool result = false; -RQ_TRACE (request,"\n" ); +RQ_TRACE (request,"dl %llu\n" , request->sched.deadline);GEM_BUG_ON (!irqs_disabled ());lockdep_assert_held (&engine->active.lock);
@@ -708,6 +708,7 @@ semaphore_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)switch (state) {case FENCE_COMPLETE : +i915_request_update_deadline (rq);break ;case FENCE_FREE :
@@ -1868,14 +1869,15 @@ long i915_request_wait(struct i915_request *rq,return timeout; } -static int print_sched_attr (const struct i915_sched_attr *attr, -char *buf,int x,int len) +static int print_sched (const struct i915_sched_node *node, +char *buf,int x,int len) { -if (attr->priority ==I915_PRIORITY_INVALID ) +if (node->attr.priority ==I915_PRIORITY_INVALID )return x; x +=snprintf (buf + x, len - x, -" prio=%d" , attr->priority); +" prio=%d, dl=%llu" , + node->attr.priority, node->deadline);return x; }
@@ -1955,7 +1957,7 @@ void i915_request_show(struct drm_printer *m,* from the lists */ - x =print_sched_attr (&rq->sched.attr, buf, x,sizeof (buf)); + x =print_sched (&rq->sched, buf, x,sizeof (buf)); drm_printf(m, "%s%.*s%c %llx:%lld%s%s %s @ %dms: %s\n", prefix, indent, " ",
drivers/gpu/drm/i915/i915_scheduler.c +321 -108
694 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +14 -4
@@ -36,9 +36,16 @@ void i915_sched_park_engine(struct i915_sched_engine *se);void i915_sched_fini_engine (struct i915_sched_engine *se);void i915_request_set_priority (struct i915_request *request,int prio); +void i915_request_set_deadline (struct i915_request *request,u64 deadline); + +void i915_request_update_deadline (struct i915_request *request); + +u64 i915_scheduler_next_virtual_deadline (int priority);void i915_request_enqueue (struct i915_request *request); +bool __intel_engine_queue_request (struct intel_engine_cs *engine, +struct i915_request *request);struct i915_request *__intel_engine_rewind_requests (struct intel_engine_cs *engine); void __intel_engine_defer_request(struct intel_engine_cs *engine,
@@ -49,11 +56,14 @@ bool __intel_engine_hold_request(struct intel_engine_cs *engine,void __intel_engine_unhold_request (struct intel_engine_cs *engine,struct i915_request *request); -void __i915_priolist_free (struct i915_priolist *p); -static inline void i915_priolist_free (struct i915_priolist *p) +static inline u64 i915_sched_to_ticks (ktime_t kt) +{ +return ktime_to_ns (kt) >>I915_SCHED_DEADLINE_SHIFT ; +} + +static inline u64 i915_sched_to_ns (u64 deadline) { -if (p->priority !=I915_PRIORITY_NORMAL ) -__i915_priolist_free (p); +return deadline <<I915_SCHED_DEADLINE_SHIFT ; }static inline bool i915_sched_is_idle (const struct i915_sched_engine *se)
drivers/gpu/drm/i915/i915_scheduler_types.h +23 -0
@@ -72,7 +72,30 @@ struct i915_sched_node {#define I915_SCHED_HAS_EXTERNAL_CHAIN BIT(0)unsigned long semaphores; +/** +* @deadline: [virtual] deadline +* +* When the request is ready for execution, it is given a quota +* (the engine's timeslice) and a virtual deadline. The virtual +* deadline is derived from the current time: +* ktime_get() + (prio_ratio * timeslice) +* +* Requests are then executed in order of deadline completion. +* Requests with earlier deadlines than currently executing on +* the engine will preempt the active requests. +* +* By treating it as a virtual deadline, we use it as a hint for +* when it is appropriate for a request to start with respect to +* all other requests in the system. It is not a hard deadline, as +* we allow requests to miss them, and we do not account for the +* request runtime. +*/ +u64 deadline; +#define I915_SCHED_DEADLINE_SHIFT 19/* i.e. roughly 500us buckets */ +#define I915_DEADLINE_NEVER U64_MAX +struct i915_request *ipi_link; +u64 ipi_deadline;int ipi_priority; };
drivers/gpu/drm/i915/selftests/i915_request.c +1 -0
@@ -2130,6 +2130,7 @@ static int measure_preemption(struct intel_context *ce)intel_ring_advance (rq, cs); rq->sched.attr.priority =I915_PRIORITY_BARRIER ; + rq->sched.deadline =0 ; elapsed[i -1 ] =ENGINE_READ_FW (ce->engine,RING_TIMESTAMP );i915_request_add (rq);
drivers/gpu/drm/i915/selftests/i915_scheduler.c +136 -0
176 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 35/54 drm/i915/gt: Specify a deadline for the heartbeat
In reply to Chris WilsonAs we know when we expect the heartbeat to be checked for completion, pass this information along as its deadline. We still do not complain if the deadline is missed, at least until we have tried a few times, but it will allow for quicker hang detection on systems where deadlines are adhered to.
--- drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/gt/intel_engine_heartbeat.c +13 -0
@@ -66,6 +66,16 @@ static void heartbeat_commit(struct i915_request *rq,__i915_request_queue (rq, attr); } +static void set_heartbeat_deadline (struct intel_engine_cs *engine, +struct i915_request *rq) +{ +unsigned long interval; + + interval =READ_ONCE (engine->props.heartbeat_interval_ms); +if (interval) +i915_request_set_deadline (rq,ktime_get () + (interval <<20 )); +} +static void show_heartbeat (const struct i915_request *rq,struct intel_engine_cs *engine) {
@@ -131,6 +141,8 @@ static void heartbeat(struct work_struct *wrk)local_bh_disable ();i915_request_set_priority (rq, attr.priority); +if (attr.priority ==I915_PRIORITY_BARRIER ) +i915_request_set_deadline (rq,0 );local_bh_enable (); }else {if (IS_ENABLED (CONFIG_DRM_I915_DEBUG_GEM ))
@@ -162,6 +174,7 @@ static void heartbeat(struct work_struct *wrk)if (IS_ERR (rq)) goto unlock; +set_heartbeat_deadline (engine, rq);heartbeat_commit (rq, &attr); unlock:
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 36/54 drm/i915: Extend the priority boosting for the display with a deadline
In reply to Chris WilsonFor a modeset/pageflip, there is a very precise deadline by which the frame must be completed in order to hit the vblank and be shown. While we don't pass along that exact information, we can at least inform the scheduler that this request-chain needs to be completed asap.
--- drivers/gpu/drm/i915/display/intel_display.c | 4 +++- drivers/gpu/drm/i915/gem/i915_gem_object.h | 2 +- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 21 +++++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +3 -1
@@ -15687,7 +15687,9 @@ intel_prepare_plane_fb(struct drm_plane *_plane,if (ret)return ret; -i915_gem_object_wait_priority (obj,0 ,I915_PRIORITY_DISPLAY ); +i915_gem_object_wait_priority (obj,0 , +I915_PRIORITY_DISPLAY , +ktime_get ()/* next vblank? */ );i915_gem_object_flush_frontbuffer (obj,ORIGIN_DIRTYFB );if (!new_plane_state->uapi.fence) {/* implicit fencing */
drivers/gpu/drm/i915/gem/i915_gem_object.h +1 -1
@@ -517,7 +517,7 @@ int i915_gem_object_wait(struct drm_i915_gem_object *obj, long timeout);int i915_gem_object_wait_priority (struct drm_i915_gem_object *obj,unsigned int flags, -int prio); +int prio,ktime_t deadline);void __i915_gem_object_flush_frontbuffer (struct drm_i915_gem_object *obj,enum fb_op_origin origin);
drivers/gpu/drm/i915/gem/i915_gem_wait.c +12 -9
@@ -45,8 +45,7 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,unsigned int count, i;int ret; - ret =dma_resv_get_fences_rcu (resv, - &excl, &count, &shared); + ret =dma_resv_get_fences_rcu (resv, &excl, &count, &shared);if (ret)return ret;
@@ -92,17 +91,20 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,return timeout; } -static void __fence_set_priority (struct dma_fence *fence,int prio) +static void +__fence_set_prio (struct dma_fence *fence,int prio,ktime_t deadline) {if (dma_fence_is_signaled (fence) || !dma_fence_is_i915 (fence))return ;local_bh_disable (); +i915_request_set_deadline (to_request (fence), +i915_sched_to_ticks (deadline));i915_request_set_priority (to_request (fence), prio);local_bh_enable ();/* kick the tasklets if queues were reprioritised */ } -static void fence_set_priority (struct dma_fence *fence,int prio) +static void fence_set_prio (struct dma_fence *fence,int prio,ktime_t deadline) {/* Recurse once into a fence-array */ if (dma_fence_is_array (fence)) {
@@ -110,16 +112,17 @@ static void fence_set_priority(struct dma_fence *fence, int prio)int i;for (i =0 ; i < array->num_fences; i++) -__fence_set_priority (array->fences[i], prio); +__fence_set_prio (array->fences[i], prio, deadline); }else { -__fence_set_priority (fence, prio); +__fence_set_prio (fence, prio, deadline); } }int i915_gem_object_wait_priority (struct drm_i915_gem_object *obj,unsigned int flags, -int prio) +int prio, +ktime_t deadline) {struct dma_fence *excl;
@@ -134,7 +137,7 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj,return ret;for (i =0 ; i < count; i++) { -fence_set_priority (shared[i], prio); +fence_set_prio (shared[i], prio, deadline);dma_fence_put (shared[i]); }
@@ -144,7 +147,7 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, }if (excl) { -fence_set_priority (excl, prio); +fence_set_prio (excl, prio, deadline);dma_fence_put (excl); }return 0 ;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 37/54 drm/i915/gt: Support virtual engine queues
In reply to Chris WilsonAllow multiple requests to be queued unto a virtual engine, whereas before we only allowed a single request to be queued at a time. The advantage of keeping just one request in the queue was to ensure that we always decided late which engine to use. However, with the introduction of the virtual deadline we throttle submission and still only drip one request into the sibling at a time (unless it is truly empty, but then a second request will have an earlier deadline than the queued virtual engine and force itself in front). This also takes advantage that a virtual engine will remain bound while it is active, i.e. we can not switch to a second engine until the context is completed -- such that we cannot be as lazy as lazy can be.
By allowing a full queue, we avoid having to synchronize via the breadcrumb interrupt everytime, letting the virtual engine reach the full throughput of the siblings.
--- .../drm/i915/gt/intel_execlists_submission.c | 397 +++++++++--------- drivers/gpu/drm/i915/i915_request.c | 3 +- drivers/gpu/drm/i915/i915_scheduler.c | 65 ++- drivers/gpu/drm/i915/i915_scheduler.h | 4 +- 4 files changed, 261 insertions(+), 208 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +202 -195
@@ -160,17 +160,6 @@ struct virtual_engine {struct intel_context context;struct rcu_work rcu; -/* -* We allow only a single request through the virtual engine at a time -* (each request in the timeline waits for the completion fence of -* the previous before being submitted). By restricting ourselves to -* only submitting a single request, each request is placed on to a -* physical to maximise load spreading (by virtue of the late greedy -* scheduling -- each real engine takes the next available request -* upon idling). -*/ -struct i915_request *request; -/* * We keep a rbtree of available virtual engines inside each physical * engine, sorted by priority. Here we preallocate the nodes we need
@@ -282,17 +271,27 @@ static struct i915_request *first_request(struct i915_sched_engine *se)return NULL ; } -static struct i915_request *first_virtual (const struct intel_engine_cs *engine) +static struct virtual_engine * +first_virtual_engine (struct intel_engine_cs *engine) { -struct rb_node *rb; +return rb_entry_safe (rb_first_cached (&engine->execlists.virtual), + struct virtual_engine, + nodes[engine->id].rb); +} - rb =rb_first_cached (&engine->execlists.virtual); -if (!rb) -return NULL ; +static const struct i915_request *first_virtual (struct intel_engine_cs *engine) +{ +struct i915_request *rq =NULL ; +struct virtual_engine *ve; + + ve =first_virtual_engine (engine); +if (ve) { +spin_lock (&ve->base.active.lock); + rq =first_request (&ve->base.active); +spin_unlock (&ve->base.active.lock); + } -return READ_ONCE (rb_entry (rb, - struct virtual_engine, - nodes[engine->id].rb)->request); +return rq; } static const struct i915_request *
@@ -389,7 +388,15 @@ assert_priority_queue(const struct i915_request *prev,if (i915_request_is_active (prev))return true; -return rq_deadline (prev) <=rq_deadline (next); +if (rq_deadline (prev) <=rq_deadline (next)) +return true; + +ENGINE_TRACE (prev->engine, +"next %llx:%lld dl %lld is before prev %llx:%lld dl %lld\n" , + next->fence.context, next->fence.seqno,rq_deadline (next), + prev->fence.context, prev->fence.seqno,rq_deadline (prev)); + +return false; } static inline void
@@ -499,7 +506,7 @@ static inline void execlists_schedule_in(struct i915_request *rq, int idx)trace_i915_request_in (rq, idx); old = ce->inflight; -if (!old) +if (!__intel_context_inflight_count (old)) old =__execlists_schedule_in (rq);WRITE_ONCE (ce->inflight,ptr_inc (old));
@@ -507,9 +514,11 @@ static inline void execlists_schedule_in(struct i915_request *rq, int idx) }static void -resubmit_virtual_request (struct i915_request *rq,struct virtual_engine *ve) +__resubmit_virtual_request (struct i915_request *rq, +struct intel_engine_cs *engine, +struct virtual_engine *ve) { -struct intel_engine_cs *engine = rq->engine; +GEM_BUG_ON (rq->engine != engine);/* Flush concurrent rcu iterators in signal_irq_work */ if (test_bit (DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT , &rq->fence.flags)) {
@@ -526,12 +535,42 @@ resubmit_virtual_request(struct i915_request *rq, struct virtual_engine *ve)cpu_relax (); } +__i915_request_requeue (rq, &ve->base); +} + +static void +resubmit_virtual_request (struct i915_request *rq,struct virtual_engine *ve) +{ +struct intel_engine_cs *engine = rq->engine; +struct i915_request *pos = rq; +struct intel_timeline *tl; +spin_lock_irq (&engine->active.lock); -clear_bit (I915_FENCE_FLAG_PQUEUE , &rq->fence.flags); -WRITE_ONCE (rq->engine, &ve->base); - ve->base.submit_request (rq); +if (__i915_request_is_complete (rq)) + goto unlock; + + tl =i915_request_active_timeline (rq); + +/* Rewind back to the start of this virtual engine queue */ +list_for_each_entry_continue_reverse (rq, &tl->requests, link) { +if (__i915_request_is_complete (rq)) +break ; + + pos = rq; + } + +/* Resubmit the queue in execution order */ +spin_lock (&ve->base.active.lock); +list_for_each_entry_from (pos, &tl->requests, link) { +if (pos->engine != engine) +break ; +__resubmit_virtual_request (pos, engine, ve); + } +spin_unlock (&ve->base.active.lock); + +unlock:spin_unlock_irq (&engine->active.lock); }
@@ -550,7 +589,7 @@ static void kick_siblings(struct i915_request *rq, struct intel_context *ce) rq->execution_mask != engine->mask)resubmit_virtual_request (rq, ve); -if (READ_ONCE (ve->request)) +if (!i915_sched_is_idle (&ve->base.active))i915_sched_kick (&ve->base.active); }
@@ -897,10 +936,16 @@ static bool ctx_single_port_submission(const struct intel_context *ce) intel_context_force_single_submission(ce)); } +static bool __can_merge_ctx (const struct intel_context *prev, +const struct intel_context *next) +{ +return prev == next; +} +static bool can_merge_ctx (const struct intel_context *prev,const struct intel_context *next) { -if (prev != next) +if (!__can_merge_ctx (prev, next))return false;if (ctx_single_port_submission (prev))
@@ -949,6 +994,9 @@ static bool virtual_matches(const struct virtual_engine *ve, {const struct intel_engine_cs *inflight; +if (!rq) +return false; +if (!(rq->execution_mask & engine->mask))/* We peeked too soon! */ return false;
@@ -968,31 +1016,6 @@ static bool virtual_matches(const struct virtual_engine *ve,return true; } -static struct virtual_engine * -first_virtual_engine (struct intel_engine_cs *engine) -{ -struct intel_engine_execlists *el = &engine->execlists; -struct rb_node *rb =rb_first_cached (&el->virtual); - -while (rb) { -struct virtual_engine *ve = -rb_entry (rb,typeof (*ve), nodes[engine->id].rb); -struct i915_request *rq =READ_ONCE (ve->request); - -/* lazily cleanup after another engine handled rq */ -if (!rq || !virtual_matches (ve, rq, engine)) { -rb_erase_cached (rb, &el->virtual); -RB_CLEAR_NODE (rb); - rb =rb_first_cached (&el->virtual); -continue ; - } - -return ve; - } - -return NULL ; -} -static void virtual_xfer_context (struct virtual_engine *ve,struct intel_engine_cs *engine) {
@@ -1156,15 +1179,124 @@ static bool completed(const struct i915_request *rq)return __i915_request_is_complete (rq); } +static void __virtual_dequeue (struct virtual_engine *ve, +struct intel_engine_cs *sibling) +{ +struct ve_node *const node = &ve->nodes[sibling->id]; +struct rb_node **parent, *rb; +struct i915_request *rq; +u64 deadline; +bool first; + +rb_erase_cached (&node->rb, &sibling->execlists.virtual); +RB_CLEAR_NODE (&node->rb); + + rq =first_request (&ve->base.active); +if (!virtual_matches (ve, rq, sibling)) +return ; + + rb =NULL ; + first = true; + parent = &sibling->execlists.virtual.rb_root.rb_node; + deadline =rq_deadline (rq); +while (*parent) { +struct ve_node *other; + + rb = *parent; + other =rb_entry (rb,typeof (*other), rb); +if (deadline <= other->deadline) { + parent = &rb->rb_left; + }else { + parent = &rb->rb_right; + first = false; + } + } + +rb_link_node (&node->rb, rb, parent); +rb_insert_color_cached (&node->rb, &sibling->execlists.virtual, first); +} + +static void virtual_requeue (struct intel_engine_cs *engine, +struct i915_request *last) +{ +const struct i915_request *const first = +first_request (&engine->active); +struct virtual_engine *ve; + +while ((ve =first_virtual_engine (engine))) { +struct i915_request *rq; + +spin_lock (&ve->base.active.lock); + + rq =first_request (&ve->base.active); +if (unlikely (!virtual_matches (ve, rq, engine))) +/* lost the race to a sibling */ + goto unlock; + +GEM_BUG_ON (rq->engine != &ve->base); +GEM_BUG_ON (rq->context != &ve->context); + +if (!dl_before (rq, first)) { +spin_unlock (&ve->base.active.lock); +return ; + } + +if (last && !__can_merge_ctx (last->context, rq->context)) { +spin_unlock (&ve->base.active.lock); +return ;/* leave this for another sibling? */ + } + +ENGINE_TRACE (engine, +"virtual rq=%llx:%lld%s, dl %llx, new engine? %s\n" , + rq->fence.context, + rq->fence.seqno, +__i915_request_is_complete (rq) ?"!" : +__i915_request_has_started (rq) ?"*" : +"" , +rq_deadline (rq), +yesno (engine != ve->siblings[0 ])); + +GEM_BUG_ON (!(rq->execution_mask & engine->mask)); +if (__i915_request_requeue (rq, engine)) { +/* +* Only after we confirm that we will submit +* this request (i.e. it has not already +* completed), do we want to update the context. +* +* This serves two purposes. It avoids +* unnecessary work if we are resubmitting an +* already completed request after timeslicing. +* But more importantly, it prevents us altering +* ve->siblings[] on an idle context, where +* we may be using ve->siblings[] in +* virtual_context_enter / virtual_context_exit. +*/ +virtual_xfer_context (ve, engine); + +/* Bind this ve before we release the lock */ +if (!ve->context.inflight) +WRITE_ONCE (ve->context.inflight, engine); + +GEM_BUG_ON (rq->engine != engine); +GEM_BUG_ON (ve->siblings[0 ] != engine); +GEM_BUG_ON (intel_context_inflight (rq->context) != engine); + + last = rq; + } + +unlock: +__virtual_dequeue (ve, engine); +spin_unlock (&ve->base.active.lock); + } +} +static void execlists_dequeue (struct intel_engine_cs *engine) {struct intel_engine_execlists *const execlists = &engine->execlists;struct i915_request **port = execlists->pending;struct i915_request **const last_port = port + execlists->port_mask;struct i915_request *last, *const *active; -struct virtual_engine *ve;struct i915_priolist *pl; -struct rb_node *rb;bool submit = false;/*
@@ -1282,85 +1414,8 @@ static void execlists_dequeue(struct intel_engine_cs *engine) } } -/* XXX virtual is always taking precedence */ -while ((ve =first_virtual_engine (engine))) { -struct i915_request *rq; - -spin_lock (&ve->base.active.lock); - - rq = ve->request; -if (unlikely (!rq))/* lost the race to a sibling */ - goto unlock; - -GEM_BUG_ON (rq->engine != &ve->base); -GEM_BUG_ON (rq->context != &ve->context); - -if (!dl_before (rq,first_request (&engine->active))) { -spin_unlock (&ve->base.active.lock); -break ; - } - -GEM_BUG_ON (!virtual_matches (ve, rq, engine)); - -if (last && !can_merge_rq (last, rq)) { -spin_unlock (&ve->base.active.lock); -spin_unlock (&engine->active.lock); -return ;/* leave this for another sibling */ - } - -ENGINE_TRACE (engine, -"virtual rq=%llx:%lld%s, dl %llx, new engine? %s\n" , - rq->fence.context, - rq->fence.seqno, -__i915_request_is_complete (rq) ?"!" : -__i915_request_has_started (rq) ?"*" : -"" , -rq_deadline (rq), -yesno (engine != ve->siblings[0 ])); -WRITE_ONCE (ve->request,NULL ); - - rb = &ve->nodes[engine->id].rb; -rb_erase_cached (rb, &execlists->virtual); -RB_CLEAR_NODE (rb); - -GEM_BUG_ON (!(rq->execution_mask & engine->mask)); -WRITE_ONCE (rq->engine, engine); - -if (__i915_request_submit (rq)) { -/* -* Only after we confirm that we will submit -* this request (i.e. it has not already -* completed), do we want to update the context. -* -* This serves two purposes. It avoids -* unnecessary work if we are resubmitting an -* already completed request after timeslicing. -* But more importantly, it prevents us altering -* ve->siblings[] on an idle context, where -* we may be using ve->siblings[] in -* virtual_context_enter / virtual_context_exit. -*/ -virtual_xfer_context (ve, engine); -GEM_BUG_ON (ve->siblings[0 ] != engine); - - submit = true; - last = rq; - } - -i915_request_put (rq); -unlock: -spin_unlock (&ve->base.active.lock); - -/* -* Hmm, we have a bunch of virtual engine requests, -* but the first one was already completed (thanks -* preempt-to-busy!). Keep looking at the veng queue -* until we have no more relevant requests (i.e. -* the normal submit queue has higher priority). -*/ -if (submit) -break ; - } +if (!RB_EMPTY_ROOT (&execlists->virtual.rb_root)) +virtual_requeue (engine, last);for_each_priolist (pl, &engine->active.queue) {struct i915_request *rq, *rn;
@@ -1368,6 +1423,8 @@ static void execlists_dequeue(struct intel_engine_cs *engine)priolist_for_each_request_safe (rq, rn, pl) {bool merge = true; +GEM_BUG_ON (rq->engine != engine); +/* * Can we combine this request with the current port? * It has to be the same context/ringbuffer and not
@@ -2700,13 +2757,11 @@ static void execlists_reset_cancel(struct intel_engine_cs *engine)RB_CLEAR_NODE (rb);spin_lock (&ve->base.active.lock); - rq =fetch_and_zero (&ve->request); -if (rq) { +while ((rq =first_request (&ve->base.active))) {mark_eio (rq); rq->engine = engine;__i915_request_submit (rq); -i915_request_put (rq); }spin_unlock (&ve->base.active.lock); }
@@ -2940,11 +2995,6 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine)return 0 ; } -static struct list_head *virtual_queue (struct virtual_engine *ve) -{ -return &ve->base.active.default_priolist.requests; -} -static void rcu_virtual_context_destroy (struct work_struct *wrk) { struct virtual_engine *ve =
@@ -2954,17 +3004,13 @@ static void rcu_virtual_context_destroy(struct work_struct *wrk)GEM_BUG_ON (ve->context.inflight);/* Preempt-to-busy may leave a stale request behind. */ -if (unlikely (ve->request)) { +if (unlikely (!i915_sched_is_idle (&ve->base.active))) {struct i915_request *old;spin_lock_irq (&ve->base.active.lock); - old =fetch_and_zero (&ve->request); -if (old) { -GEM_BUG_ON (!i915_request_completed (old)); +while ((old =first_request (&ve->base.active)))__i915_request_submit (old); -i915_request_put (old); - }spin_unlock_irq (&ve->base.active.lock); }
@@ -2995,7 +3041,6 @@ static void rcu_virtual_context_destroy(struct work_struct *wrk)spin_unlock_irq (&sibling->active.lock); }GEM_BUG_ON (__tasklet_is_scheduled (&ve->base.active.tasklet)); -GEM_BUG_ON (!list_empty (virtual_queue (ve)));lrc_fini (&ve->context);intel_context_fini (&ve->context);
@@ -3118,7 +3163,9 @@ virtual_submission_mask(struct virtual_engine *ve, u64 *deadline)struct i915_request *rq;intel_engine_mask_t mask; - rq =READ_ONCE (ve->request); +spin_lock_irq (&ve->base.active.lock); + rq =first_request (&ve->base.active); +spin_unlock_irq (&ve->base.active.lock);if (!rq)return 0 ;
@@ -3158,9 +3205,6 @@ static void virtual_submission_tasklet(unsigned long data)struct rb_node **parent, *rb;bool first; -if (!READ_ONCE (ve->request)) -break ;/* already handled by a sibling's tasklet */ -spin_lock_irq (&sibling->active.lock);if (unlikely (!(mask & sibling->mask))) {
@@ -3222,45 +3266,6 @@ static void virtual_submission_tasklet(unsigned long data) } } -static void virtual_submit_request (struct i915_request *rq) -{ -struct virtual_engine *ve =to_virtual_engine (rq->engine); -unsigned long flags; - -ENGINE_TRACE (&ve->base,"rq=%llx:%lld\n" , - rq->fence.context, - rq->fence.seqno); - -GEM_BUG_ON (ve->base.submit_request != virtual_submit_request); - -spin_lock_irqsave (&ve->base.active.lock, flags); - -/* By the time we resubmit a request, it may be completed */ -if (__i915_request_is_complete (rq)) { -__i915_request_submit (rq); - goto unlock; - } - -if (ve->request) {/* background completion from preempt-to-busy */ -GEM_BUG_ON (!i915_request_completed (ve->request)); -__i915_request_submit (ve->request); -i915_request_put (ve->request); - } - - rq->sched.deadline = -min (rq->sched.deadline, -i915_scheduler_next_virtual_deadline (rq_prio (rq))); - ve->request =i915_request_get (rq); - -GEM_BUG_ON (!list_empty (virtual_queue (ve))); -list_move_tail (&rq->sched.link,virtual_queue (ve)); - -i915_sched_kick (&ve->base.active); - -unlock: -spin_unlock_irqrestore (&ve->base.active.lock, flags); -} -static struct ve_bond *virtual_find_bond (struct virtual_engine *ve,const struct intel_engine_cs *master)
@@ -3348,10 +3353,9 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings, ve->base.cops = &virtual_context_ops; ve->base.request_alloc = execlists_request_alloc; - ve->base.submit_request = virtual_submit_request; + ve->base.submit_request = i915_request_enqueue; ve->base.bond_execute = virtual_bond_execute; -INIT_LIST_HEAD (virtual_queue (ve));tasklet_init (&ve->base.active.tasklet, virtual_submission_tasklet, (unsigned long )ve);
@@ -3559,14 +3563,17 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine,for (rb =rb_first_cached (&execlists->virtual); rb; rb =rb_next (rb)) {struct virtual_engine *ve =rb_entry (rb,typeof (*ve), nodes[engine->id].rb); -struct i915_request *rq =READ_ONCE (ve->request); +struct i915_request *rq; +spin_lock (&ve->base.active.lock); + rq =first_request (&ve->base.active);if (rq) {if (count++ < max -1 )show_request (m, rq,"\t\t" ,0 );else last = rq; } +spin_unlock (&ve->base.active.lock); }if (last) {if (count > max) {
drivers/gpu/drm/i915/i915_request.c +2 -1
@@ -1343,6 +1343,7 @@ i915_request_await_request(struct i915_request *to, struct i915_request *from)GEM_BUG_ON (to == from);GEM_BUG_ON (to->timeline == from->timeline); +GEM_BUG_ON (to->context == from->context);if (i915_request_completed (from)) {i915_sw_fence_set_error_once (&to->submit, from->fence.error);
@@ -1528,7 +1529,7 @@ __i915_request_add_to_timeline(struct i915_request *rq)i915_seqno_passed (prev->fence.seqno, rq->fence.seqno)); -if (is_power_of_2 (READ_ONCE (prev->engine)->mask | rq->engine->mask)) +if (prev->context == rq->context)i915_sw_fence_await_sw_fence (&rq->submit, &prev->submit, &rq->submitq);
drivers/gpu/drm/i915/i915_scheduler.c +55 -10
103 lines not on this page · raw message
drivers/gpu/drm/i915/i915_scheduler.h +2 -2
@@ -40,9 +40,9 @@ void i915_request_set_deadline(struct i915_request *request, u64 deadline);void i915_request_update_deadline (struct i915_request *request); -u64 i915_scheduler_next_virtual_deadline (int priority); -void i915_request_enqueue (struct i915_request *request); +bool __i915_request_requeue (struct i915_request *rq, +struct intel_engine_cs *engine);bool __intel_engine_queue_request (struct intel_engine_cs *engine,struct i915_request *request);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 38/54 drm/i915: Move saturated workload detection back to the context
In reply to Chris WilsonWhen we introduced the saturated workload detection to tell us to back off from semaphore usage [semaphores have a noticeable impact on contended bus cycles with the CPU for some heavy workloads], we first introduced it as a per-context tracker. This allows individual contexts to try and optimise their own usage, but we found that with the local tracking and the no-semaphore boosting, the first context to disable semaphores got a massive priority boost and so would starve the rest and all new contexts (as they started with semaphores enabled and lower priority). Hence we moved the saturated workload detection to the engine, and a consequence had to disable semaphores on virtual engines.
Now that we do not have semaphore priority boosting, and try to fairly schedule irrespective of semaphore usage, we can move the tracking back to the context and virtual engines can now utilise the faster inter-engine synchronisation. If we see that any context fairs to use the semaphore, because the system is oversubscribed and was busy doing something else instead of spinning on the semaphore, we disable further usage of semaphores with that context until it idles again. This should restrict the semaphores to lightly utilised system where the latency between requests is more noticeable, and curtail the bus-contention from checking for signaled semaphores.
References: 44d89409a12e ("drm/i915: Make the semaphore saturation mask global")
--- drivers/gpu/drm/i915/gt/intel_context.c | 3 +++ drivers/gpu/drm/i915/gt/intel_context_types.h | 2 ++ drivers/gpu/drm/i915/gt/intel_engine_pm.c | 2 -- drivers/gpu/drm/i915/gt/intel_engine_types.h | 2 -- .../gpu/drm/i915/gt/intel_execlists_submission.c | 15 --------------- drivers/gpu/drm/i915/i915_request.c | 4 ++-- 6 files changed, 7 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/gt/intel_context.c +3 -0
@@ -345,6 +345,9 @@ static int __intel_context_active(struct i915_active *active) {struct intel_context *ce =container_of (active,typeof (*ce), active); +CE_TRACE (ce,"active\n" ); + ce->saturated =0 ; +intel_context_get (ce);/* everything should already be activated by intel_context_pre_pin() */
drivers/gpu/drm/i915/gt/intel_context_types.h +2 -0
@@ -103,6 +103,8 @@ struct intel_context { } lrc;u32 tag;/* cookie passed to HW to track this context on submission */ +intel_engine_mask_t saturated;/* submitting semaphores too late? */ +/* Time on GPU as tracked by the hw. */ struct {struct ewma_runtime avg;
drivers/gpu/drm/i915/gt/intel_engine_pm.c +0 -2
@@ -254,8 +254,6 @@ static int __engine_park(struct intel_wakeref *wf)struct intel_engine_cs *engine =container_of (wf,typeof (*engine), wakeref); - engine->saturated =0 ; -/* * If one and only one request is completed between pm events, * we know that we are inside the kernel context and it is
drivers/gpu/drm/i915/gt/intel_engine_types.h +0 -2
@@ -304,8 +304,6 @@ struct intel_engine_cs {struct intel_context *kernel_context;/* pinned */ -intel_engine_mask_t saturated;/* submitting semaphores too late? */ -struct {struct delayed_work work;struct i915_request *systole;
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +0 -15
@@ -3330,21 +3330,6 @@ intel_execlists_create_virtual(struct intel_engine_cs **siblings, ve->base.instance =I915_ENGINE_CLASS_INVALID_VIRTUAL ; ve->base.uabi_instance =I915_ENGINE_CLASS_INVALID_VIRTUAL ; -/* -* The decision on whether to submit a request using semaphores -* depends on the saturated state of the engine. We only compute -* this during HW submission of the request, and we need for this -* state to be globally applied to all requests being submitted -* to this engine. Virtual engines encompass more than one physical -* engine and so we cannot accurately tell in advance if one of those -* engines is already saturated and so cannot afford to use a semaphore -* and be pessimized in priority for doing so -- if we are the only -* context using semaphores after all other clients have stopped, we -* will be starved on the saturated system. Such a global switch for -* semaphores is less than ideal, but alas is the current compromise. -*/ - ve->base.saturated =ALL_ENGINES ; -snprintf (ve->base.name,sizeof (ve->base.name),"virtual" );i915_sched_init_engine (&ve->base.active,ENGINE_VIRTUAL );
drivers/gpu/drm/i915/i915_request.c +2 -2
@@ -569,7 +569,7 @@ bool __i915_request_submit(struct i915_request *request)*/ if (request->sched.semaphores &&i915_sw_fence_signaled (&request->semaphore)) - engine->saturated |= request->sched.semaphores; + request->context->saturated |= request->sched.semaphores; engine->emit_fini_breadcrumb (request, request->ring->vaddr + request->postfix);
@@ -1030,7 +1030,7 @@ already_busywaiting(struct i915_request *rq)* * See the are-we-too-late? check in __i915_request_submit(). */ -return rq->sched.semaphores |READ_ONCE (rq->engine->saturated); +return rq->sched.semaphores |READ_ONCE (rq->context->saturated); } static int
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 39/54 drm/i915: Bump default timeslicing quantum to 5ms
In reply to Chris Wilson--- drivers/gpu/drm/i915/Kconfig.profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/Kconfig.profile +1 -1
@@ -90,7 +90,7 @@ config DRM_I915_STOP_TIMEOUT config DRM_I915_TIMESLICE_DURATION int "Scheduling quantum for userspace batches (ms, jiffy granularity)" - default 1 # milliseconds + default 5 # milliseconds help When two user batches of equal priority are executing, we will alternate execution of each batch to ensure forward progress of
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 40/54 drm/i915/gt: Wrap intel_timeline.has_initial_breadcrumb
In reply to Chris WilsonIn preparation for removing the has_initial_breadcrumb field, add a helper function for the existing callers.
--- drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/intel_ring_submission.c | 4 ++-- drivers/gpu/drm/i915/gt/intel_timeline.c | 6 +++--- drivers/gpu/drm/i915/gt/intel_timeline.h | 6 ++++++ drivers/gpu/drm/i915/gt/selftest_timeline.c | 5 +++-- 5 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1 -1
@@ -354,7 +354,7 @@ int gen8_emit_init_breadcrumb(struct i915_request *rq)u32 *cs;GEM_BUG_ON (i915_request_has_initial_breadcrumb (rq)); -if (!i915_request_timeline (rq)->has_initial_breadcrumb) +if (!intel_timeline_has_initial_breadcrumb (i915_request_timeline (rq)))return 0 ; cs =intel_ring_begin (rq,6 );
drivers/gpu/drm/i915/gt/intel_ring_submission.c +2 -2
@@ -981,7 +981,7 @@ static int ring_request_alloc(struct i915_request *request)int ret;GEM_BUG_ON (!intel_context_is_pinned (request->context)); -GEM_BUG_ON (i915_request_timeline (request)->has_initial_breadcrumb); +GEM_BUG_ON (intel_timeline_has_initial_breadcrumb (i915_request_timeline (request)));/* * Flush enough space to reduce the likelihood of waiting after
@@ -1306,7 +1306,7 @@ int intel_ring_submission_setup(struct intel_engine_cs *engine) err =PTR_ERR (timeline); goto err; } -GEM_BUG_ON (timeline->has_initial_breadcrumb); +GEM_BUG_ON (intel_timeline_has_initial_breadcrumb (timeline)); err =intel_timeline_pin (timeline,NULL );if (err)
drivers/gpu/drm/i915/gt/intel_timeline.c +3 -3
@@ -445,14 +445,14 @@ void intel_timeline_exit(struct intel_timeline *tl)static u32 timeline_advance (struct intel_timeline *tl) {GEM_BUG_ON (!atomic_read (&tl->pin_count)); -GEM_BUG_ON (tl->seqno & tl->has_initial_breadcrumb); +GEM_BUG_ON (tl->seqno &intel_timeline_has_initial_breadcrumb (tl)); -return tl->seqno +=1 + tl->has_initial_breadcrumb; +return tl->seqno +=1 +intel_timeline_has_initial_breadcrumb (tl); }static void timeline_rollback (struct intel_timeline *tl) { - tl->seqno -=1 + tl->has_initial_breadcrumb; + tl->seqno -=1 +intel_timeline_has_initial_breadcrumb (tl); }static noinline int
drivers/gpu/drm/i915/gt/intel_timeline.h +6 -0
@@ -61,6 +61,12 @@ static inline void intel_timeline_put(struct intel_timeline *timeline)kref_put (&timeline->kref, __intel_timeline_free); } +static inline bool +intel_timeline_has_initial_breadcrumb (const struct intel_timeline *tl) +{ +return tl->has_initial_breadcrumb; +} +static inline int __intel_timeline_sync_set (struct intel_timeline *tl,u64 context,u32 seqno) {
drivers/gpu/drm/i915/gt/selftest_timeline.c +3 -2
@@ -666,7 +666,7 @@ static int live_hwsp_wrap(void *arg)if (IS_ERR (tl))return PTR_ERR (tl); -if (!tl->has_initial_breadcrumb || !tl->hwsp_cacheline) +if (!intel_timeline_has_initial_breadcrumb (tl) || !tl->hwsp_cacheline) goto out_free; err =intel_timeline_pin (tl,NULL );
@@ -1235,7 +1235,8 @@ static int live_hwsp_rollover_user(void *arg) goto out; tl = ce->timeline; -if (!tl->has_initial_breadcrumb || !tl->hwsp_cacheline) +if (!intel_timeline_has_initial_breadcrumb (tl) || + !tl->hwsp_cacheline) goto out;timeline_rollback (tl);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 41/54 drm/i915/gt: Track timeline GGTT offset separately from subpage offset
In reply to Chris WilsonCurrently we know that the timeline status page is at most a page in size, and so we can preserve the lower 12bits of the offset when relocating the status page in the GGTT. If we want to use a larger object, such as the context state, we may not necessarily use a position within the first page and so need more than 12b.
--- drivers/gpu/drm/i915/gt/gen6_engine_cs.c | 4 ++-- drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 4 ++-- drivers/gpu/drm/i915/gt/intel_timeline.c | 17 +++++++---------- drivers/gpu/drm/i915/gt/intel_timeline_types.h | 1 + drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/selftest_rc6.c | 2 +- drivers/gpu/drm/i915/gt/selftest_timeline.c | 16 ++++++++-------- 8 files changed, 23 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/gt/gen6_engine_cs.c +2 -2
@@ -161,7 +161,7 @@ u32 *gen6_emit_breadcrumb_rcs(struct i915_request *rq, u32 *cs)PIPE_CONTROL_DC_FLUSH_ENABLE |PIPE_CONTROL_QW_WRITE | PIPE_CONTROL_CS_STALL); - *cs++ =i915_request_active_timeline (rq)->hwsp_offset | + *cs++ =i915_request_active_timeline (rq)->ggtt_offset |PIPE_CONTROL_GLOBAL_GTT ; *cs++ = rq->fence.seqno;
@@ -359,7 +359,7 @@ u32 *gen7_emit_breadcrumb_rcs(struct i915_request *rq, u32 *cs)PIPE_CONTROL_QW_WRITE |PIPE_CONTROL_GLOBAL_GTT_IVB | PIPE_CONTROL_CS_STALL); - *cs++ =i915_request_active_timeline (rq)->hwsp_offset; + *cs++ =i915_request_active_timeline (rq)->ggtt_offset; *cs++ = rq->fence.seqno; *cs++ =MI_USER_INTERRUPT ;
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1 -1
@@ -346,7 +346,7 @@ static u32 hwsp_offset(const struct i915_request *rq)if (cl)return cl->ggtt_offset; -return rcu_dereference_protected (rq->timeline,1 )->hwsp_offset; +return rcu_dereference_protected (rq->timeline,1 )->ggtt_offset; }int gen8_emit_init_breadcrumb (struct i915_request *rq)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -2
@@ -1324,7 +1324,7 @@ static int print_ring(char *buf, int sz, struct i915_request *rq) len =scnprintf (buf, sz,"ring:{start:%08x, hwsp:%08x, seqno:%08x, runtime:%llums}, " ,i915_ggtt_offset (rq->ring->vma), - tl ? tl->hwsp_offset :0 , + tl ? tl->ggtt_offset :0 ,hwsp_seqno (rq),DIV_ROUND_CLOSEST_ULL (intel_context_get_total_runtime_ns (rq->context),1000 *1000 ));
@@ -1663,7 +1663,7 @@ void intel_engine_dump(struct intel_engine_cs *engine,if (tl) {drm_printf (m,"\t\tring->hwsp: 0x%08x\n" , - tl->hwsp_offset); + tl->ggtt_offset);intel_timeline_put (tl); }
drivers/gpu/drm/i915/gt/intel_timeline.c +7 -10
@@ -355,13 +355,11 @@ int intel_timeline_pin(struct intel_timeline *tl, struct i915_gem_ww_ctx *ww)if (err)return err; - tl->hwsp_offset = -i915_ggtt_offset (tl->hwsp_ggtt) + -offset_in_page (tl->hwsp_offset); + tl->ggtt_offset =i915_ggtt_offset (tl->hwsp_ggtt) + tl->hwsp_offset;GT_TRACE (tl->gt,"timeline:%llx using HWSP offset:%x\n" , - tl->fence_context, tl->hwsp_offset); + tl->fence_context, tl->ggtt_offset); -cacheline_acquire (tl->hwsp_cacheline, tl->hwsp_offset); +cacheline_acquire (tl->hwsp_cacheline, tl->ggtt_offset);if (atomic_fetch_inc (&tl->pin_count)) {cacheline_release (tl->hwsp_cacheline);__i915_vma_unpin (tl->hwsp_ggtt);
@@ -529,14 +527,13 @@ __intel_timeline_get_seqno(struct intel_timeline *tl, vaddr =page_mask_bits (cl->vaddr); tl->hwsp_offset = cacheline *CACHELINE_BYTES ; - tl->hwsp_seqno = -memset (vaddr + tl->hwsp_offset,0 ,CACHELINE_BYTES ); + tl->hwsp_seqno =memset (vaddr + tl->hwsp_offset,0 ,CACHELINE_BYTES ); - tl->hwsp_offset +=i915_ggtt_offset (vma); + tl->ggtt_offset =i915_ggtt_offset (vma) + tl->hwsp_offset;GT_TRACE (tl->gt,"timeline:%llx using HWSP offset:%x\n" , - tl->fence_context, tl->hwsp_offset); + tl->fence_context, tl->ggtt_offset); -cacheline_acquire (cl, tl->hwsp_offset); +cacheline_acquire (cl, tl->ggtt_offset); tl->hwsp_cacheline = cl; *seqno =timeline_advance (tl);
drivers/gpu/drm/i915/gt/intel_timeline_types.h +1 -0
@@ -48,6 +48,7 @@ struct intel_timeline {const u32 *hwsp_seqno;struct i915_vma *hwsp_ggtt;u32 hwsp_offset; +u32 ggtt_offset;struct intel_timeline_cacheline *hwsp_cacheline;
drivers/gpu/drm/i915/gt/selftest_engine_cs.c +1 -1
@@ -54,7 +54,7 @@ static int write_timestamp(struct i915_request *rq, int slot) cmd++; *cs++ = cmd; *cs++ =i915_mmio_reg_offset (RING_TIMESTAMP (rq->engine->mmio_base)); - *cs++ =i915_request_timeline (rq)->hwsp_offset + slot *sizeof (u32); + *cs++ =i915_request_timeline (rq)->ggtt_offset + slot *sizeof (u32); *cs++ =0 ;intel_ring_advance (rq, cs);
drivers/gpu/drm/i915/gt/selftest_rc6.c +1 -1
@@ -138,7 +138,7 @@ static const u32 *__live_rc6_ctx(struct intel_context *ce) *cs++ = cmd; *cs++ =i915_mmio_reg_offset (GEN8_RC6_CTX_INFO ); - *cs++ = ce->timeline->hwsp_offset +8 ; + *cs++ = ce->timeline->ggtt_offset +8 ; *cs++ =0 ;intel_ring_advance (rq, cs);
drivers/gpu/drm/i915/gt/selftest_timeline.c +8 -8
@@ -469,7 +469,7 @@ tl_write(struct intel_timeline *tl, struct intel_engine_cs *engine, u32 value)i915_request_get (rq); - err =emit_ggtt_store_dw (rq, tl->hwsp_offset, value); + err =emit_ggtt_store_dw (rq, tl->ggtt_offset, value);i915_request_add (rq);if (err) {i915_request_put (rq);
@@ -565,7 +565,7 @@ static int live_hwsp_engine(void *arg)if (!err &&READ_ONCE (*tl->hwsp_seqno) != n) {GEM_TRACE_ERR ("Invalid seqno:%lu stored in timeline %llu @ %x, found 0x%x\n" , - n, tl->fence_context, tl->hwsp_offset, *tl->hwsp_seqno); + n, tl->fence_context, tl->ggtt_offset, *tl->hwsp_seqno);GEM_TRACE_DUMP (); err = -EINVAL ; }
@@ -637,7 +637,7 @@ static int live_hwsp_alternate(void *arg)if (!err &&READ_ONCE (*tl->hwsp_seqno) != n) {GEM_TRACE_ERR ("Invalid seqno:%lu stored in timeline %llu @ %x, found 0x%x\n" , - n, tl->fence_context, tl->hwsp_offset, *tl->hwsp_seqno); + n, tl->fence_context, tl->ggtt_offset, *tl->hwsp_seqno);GEM_TRACE_DUMP (); err = -EINVAL ; }
@@ -697,9 +697,9 @@ static int live_hwsp_wrap(void *arg) goto out; }pr_debug ("seqno[0]:%08x, hwsp_offset:%08x\n" , - seqno[0 ], tl->hwsp_offset); + seqno[0 ], tl->ggtt_offset); - err =emit_ggtt_store_dw (rq, tl->hwsp_offset, seqno[0 ]); + err =emit_ggtt_store_dw (rq, tl->ggtt_offset, seqno[0 ]);if (err) {i915_request_add (rq); goto out;
@@ -714,9 +714,9 @@ static int live_hwsp_wrap(void *arg) goto out; }pr_debug ("seqno[1]:%08x, hwsp_offset:%08x\n" , - seqno[1 ], tl->hwsp_offset); + seqno[1 ], tl->ggtt_offset); - err =emit_ggtt_store_dw (rq, tl->hwsp_offset, seqno[1 ]); + err =emit_ggtt_store_dw (rq, tl->ggtt_offset, seqno[1 ]);if (err) {i915_request_add (rq); goto out;
@@ -1344,7 +1344,7 @@ static int live_hwsp_recycle(void *arg)if (READ_ONCE (*tl->hwsp_seqno) != count) {GEM_TRACE_ERR ("Invalid seqno:%lu stored in timeline %llu @ %x found 0x%x\n" , count, tl->fence_context, - tl->hwsp_offset, *tl->hwsp_seqno); + tl->ggtt_offset, *tl->hwsp_seqno);GEM_TRACE_DUMP (); err = -EINVAL ; }
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 42/54 drm/i915/gt: Add timeline "mode"
In reply to Chris WilsonExplicitly differentiate between the absolute and relative timelines, and the global HWSP and ppHWSP relative offsets. When using a timeline that is relative to a known status page, we can replace the absolute addressing in the commands with indexed variants.
--- drivers/gpu/drm/i915/gt/intel_timeline.c | 21 ++++++++++++++++--- drivers/gpu/drm/i915/gt/intel_timeline.h | 2 +- .../gpu/drm/i915/gt/intel_timeline_types.h | 10 +++++++-- 3 files changed, 27 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gt/intel_timeline.c +18 -3
@@ -227,7 +227,6 @@ static int intel_timeline_init(struct intel_timeline *timeline, timeline->gt = gt; - timeline->has_initial_breadcrumb = !hwsp; timeline->hwsp_cacheline =NULL ;if (!hwsp) {
@@ -244,13 +243,29 @@ static int intel_timeline_init(struct intel_timeline *timeline,return PTR_ERR (cl); } + timeline->mode =INTEL_TIMELINE_ABSOLUTE ; timeline->hwsp_cacheline = cl; timeline->hwsp_offset = cacheline *CACHELINE_BYTES ; vaddr =page_mask_bits (cl->vaddr); }else { - timeline->hwsp_offset = offset; - vaddr =i915_gem_object_pin_map (hwsp->obj,I915_MAP_WB ); +int preferred; + +if (offset &INTEL_TIMELINE_RELATIVE_CONTEXT ) { + timeline->mode =INTEL_TIMELINE_RELATIVE_CONTEXT ; + timeline->hwsp_offset = + offset & ~INTEL_TIMELINE_RELATIVE_CONTEXT ; + preferred =i915_coherent_map_type (gt->i915); + }else { + timeline->mode =INTEL_TIMELINE_RELATIVE_ENGINE ; + timeline->hwsp_offset = offset; + preferred =I915_MAP_WB ; + } + + vaddr =i915_gem_object_pin_map (hwsp->obj, + preferred |I915_MAP_OVERRIDE ); +if (IS_ERR (vaddr)) + vaddr =i915_gem_object_pin_map (hwsp->obj,I915_MAP_WC );if (IS_ERR (vaddr))return PTR_ERR (vaddr); }
drivers/gpu/drm/i915/gt/intel_timeline.h +1 -1
@@ -64,7 +64,7 @@ static inline void intel_timeline_put(struct intel_timeline *timeline)static inline bool intel_timeline_has_initial_breadcrumb (const struct intel_timeline *tl) { -return tl->has_initial_breadcrumb; +return tl->mode ==INTEL_TIMELINE_ABSOLUTE ; } static inline int __intel_timeline_sync_set(struct intel_timeline *tl,
drivers/gpu/drm/i915/gt/intel_timeline_types.h +8 -2
@@ -20,6 +20,12 @@ struct i915_syncmap;struct intel_gt ;struct intel_timeline_hwsp ; +enum intel_timeline_mode { +INTEL_TIMELINE_ABSOLUTE =0 , +INTEL_TIMELINE_RELATIVE_CONTEXT =BIT (0 ), +INTEL_TIMELINE_RELATIVE_ENGINE =BIT (1 ), +}; +struct intel_timeline {u64 fence_context;u32 seqno;
@@ -45,6 +51,8 @@ struct intel_timeline {atomic_t pin_count;atomic_t active_count; +enum intel_timeline_mode mode; +const u32 *hwsp_seqno;struct i915_vma *hwsp_ggtt;u32 hwsp_offset;
@@ -52,8 +60,6 @@ struct intel_timeline {struct intel_timeline_cacheline *hwsp_cacheline; -bool has_initial_breadcrumb; -/** * List of breadcrumbs associated with GPU requests currently * outstanding.
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 43/54 drm/i915/gt: Use indices for writing into relative timelines
In reply to Chris WilsonRelative timelines are relative to either the global or per-process HWSP, and so we can replace the absolute addressing with store-index variants for position invariance.
--- drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 98 +++++++++++++++++------- drivers/gpu/drm/i915/gt/intel_timeline.h | 12 +++ 2 files changed, 82 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +70 -28
@@ -502,7 +502,19 @@ gen8_emit_fini_breadcrumb_tail(struct i915_request *rq, u32 *cs)static u32 *emit_xcs_breadcrumb (struct i915_request *rq,u32 *cs) { -return gen8_emit_ggtt_write (cs, rq->fence.seqno,hwsp_offset (rq),0 ); +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +unsigned int flags =MI_FLUSH_DW_OP_STOREDW ; +u32 offset =hwsp_offset (rq); + +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + flags |=MI_FLUSH_DW_STORE_INDEX ; + } +GEM_BUG_ON (offset &7 ); +if (!intel_timeline_in_context (tl)) + offset |=MI_FLUSH_DW_USE_GTT ; + +return __gen8_emit_flush_dw (cs, rq->fence.seqno, offset, flags); }u32 *gen8_emit_fini_breadcrumb_xcs (struct i915_request *rq,u32 *cs)
@@ -512,6 +524,18 @@ u32 *gen8_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs)u32 *gen8_emit_fini_breadcrumb_rcs (struct i915_request *rq,u32 *cs) { +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +unsigned int flags =PIPE_CONTROL_FLUSH_ENABLE |PIPE_CONTROL_CS_STALL ; +u32 offset =hwsp_offset (rq); + +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + flags |=PIPE_CONTROL_STORE_DATA_INDEX ; + } +GEM_BUG_ON (offset &7 ); +if (!intel_timeline_in_context (tl)) + flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; + cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | PIPE_CONTROL_DEPTH_CACHE_FLUSH |
@@ -519,26 +543,33 @@ u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs) 0);/* XXX flush+write+CS_STALL all in one upsets gem_concurrent_blt:kbl */ - cs =gen8_emit_ggtt_write_rcs (cs, - rq->fence.seqno, -hwsp_offset (rq), -PIPE_CONTROL_FLUSH_ENABLE | -PIPE_CONTROL_CS_STALL ); + cs =__gen8_emit_write_rcs (cs, rq->fence.seqno, offset,0 , flags);return gen8_emit_fini_breadcrumb_tail (rq, cs); }u32 *gen11_emit_fini_breadcrumb_rcs (struct i915_request *rq,u32 *cs) { - cs =gen8_emit_ggtt_write_rcs (cs, - rq->fence.seqno, -hwsp_offset (rq), -PIPE_CONTROL_CS_STALL | -PIPE_CONTROL_TILE_CACHE_FLUSH | -PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | -PIPE_CONTROL_DEPTH_CACHE_FLUSH | -PIPE_CONTROL_DC_FLUSH_ENABLE | -PIPE_CONTROL_FLUSH_ENABLE ); +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +u32 offset =hwsp_offset (rq); +unsigned int flags; + + flags = (PIPE_CONTROL_CS_STALL | +PIPE_CONTROL_TILE_CACHE_FLUSH | +PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | +PIPE_CONTROL_DEPTH_CACHE_FLUSH | +PIPE_CONTROL_DC_FLUSH_ENABLE | +PIPE_CONTROL_FLUSH_ENABLE ); + +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + flags |=PIPE_CONTROL_STORE_DATA_INDEX ; + } +GEM_BUG_ON (offset &7 ); +if (!intel_timeline_in_context (tl)) + flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; + + cs =__gen8_emit_write_rcs (cs, rq->fence.seqno, offset,0 , flags);return gen8_emit_fini_breadcrumb_tail (rq, cs); }
@@ -601,19 +632,30 @@ u32 *gen12_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs)u32 *gen12_emit_fini_breadcrumb_rcs (struct i915_request *rq,u32 *cs) { - cs =gen12_emit_ggtt_write_rcs (cs, - rq->fence.seqno, -hwsp_offset (rq), -PIPE_CONTROL0_HDC_PIPELINE_FLUSH , -PIPE_CONTROL_CS_STALL | -PIPE_CONTROL_TILE_CACHE_FLUSH | -PIPE_CONTROL_FLUSH_L3 | -PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | -PIPE_CONTROL_DEPTH_CACHE_FLUSH | -/* Wa_1409600907:tgl */ -PIPE_CONTROL_DEPTH_STALL | -PIPE_CONTROL_DC_FLUSH_ENABLE | -PIPE_CONTROL_FLUSH_ENABLE ); +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +u32 offset =hwsp_offset (rq); +unsigned int flags; + + flags = (PIPE_CONTROL_CS_STALL | +PIPE_CONTROL_TILE_CACHE_FLUSH | +PIPE_CONTROL_FLUSH_L3 | +PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | +PIPE_CONTROL_DEPTH_CACHE_FLUSH | +/* Wa_1409600907:tgl */ +PIPE_CONTROL_DEPTH_STALL | +PIPE_CONTROL_DC_FLUSH_ENABLE | +PIPE_CONTROL_FLUSH_ENABLE ); + +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + flags |=PIPE_CONTROL_STORE_DATA_INDEX ; + } +GEM_BUG_ON (offset &7 ); +if (!intel_timeline_in_context (tl)) + flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; + + cs =__gen8_emit_write_rcs (cs, rq->fence.seqno, offset, +PIPE_CONTROL0_HDC_PIPELINE_FLUSH , flags);return gen12_emit_fini_breadcrumb_tail (rq, cs); }
drivers/gpu/drm/i915/gt/intel_timeline.h +12 -0
@@ -67,6 +67,18 @@ intel_timeline_has_initial_breadcrumb(const struct intel_timeline *tl)return tl->mode ==INTEL_TIMELINE_ABSOLUTE ; } +static inline bool +intel_timeline_is_relative (const struct intel_timeline *tl) +{ +return tl->mode !=INTEL_TIMELINE_ABSOLUTE ; +} + +static inline bool +intel_timeline_in_context (const struct intel_timeline *tl) +{ +return tl->mode ==INTEL_TIMELINE_RELATIVE_CONTEXT ; +} +static inline int __intel_timeline_sync_set (struct intel_timeline *tl,u64 context,u32 seqno) {
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 44/54 drm/i915/selftests: Exercise relative timeline modes
In reply to Chris WilsonA quick test to verify that the backend accepts each type of timeline and can use them to track and control request emission.
--- drivers/gpu/drm/i915/gt/selftest_timeline.c | 105 ++++++++++++++++++++ 1 file changed, 105 insertions(+)
drivers/gpu/drm/i915/gt/selftest_timeline.c +105 -0
@@ -1365,9 +1365,114 @@ static int live_hwsp_recycle(void *arg)return err; } +static int live_hwsp_relative (void *arg) +{ +struct intel_gt *gt = arg; +struct intel_engine_cs *engine; +enum intel_engine_id id; + +/* +* Check backend support for different timeline modes. +*/ + +for_each_engine (engine, gt, id) { +enum intel_timeline_mode mode; + +if (!intel_engine_has_scheduler (engine)) +continue ; + +for (mode =INTEL_TIMELINE_ABSOLUTE ; + mode <=INTEL_TIMELINE_RELATIVE_ENGINE ; + mode++) { +struct intel_timeline *tl; +struct i915_request *rq; +struct intel_context *ce; +const char *msg; +int err; + +if (mode ==INTEL_TIMELINE_RELATIVE_CONTEXT && + !HAS_EXECLISTS (gt->i915)) +continue ; + + ce =intel_context_create (engine); +if (IS_ERR (ce)) +return PTR_ERR (ce); + + err =intel_context_alloc_state (ce); +if (err) { +intel_context_put (ce); +return err; + } + +switch (mode) { +case INTEL_TIMELINE_ABSOLUTE : + tl =intel_timeline_create (gt); + msg ="local" ; +break ; + +case INTEL_TIMELINE_RELATIVE_CONTEXT : + tl =__intel_timeline_create (gt, + ce->state, +INTEL_TIMELINE_RELATIVE_CONTEXT | +0x400 ); + msg ="ppHWSP" ; +break ; + +case INTEL_TIMELINE_RELATIVE_ENGINE : + tl =__intel_timeline_create (gt, + engine->status_page.vma, +0x400 ); + msg ="HWSP" ; +break ; +default : +continue ; + } +if (IS_ERR (tl)) { +intel_context_put (ce); +return PTR_ERR (tl); + } + +pr_info ("Testing %s timeline on %s\n" , + msg, engine->name); + +intel_timeline_put (ce->timeline); + ce->timeline = tl; + + err =intel_timeline_pin (tl,NULL ); +if (err) { +intel_context_put (ce); +return err; + } + tl->seqno =0xc0000000 ; +WRITE_ONCE (*(u32 *)tl->hwsp_seqno, tl->seqno); +intel_timeline_unpin (tl); + + rq =intel_context_create_request (ce); +intel_context_put (ce); +if (IS_ERR (rq)) +return PTR_ERR (rq); + +GEM_BUG_ON (rcu_access_pointer (rq->timeline) != tl); + +i915_request_get (rq); +i915_request_add (rq); + +if (i915_request_wait (rq,0 ,HZ /5 ) <0 ) { +i915_request_put (rq); +return -EIO ; + } + +i915_request_put (rq); + } + } + +return 0 ; +} +int intel_timeline_live_selftests (struct drm_i915_private *i915) {static const struct i915_subtest tests[] = { +SUBTEST (live_hwsp_relative),SUBTEST (live_hwsp_recycle),SUBTEST (live_hwsp_engine),SUBTEST (live_hwsp_alternate),
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 45/54 drm/i915/gt: Use ppHWSP for unshared non-semaphore related timelines
In reply to Chris WilsonWhen we are not using semaphores with a context/engine, we can simply reuse the same seqno location across wraps, but we still require each timeline to have its own address. For LRC submission, each context is prefixed by a per-process HWSP, which provides us with a unique location for each context-local timeline. A shared timeline that is common to multiple contexts will continue to use a separate page.
This enables us to create position invariant contexts should we feel the need to relocate them.
Initially they are automatically used by Broadwell/Braswell as they do not require independent timelines.
--- drivers/gpu/drm/i915/gt/intel_lrc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_lrc.c +11 -1
@@ -834,6 +834,14 @@ pinned_timeline(struct intel_context *ce, struct intel_engine_cs *engine)return intel_timeline_create_from_engine (engine,page_unmask_bits (tl)); } +static struct intel_timeline * +pphwsp_timeline (struct intel_context *ce,struct i915_vma *state) +{ +return __intel_timeline_create (ce->engine->gt, state, +I915_GEM_HWS_SEQNO_ADDR | +INTEL_TIMELINE_RELATIVE_CONTEXT ); +} +int lrc_alloc (struct intel_context *ce,struct intel_engine_cs *engine) {struct intel_ring *ring;
@@ -861,8 +869,10 @@ int lrc_alloc(struct intel_context *ce, struct intel_engine_cs *engine)*/ if (unlikely (ce->timeline)) tl =pinned_timeline (ce, engine); -else +else if (intel_engine_has_semaphores (engine)) tl =intel_timeline_create (engine->gt); +else + tl =pphwsp_timeline (ce, vma);if (IS_ERR (tl)) { err =PTR_ERR (tl); goto err_ring;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 46/54 Restore "drm/i915: drop engine_pin/unpin_breadcrumbs_irq"
In reply to Chris WilsonThis was removed in commit 478ffad6d690 ("drm/i915: drop engine_pin/unpin_breadcrumbs_irq") as the last user had been removed, but now there is a promise of a new user in the next patch.
--- drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 24 +++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_breadcrumbs.h | 3 +++ 2 files changed, 27 insertions(+)
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c +24 -0
@@ -329,6 +329,30 @@ void intel_breadcrumbs_reset(struct intel_breadcrumbs *b)spin_unlock_irqrestore (&b->irq_lock, flags); } +void intel_breadcrumbs_pin_irq (struct intel_breadcrumbs *b) +{ +if (GEM_DEBUG_WARN_ON (!b->irq_engine)) +return ; + +spin_lock_irq (&b->irq_lock); +if (!b->irq_enabled++) +irq_enable (b->irq_engine); +GEM_BUG_ON (!b->irq_enabled);/* no overflow! */ +spin_unlock_irq (&b->irq_lock); +} + +void intel_breadcrumbs_unpin_irq (struct intel_breadcrumbs *b) +{ +if (GEM_DEBUG_WARN_ON (!b->irq_engine)) +return ; + +spin_lock_irq (&b->irq_lock); +GEM_BUG_ON (!b->irq_enabled);/* no underflow! */ +if (!--b->irq_enabled) +irq_disable (b->irq_engine); +spin_unlock_irq (&b->irq_lock); +} +void __intel_breadcrumbs_park (struct intel_breadcrumbs *b) {if (!READ_ONCE (b->irq_armed))
drivers/gpu/drm/i915/gt/intel_breadcrumbs.h +3 -0
@@ -18,6 +18,9 @@ struct intel_breadcrumbs * intel_breadcrumbs_create(struct intel_engine_cs *irq_engine);void intel_breadcrumbs_free (struct intel_breadcrumbs *b); +void intel_breadcrumbs_pin_irq (struct intel_breadcrumbs *b); +void intel_breadcrumbs_unpin_irq (struct intel_breadcrumbs *b); +void intel_breadcrumbs_reset (struct intel_breadcrumbs *b);void __intel_breadcrumbs_park (struct intel_breadcrumbs *b);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 47/54 drm/i915/gt: Couple tasklet scheduling for all CS interrupts
In reply to Chris WilsonIf any engine asks for the tasklet to be kicked from the CS interrupt, do so. Currently, this is used by the execlists scheduler backends to feed in the next request to the HW, and similarly could be used by a ring scheduler, as will be seen in the next patch.
--- drivers/gpu/drm/i915/gt/intel_gt_irq.c | 17 ++++++++++++----- drivers/gpu/drm/i915/gt/intel_gt_irq.h | 3 +++ drivers/gpu/drm/i915/gt/intel_rps.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 8 ++++---- 4 files changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt_irq.c +12 -5
@@ -63,6 +63,13 @@ cs_irq_handler(struct intel_engine_cs *engine, u32 iir)i915_sched_kick (&engine->active); } +void gen2_engine_cs_irq (struct intel_engine_cs *engine) +{ +intel_engine_signal_breadcrumbs (engine); +if (intel_engine_needs_breadcrumb_tasklet (engine)) +i915_sched_kick (&engine->active); +} +static u32 gen11_gt_engine_identity (struct intel_gt *gt,const unsigned int bank,const unsigned int bit)
@@ -276,9 +283,9 @@ void gen11_gt_irq_postinstall(struct intel_gt *gt)void gen5_gt_irq_handler (struct intel_gt *gt,u32 gt_iir) {if (gt_iir >_RENDER_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (gt->engine_class[RENDER_CLASS ][0 ]); +gen2_engine_cs_irq (gt->engine_class[RENDER_CLASS ][0 ]);if (gt_iir &ILK_BSD_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (gt->engine_class[VIDEO_DECODE_CLASS ][0 ]); +gen2_engine_cs_irq (gt->engine_class[VIDEO_DECODE_CLASS ][0 ]); }static void gen7_parity_error_irq_handler (struct intel_gt *gt,u32 iir)
@@ -302,11 +309,11 @@ static void gen7_parity_error_irq_handler(struct intel_gt *gt, u32 iir)void gen6_gt_irq_handler (struct intel_gt *gt,u32 gt_iir) {if (gt_iir >_RENDER_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (gt->engine_class[RENDER_CLASS ][0 ]); +gen2_engine_cs_irq (gt->engine_class[RENDER_CLASS ][0 ]);if (gt_iir >_BSD_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (gt->engine_class[VIDEO_DECODE_CLASS ][0 ]); +gen2_engine_cs_irq (gt->engine_class[VIDEO_DECODE_CLASS ][0 ]);if (gt_iir >_BLT_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (gt->engine_class[COPY_ENGINE_CLASS ][0 ]); +gen2_engine_cs_irq (gt->engine_class[COPY_ENGINE_CLASS ][0 ]); if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT | GT_BSD_CS_ERROR_INTERRUPT |
drivers/gpu/drm/i915/gt/intel_gt_irq.h +3 -0
@@ -9,6 +9,7 @@#include <linux/types.h> +struct intel_engine_cs ;struct intel_gt ;#define GEN8_GT_IRQS (GEN8_GT_RCS_IRQ | \
@@ -19,6 +20,8 @@ struct intel_gt; GEN8_GT_PM_IRQ | \ GEN8_GT_GUC_IRQ) +void gen2_engine_cs_irq (struct intel_engine_cs *engine); +void gen11_gt_irq_reset (struct intel_gt *gt);void gen11_gt_irq_postinstall (struct intel_gt *gt);void gen11_gt_irq_handler (struct intel_gt *gt,const u32 master_ctl);
drivers/gpu/drm/i915/gt/intel_rps.c +1 -1
@@ -1771,7 +1771,7 @@ void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir)return ;if (pm_iir &PM_VEBOX_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (gt->engine[VECS0 ]); +gen2_engine_cs_irq (gt->engine[VECS0 ]);if (pm_iir &PM_VEBOX_CS_ERROR_INTERRUPT )DRM_DEBUG ("Command parser error, pm_iir 0x%08x\n" , pm_iir);
drivers/gpu/drm/i915/i915_irq.c +4 -4
@@ -3941,7 +3941,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)intel_uncore_write16 (&dev_priv->uncore,GEN2_IIR , iir);if (iir &I915_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (dev_priv->gt.engine[RCS0 ]); +gen2_engine_cs_irq (dev_priv->gt.engine[RCS0 ]);if (iir &I915_MASTER_ERROR_INTERRUPT )i8xx_error_irq_handler (dev_priv, eir, eir_stuck);
@@ -4049,7 +4049,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)intel_uncore_write (&dev_priv->uncore,GEN2_IIR , iir);if (iir &I915_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (dev_priv->gt.engine[RCS0 ]); +gen2_engine_cs_irq (dev_priv->gt.engine[RCS0 ]);if (iir &I915_MASTER_ERROR_INTERRUPT )i9xx_error_irq_handler (dev_priv, eir, eir_stuck);
@@ -4194,10 +4194,10 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)intel_uncore_write (&dev_priv->uncore,GEN2_IIR , iir);if (iir &I915_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (dev_priv->gt.engine[RCS0 ]); +gen2_engine_cs_irq (dev_priv->gt.engine[RCS0 ]);if (iir &I915_BSD_USER_INTERRUPT ) -intel_engine_signal_breadcrumbs (dev_priv->gt.engine[VCS0 ]); +gen2_engine_cs_irq (dev_priv->gt.engine[VCS0 ]);if (iir &I915_MASTER_ERROR_INTERRUPT )i9xx_error_irq_handler (dev_priv, eir, eir_stuck);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 48/54 drm/i915/gt: Support creation of 'internal' rings
In reply to Chris WilsonTo support legacy ring buffer scheduling, we want a virtual ringbuffer for each client. These rings are purely for holding the requests as they are being constructed on the CPU and never accessed by the GPU, so they should not be bound into the GGTT, and we can use plain old WB mapped pages.
As they are not bound, we need to nerf a few assumptions that a rq->ring is in the GGTT.
--- drivers/gpu/drm/i915/gt/intel_context.c | 2 +- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 17 +----- drivers/gpu/drm/i915/gt/intel_ring.c | 66 ++++++++++++++-------- drivers/gpu/drm/i915/gt/intel_ring.h | 12 +++- drivers/gpu/drm/i915/gt/intel_ring_types.h | 2 + 5 files changed, 59 insertions(+), 40 deletions(-)
drivers/gpu/drm/i915/gt/intel_context.c +1 -1
@@ -259,7 +259,7 @@ int __intel_context_do_pin_ww(struct intel_context *ce, }CE_TRACE (ce,"pin ring:{start:%08x, head:%04x, tail:%04x}\n" , -i915_ggtt_offset (ce->ring->vma), +intel_ring_address (ce->ring), ce->ring->head, ce->ring->tail); handoff = true;
drivers/gpu/drm/i915/gt/intel_engine_cs.c +3 -14
@@ -1323,7 +1323,7 @@ static int print_ring(char *buf, int sz, struct i915_request *rq) len = scnprintf(buf, sz, "ring:{start:%08x, hwsp:%08x, seqno:%08x, runtime:%llums}, ", - i915_ggtt_offset(rq->ring->vma), + intel_ring_address(rq->ring), tl ? tl->ggtt_offset : 0, hwsp_seqno(rq), DIV_ROUND_CLOSEST_ULL(intel_context_get_total_runtime_ns(rq->context),
@@ -1651,7 +1651,7 @@ void intel_engine_dump(struct intel_engine_cs *engine,i915_request_show (m, rq,"\t\tactive " ,0 );drm_printf (m,"\t\tring->start: 0x%08x\n" , -i915_ggtt_offset (rq->ring->vma)); +intel_ring_address (rq->ring));drm_printf (m,"\t\tring->head: 0x%08x\n" , rq->ring->head); drm_printf(m, "\t\tring->tail: 0x%08x\n",
@@ -1732,13 +1732,6 @@ ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine, ktime_t *now)return total; } -static bool match_ring (struct i915_request *rq) -{ -u32 ring =ENGINE_READ (rq->engine,RING_START ); - -return ring ==i915_ggtt_offset (rq->ring->vma); -} -struct i915_request *intel_engine_find_active_request (struct intel_engine_cs *engine) {
@@ -1778,11 +1771,7 @@ intel_engine_find_active_request(struct intel_engine_cs *engine)continue ;if (!i915_request_started (request)) -continue ; - -/* More than one preemptible request may match! */ -if (!match_ring (request)) -continue ; +break ; active = request;break ;
drivers/gpu/drm/i915/gt/intel_ring.c +42 -24
124 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_ring.h +11 -1
@@ -9,12 +9,14 @@#include "i915_gem.h" /* GEM_BUG_ON */ #include "i915_request.h" +#include "i915_vma.h" #include "intel_ring_types.h" struct intel_engine_cs ;struct intel_ring * -intel_engine_create_ring (struct intel_engine_cs *engine,int size); +intel_engine_create_ring (struct intel_engine_cs *engine,unsigned int size); +#define INTEL_RING_CREATE_INTERNAL BIT(0)u32 *intel_ring_begin (struct i915_request *rq,unsigned int num_dwords);int intel_ring_cacheline_align (struct i915_request *rq);
@@ -138,4 +140,12 @@ __intel_ring_space(unsigned int head, unsigned int tail, unsigned int size) return (head - tail - CACHELINE_BYTES) & (size - 1); } +static inline u32 intel_ring_address (const struct intel_ring *ring) +{ +if (ring->flags &INTEL_RING_CREATE_INTERNAL ) +return -1 ; + +return i915_ggtt_offset (ring->vma); +} +#endif /* INTEL_RING_H */
drivers/gpu/drm/i915/gt/intel_ring_types.h +2 -0
@@ -47,6 +47,8 @@ struct intel_ring {u32 size;u32 wrap;u32 effective_size; + + unsigned long flags; };#endif /* INTEL_RING_TYPES_H */
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 49/54 drm/i915/gt: Use client timeline address for seqno writes
In reply to Chris WilsonIf we allow for per-client timelines, even with legacy ring submission, we open the door to a world full of possiblities [scheduling and semaphores].
--- drivers/gpu/drm/i915/gt/gen6_engine_cs.c | 89 +++++++++++++++++------- drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 23 ++---- drivers/gpu/drm/i915/i915_request.h | 13 ++++ 3 files changed, 82 insertions(+), 43 deletions(-)
drivers/gpu/drm/i915/gt/gen6_engine_cs.c +64 -25
@@ -141,6 +141,12 @@ int gen6_emit_flush_rcs(struct i915_request *rq, u32 mode)u32 *gen6_emit_breadcrumb_rcs (struct i915_request *rq,u32 *cs) { +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +u32 offset =__i915_request_hwsp_offset (rq); +unsigned int flags; + +GEM_BUG_ON (tl->mode ==INTEL_TIMELINE_RELATIVE_CONTEXT ); +/* First we do the gen6_emit_post_sync_nonzero_flush w/a */ *cs++ =GFX_OP_PIPE_CONTROL (4 ); *cs++ =PIPE_CONTROL_CS_STALL |PIPE_CONTROL_STALL_AT_SCOREBOARD ;
@@ -154,15 +160,22 @@ u32 *gen6_emit_breadcrumb_rcs(struct i915_request *rq, u32 *cs)PIPE_CONTROL_GLOBAL_GTT ; *cs++ =0 ; -/* Finally we can flush and with it emit the breadcrumb */ - *cs++ =GFX_OP_PIPE_CONTROL (4 ); - *cs++ = (PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | + flags = (PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH |PIPE_CONTROL_DEPTH_CACHE_FLUSH |PIPE_CONTROL_DC_FLUSH_ENABLE |PIPE_CONTROL_QW_WRITE |PIPE_CONTROL_CS_STALL ); - *cs++ =i915_request_active_timeline (rq)->ggtt_offset | -PIPE_CONTROL_GLOBAL_GTT ; +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + flags |=PIPE_CONTROL_STORE_DATA_INDEX ; + } +if (!intel_timeline_in_context (tl)) + offset |=PIPE_CONTROL_GLOBAL_GTT ; + +/* Finally we can flush and with it emit the breadcrumb */ + *cs++ =GFX_OP_PIPE_CONTROL (4 ); + *cs++ = flags; + *cs++ = offset; *cs++ = rq->fence.seqno; *cs++ =MI_USER_INTERRUPT ;
@@ -351,15 +364,28 @@ int gen7_emit_flush_rcs(struct i915_request *rq, u32 mode)u32 *gen7_emit_breadcrumb_rcs (struct i915_request *rq,u32 *cs) { - *cs++ =GFX_OP_PIPE_CONTROL (4 ); - *cs++ = (PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH | +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +u32 offset =__i915_request_hwsp_offset (rq); +unsigned int flags; + +GEM_BUG_ON (tl->mode ==INTEL_TIMELINE_RELATIVE_CONTEXT ); + + flags = (PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH |PIPE_CONTROL_DEPTH_CACHE_FLUSH |PIPE_CONTROL_DC_FLUSH_ENABLE |PIPE_CONTROL_FLUSH_ENABLE |PIPE_CONTROL_QW_WRITE | -PIPE_CONTROL_GLOBAL_GTT_IVB |PIPE_CONTROL_CS_STALL ); - *cs++ =i915_request_active_timeline (rq)->ggtt_offset; +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + flags |=PIPE_CONTROL_STORE_DATA_INDEX ; + } +if (!intel_timeline_in_context (tl)) + flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; + + *cs++ =GFX_OP_PIPE_CONTROL (4 ); + *cs++ = flags; + *cs++ = offset; *cs++ = rq->fence.seqno; *cs++ =MI_USER_INTERRUPT ;
@@ -373,11 +399,21 @@ u32 *gen7_emit_breadcrumb_rcs(struct i915_request *rq, u32 *cs)u32 *gen6_emit_breadcrumb_xcs (struct i915_request *rq,u32 *cs) { -GEM_BUG_ON (i915_request_active_timeline (rq)->hwsp_ggtt != rq->engine->status_page.vma); -GEM_BUG_ON (offset_in_page (i915_request_active_timeline (rq)->hwsp_offset) !=I915_GEM_HWS_SEQNO_ADDR ); +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +u32 offset =__i915_request_hwsp_offset (rq); +unsigned int flags =0 ; + +GEM_BUG_ON (tl->mode ==INTEL_TIMELINE_RELATIVE_CONTEXT ); - *cs++ =MI_FLUSH_DW |MI_FLUSH_DW_OP_STOREDW |MI_FLUSH_DW_STORE_INDEX ; - *cs++ =I915_GEM_HWS_SEQNO_ADDR |MI_FLUSH_DW_USE_GTT ; +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + flags |=MI_FLUSH_DW_STORE_INDEX ; + } +if (!intel_timeline_in_context (tl)) + offset |=MI_FLUSH_DW_USE_GTT ; + + *cs++ =MI_FLUSH_DW |MI_FLUSH_DW_OP_STOREDW | flags; + *cs++ = offset; *cs++ = rq->fence.seqno; *cs++ =MI_USER_INTERRUPT ;
@@ -391,28 +427,31 @@ u32 *gen6_emit_breadcrumb_xcs(struct i915_request *rq, u32 *cs)#define GEN7_XCS_WA 32u32 *gen7_emit_breadcrumb_xcs (struct i915_request *rq,u32 *cs) { +struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); +u32 offset =__i915_request_hwsp_offset (rq); +u32 cmd =MI_FLUSH_DW |MI_FLUSH_DW_OP_STOREDW ;int i; -GEM_BUG_ON (i915_request_active_timeline (rq)->hwsp_ggtt != rq->engine->status_page.vma); -GEM_BUG_ON (offset_in_page (i915_request_active_timeline (rq)->hwsp_offset) !=I915_GEM_HWS_SEQNO_ADDR ); +GEM_BUG_ON (tl->mode ==INTEL_TIMELINE_RELATIVE_CONTEXT ); - *cs++ =MI_FLUSH_DW |MI_INVALIDATE_TLB | -MI_FLUSH_DW_OP_STOREDW |MI_FLUSH_DW_STORE_INDEX ; - *cs++ =I915_GEM_HWS_SEQNO_ADDR |MI_FLUSH_DW_USE_GTT ; +if (intel_timeline_is_relative (tl)) { + offset =offset_in_page (offset); + cmd |=MI_FLUSH_DW_STORE_INDEX ; + } +if (!intel_timeline_in_context (tl)) + offset |=MI_FLUSH_DW_USE_GTT ; + + *cs++ = cmd; + *cs++ = offset; *cs++ = rq->fence.seqno;for (i =0 ; i <GEN7_XCS_WA ; i++) { - *cs++ =MI_STORE_DWORD_INDEX ; - *cs++ =I915_GEM_HWS_SEQNO_ADDR ; + *cs++ = cmd; + *cs++ = offset; *cs++ = rq->fence.seqno; } - *cs++ =MI_FLUSH_DW ; - *cs++ =0 ; - *cs++ =0 ; - *cs++ =MI_USER_INTERRUPT ; - *cs++ =MI_NOOP ; rq->tail =intel_ring_offset (rq, cs);assert_ring_tail_valid (rq->ring, rq->tail);
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +5 -18
@@ -336,19 +336,6 @@ static inline u32 preempt_address(struct intel_engine_cs *engine) I915_GEM_HWS_PREEMPT_ADDR); } -static u32 hwsp_offset (const struct i915_request *rq) -{ -const struct intel_timeline_cacheline *cl; - -/* Before the request is executed, the timeline/cachline is fixed */ - - cl =rcu_dereference_protected (rq->hwsp_cacheline,1 ); -if (cl) -return cl->ggtt_offset; - -return rcu_dereference_protected (rq->timeline,1 )->ggtt_offset; -} -int gen8_emit_init_breadcrumb (struct i915_request *rq) {u32 *cs;
@@ -371,7 +358,7 @@ int gen8_emit_init_breadcrumb(struct i915_request *rq) *cs++ =MI_NOOP ; *cs++ =MI_STORE_DWORD_IMM_GEN4 |MI_USE_GGTT ; - *cs++ =hwsp_offset (rq); + *cs++ =__i915_request_hwsp_offset (rq); *cs++ =0 ; *cs++ = rq->fence.seqno -1 ;
@@ -504,7 +491,7 @@ static u32 *emit_xcs_breadcrumb(struct i915_request *rq, u32 *cs) {struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 );unsigned int flags =MI_FLUSH_DW_OP_STOREDW ; -u32 offset =hwsp_offset (rq); +u32 offset =__i915_request_hwsp_offset (rq);if (intel_timeline_is_relative (tl)) { offset =offset_in_page (offset);
@@ -526,7 +513,7 @@ u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs) {struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 );unsigned int flags =PIPE_CONTROL_FLUSH_ENABLE |PIPE_CONTROL_CS_STALL ; -u32 offset =hwsp_offset (rq); +u32 offset =__i915_request_hwsp_offset (rq);if (intel_timeline_is_relative (tl)) { offset =offset_in_page (offset);
@@ -551,7 +538,7 @@ u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs)u32 *gen11_emit_fini_breadcrumb_rcs (struct i915_request *rq,u32 *cs) {struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); -u32 offset =hwsp_offset (rq); +u32 offset =__i915_request_hwsp_offset (rq);unsigned int flags; flags = (PIPE_CONTROL_CS_STALL |
@@ -633,7 +620,7 @@ u32 *gen12_emit_fini_breadcrumb_xcs(struct i915_request *rq, u32 *cs)u32 *gen12_emit_fini_breadcrumb_rcs (struct i915_request *rq,u32 *cs) {struct intel_timeline *tl =rcu_dereference_protected (rq->timeline,1 ); -u32 offset =hwsp_offset (rq); +u32 offset =__i915_request_hwsp_offset (rq);unsigned int flags; flags = (PIPE_CONTROL_CS_STALL |
drivers/gpu/drm/i915/i915_request.h +13 -0
@@ -615,4 +615,17 @@ i915_request_active_timeline(const struct i915_request *rq) lockdep_is_held(&rq->engine->active.lock)); } +static inline u32 __i915_request_hwsp_offset (const struct i915_request *rq) +{ +const struct intel_timeline_cacheline *cl; + +/* Before the request is executed, the timeline/cachline is fixed */ + + cl =rcu_dereference_protected (rq->hwsp_cacheline,1 ); +if (cl) +return cl->ggtt_offset; + +return rcu_dereference_protected (rq->timeline,1 )->ggtt_offset; +} +#endif /* I915_REQUEST_H */
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 50/54 drm/i915/gt: Infrastructure for ring scheduling
In reply to Chris WilsonBuild a bare bones scheduler to sit on top the global legacy ringbuffer submission. This virtual execlists scheme should be applicable to all older platforms.
A key problem we have with the legacy ring buffer submission is that it only allows for FIFO queuing. All clients share the global request queue and must contend for its lock when submitting. As any client may need to wait for external events, all clients must then wait. However, if we stage each client into their own virtual ringbuffer with their own timelines, we can copy the client requests into the global ringbuffer only when they are ready, reordering the submission around stalls. Furthermore, the ability to reorder gives us rudimentarily priority sorting -- although without preemption support, once something is on the GPU it stays on the GPU, and so it is still possible for a hog to delay a high priority request (such as updating the display). However, it does means that in keeping a short submission queue, the high priority request will be next. This design resembles the old guc submission scheduler, for reordering requests onto a global workqueue.
The implementation uses the MI_USER_INTERRUPT at the end of every request to track completion, so is more interrupt happy than execlists [which has an interrupt for each context event, albeit two]. Our interrupts on these system are relatively heavy, and in the past we have been able to completely starve Sandybrige by the interrupt traffic. Our interrupt handlers are being much better (in part offloading the work to bottom halves leaving the interrupt itself only dealing with acking the registers) but we can still see the impact of starvation in the uneven submission latency on a saturated system.
Overall though, the short sumission queues and extra interrupts do not appear to be affecting throughput (+-10%, some tasks even improve to the reduced request overheads) and improve latency. [Which is a massive improvement since the introduction of Sandybridge!]
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gt/intel_engine.h | 1 + drivers/gpu/drm/i915/gt/intel_engine_types.h | 1 + .../gpu/drm/i915/gt/intel_ring_scheduler.c | 768 ++++++++++++++++++ .../gpu/drm/i915/gt/intel_ring_submission.c | 17 +- .../gpu/drm/i915/gt/intel_ring_submission.h | 17 + 6 files changed, 797 insertions(+), 8 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/intel_ring_scheduler.c create mode 100644 drivers/gpu/drm/i915/gt/intel_ring_submission.h
drivers/gpu/drm/i915/Makefile +1 -0
@@ -112,6 +112,7 @@ gt-y += \ gt/intel_renderstate.o \ gt/intel_reset.o \ gt/intel_ring.o \ + gt/intel_ring_scheduler.o \ gt/intel_ring_submission.o \ gt/intel_rps.o \ gt/intel_sseu.o \
drivers/gpu/drm/i915/gt/intel_engine.h +1 -0
@@ -191,6 +191,7 @@ void intel_engine_cleanup_common(struct intel_engine_cs *engine);int intel_engine_resume (struct intel_engine_cs *engine);int intel_ring_submission_setup (struct intel_engine_cs *engine); +int intel_ring_scheduler_setup (struct intel_engine_cs *engine);int intel_engine_stop_cs (struct intel_engine_cs *engine);void intel_engine_cancel_stop_cs (struct intel_engine_cs *engine);
drivers/gpu/drm/i915/gt/intel_engine_types.h +1 -0
@@ -319,6 +319,7 @@ struct intel_engine_cs {struct {struct intel_ring *ring;struct intel_timeline *timeline; +struct intel_context *context; } legacy;/*
drivers/gpu/drm/i915/gt/intel_ring_scheduler.c new file +768 -0
768 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_ring_submission.c +9 -8
@@ -37,6 +37,7 @@#include "intel_gt.h" #include "intel_reset.h" #include "intel_ring.h" +#include "intel_ring_submission.h" #include "shmem_utils.h" /* Rough estimate of the typical request size, performing a flush,
@@ -217,7 +218,7 @@ static void set_pp_dir(struct intel_engine_cs *engine) } } -static int xcs_resume (struct intel_engine_cs *engine) +int intel_ring_submission_resume (struct intel_engine_cs *engine) {struct drm_i915_private *dev_priv = engine->i915;struct intel_ring *ring = engine->legacy.ring;
@@ -329,7 +330,7 @@ static void sanitize_hwsp(struct intel_engine_cs *engine)intel_timeline_reset_seqno (tl); } -static void xcs_sanitize (struct intel_engine_cs *engine) +void intel_ring_submission_sanitize (struct intel_engine_cs *engine) {/* * Poison residual state on resume, in case the suspend didn't!
@@ -354,7 +355,7 @@ static void xcs_sanitize(struct intel_engine_cs *engine)clflush_cache_range (engine->status_page.addr,PAGE_SIZE ); } -static void reset_prepare (struct intel_engine_cs *engine) +void intel_ring_submission_reset_prepare (struct intel_engine_cs *engine) {struct intel_uncore *uncore = engine->uncore;const u32 base = engine->mmio_base;
@@ -463,7 +464,7 @@ static void reset_rewind(struct intel_engine_cs *engine, bool stalled)spin_unlock_irqrestore (&engine->active.lock, flags); } -static void reset_finish (struct intel_engine_cs *engine) +void intel_ring_submission_reset_finish (struct intel_engine_cs *engine) { }
@@ -1104,13 +1105,13 @@ static void setup_common(struct intel_engine_cs *engine)setup_irq (engine); - engine->resume = xcs_resume; - engine->sanitize = xcs_sanitize; + engine->resume = intel_ring_submission_resume; + engine->sanitize = intel_ring_submission_sanitize; - engine->reset.prepare = reset_prepare; + engine->reset.prepare = intel_ring_submission_reset_prepare; engine->reset.rewind = reset_rewind; engine->reset.cancel = reset_cancel; - engine->reset.finish = reset_finish; + engine->reset.finish = intel_ring_submission_reset_finish; engine->cops = &ring_context_ops; engine->request_alloc = ring_request_alloc;
drivers/gpu/drm/i915/gt/intel_ring_submission.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2020 Intel Corporation +*/ + +#ifndef __INTEL_RING_SUBMISSION_H__ +#define __INTEL_RING_SUBMISSION_H__ + +struct intel_engine_cs ; + +void intel_ring_submission_reset_prepare (struct intel_engine_cs *engine); +void intel_ring_submission_reset_finish (struct intel_engine_cs *engine); + +int intel_ring_submission_resume (struct intel_engine_cs *engine); +void intel_ring_submission_sanitize (struct intel_engine_cs *engine); + +#endif /* __INTEL_RING_SUBMISSION_H__ */
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 51/54 drm/i915/gt: Enable busy-stats for ring-scheduler
In reply to Chris WilsonCouple up the context in/out accounting to record how long each engine is busy handling requests. This is exposed to userspace for more accurate measurements, and also enables our soft-rps timer.
--- drivers/gpu/drm/i915/gt/intel_ring_scheduler.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/gt/intel_ring_scheduler.c +6 -0
@@ -11,6 +11,7 @@#include "intel_breadcrumbs.h" #include "intel_context.h" #include "intel_engine_pm.h" +#include "intel_engine_stats.h" #include "intel_gt.h" #include "intel_gt_pm.h" #include "intel_gt_requests.h"
@@ -63,6 +64,8 @@ static struct intel_engine_cs *__schedule_in(struct i915_request *rq)if (engine->fw_domain && !engine->fw_active++)intel_uncore_forcewake_get (engine->uncore, engine->fw_domain); +intel_engine_context_in (engine); +CE_TRACE (ce,"schedule-in\n" );return engine;
@@ -96,6 +99,8 @@ static void __schedule_out(struct i915_request *rq)else i915_request_update_deadline (list_next_entry (rq, link)); +intel_engine_context_out (engine); +if (engine->fw_domain && !--engine->fw_active)intel_uncore_forcewake_put (engine->uncore, engine->fw_domain);intel_gt_pm_put_async (engine->gt);
@@ -755,6 +760,7 @@ int intel_ring_scheduler_setup(struct intel_engine_cs *engine) engine->flags |=I915_ENGINE_HAS_SCHEDULER ; engine->flags |=I915_ENGINE_NEEDS_BREADCRUMB_TASKLET ; + engine->flags |=I915_ENGINE_SUPPORTS_STATS ;/* Finally, take ownership and responsibility for cleanup! */ engine->release = ring_release;
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 52/54 drm/i915/gt: Implement ring scheduler for gen6/7
In reply to Chris WilsonA key prolem with legacy ring buffer submission is that it is an inheret FIFO queue across all clients; if one blocks, they all block. A scheduler allows us to avoid that limitation, and ensures that all clients can submit in parallel, removing the resource contention of the global ringbuffer.
Having built the ring scheduler infrastructure over top of the global ringbuffer submission, we now need to provide the HW knowledge required to build command packets and implement context switching.
--- .../gpu/drm/i915/gt/intel_ring_scheduler.c | 447 +++++++++++++++++- drivers/gpu/drm/i915/i915_reg.h | 10 + 2 files changed, 454 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gt/intel_ring_scheduler.c +444 -3
@@ -7,6 +7,10 @@#include <drm/i915_drm.h> +#include "gen2_engine_cs.h" +#include "gen6_engine_cs.h" +#include "gen6_ppgtt.h" +#include "gen7_renderclear.h" #include "i915_drv.h" #include "intel_breadcrumbs.h" #include "intel_context.h"
@@ -164,8 +168,263 @@ static void ring_copy(struct intel_ring *dst,memcpy (out, src->vaddr + start, end - start); } +static void mi_set_context (struct intel_ring *ring, +struct intel_engine_cs *engine, +struct intel_context *ce, +u32 flags) +{ +struct drm_i915_private *i915 = engine->i915; +enum intel_engine_id id; +const int num_engines = +IS_HASWELL (i915) ? engine->gt->info.num_engines -1 :0 ; +int len; +u32 *cs; + + len =4 ; +if (IS_GEN (i915,7 )) + len +=2 + (num_engines ?4 * num_engines +6 :0 ); +else if (IS_GEN (i915,5 )) + len +=2 ; + + cs =ring_map_dw (ring, len); + +/* WaProgramMiArbOnOffAroundMiSetContext:ivb,vlv,hsw,bdw,chv */ +if (IS_GEN (i915,7 )) { + *cs++ =MI_ARB_ON_OFF |MI_ARB_DISABLE ; +if (num_engines) { +struct intel_engine_cs *signaller; + + *cs++ =MI_LOAD_REGISTER_IMM (num_engines); +for_each_engine (signaller, engine->gt, id) { +if (signaller == engine) +continue ; + + *cs++ =i915_mmio_reg_offset ( +RING_PSMI_CTL (signaller->mmio_base)); + *cs++ =_MASKED_BIT_ENABLE ( +GEN6_PSMI_SLEEP_MSG_DISABLE ); + } + } + }else if (IS_GEN (i915,5 )) { +/* +* This w/a is only listed for pre-production ilk a/b steppings, +* but is also mentioned for programming the powerctx. To be +* safe, just apply the workaround; we do not use SyncFlush so +* this should never take effect and so be a no-op! +*/ + *cs++ =MI_SUSPEND_FLUSH |MI_SUSPEND_FLUSH_EN ; + } + + *cs++ =MI_NOOP ; + *cs++ =MI_SET_CONTEXT ; + *cs++ =i915_ggtt_offset (ce->state) | flags; +/* +* w/a: MI_SET_CONTEXT must always be followed by MI_NOOP +* WaMiSetContext_Hang:snb,ivb,vlv +*/ + *cs++ =MI_NOOP ; + +if (IS_GEN (i915,7 )) { +if (num_engines) { +struct intel_engine_cs *signaller; +i915_reg_t last_reg = {};/* keep gcc quiet */ + + *cs++ =MI_LOAD_REGISTER_IMM (num_engines); +for_each_engine (signaller, engine->gt, id) { +if (signaller == engine) +continue ; + + last_reg =RING_PSMI_CTL (signaller->mmio_base); + *cs++ =i915_mmio_reg_offset (last_reg); + *cs++ =_MASKED_BIT_DISABLE ( +GEN6_PSMI_SLEEP_MSG_DISABLE ); + } + +/* Insert a delay before the next switch! */ + *cs++ =MI_STORE_REGISTER_MEM |MI_SRM_LRM_GLOBAL_GTT ; + *cs++ =i915_mmio_reg_offset (last_reg); + *cs++ =intel_gt_scratch_offset (engine->gt, +INTEL_GT_SCRATCH_FIELD_DEFAULT ); + *cs++ =MI_NOOP ; + } + *cs++ =MI_ARB_ON_OFF |MI_ARB_ENABLE ; + }else if (IS_GEN (i915,5 )) { + *cs++ =MI_SUSPEND_FLUSH ; + } +} + +static struct i915_address_space *vm_alias (struct i915_address_space *vm) +{ +if (i915_is_ggtt (vm)) + vm = &i915_vm_to_ggtt (vm)->alias->vm; + +return vm; +} + +static u32 pp_dir (const struct i915_ppgtt *ppgtt) +{ + return container_of(ppgtt, const struct gen6_ppgtt, base)->pp_dir; +} + +static void load_pd_dir (struct intel_ring *ring, +struct intel_engine_cs *engine, +const struct i915_ppgtt *ppgtt) +{ +u32 *cs =ring_map_dw (ring,10 ); + + *cs++ =MI_LOAD_REGISTER_IMM (1 ); + *cs++ =i915_mmio_reg_offset (RING_PP_DIR_DCLV (engine->mmio_base)); + *cs++ =PP_DIR_DCLV_2G ; + + *cs++ =MI_LOAD_REGISTER_IMM (1 ); + *cs++ =i915_mmio_reg_offset (RING_PP_DIR_BASE (engine->mmio_base)); + *cs++ =pp_dir (ppgtt); + +/* Stall until the page table load is complete? */ + *cs++ =MI_STORE_REGISTER_MEM |MI_SRM_LRM_GLOBAL_GTT ; + *cs++ =i915_mmio_reg_offset (RING_PP_DIR_BASE (engine->mmio_base)); + *cs++ =intel_gt_scratch_offset (engine->gt, +INTEL_GT_SCRATCH_FIELD_DEFAULT ); + *cs++ =MI_NOOP ; +} + +static struct i915_address_space *current_vm (struct intel_engine_cs *engine) +{ +struct intel_context *old = engine->legacy.context; + +return old ?vm_alias (old->vm) :NULL ; +} + +static void gen6_emit_invalidate_rcs (struct intel_ring *ring, +struct intel_engine_cs *engine) +{ +u32 addr, flags; +u32 *cs; + + addr =intel_gt_scratch_offset (engine->gt, +INTEL_GT_SCRATCH_FIELD_RENDER_FLUSH ); + + flags =PIPE_CONTROL_QW_WRITE |PIPE_CONTROL_CS_STALL ; + flags |=PIPE_CONTROL_TLB_INVALIDATE ; + +if (INTEL_GEN (engine->i915) >=7 ) + flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; +else + addr |=PIPE_CONTROL_GLOBAL_GTT ; + + cs =ring_map_dw (ring,4 ); + *cs++ =GFX_OP_PIPE_CONTROL (4 ); + *cs++ = flags; + *cs++ = addr; + *cs++ =0 ; +} + +static struct i915_address_space * +clear_residuals (struct intel_ring *ring,struct intel_engine_cs *engine) +{ +struct intel_context *ce = engine->kernel_context; +struct i915_address_space *vm =vm_alias (engine->gt->vm); +u32 flags; + +if (vm !=current_vm (engine)) +load_pd_dir (ring, engine,i915_vm_to_ppgtt (vm)); + +if (ce->state) +mi_set_context (ring, engine, ce, +MI_MM_SPACE_GTT |MI_RESTORE_INHIBIT ); + +if (IS_HASWELL (engine->i915)) + flags =MI_BATCH_PPGTT_HSW |MI_BATCH_NON_SECURE_HSW ; +else + flags =MI_BATCH_NON_SECURE_I965 ; + +__gen6_emit_bb_start (ring_map_dw (ring,2 ), + engine->wa_ctx.vma->node.start, flags); + +return vm; +} + +static void remap_l3_slice (struct intel_ring *ring, +struct intel_engine_cs *engine, +int slice) +{ +u32 *cs, *remap_info = engine->i915->l3_parity.remap_info[slice]; +int i; + +if (!remap_info) +return ; + +/* +* Note: We do not worry about the concurrent register cacheline hang +* here because no other code should access these registers other than +* at initialization time. +*/ + cs =ring_map_dw (ring,GEN7_L3LOG_SIZE /4 *2 +2 ); + *cs++ =MI_LOAD_REGISTER_IMM (GEN7_L3LOG_SIZE /4 ); +for (i =0 ; i <GEN7_L3LOG_SIZE /4 ; i++) { + *cs++ =i915_mmio_reg_offset (GEN7_L3LOG (slice, i)); + *cs++ = remap_info[i]; + } + *cs++ =MI_NOOP ; +} + +static void remap_l3 (struct intel_ring *ring, +struct intel_engine_cs *engine, +struct intel_context *ce) +{ +struct i915_gem_context *ctx = +rcu_dereference_protected (ce->gem_context, true); +int bit, idx =-1 ; + +if (!ctx || !ctx->remap_slice) +return ; + +do { + bit =ffs (ctx->remap_slice); +remap_l3_slice (ring, engine, idx += bit); + }while (ctx->remap_slice >>= bit); +} +static void switch_context (struct intel_ring *ring,struct i915_request *rq) { +struct intel_engine_cs *engine = rq->engine; +struct i915_address_space *cvm =current_vm (engine); +struct intel_context *ce = rq->context; +struct i915_address_space *vm; + +if (engine->wa_ctx.vma && ce != engine->kernel_context) { +if (engine->wa_ctx.vma->private != ce) { + cvm =clear_residuals (ring, engine); +intel_context_put (engine->wa_ctx.vma->private); + engine->wa_ctx.vma->private =intel_context_get (ce); + } + } + + vm =vm_alias (ce->vm); +if (vm != cvm) +load_pd_dir (ring, engine,i915_vm_to_ppgtt (vm)); + +if (ce->state) { +u32 flags; + +GEM_BUG_ON (engine->id !=RCS0 ); + +/* For resource streamer on HSW+ and power context elsewhere */ +BUILD_BUG_ON (HSW_MI_RS_SAVE_STATE_EN !=MI_SAVE_EXT_STATE_EN ); +BUILD_BUG_ON (HSW_MI_RS_RESTORE_STATE_EN !=MI_RESTORE_EXT_STATE_EN ); + + flags =MI_SAVE_EXT_STATE_EN |MI_MM_SPACE_GTT ; +if (test_bit (CONTEXT_VALID_BIT , &ce->flags)) { +gen6_emit_invalidate_rcs (ring, engine); + flags |=MI_RESTORE_EXT_STATE_EN ; + }else { + flags |=MI_RESTORE_INHIBIT ; + } + +mi_set_context (ring, engine, ce, flags); + } + +remap_l3 (ring, engine, ce); }static struct i915_request *ring_submit (struct i915_request *rq)
@@ -205,6 +464,36 @@ static inline void write_tail(const struct intel_engine_cs *engine)ENGINE_WRITE (engine,RING_TAIL , engine->legacy.ring->tail); } +static void wa_write_tail (const struct intel_engine_cs *engine) +{ +const i915_reg_t psmi =RING_PSMI_CTL (engine->mmio_base); +struct intel_uncore *uncore = engine->uncore; + +intel_uncore_write_fw (uncore, psmi, +_MASKED_BIT_ENABLE (PSMI_SLEEP_MSG_DISABLE )); + +/* Clear the context id. Here be magic! */ +intel_uncore_write64_fw (uncore,RING_RNCID (engine->mmio_base),0x0 ); + +/* Wait for the ring not to be idle, i.e. for it to wake up. */ +if (__intel_wait_for_register_fw (uncore, psmi, +PSMI_SLEEP_INDICATOR ,0 , +1000 ,0 ,NULL )) +drm_err (&uncore->i915->drm, +"timed out waiting for %s to wake up\n" , + engine->name); + +/* Now that the ring is fully powered up, update the tail */ +write_tail (engine); + +/* +* Let the ring send IDLE messages to the GT again, +* and so let it sleep to conserve power when idle. +*/ +intel_uncore_write_fw (uncore, psmi, +_MASKED_BIT_DISABLE (PSMI_SLEEP_MSG_DISABLE )); +} +static void dequeue (struct intel_engine_cs *engine) {struct intel_engine_execlists *const el = &engine->execlists;
@@ -252,7 +541,10 @@ static void dequeue(struct intel_engine_cs *engine)schedule_in (*port);wmb ();/* paranoid flush of WCB before RING_TAIL write */ -write_tail (engine); +if (!engine->fw_active) +write_tail (engine); +else +wa_write_tail (engine);WRITE_ONCE (el->active, el->inflight);GEM_BUG_ON (!*el->active);
@@ -442,6 +734,33 @@ static void submission_unpark(struct intel_engine_cs *engine)intel_breadcrumbs_pin_irq (engine->breadcrumbs); } +static int gen6_emit_init_breadcrumb (struct i915_request *rq) +{ +struct intel_timeline *tl =i915_request_timeline (rq); +u32 *cs; + +GEM_BUG_ON (i915_request_has_initial_breadcrumb (rq)); +if (!intel_timeline_has_initial_breadcrumb (tl)) +return 0 ; + + cs =intel_ring_begin (rq,4 ); +if (IS_ERR (cs)) +return PTR_ERR (cs); + + *cs++ =MI_STORE_DWORD_IMM_GEN4 |MI_USE_GGTT ; + *cs++ =0 ; + *cs++ =__i915_request_hwsp_offset (rq); + *cs++ = rq->fence.seqno -1 ; + +intel_ring_advance (rq, cs); + +/* Record the updated position of the request's payload */ + rq->infix =intel_ring_offset (rq, cs); + +__set_bit (I915_FENCE_FLAG_INITIAL_BREADCRUMB , &rq->fence.flags); +return 0 ; +} +static void ring_context_destroy (struct kref *ref) {struct intel_context *ce =container_of (ref,typeof (*ce), ref);
@@ -586,7 +905,14 @@ static int ring_context_pre_pin(struct intel_context *ce,struct i915_gem_ww_ctx *ww, void **unused) { -return 0 ; + struct i915_address_space *vm; +int err =0 ; + + vm =vm_alias (ce->vm); +if (vm) + err =gen6_ppgtt_pin (i915_vm_to_ppgtt ((vm)), ww); + +return err; }static int ring_context_pin (struct intel_context *ce,void *unused)
@@ -594,12 +920,22 @@ static int ring_context_pin(struct intel_context *ce, void *unused)return 0 ; } +static void __context_unpin_ppgtt (struct intel_context *ce) +{ +struct i915_address_space *vm; + + vm =vm_alias (ce->vm); +if (vm) +gen6_ppgtt_unpin (i915_vm_to_ppgtt (vm)); +} +static void ring_context_unpin (struct intel_context *ce) { }static void ring_context_post_unpin (struct intel_context *ce) { +__context_unpin_ppgtt (ce); }static void ring_context_reset (struct intel_context *ce)
@@ -657,12 +993,19 @@ static void ring_release(struct intel_engine_cs *engine)set_current_context (&engine->legacy.context,NULL ); +if (engine->wa_ctx.vma) { +intel_context_put (engine->wa_ctx.vma->private); +i915_vma_unpin_and_release (&engine->wa_ctx.vma,0 ); + } +intel_ring_unpin (engine->legacy.ring);intel_ring_put (engine->legacy.ring); }static void setup_irq (struct intel_engine_cs *engine) { + engine->irq_enable = gen6_irq_enable; + engine->irq_disable = gen6_irq_disable; }static void setup_common (struct intel_engine_cs *engine)
@@ -671,7 +1014,7 @@ static void setup_common(struct intel_engine_cs *engine)/* gen8+ are only supported with execlists */ GEM_BUG_ON (INTEL_GEN (i915) >=8 ); -GEM_BUG_ON (INTEL_GEN (i915) <8 ); +GEM_BUG_ON (INTEL_GEN (i915) <6 );setup_irq (engine);
@@ -689,24 +1032,62 @@ static void setup_common(struct intel_engine_cs *engine) engine->cops = &ring_context_ops; engine->request_alloc = ring_request_alloc; + engine->emit_init_breadcrumb = gen6_emit_init_breadcrumb; +if (INTEL_GEN (i915) >=7 ) + engine->emit_fini_breadcrumb = gen7_emit_breadcrumb_xcs; +else if (INTEL_GEN (i915) >=6 ) + engine->emit_fini_breadcrumb = gen6_emit_breadcrumb_xcs; +else + engine->emit_fini_breadcrumb = gen3_emit_breadcrumb; + engine->set_default_submission = set_default_submission; + + engine->emit_bb_start = gen6_emit_bb_start; }static void setup_rcs (struct intel_engine_cs *engine) { +struct drm_i915_private *i915 = engine->i915; + +if (HAS_L3_DPF (i915)) + engine->irq_keep_mask =GT_RENDER_L3_PARITY_ERROR_INTERRUPT ; + + engine->irq_enable_mask =GT_RENDER_USER_INTERRUPT ; + +if (INTEL_GEN (i915) >=7 ) { + engine->emit_flush = gen7_emit_flush_rcs; + engine->emit_fini_breadcrumb = gen7_emit_breadcrumb_rcs; +if (IS_HASWELL (i915)) + engine->emit_bb_start = hsw_emit_bb_start; + }else { + engine->emit_flush = gen6_emit_flush_rcs; + engine->emit_fini_breadcrumb = gen6_emit_breadcrumb_rcs; + } }static void setup_vcs (struct intel_engine_cs *engine) { + engine->emit_flush = gen6_emit_flush_vcs; + engine->irq_enable_mask =GT_BSD_USER_INTERRUPT ; + +if (IS_GEN (engine->i915,6 )) + engine->fw_domain =FORCEWAKE_ALL ; }static void setup_bcs (struct intel_engine_cs *engine) { + engine->emit_flush = gen6_emit_flush_xcs; + engine->irq_enable_mask =GT_BLT_USER_INTERRUPT ; }static void setup_vecs (struct intel_engine_cs *engine) {GEM_BUG_ON (!IS_HASWELL (engine->i915)); + + engine->emit_flush = gen6_emit_flush_xcs; + engine->irq_enable_mask =PM_VEBOX_USER_INTERRUPT ; + engine->irq_enable = hsw_irq_enable_vecs; + engine->irq_disable = hsw_irq_disable_vecs; }static unsigned int global_ring_size (void )
@@ -715,6 +1096,58 @@ static unsigned int global_ring_size(void)return roundup_pow_of_two (EXECLIST_MAX_PORTS *SZ_16K +SZ_4K ); } +static int gen7_ctx_switch_bb_init (struct intel_engine_cs *engine) +{ +struct drm_i915_gem_object *obj; +struct i915_vma *vma; +int size; +int err; + + size =gen7_setup_clear_gpr_bb (engine,NULL /* probe size */ ); +if (size <=0 ) +return size; + + size =ALIGN (size,PAGE_SIZE ); + obj =i915_gem_object_create_internal (engine->i915, size); +if (IS_ERR (obj)) +return PTR_ERR (obj); + + vma =i915_vma_instance (obj, engine->gt->vm,NULL ); +if (IS_ERR (vma)) { + err =PTR_ERR (vma); + goto err_obj; + } + + vma->private =intel_context_create (engine);/* dummy residuals */ +if (IS_ERR (vma->private)) { + err =PTR_ERR (vma->private); + goto err_obj; + } + + err =i915_vma_pin (vma,0 ,0 ,PIN_USER |PIN_HIGH ); +if (err) + goto err_private; + + err =i915_vma_sync (vma); +if (err) + goto err_unpin; + + size =gen7_setup_clear_gpr_bb (engine, vma); +if (err) + goto err_unpin; + + engine->wa_ctx.vma = vma; +return 0 ; + +err_unpin: +i915_vma_unpin (vma); +err_private: +intel_context_put (vma->private); +err_obj: +i915_gem_object_put (obj); +return err; +} +int intel_ring_scheduler_setup (struct intel_engine_cs *engine) {struct intel_ring *ring;
@@ -758,6 +1191,12 @@ int intel_ring_scheduler_setup(struct intel_engine_cs *engine)GEM_BUG_ON (engine->legacy.ring); engine->legacy.ring = ring; +if (IS_HASWELL (engine->i915) && engine->class ==RENDER_CLASS ) { + err =gen7_ctx_switch_bb_init (engine); +if (err) + goto err_ring_unpin; + } + engine->flags |=I915_ENGINE_HAS_SCHEDULER ; engine->flags |=I915_ENGINE_NEEDS_BREADCRUMB_TASKLET ; engine->flags |=I915_ENGINE_SUPPORTS_STATS ;
@@ -766,6 +1205,8 @@ int intel_ring_scheduler_setup(struct intel_engine_cs *engine) engine->release = ring_release;return 0 ; +err_ring_unpin: +intel_ring_unpin (ring); err_ring:intel_ring_put (ring); err:
drivers/gpu/drm/i915/i915_reg.h +10 -0
@@ -2529,7 +2529,16 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define GEN6_VERSYNC (RING_SYNC_1(VEBOX_RING_BASE))#define GEN6_VEVSYNC (RING_SYNC_2(VEBOX_RING_BASE))#define GEN6_NOSYNC INVALID_MMIO_REG +#define RING_PSMI_CTL (base) _MMIO((base) + 0x50) +#define PSMI_SLEEP_MSG_DISABLE REG_BIT(0) +#define PSMI_SLEEP_FLUSH_DISABLE REG_BIT(2) +#define PSMI_SLEEP_INDICATOR REG_BIT(3) +#define PSMI_GO_INDICATOR REG_BIT(4) +#define GEN12_PSMI_WAIT_FOR_EVENT_POWER_DOWN_DISABLE REG_BIT(7) +#define GEN8_PSMI_FF_DOP_CLOCK_GATE_DISABLE REG_BIT(10) +#define GEN8_PSMI_RC_SEMA_IDLE_MSG_DISABLE REG_BIT(12) +#define RING_MAX_IDLE (base) _MMIO((base) + 0x54)#define RING_HWS_PGA (base) _MMIO((base) + 0x80)#define RING_ID (base) _MMIO((base) + 0x8c)
@@ -2539,6 +2548,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define RESET_CTL_READY_TO_RESET REG_BIT(1)#define RESET_CTL_REQUEST_RESET REG_BIT(0) +#define RING_RNCID (base) _MMIO((base) + 0x198)#define RING_SEMA_WAIT_POLL (base) _MMIO((base) + 0x24c)#define HSW_GTT_CACHE_EN _MMIO(0x4024)
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 53/54 drm/i915/gt: Enable ring scheduling for gen6/7
In reply to Chris WilsonSwitch over from FIFO global submission to the priority-sorted topographical scheduler. At the cost of more busy work on the CPU to keep the GPU supplied with the next packet of requests, this allows us to reorder requests around submission stalls.
This also enables the timer based RPS, with the exception of Valleyview whose PCU doesn't take kindly to our interference.
--- drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c | 2 +- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 ++ drivers/gpu/drm/i915/gt/intel_rps.c | 6 ++---- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c +1 -1
@@ -94,7 +94,7 @@ static int live_nop_switch(void *arg) rq =i915_request_get (this);i915_request_add (this); } -if (i915_request_wait (rq,0 ,HZ /5 ) <0 ) { +if (i915_request_wait (rq,0 ,HZ ) <0 ) {pr_err ("Failed to populated %d contexts\n" , nctx);intel_gt_set_wedged (&i915->gt);i915_request_put (rq);
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -0
@@ -881,6 +881,8 @@ int intel_engines_init(struct intel_gt *gt)if (HAS_EXECLISTS (gt->i915)) setup = intel_execlists_submission_setup; +else if (INTEL_GEN (gt->i915) >=6 ) + setup = intel_ring_scheduler_setup;else setup = intel_ring_submission_setup;
drivers/gpu/drm/i915/gt/intel_rps.c +2 -4
@@ -1078,9 +1078,7 @@ static bool gen6_rps_enable(struct intel_rps *rps)intel_uncore_write_fw (uncore,GEN6_RP_DOWN_TIMEOUT ,50000 );intel_uncore_write_fw (uncore,GEN6_RP_IDLE_HYSTERSIS ,10 ); - rps->pm_events = (GEN6_PM_RP_UP_THRESHOLD | -GEN6_PM_RP_DOWN_THRESHOLD | -GEN6_PM_RP_DOWN_TIMEOUT ); + rps->pm_events =GEN6_PM_RP_UP_THRESHOLD |GEN6_PM_RP_DOWN_THRESHOLD ;return rps_reset (rps); }
@@ -1388,7 +1386,7 @@ void intel_rps_enable(struct intel_rps *rps)GEM_BUG_ON (rps->efficient_freq < rps->min_freq);GEM_BUG_ON (rps->efficient_freq > rps->max_freq); -if (has_busy_stats (rps)) +if (has_busy_stats (rps) && !IS_VALLEYVIEW (i915))intel_rps_set_timer (rps);else if (INTEL_GEN (i915) >=6 )intel_rps_set_interrupts (rps);
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 54/54 drm/i915/gt: Limit C-states while waiting for requests
In reply to Chris WilsonAllow the sysadmin to specify whether we should prevent the CPU from entering higher C-states while waiting for the CPU, in order to reduce the latency of request completions and so speed up client continuations.
The target dma latency can be adjusted per-engine using,
/sys/class/drm/card?/engine/*/dma_latency_ns
(For waiting on a virtual engine, the underlying physical engine is used for the wait once the request is active, so set all the physical engines in the virtual set to the same target dma latency.)
Note that in most cases, the ratelimiting step does not appear to the interrupt latency per se, but secondary effects of avoiding additional memory latencies while active.
--- drivers/gpu/drm/i915/Kconfig.profile | 14 ++++++ drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 45 +++++++++++++++++++ .../gpu/drm/i915/gt/intel_breadcrumbs_types.h | 7 +++ drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 + drivers/gpu/drm/i915/gt/intel_engine_types.h | 2 + drivers/gpu/drm/i915/gt/sysfs_engines.c | 43 ++++++++++++++++++ 6 files changed, 113 insertions(+)
drivers/gpu/drm/i915/Kconfig.profile +14 -0
@@ -24,6 +24,20 @@ config DRM_I915_USERFAULT_AUTOSUSPEND May be 0 to disable the extra delay and solely use the device level runtime pm autosuspend delay tunable. +config DRM_I915_DMA_LATENCY + int "Target CPU-DMA latency while waiting on active requests (ns)" + default -1 # nanoseconds + help + Specify a target latency for DMA wakeup, see /dev/cpu_dma_latency, + used while the CPU is waiting for GPU results. + + This is adjustable via + /sys/class/drm/card?/engine/*/dma_latency_ns + + May be -1 to prevent specifying a target wakeup and let the CPU + enter powersaving while waiting. Conversely, 0 may be used to + prevent the CPU from entering any C-states while waiting. + config DRM_I915_HEARTBEAT_INTERVAL int "Interval between heartbeat pulses (ms)" default 2500 # milliseconds
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c +45 -0
76 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_breadcrumbs_types.h +7 -0
@@ -8,6 +8,7 @@#include <linux/irq_work.h> #include <linux/list.h> +#include <linux/pm_qos.h> #include <linux/spinlock.h> #include <linux/types.h>
@@ -43,6 +44,12 @@ struct intel_breadcrumbs {/* Not all breadcrumbs are attached to physical HW */ struct intel_engine_cs *irq_engine; + +struct intel_breadcrumbs_dma_qos { +struct pm_qos_request req; +struct work_struct update; +s32 latency; + } qos; };#endif /* __INTEL_BREADCRUMBS_TYPES__ */
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -0
@@ -314,6 +314,8 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id) engine->instance = info->instance;__sprint_engine_name (engine); + engine->props.dma_latency_ns = +CONFIG_DRM_I915_DMA_LATENCY ; engine->props.heartbeat_interval_ms =CONFIG_DRM_I915_HEARTBEAT_INTERVAL ; engine->props.max_busywait_duration_ns =
drivers/gpu/drm/i915/gt/intel_engine_types.h +2 -0
@@ -506,6 +506,8 @@ struct intel_engine_cs {unsigned long preempt_timeout_ms;unsigned long stop_timeout_ms;unsigned long timeslice_duration_ms; + +s32 dma_latency_ns; } props, defaults; };
drivers/gpu/drm/i915/gt/sysfs_engines.c +43 -0
61 lines not on this page · raw message
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/54] drm/i915/gt: Cancel submitted requests upon context reset
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [01/54] drm/i915/gt: Cancel submitted requests upon context reset
URL : https://patchwork.freedesktop.org/series/85275/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 0b9748fc4fd3 drm/i915/gt: Cancel submitted requests upon context reset 69e67c0b5c51 drm/i915/gt: Pull context closure check from request submit to schedule-in 9f63c2557add drm/i915/gem: Peek at the inflight context 5eb79ce389c1 drm/i915: Mark up protected uses of 'i915_request_completed' 34004d143982 drm/i915: Drop i915_request.lock serialisation around await_start d1078b6751d7 drm/i915: Drop i915_request.lock requirement for intel_rps_boost() 279d9aafdb7b drm/i915/gem: Reduce ctx->engine_mutex for reading the clone source 84fade942b88 drm/i915/gem: Reduce ctx->engines_mutex for get_engines() ce5d84639d7c drm/i915: Reduce test_and_set_bit to set_bit in i915_request_submit() 54b08969c728 drm/i915/gt: Drop atomic for engine->fw_active tracking cb7601bcf0b2 drm/i915/gt: Extract busy-stats for ring-scheduler -:12: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #12: new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 95 lines checkedee4ba8911307 drm/i915/gt: Convert stats.active to plain unsigned intd5cc1786e885 drm/i915/gt: Do not suspend bonded requests if one hangsd654d951ab15 drm/i915/gt: Remove timeslice suppression157c2def0cb3 drm/i915/gt: Skip over completed active execlists, again
-:10: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #10:
Referenecs: 35f3fd8182ba ("drm/i915/execlists: Workaround switching back to a completed context")
-:10: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 35f3fd8182ba ("drm/i915/execlists: Workaround switching back to a completed context")' #10:
Referenecs: 35f3fd8182ba ("drm/i915/execlists: Workaround switching back to a completed context")
-:11: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 8ab3a3812aa9 ("drm/i915/gt: Incrementally check for rewinding")' #11:
References: 8ab3a3812aa9 ("drm/i915/gt: Incrementally check for rewinding")
total: 2 errors, 1 warnings, 0 checks, 71 lines checked34ee71c219d7 drm/i915: Strip out internal prioritiesee184d638694 drm/i915: Remove I915_USER_PRIORITY_SHIFT08990ad0d442 drm/i915: Replace engine->schedule() with a known request operation 478814419b5e drm/i915: Teach the i915_dependency to use a double-lock 3d95d5214a1d drm/i915: Restructure priority inheritancea3467b661390 drm/i915/selftests: Measure set-priority duration
-:52: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #52:
new file mode 100644
-:434: WARNING:LINE_SPACING: Missing a blank line after declarations #434: FILE: drivers/gpu/drm/i915/selftests/i915_scheduler.c:378:
+ struct igt_spinner spin;
+ I915_RND_STATE(prng);
total: 0 errors, 2 warnings, 0 checks, 702 lines checkedfb9f48e3fe22 drm/i915/selftests: Exercise priority inheritance around an engine loop 4bea1b5f3437 drm/i915: Improve DFS for priority inheritance edaf360fa696 drm/i915: Extract request submission from execlists 325e252e7bac drm/i915: Extract request rewinding from execlists 1c3bd294373d drm/i915: Extract request suspension from the execlists backend 6aca7a704425 drm/i915: Extract the ability to defer and rerun a request later ad32d79a370d drm/i915: Fix the iterative dfs for defering requests 4f299a9c3688 drm/i915: Move common active lists from engine to i915_scheduler -:198: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment #198: FILE: drivers/gpu/drm/i915/i915_scheduler_types.h:84:
+ spinlock_t lock;
total: 0 errors, 0 warnings, 1 checks, 157 lines checked718db6262de1 drm/i915: Move scheduler queue152ed7b45e2e drm/i915: Move tasklet from execlists to sched 082e8ae14675 drm/i915: Replace priolist rbtree with a skiplist
-:305: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'root' - possible side-effects? #305: FILE: drivers/gpu/drm/i915/i915_priolist_types.h:61:
+#define i915_priolist_is_empty(root) (priolist_first(root) == &(root)->sentinel)
-:307: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'p' - possible side-effects? #307: FILE: drivers/gpu/drm/i915/i915_priolist_types.h:63:
+#define for_each_priolist(p, root) \
+ for ((p) = priolist_first(root); \
+ (p) != &(root)->sentinel; \
+ (p) = (p)->next[0])
-:307: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'root' - possible side-effects? #307: FILE: drivers/gpu/drm/i915/i915_priolist_types.h:63:
+#define for_each_priolist(p, root) \
+ for ((p) = priolist_first(root); \
+ (p) != &(root)->sentinel; \
+ (p) = (p)->next[0])
total: 0 errors, 0 warnings, 3 checks, 675 lines checked 91c1ecade9a3 drm/i915: Wrap cmpxchg64 with try_cmpxchg64() helper -:23: CHECK:MACRO_ARG_REUSE: Macro argument reuse '_ptr' - possible side-effects? #23: FILE: drivers/gpu/drm/i915/i915_utils.h:463:
+#define try_cmpxchg64(_ptr, _pold, _new) \
+({ \
+ __typeof__(_ptr) _old = (__typeof__(_ptr))(_pold); \
+ __typeof__(*(_ptr)) __old = *_old; \
+ __typeof__(*(_ptr)) __cur = cmpxchg64(_ptr, __old, _new); \
+ bool success = __cur == __old; \
+ if (unlikely(!success)) \
+ *_old = __cur; \
+ likely(success); \
+})
-:40: CHECK:MACRO_ARG_REUSE: Macro argument reuse '_ptr' - possible side-effects? #40: FILE: drivers/gpu/drm/i915/i915_utils.h:480:
+#define xchg64(_ptr, _new) \
+({ \
+ __typeof__(_ptr) __ptr = (_ptr); \
+ __typeof__(*(_ptr)) __old = *__ptr; \
+ while (!try_cmpxchg64(__ptr, &__old, (_new))) \
+ ; \
+ __old; \
+})
total: 0 errors, 0 warnings, 2 checks, 36 lines checked3e371540df63 drm/i915: Fair low-latency scheduling11ed8ad94eeb drm/i915/gt: Specify a deadline for the heartbeat94a385b757e2 drm/i915: Extend the priority boosting for the display with a deadline 6098f9f08113 drm/i915/gt: Support virtual engine queuesccb84bd14161 drm/i915: Move saturated workload detection back to the context
-:29: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #29:
References: 44d89409a12e ("drm/i915: Make the semaphore saturation mask global")
-:29: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 44d89409a12e ("drm/i915: Make the semaphore saturation mask global")' #29:
References: 44d89409a12e ("drm/i915: Make the semaphore saturation mask global")
total: 1 errors, 1 warnings, 0 checks, 70 lines checked 01a354fdc655 drm/i915: Bump default timeslicing quantum to 5ms
-:7: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
total: 0 errors, 1 warnings, 0 checks, 8 lines checked16a564083b55 drm/i915/gt: Wrap intel_timeline.has_initial_breadcrumb6c93d6121ff6 drm/i915/gt: Track timeline GGTT offset separately from subpage offset a7e054e1d51f drm/i915/gt: Add timeline "mode"052ed5effc8f drm/i915/gt: Use indices for writing into relative timelines 3aab63db2a5a drm/i915/selftests: Exercise relative timeline modese6b3a4e89fdb drm/i915/gt: Use ppHWSP for unshared non-semaphore related timelines d7f96649f044 Restore "drm/i915: drop engine_pin/unpin_breadcrumbs_irq" cf7d73fc42f7 drm/i915/gt: Couple tasklet scheduling for all CS interrupts c9361a735109 drm/i915/gt: Support creation of 'internal' rings7c96efa12d48 drm/i915/gt: Use client timeline address for seqno writes 6f6f3304e33a drm/i915/gt: Infrastructure for ring scheduling
-:79: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #79:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 862 lines checked dd507815ad29 drm/i915/gt: Enable busy-stats for ring-scheduler 68a57f8992ac drm/i915/gt: Implement ring scheduler for gen6/7 -:68: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #68: FILE: drivers/gpu/drm/i915/gt/intel_ring_scheduler.c:202:
+ *cs++ = i915_mmio_reg_offset(
-:70: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #70: FILE: drivers/gpu/drm/i915/gt/intel_ring_scheduler.c:204:
+ *cs++ = _MASKED_BIT_ENABLE(
-:105: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #105: FILE: drivers/gpu/drm/i915/gt/intel_ring_scheduler.c:239:
+ *cs++ = _MASKED_BIT_DISABLE(
total: 0 errors, 0 warnings, 3 checks, 580 lines checked b1e8c9683e18 drm/i915/gt: Enable ring scheduling for gen6/7 85f98ac537c4 drm/i915/gt: Limit C-states while waiting for requests
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [01/54] drm/i915/gt: Cancel submitted requests upon context reset
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [01/54] drm/i915/gt: Cancel submitted requests upon context reset
URL : https://patchwork.freedesktop.org/series/85275/
State : warning
== Summary ==
$ dim sparse --fast origin/drm-tip Sparse version: v0.6.2 Fast mode used, each commit won't be checked separately. +drivers/gpu/drm/i915/gt/intel_engine_stats.h:27:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:27:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:27:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:27:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:27:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:27:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:32:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:32:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:32:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:32:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:49:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:49:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:49:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:49:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:49:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:49:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:56:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:56:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:56:9: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/gt/intel_engine_stats.h:56:9: warning: trying to copy expression type 31 -./include/linux/seqlock.h:843:24: warning: trying to copy expression type 31 -./include/linux/seqlock.h:843:24: warning: trying to copy expression type 31 -./include/linux/seqlock.h:869:16: warning: trying to copy expression type 31 +drivers/gpu/drm/i915/intel_wakeref.c:137:19: warning: context imbalance in 'wakeref_auto_timeout' - unexpected unlock +drivers/gpu/drm/i915/selftests/i915_syncmap.c:80:54: warning: dubious: x | !y
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [01/54] drm/i915/gt: Cancel submitted requests upon context reset
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [01/54] drm/i915/gt: Cancel submitted requests upon context reset
URL : https://patchwork.freedesktop.org/series/85275/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_9530 -> Patchwork_19219
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_19219 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_19219, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_19219:
### CI changes ###
#### Possible regressions ####
* boot:
- fi-kbl-soraka: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-kbl-soraka/boot.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-kbl-soraka/boot.html
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@execlists:
- fi-cfl-8109u: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-cfl-8109u/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-cfl-8109u/igt@i915_selftest@[email protected]
- fi-apl-guc: [PASS][5] -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-apl-guc/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-apl-guc/igt@i915_selftest@[email protected]
- fi-bsw-nick: [PASS][7] -> [INCOMPLETE][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-bsw-nick/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bsw-nick/igt@i915_selftest@[email protected]
- fi-cfl-8700k: [PASS][9] -> [INCOMPLETE][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-cfl-8700k/igt@i915_selftest@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-cfl-8700k/igt@i915_selftest@[email protected]
- fi-bsw-kefka: [PASS][11] -> [INCOMPLETE][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-bsw-kefka/igt@i915_selftest@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bsw-kefka/igt@i915_selftest@[email protected]
- fi-bsw-n3050: [PASS][13] -> [INCOMPLETE][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-bsw-n3050/igt@i915_selftest@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bsw-n3050/igt@i915_selftest@[email protected]
- fi-cml-s: [PASS][15] -> [INCOMPLETE][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-cml-s/igt@i915_selftest@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-cml-s/igt@i915_selftest@[email protected]
- fi-cfl-guc: [PASS][17] -> [INCOMPLETE][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-cfl-guc/igt@i915_selftest@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-cfl-guc/igt@i915_selftest@[email protected]
- fi-bxt-dsi: [PASS][19] -> [INCOMPLETE][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-bxt-dsi/igt@i915_selftest@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bxt-dsi/igt@i915_selftest@[email protected]
- fi-cml-u2: [PASS][21] -> [INCOMPLETE][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-cml-u2/igt@i915_selftest@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-cml-u2/igt@i915_selftest@[email protected]
- fi-bdw-5557u: [PASS][23] -> [INCOMPLETE][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-bdw-5557u/igt@i915_selftest@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bdw-5557u/igt@i915_selftest@[email protected]
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-glk-dsi: [PASS][25] -> [INCOMPLETE][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-glk-dsi/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-glk-dsi/igt@[email protected]
* igt@runner@aborted:
- fi-tgl-u2: NOTRUN -> [FAIL][27]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-tgl-u2/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@i915_selftest@live@execlists:
- {fi-ehl-1}: [PASS][28] -> [INCOMPLETE][29]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-ehl-1/igt@i915_selftest@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-ehl-1/igt@i915_selftest@[email protected]
* igt@i915_selftest@live@gem_contexts:
- {fi-tgl-dsi}: [PASS][30] -> [DMESG-WARN][31]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-tgl-dsi/igt@i915_selftest@live@gem_contexts.html
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-tgl-dsi/igt@i915_selftest@live@gem_contexts.html
* igt@i915_selftest@live@hangcheck:
- {fi-tgl-dsi}: [PASS][32] -> [INCOMPLETE][33]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-tgl-dsi/igt@i915_selftest@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-tgl-dsi/igt@i915_selftest@[email protected]
* igt@runner@aborted:
- {fi-tgl-dsi}: NOTRUN -> [FAIL][34]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-tgl-dsi/igt@[email protected]
New tests
---------
New tests have been introduced between CI_DRM_9530 and Patchwork_19219:
### New IGT tests (1) ###
* igt@i915_selftest@live@scheduler:
- Statuses : 31 pass(s)
- Exec time: [0.64, 7.52] s
Known issues
------------
Here are the changes found in Patchwork_19219 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_huc_copy@huc-copy:
- fi-byt-j1900: NOTRUN -> [SKIP][35] ([fdo#109271]) +27 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-byt-j1900/igt@[email protected]
* igt@i915_selftest@live@execlists:
- fi-kbl-r: [PASS][36] -> [INCOMPLETE][37] ([i915#794])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-kbl-r/igt@i915_selftest@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-kbl-r/igt@i915_selftest@[email protected]
- fi-kbl-x1275: [PASS][38] -> [INCOMPLETE][39] ([i915#794])
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-kbl-x1275/igt@i915_selftest@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-kbl-x1275/igt@i915_selftest@[email protected]
- fi-icl-u2: [PASS][40] -> [INCOMPLETE][41] ([i915#2276])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-icl-u2/igt@i915_selftest@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-icl-u2/igt@i915_selftest@[email protected]
- fi-skl-6600u: [PASS][42] -> [INCOMPLETE][43] ([CI#80])
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-skl-6600u/igt@i915_selftest@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-skl-6600u/igt@i915_selftest@[email protected]
- fi-tgl-u2: [PASS][44] -> [INCOMPLETE][45] ([i915#2268])
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-tgl-u2/igt@i915_selftest@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-tgl-u2/igt@i915_selftest@[email protected]
- fi-skl-guc: [PASS][46] -> [INCOMPLETE][47] ([CI#80])
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-skl-guc/igt@i915_selftest@[email protected]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-skl-guc/igt@i915_selftest@[email protected]
- fi-icl-y: [PASS][48] -> [INCOMPLETE][49] ([i915#2276])
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-icl-y/igt@i915_selftest@[email protected]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-icl-y/igt@i915_selftest@[email protected]
- fi-kbl-guc: [PASS][50] -> [INCOMPLETE][51] ([i915#794])
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-kbl-guc/igt@i915_selftest@[email protected]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-kbl-guc/igt@i915_selftest@[email protected]
- fi-kbl-7500u: [PASS][52] -> [INCOMPLETE][53] ([i915#794])
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-kbl-7500u/igt@i915_selftest@[email protected]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-kbl-7500u/igt@i915_selftest@[email protected]
* igt@kms_chamelium@hdmi-crc-fast:
- fi-byt-j1900: NOTRUN -> [SKIP][54] ([fdo#109271] / [fdo#111827]) +8 similar issues
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-byt-j1900/igt@[email protected]
* igt@runner@aborted:
- fi-bsw-kefka: NOTRUN -> [FAIL][55] ([i915#1436] / [i915#2109])
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bsw-kefka/igt@[email protected]
- fi-cfl-8109u: NOTRUN -> [FAIL][56] ([i915#2426])
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-cfl-8109u/igt@[email protected]
- fi-bsw-nick: NOTRUN -> [FAIL][57] ([i915#1436] / [i915#2109])
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bsw-nick/igt@[email protected]
- fi-bdw-5557u: NOTRUN -> [FAIL][58] ([i915#2426])
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bdw-5557u/igt@[email protected]
- fi-kbl-7500u: NOTRUN -> [FAIL][59] ([i915#1436] / [i915#2426])
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-kbl-7500u/igt@[email protected]
- fi-kbl-guc: NOTRUN -> [FAIL][60] ([i915#1436] / [i915#2426])
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-kbl-guc/igt@[email protected]
- fi-cml-s: NOTRUN -> [FAIL][61] ([i915#2082] / [i915#2426])
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-cml-s/igt@[email protected]
- fi-skl-guc: NOTRUN -> [FAIL][62] ([i915#1436] / [i915#2426])
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-skl-guc/igt@[email protected]
- fi-bsw-n3050: NOTRUN -> [FAIL][63] ([i915#1436] / [i915#2109])
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bsw-n3050/igt@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live@gt_heartbeat:
- fi-bsw-nick: [DMESG-FAIL][64] ([i915#2675] / [i915#541]) -> [PASS][65]
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9530/fi-bsw-nick/igt@i915_selftest@live@gt_heartbeat.html
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/fi-bsw-nick/igt@i915_selftest@live@gt_heartbeat.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[CI#80]: https://gitlab.freedesktop.org/gfx-ci/i915-infra/issues/80
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#2082]: https://gitlab.freedesktop.org/drm/intel/issues/2082
[i915#2109]: https://gitlab.freedesktop.org/drm/intel/issues/2109
[i915#2268]: https://gitlab.freedesktop.org/drm/intel/issues/2268
[i915#2276]: https://gitlab.freedesktop.org/drm/intel/issues/2276
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#2675]: https://gitlab.freedesktop.org/drm/intel/issues/2675
[i915#541]: https://gitlab.freedesktop.org/drm/intel/issues/541
[i915#794]: https://gitlab.freedesktop.org/drm/intel/issues/794
Participating hosts (39 -> 37)
------------------------------
Additional (1): fi-byt-j1900
Missing (3): fi-tgl-y fi-bsw-cyan fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_9530 -> Patchwork_19219
CI-20190529: 20190529
CI_DRM_9530: 4b094e30c7d79e59faef5ce793d6ebbcdbede5a2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5926: c81567cf1c05050f7becd4d78ebe349dfb2f9520 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_19219: 85f98ac537c4cee76a85bf160b6823ee851e1f19 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
85f98ac537c4 drm/i915/gt: Limit C-states while waiting for requests b1e8c9683e18 drm/i915/gt: Enable ring scheduling for gen6/768a57f8992ac drm/i915/gt: Implement ring scheduler for gen6/7 dd507815ad29 drm/i915/gt: Enable busy-stats for ring-scheduler 6f6f3304e33a drm/i915/gt: Infrastructure for ring scheduling7c96efa12d48 drm/i915/gt: Use client timeline address for seqno writes c9361a735109 drm/i915/gt: Support creation of 'internal' rings cf7d73fc42f7 drm/i915/gt: Couple tasklet scheduling for all CS interrupts d7f96649f044 Restore "drm/i915: drop engine_pin/unpin_breadcrumbs_irq" e6b3a4e89fdb drm/i915/gt: Use ppHWSP for unshared non-semaphore related timelines 3aab63db2a5a drm/i915/selftests: Exercise relative timeline modes 052ed5effc8f drm/i915/gt: Use indices for writing into relative timelines a7e054e1d51f drm/i915/gt: Add timeline "mode"6c93d6121ff6 drm/i915/gt: Track timeline GGTT offset separately from subpage offset 16a564083b55 drm/i915/gt: Wrap intel_timeline.has_initial_breadcrumb 01a354fdc655 drm/i915: Bump default timeslicing quantum to 5ms ccb84bd14161 drm/i915: Move saturated workload detection back to the context 6098f9f08113 drm/i915/gt: Support virtual engine queues94a385b757e2 drm/i915: Extend the priority boosting for the display with a deadline 11ed8ad94eeb drm/i915/gt: Specify a deadline for the heartbeat 3e371540df63 drm/i915: Fair low-latency scheduling91c1ecade9a3 drm/i915: Wrap cmpxchg64 with try_cmpxchg64() helper 082e8ae14675 drm/i915: Replace priolist rbtree with a skiplist 152ed7b45e2e drm/i915: Move tasklet from execlists to sched718db6262de1 drm/i915: Move scheduler queue4f299a9c3688 drm/i915: Move common active lists from engine to i915_scheduler ad32d79a370d drm/i915: Fix the iterative dfs for defering requests 6aca7a704425 drm/i915: Extract the ability to defer and rerun a request later 1c3bd294373d drm/i915: Extract request suspension from the execlists backend 325e252e7bac drm/i915: Extract request rewinding from execlists edaf360fa696 drm/i915: Extract request submission from execlists 4bea1b5f3437 drm/i915: Improve DFS for priority inheritancefb9f48e3fe22 drm/i915/selftests: Exercise priority inheritance around an engine loop a3467b661390 drm/i915/selftests: Measure set-priority duration 3d95d5214a1d drm/i915: Restructure priority inheritance478814419b5e drm/i915: Teach the i915_dependency to use a double-lock 08990ad0d442 drm/i915: Replace engine->schedule() with a known request operation ee184d638694 drm/i915: Remove I915_USER_PRIORITY_SHIFT34ee71c219d7 drm/i915: Strip out internal priorities157c2def0cb3 drm/i915/gt: Skip over completed active execlists, again d654d951ab15 drm/i915/gt: Remove timeslice suppressiond5cc1786e885 drm/i915/gt: Do not suspend bonded requests if one hangs ee4ba8911307 drm/i915/gt: Convert stats.active to plain unsigned int cb7601bcf0b2 drm/i915/gt: Extract busy-stats for ring-scheduler 54b08969c728 drm/i915/gt: Drop atomic for engine->fw_active tracking ce5d84639d7c drm/i915: Reduce test_and_set_bit to set_bit in i915_request_submit() 84fade942b88 drm/i915/gem: Reduce ctx->engines_mutex for get_engines() 279d9aafdb7b drm/i915/gem: Reduce ctx->engine_mutex for reading the clone source d1078b6751d7 drm/i915: Drop i915_request.lock requirement for intel_rps_boost() 34004d143982 drm/i915: Drop i915_request.lock serialisation around await_start 5eb79ce389c1 drm/i915: Mark up protected uses of 'i915_request_completed' 9f63c2557add drm/i915/gem: Peek at the inflight context69e67c0b5c51 drm/i915/gt: Pull context closure check from request submit to schedule-in 0b9748fc4fd3 drm/i915/gt: Cancel submitted requests upon context reset
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19219/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx