Patches that didn't applied cleanly on drm-intel-next-fixes
Subsystems (2)
Rodrigo Vivi
maintainerHi Ashutosh and Chris,
these patches seems needed for 5.7 but didn't applied cleanly on dinf:
Failed to cherry-pick:6352219c39c0 ("drm/i915/perf: Do not clear pollin for small user read buffers") 614654abe847 ("drm/i915: Check current i915_vma.pin_count status first on unbind") c4e8ba739034 ("drm/i915/gt: Yield the timeslice if caught waiting on a user semaphore")
If they are critical for 5.7 please provide a version that applies or list the dependencies.
Thanks,
Rodrigo.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: Check current i915_vma.pin_count status first on unbind
Do an early rejection of a i915_vma_unbind() attempt if the i915_vma is currently pinned, without waiting to see if the inflight operations may unpin it. We see this problem with the shrinker trying to unbind the active vma from inside its bind worker:
<6> [472.618968] Workqueue: events_unbound fence_work [i915] <4> [472.618970] Call Trace:
<4> [472.618974] ? __schedule+0x2e5/0x810 <4> [472.618978] schedule+0x37/0xe0 <4> [472.618982] schedule_preempt_disabled+0xf/0x20 <4> [472.618984] __mutex_lock+0x281/0x9c0 <4> [472.618987] ? mark_held_locks+0x49/0x70 <4> [472.618989] ? _raw_spin_unlock_irqrestore+0x47/0x60 <4> [472.619038] ? i915_vma_unbind+0xae/0x110 [i915] <4> [472.619084] ? i915_vma_unbind+0xae/0x110 [i915] <4> [472.619122] i915_vma_unbind+0xae/0x110 [i915] <4> [472.619165] i915_gem_object_unbind+0x1dc/0x400 [i915] <4> [472.619208] i915_gem_shrink+0x328/0x660 [i915] <4> [472.619250] ? i915_gem_shrink_all+0x38/0x60 [i915] <4> [472.619282] i915_gem_shrink_all+0x38/0x60 [i915] <4> [472.619325] vm_alloc_page.constprop.25+0x1aa/0x240 [i915] <4> [472.619330] ? rcu_read_lock_sched_held+0x4d/0x80 <4> [472.619363] ? __alloc_pd+0xb/0x30 [i915] <4> [472.619366] ? module_assert_mutex_or_preempt+0xf/0x30 <4> [472.619368] ? __module_address+0x23/0xe0 <4> [472.619371] ? is_module_address+0x26/0x40 <4> [472.619374] ? static_obj+0x34/0x50 <4> [472.619376] ? lockdep_init_map+0x4d/0x1e0 <4> [472.619407] setup_page_dma+0xd/0x90 [i915] <4> [472.619437] alloc_pd+0x29/0x50 [i915] <4> [472.619470] __gen8_ppgtt_alloc+0x443/0x6b0 [i915] <4> [472.619503] gen8_ppgtt_alloc+0xd7/0x300 [i915] <4> [472.619535] ppgtt_bind_vma+0x2a/0xe0 [i915] <4> [472.619577] __vma_bind+0x26/0x40 [i915] <4> [472.619611] fence_work+0x1c/0x90 [i915] <4> [472.619617] process_one_work+0x26a/0x620
--- drivers/gpu/drm/i915/i915_vma.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_vma.c +9 -16
@@ -1226,18 +1226,6 @@ int __i915_vma_unbind(struct i915_vma *vma)lockdep_assert_held (&vma->vm->mutex); -/* -* First wait upon any activity as retiring the request may -* have side-effects such as unpinning or even unbinding this vma. -* -* XXX Actually waiting under the vm->mutex is a hinderance and -* should be pipelined wherever possible. In cases where that is -* unavoidable, we should lift the wait to before the mutex. -*/ - ret =i915_vma_sync (vma); -if (ret) -return ret; -if (i915_vma_is_pinned (vma)) {vma_print_allocator (vma,"is pinned" );return -EAGAIN ;
@@ -1311,15 +1299,20 @@ int i915_vma_unbind(struct i915_vma *vma)if (!drm_mm_node_allocated (&vma->node))return 0 ; -if (i915_vma_is_bound (vma,I915_VMA_GLOBAL_BIND )) -/* XXX not always required: nop_clear_range */ - wakeref =intel_runtime_pm_get (&vm->i915->runtime_pm); -/* Optimistic wait before taking the mutex */ err =i915_vma_sync (vma);if (err) goto out_rpm; +if (i915_vma_is_pinned (vma)) { +vma_print_allocator (vma,"is pinned" ); +return -EAGAIN ; + } + +if (i915_vma_is_bound (vma,I915_VMA_GLOBAL_BIND )) +/* XXX not always required: nop_clear_range */ + wakeref =intel_runtime_pm_get (&vm->i915->runtime_pm); + err =mutex_lock_interruptible (&vm->mutex);if (err) goto out_rpm;
Signature · 6 lines
2.26.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/2 drm/i915/execlists: Workaround switching back to a completed context
In reply to Rodrigo ViviIn what seems remarkably similar to the w/a required to not reload an idle context with HEAD==TAIL, it appears we must prevent the HW from switching to an idle context in ELSP[1], while simultaneously trying to preempt the HW to run another context and a continuation of the idle context (which is no longer idle).
We can achieve this by preventing the context from completing while we reload a new ELSP (by applying ring_set_paused(1) across the whole of dequeue), except this eventually fails due to a lite-restore into a waiting semaphore does not generate an ACK. Instead, we try to avoid making the GPU do anything too challenging and not submit a new ELSP while the interrupts + CSB events appear to have fallen behind the completed contexts. We expect it to catch up shortly so we queue another tasklet execution and hope for the best.
--- drivers/gpu/drm/i915/gt/intel_lrc.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gt/intel_lrc.c +23 -3
@@ -1915,11 +1915,26 @@ static void execlists_dequeue(struct intel_engine_cs *engine)* of trouble. */ active =READ_ONCE (execlists->active); -while ((last = *active) &&i915_request_completed (last)) - active++; -if (last) { +/* +* 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. +*/ + +if ((last = *active)) {if (need_preempt (engine, last, rb)) { +if (i915_request_completed (last)) { +tasklet_hi_schedule (&execlists->tasklet); +return ; + } + ENGINE_TRACE(engine, "preempting last=%llx:%lld, prio=%d, hint=%d\n", last->fence.context,
@@ -1947,6 +1962,11 @@ static void execlists_dequeue(struct intel_engine_cs *engine) last =NULL ; }else if (need_timeslice (engine, last) &&timer_expired (&engine->execlists.timer)) { +if (i915_request_completed (last)) { +tasklet_hi_schedule (&execlists->tasklet); +return ; + } + ENGINE_TRACE(engine, "expired last=%llx:%lld, prio=%d, hint=%d\n", last->fence.context,
Signature · 6 lines
2.26.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915/gt: Yield the timeslice if caught waiting on a user semaphore
If we find ourselves waiting on a MI_SEMAPHORE_WAIT, either within the user batch or in our own preamble, the engine raises a GT_WAIT_ON_SEMAPHORE interrupt. We can unmask that interrupt and so respond to a semaphore wait by yielding the timeslice, if we have another context to yield to!
The only real complication is that the interrupt is only generated for the start of the semaphore wait, and is asynchronous to our process_csb() -- that is, we may not have registered the timeslice before we see the interrupt. To ensure we don't miss a potential semaphore blocking forward progress (e.g. selftests/live_timeslice_preempt) we mark the interrupt and apply it to the next timeslice regardless of whether it was active at the time.
v2: We use semaphores in preempt-to-busy, within the timeslicing implementation itself! Ergo, when we do insert a preemption due to an expired timeslice, the new context may start with the missed semaphore flagged by the retired context and be yielded, ad infinitum. To avoid this, read the context id at the time of the semaphore interrupt and only yield if that context is still active.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 6 +++ drivers/gpu/drm/i915/gt/intel_engine_types.h | 9 +++++ drivers/gpu/drm/i915/gt/intel_gt_irq.c | 15 ++++++- drivers/gpu/drm/i915/gt/intel_lrc.c | 41 +++++++++++++++++--- drivers/gpu/drm/i915/gt/selftest_lrc.c | 34 ++++++++-------- drivers/gpu/drm/i915/i915_reg.h | 1 + 6 files changed, 82 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +6 -0
@@ -1295,6 +1295,12 @@ static void intel_engine_print_registers(struct intel_engine_cs *engine,if (engine->id ==RENDER_CLASS &&IS_GEN_RANGE (dev_priv,4 ,7 ))drm_printf (m,"\tCCID: 0x%08x\n" ,ENGINE_READ (engine,CCID )); +if (HAS_EXECLISTS (dev_priv)) { +drm_printf (m,"\tEL_STAT_HI: 0x%08x\n" , +ENGINE_READ (engine,RING_EXECLIST_STATUS_HI )); +drm_printf (m,"\tEL_STAT_LO: 0x%08x\n" , +ENGINE_READ (engine,RING_EXECLIST_STATUS_LO )); + }drm_printf (m,"\tRING_START: 0x%08x\n" ,ENGINE_READ (engine,RING_START )); drm_printf(m, "\tRING_HEAD: 0x%08x\n",
drivers/gpu/drm/i915/gt/intel_engine_types.h +9 -0
@@ -156,6 +156,15 @@ struct intel_engine_execlists {*/ struct i915_priolist default_priolist; +/** +* @yield: CCID at the time of the last semaphore-wait interrupt. +* +* Instead of leaving a semaphore busy-spinning on an engine, we would +* like to switch to another ready context, i.e. yielding the semaphore +* timeslice. +*/ +u32 yield; +/** * @error_interrupt: CS Master EIR *
drivers/gpu/drm/i915/gt/intel_gt_irq.c +13 -2
@@ -39,6 +39,15 @@ cs_irq_handler(struct intel_engine_cs *engine, u32 iir) } } +if (iir >_WAIT_SEMAPHORE_INTERRUPT ) { +WRITE_ONCE (engine->execlists.yield, +ENGINE_READ_FW (engine,RING_EXECLIST_STATUS_HI )); +ENGINE_TRACE (engine,"semaphore yield: %08x\n" , + engine->execlists.yield); +if (del_timer (&engine->execlists.timer)) + tasklet = true; + } +if (iir >_CONTEXT_SWITCH_INTERRUPT ) tasklet = true;
@@ -228,7 +237,8 @@ void gen11_gt_irq_postinstall(struct intel_gt *gt)const u32 irqs =GT_CS_MASTER_ERROR_INTERRUPT |GT_RENDER_USER_INTERRUPT | -GT_CONTEXT_SWITCH_INTERRUPT ; +GT_CONTEXT_SWITCH_INTERRUPT | +GT_WAIT_SEMAPHORE_INTERRUPT ;struct intel_uncore *uncore = gt->uncore;const u32 dmask = irqs <<16 | irqs;const u32 smask = irqs <<16 ;
@@ -366,7 +376,8 @@ void gen8_gt_irq_postinstall(struct intel_gt *gt)const u32 irqs =GT_CS_MASTER_ERROR_INTERRUPT |GT_RENDER_USER_INTERRUPT | -GT_CONTEXT_SWITCH_INTERRUPT ; +GT_CONTEXT_SWITCH_INTERRUPT | +GT_WAIT_SEMAPHORE_INTERRUPT ;const u32 gt_interrupts[] = { irqs <<GEN8_RCS_IRQ_SHIFT | irqs <<GEN8_BCS_IRQ_SHIFT , irqs <<GEN8_VCS0_IRQ_SHIFT | irqs <<GEN8_VCS1_IRQ_SHIFT ,
drivers/gpu/drm/i915/gt/intel_lrc.c +35 -6
86 lines not on this page · raw message
drivers/gpu/drm/i915/gt/selftest_lrc.c +18 -16
@@ -929,7 +929,7 @@ create_rewinder(struct intel_context *ce, goto err; } - cs =intel_ring_begin (rq,10 ); + cs =intel_ring_begin (rq,14 );if (IS_ERR (cs)) { err =PTR_ERR (cs); goto err;
@@ -941,8 +941,8 @@ create_rewinder(struct intel_context *ce, *cs++ =MI_SEMAPHORE_WAIT |MI_SEMAPHORE_GLOBAL_GTT |MI_SEMAPHORE_POLL | -MI_SEMAPHORE_SAD_NEQ_SDD ; - *cs++ =0 ; +MI_SEMAPHORE_SAD_GTE_SDD ; + *cs++ = idx; *cs++ = offset; *cs++ =0 ;
@@ -951,6 +951,11 @@ create_rewinder(struct intel_context *ce, *cs++ = offset + idx *sizeof (u32); *cs++ =0 ; + *cs++ =MI_STORE_DWORD_IMM_GEN4 |MI_USE_GGTT ; + *cs++ = offset; + *cs++ =0 ; + *cs++ = idx +1 ; +intel_ring_advance (rq, cs); rq->sched.attr.priority =I915_PRIORITY_MASK ;
@@ -984,7 +989,7 @@ static int live_timeslice_rewind(void *arg)for_each_engine (engine, gt, id) {enum {A1 ,A2 ,B1 }; -enum {X =1 ,Y ,Z }; +enum {X =1 ,Z ,Y };struct i915_request *rq[3 ] = {};struct intel_context *ce;unsigned long heartbeat;
@@ -1017,13 +1022,13 @@ static int live_timeslice_rewind(void *arg) goto err; } - rq[0 ] =create_rewinder (ce,NULL , slot,1 ); + rq[0 ] =create_rewinder (ce,NULL , slot,X );if (IS_ERR (rq[0 ])) {intel_context_put (ce); goto err; } - rq[1 ] =create_rewinder (ce,NULL , slot,2 ); + rq[1 ] =create_rewinder (ce,NULL , slot,Y );intel_context_put (ce);if (IS_ERR (rq[1 ])) goto err;
@@ -1041,7 +1046,7 @@ static int live_timeslice_rewind(void *arg) goto err; } - rq[2 ] =create_rewinder (ce, rq[0 ], slot,3 ); + rq[2 ] =create_rewinder (ce, rq[0 ], slot,Z );intel_context_put (ce);if (IS_ERR (rq[2 ])) goto err;
@@ -1055,15 +1060,12 @@ static int live_timeslice_rewind(void *arg)GEM_BUG_ON (!timer_pending (&engine->execlists.timer));/* ELSP[] = { { A:rq1, A:rq2 }, { B:rq1 } } */ -GEM_BUG_ON (!i915_request_is_active (rq[A1 ])); -GEM_BUG_ON (!i915_request_is_active (rq[A2 ])); -GEM_BUG_ON (!i915_request_is_active (rq[B1 ])); - -/* Wait for the timeslice to kick in */ -del_timer (&engine->execlists.timer); -tasklet_hi_schedule (&engine->execlists.tasklet); -intel_engine_flush_submission (engine); - +if (i915_request_is_active (rq[A2 ])) {/* semaphore yielded! */ +/* Wait for the timeslice to kick in */ +del_timer (&engine->execlists.timer); +tasklet_hi_schedule (&engine->execlists.tasklet); +intel_engine_flush_submission (engine); + }/* -> ELSP[] = { { A:rq1 }, { B:rq1 } } */ GEM_BUG_ON (!i915_request_is_active (rq[A1 ]));GEM_BUG_ON (!i915_request_is_active (rq[B1 ]));
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -3094,6 +3094,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define GT_BSD_CS_ERROR_INTERRUPT (1 << 15)#define GT_BSD_USER_INTERRUPT (1 << 12)#define GT_RENDER_L3_PARITY_ERROR_INTERRUPT_S1 (1 << 11)/* hsw+; rsvd on snb, ivb, vlv */ +#define GT_WAIT_SEMAPHORE_INTERRUPT REG_BIT(11)/* bdw+ */ #define GT_CONTEXT_SWITCH_INTERRUPT (1 << 8)#define GT_RENDER_L3_PARITY_ERROR_INTERRUPT (1 << 5)/* !snb */ #define GT_RENDER_PIPECTL_NOTIFY_INTERRUPT (1 << 4)
Signature · 6 lines
2.26.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915: Check current i915_vma.pin_count status first on unbind (rev8)
In reply to Rodrigo Vivi== Series Details ==
== Series Details ==
Series: drm/i915: Check current i915_vma.pin_count status first on unbind (rev8)
URL : https://patchwork.freedesktop.org/series/72529/
State : failure
== Summary ==
Applying: drm/i915: Check current i915_vma.pin_count status first on unbind Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_vma.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/i915_vma.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/i915_vma.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 drm/i915: Check current i915_vma.pin_count status first on unbind When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · Rodrigo Vivi
Hi Ashutosh and Chris,
these patches seems needed for 5.7 but didn't applied cleanly on dinf:
Failed to cherry-pick:
6352219c39c0("drm/i915/perf: Do not clear pollin for small user read buffers")614654abe847("drm/i915: Check current i915_vma.pin_count status first on unbind")c4e8ba739034("drm/i915/gt: Yield the timeslice if caught waiting on a user semaphore")If they are critical for 5.7 please provide a version that applies or list the dependencies.
I have sent a version of 6352219c39c0 to intel-gfx which should apply on dinf:
https://patchwork.freedesktop.org/series/75085/#rev8
Thanks!
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx