From: Chris Wilson Date: Wed, 6 Jul 2016 11:39:00 +0000 (+0100) Subject: drm/i915: Always double check for a missed interrupt for new bottom halves X-Git-Tag: v5.15~12629^2~42^2~243 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04171313cb25311acf82279284d722fed7b70d53;p=platform%2Fkernel%2Flinux-starfive.git drm/i915: Always double check for a missed interrupt for new bottom halves After assigning ourselves as the new bottom-half, we must perform a cursory check to prevent a missed interrupt. Either we miss the interrupt whilst programming the hardware, or if there was a previous waiter (for a later seqno) they may be woken instead of us (due to the inherent race in the unlocked read of b->tasklet in the irq handler) and so we miss the wake up. Spotted-by: Tvrtko Ursulin Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96806 Fixes: 688e6c725816 ("drm/i915: Slaughter the thundering... herd") Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin Link: http://patchwork.freedesktop.org/patch/msgid/1467805142-22219-1-git-send-email-chris@chris-wilson.co.uk --- diff --git a/drivers/gpu/drm/i915/intel_breadcrumbs.c b/drivers/gpu/drm/i915/intel_breadcrumbs.c index 009d6e1..6fcbb52 100644 --- a/drivers/gpu/drm/i915/intel_breadcrumbs.c +++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c @@ -65,7 +65,7 @@ static void irq_disable(struct intel_engine_cs *engine) engine->irq_posted = false; } -static bool __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b) +static void __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b) { struct intel_engine_cs *engine = container_of(b, struct intel_engine_cs, breadcrumbs); @@ -73,7 +73,7 @@ static bool __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b) assert_spin_locked(&b->lock); if (b->rpm_wakelock) - return false; + return; /* Since we are waiting on a request, the GPU should be busy * and should have its own rpm reference. For completeness, @@ -93,8 +93,6 @@ static bool __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b) if (!b->irq_enabled || test_bit(engine->id, &i915->gpu_error.missed_irq_rings)) mod_timer(&b->fake_irq, jiffies + 1); - - return engine->irq_posted; } static void __intel_breadcrumbs_disable_irq(struct intel_breadcrumbs *b) @@ -233,7 +231,15 @@ static bool __intel_engine_add_wait(struct intel_engine_cs *engine, GEM_BUG_ON(rb_first(&b->waiters) != &wait->node); b->first_wait = wait; smp_store_mb(b->tasklet, wait->tsk); - first = __intel_breadcrumbs_enable_irq(b); + /* After assigning ourselves as the new bottom-half, we must + * perform a cursory check to prevent a missed interrupt. + * Either we miss the interrupt whilst programming the hardware, + * or if there was a previous waiter (for a later seqno) they + * may be woken instead of us (due to the inherent race + * in the unlocked read of b->tasklet in the irq handler) and + * so we miss the wake up. + */ + __intel_breadcrumbs_enable_irq(b); } GEM_BUG_ON(!b->tasklet); GEM_BUG_ON(!b->first_wait);