Skip to content

Commit 14a0d52

Browse files
icklejnikula
authored andcommitted
drm/i915: Defer semaphore priority bumping to a workqueue
Since the semaphore fence may be signaled from inside an interrupt handler from inside a request holding its request->lock, we cannot then enter into the engine->active.lock for processing the semaphore priority bump as we may traverse our call tree and end up on another held request. CPU 0: [ 2243.218864] _raw_spin_lock_irqsave+0x9a/0xb0 [ 2243.218867] i915_schedule_bump_priority+0x49/0x80 [i915] [ 2243.218869] semaphore_notify+0x6d/0x98 [i915] [ 2243.218871] __i915_sw_fence_complete+0x61/0x420 [i915] [ 2243.218874] ? kmem_cache_free+0x211/0x290 [ 2243.218876] i915_sw_fence_complete+0x58/0x80 [i915] [ 2243.218879] dma_i915_sw_fence_wake+0x3e/0x80 [i915] [ 2243.218881] signal_irq_work+0x571/0x690 [i915] [ 2243.218883] irq_work_run_list+0xd7/0x120 [ 2243.218885] irq_work_run+0x1d/0x50 [ 2243.218887] smp_irq_work_interrupt+0x21/0x30 [ 2243.218889] irq_work_interrupt+0xf/0x20 CPU 1: [ 2242.173107] _raw_spin_lock+0x8f/0xa0 [ 2242.173110] __i915_request_submit+0x64/0x4a0 [i915] [ 2242.173112] __execlists_submission_tasklet+0x8ee/0x2120 [i915] [ 2242.173114] ? i915_sched_lookup_priolist+0x1e3/0x2b0 [i915] [ 2242.173117] execlists_submit_request+0x2e8/0x2f0 [i915] [ 2242.173119] submit_notify+0x8f/0xc0 [i915] [ 2242.173121] __i915_sw_fence_complete+0x61/0x420 [i915] [ 2242.173124] ? _raw_spin_unlock_irqrestore+0x39/0x40 [ 2242.173137] i915_sw_fence_complete+0x58/0x80 [i915] [ 2242.173140] i915_sw_fence_commit+0x16/0x20 [i915] Closes: https://gitlab.freedesktop.org/drm/intel/issues/1318 Fixes: b7404c7 ("drm/i915: Bump ready tasks ahead of busywaits") Signed-off-by: Chris Wilson <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: <[email protected]> # v5.2+ Reviewed-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 209df10) Signed-off-by: Jani Nikula <[email protected]>
1 parent 8ea6bb8 commit 14a0d52

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

drivers/gpu/drm/i915/i915_request.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,19 +527,31 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
527527
return NOTIFY_DONE;
528528
}
529529

530+
static void irq_semaphore_cb(struct irq_work *wrk)
531+
{
532+
struct i915_request *rq =
533+
container_of(wrk, typeof(*rq), semaphore_work);
534+
535+
i915_schedule_bump_priority(rq, I915_PRIORITY_NOSEMAPHORE);
536+
i915_request_put(rq);
537+
}
538+
530539
static int __i915_sw_fence_call
531540
semaphore_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
532541
{
533-
struct i915_request *request =
534-
container_of(fence, typeof(*request), semaphore);
542+
struct i915_request *rq = container_of(fence, typeof(*rq), semaphore);
535543

536544
switch (state) {
537545
case FENCE_COMPLETE:
538-
i915_schedule_bump_priority(request, I915_PRIORITY_NOSEMAPHORE);
546+
if (!(READ_ONCE(rq->sched.attr.priority) & I915_PRIORITY_NOSEMAPHORE)) {
547+
i915_request_get(rq);
548+
init_irq_work(&rq->semaphore_work, irq_semaphore_cb);
549+
irq_work_queue(&rq->semaphore_work);
550+
}
539551
break;
540552

541553
case FENCE_FREE:
542-
i915_request_put(request);
554+
i915_request_put(rq);
543555
break;
544556
}
545557

@@ -1318,9 +1330,9 @@ void __i915_request_queue(struct i915_request *rq,
13181330
* decide whether to preempt the entire chain so that it is ready to
13191331
* run at the earliest possible convenience.
13201332
*/
1321-
i915_sw_fence_commit(&rq->semaphore);
13221333
if (attr && rq->engine->schedule)
13231334
rq->engine->schedule(rq, attr);
1335+
i915_sw_fence_commit(&rq->semaphore);
13241336
i915_sw_fence_commit(&rq->submit);
13251337
}
13261338

drivers/gpu/drm/i915/i915_request.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define I915_REQUEST_H
2727

2828
#include <linux/dma-fence.h>
29+
#include <linux/irq_work.h>
2930
#include <linux/lockdep.h>
3031

3132
#include "gem/i915_gem_context_types.h"
@@ -208,6 +209,7 @@ struct i915_request {
208209
};
209210
struct list_head execute_cb;
210211
struct i915_sw_fence semaphore;
212+
struct irq_work semaphore_work;
211213

212214
/*
213215
* A list of everyone we wait upon, and everyone who waits upon us.

0 commit comments

Comments
 (0)