Skip to content

Commit 2328e1b

Browse files
icklerodrigovivi
authored andcommitted
drm/i915/selftests: Reorder tasklet_disable vs local_bh_disable
Due to a change in requirements that disallows tasklet_disable() being called from atomic context, rearrange the selftest to avoid doing so. <3> [324.942939] BUG: sleeping function called from invalid context at kernel/softirq.c:888 <3> [324.942952] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 5601, name: i915_selftest <4> [324.942960] 1 lock held by i915_selftest/5601: <4> [324.942963] #0: ffff888101d19240 (&dev->mutex){....}-{3:3}, at: device_driver_attach+0x18/0x50 <3> [324.942987] Preemption disabled at: <3> [324.942990] [<ffffffffa026fbd2>] live_hold_reset.part.65+0xc2/0x2f0 [i915] <4> [324.943255] CPU: 0 PID: 5601 Comm: i915_selftest Tainted: G U 5.13.0-rc5-CI-CI_DRM_10197+ Rust-for-Linux#1 <4> [324.943259] Hardware name: Intel Corp. Geminilake/GLK RVP2 LP4SD (07), BIOS GELKRVPA.X64.0062.B30.1708222146 08/22/2017 <4> [324.943263] Call Trace: <4> [324.943267] dump_stack+0x7f/0xad <4> [324.943276] ___might_sleep.cold.123+0xf2/0x106 <4> [324.943286] tasklet_unlock_wait+0x2e/0xb0 <4> [324.943291] ? ktime_get_raw+0x81/0x120 <4> [324.943305] live_hold_reset.part.65+0x1ab/0x2f0 [i915] <4> [324.943500] __i915_subtests.cold.7+0x42/0x92 [i915] <4> [324.943723] ? __i915_live_teardown+0x50/0x50 [i915] <4> [324.943922] ? __intel_gt_live_setup+0x30/0x30 [i915] Fixes: da04474 ("tasklets: Replace spin wait in tasklet_unlock_wait()") Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Signed-off-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 35c6367) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 1bd8a7d commit 2328e1b

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

drivers/gpu/drm/i915/gt/selftest_execlists.c

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,32 @@ static int live_pin_rewind(void *arg)
551551
return err;
552552
}
553553

554+
static int engine_lock_reset_tasklet(struct intel_engine_cs *engine)
555+
{
556+
tasklet_disable(&engine->execlists.tasklet);
557+
local_bh_disable();
558+
559+
if (test_and_set_bit(I915_RESET_ENGINE + engine->id,
560+
&engine->gt->reset.flags)) {
561+
local_bh_enable();
562+
tasklet_enable(&engine->execlists.tasklet);
563+
564+
intel_gt_set_wedged(engine->gt);
565+
return -EBUSY;
566+
}
567+
568+
return 0;
569+
}
570+
571+
static void engine_unlock_reset_tasklet(struct intel_engine_cs *engine)
572+
{
573+
clear_and_wake_up_bit(I915_RESET_ENGINE + engine->id,
574+
&engine->gt->reset.flags);
575+
576+
local_bh_enable();
577+
tasklet_enable(&engine->execlists.tasklet);
578+
}
579+
554580
static int live_hold_reset(void *arg)
555581
{
556582
struct intel_gt *gt = arg;
@@ -598,15 +624,9 @@ static int live_hold_reset(void *arg)
598624

599625
/* We have our request executing, now remove it and reset */
600626

601-
local_bh_disable();
602-
if (test_and_set_bit(I915_RESET_ENGINE + id,
603-
&gt->reset.flags)) {
604-
local_bh_enable();
605-
intel_gt_set_wedged(gt);
606-
err = -EBUSY;
627+
err = engine_lock_reset_tasklet(engine);
628+
if (err)
607629
goto out;
608-
}
609-
tasklet_disable(&engine->execlists.tasklet);
610630

611631
engine->execlists.tasklet.callback(&engine->execlists.tasklet);
612632
GEM_BUG_ON(execlists_active(&engine->execlists) != rq);
@@ -618,10 +638,7 @@ static int live_hold_reset(void *arg)
618638
__intel_engine_reset_bh(engine, NULL);
619639
GEM_BUG_ON(rq->fence.error != -EIO);
620640

621-
tasklet_enable(&engine->execlists.tasklet);
622-
clear_and_wake_up_bit(I915_RESET_ENGINE + id,
623-
&gt->reset.flags);
624-
local_bh_enable();
641+
engine_unlock_reset_tasklet(engine);
625642

626643
/* Check that we do not resubmit the held request */
627644
if (!i915_request_wait(rq, 0, HZ / 5)) {
@@ -4585,15 +4602,9 @@ static int reset_virtual_engine(struct intel_gt *gt,
45854602
GEM_BUG_ON(engine == ve->engine);
45864603

45874604
/* Take ownership of the reset and tasklet */
4588-
local_bh_disable();
4589-
if (test_and_set_bit(I915_RESET_ENGINE + engine->id,
4590-
&gt->reset.flags)) {
4591-
local_bh_enable();
4592-
intel_gt_set_wedged(gt);
4593-
err = -EBUSY;
4605+
err = engine_lock_reset_tasklet(engine);
4606+
if (err)
45944607
goto out_heartbeat;
4595-
}
4596-
tasklet_disable(&engine->execlists.tasklet);
45974608

45984609
engine->execlists.tasklet.callback(&engine->execlists.tasklet);
45994610
GEM_BUG_ON(execlists_active(&engine->execlists) != rq);
@@ -4612,9 +4623,7 @@ static int reset_virtual_engine(struct intel_gt *gt,
46124623
GEM_BUG_ON(rq->fence.error != -EIO);
46134624

46144625
/* Release our grasp on the engine, letting CS flow again */
4615-
tasklet_enable(&engine->execlists.tasklet);
4616-
clear_and_wake_up_bit(I915_RESET_ENGINE + engine->id, &gt->reset.flags);
4617-
local_bh_enable();
4626+
engine_unlock_reset_tasklet(engine);
46184627

46194628
/* Check that we do not resubmit the held request */
46204629
i915_request_get(rq);

0 commit comments

Comments
 (0)