From patchwork Mon Jul 23 19:56:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10540823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6935112E for ; Mon, 23 Jul 2018 19:56:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C89942838B for ; Mon, 23 Jul 2018 19:56:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B92582842D; Mon, 23 Jul 2018 19:56:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 582262838B for ; Mon, 23 Jul 2018 19:56:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CCD356E036; Mon, 23 Jul 2018 19:56:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 244576E036 for ; Mon, 23 Jul 2018 19:56:37 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 12439418-1500050 for multiple; Mon, 23 Jul 2018 20:56:31 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 23 Jul 2018 20:56:30 +0100 Message-Id: <20180723195630.3545-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723145335.24579-1-chris@chris-wilson.co.uk> References: <20180723145335.24579-1-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH v4] drm/i915: Skip repeated calls to i915_gem_set_wedged() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP If we already wedged, i915_gem_set_wedged() becomes a complicated no-op. v2: Make sure the double set-wedged is synchronous, a parallel call should not return before the driver is indeed wedged. References: https://bugs.freedesktop.org/show_bug.cgi?id=107343 Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 32 ++++++++++++++++++++++----- drivers/gpu/drm/i915/i915_gpu_error.h | 3 ++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8b52cb768a67..912be7356984 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3298,12 +3298,27 @@ static void nop_complete_submit_request(struct i915_request *request) spin_unlock_irqrestore(&request->engine->timeline.lock, flags); } +static void wait_for_wedged(struct i915_gpu_error *error) +{ + DEFINE_WAIT_BIT(wq_entry, &error->flags, I915_WEDGED); + + __wait_on_bit(&error->reset_queue, + &wq_entry, bit_wait, TASK_UNINTERRUPTIBLE); +} + void i915_gem_set_wedged(struct drm_i915_private *i915) { + struct i915_gpu_error *error = &i915->gpu_error; struct intel_engine_cs *engine; enum intel_engine_id id; - GEM_TRACE("start\n"); + if (test_bit(I915_WEDGED, &error->flags)) + return; + + if (test_and_set_bit(I915_WEDGE_IN_PROGRESS, &error->flags)) { + wait_for_wedged(error); + return; + } if (GEM_SHOW_DEBUG()) { struct drm_printer p = drm_debug_printer(__func__); @@ -3312,8 +3327,7 @@ void i915_gem_set_wedged(struct drm_i915_private *i915) intel_engine_dump(engine, &p, "%s\n", engine->name); } - set_bit(I915_WEDGED, &i915->gpu_error.flags); - smp_mb__after_atomic(); + GEM_TRACE("start\n"); /* * First, stop submission to hw, but do not yet complete requests by @@ -3372,17 +3386,25 @@ void i915_gem_set_wedged(struct drm_i915_private *i915) i915_gem_reset_finish_engine(engine); } + smp_mb__before_atomic(); + set_bit(I915_WEDGED, &error->flags); + clear_bit(I915_WEDGE_IN_PROGRESS, &error->flags); + GEM_TRACE("end\n"); - wake_up_all(&i915->gpu_error.reset_queue); + wake_up_all(&error->reset_queue); } bool i915_gem_unset_wedged(struct drm_i915_private *i915) { + struct i915_gpu_error *error = &i915->gpu_error; struct i915_timeline *tl; lockdep_assert_held(&i915->drm.struct_mutex); - if (!test_bit(I915_WEDGED, &i915->gpu_error.flags)) + + if (test_bit(I915_WEDGE_IN_PROGRESS, &error->flags)) + wait_for_wedged(error); + if (!test_bit(I915_WEDGED, &error->flags)) return true; GEM_TRACE("start\n"); diff --git a/drivers/gpu/drm/i915/i915_gpu_error.h b/drivers/gpu/drm/i915/i915_gpu_error.h index f893a4e8b783..1a78a8f330f2 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.h +++ b/drivers/gpu/drm/i915/i915_gpu_error.h @@ -267,8 +267,9 @@ struct i915_gpu_error { #define I915_RESET_BACKOFF 0 #define I915_RESET_HANDOFF 1 #define I915_RESET_MODESET 2 +#define I915_RESET_ENGINE 3 #define I915_WEDGED (BITS_PER_LONG - 1) -#define I915_RESET_ENGINE (I915_WEDGED - I915_NUM_ENGINES) +#define I915_WEDGE_IN_PROGRESS (I915_WEDGED - 1) /** Number of times an engine has been reset */ u32 reset_engine_count[I915_NUM_ENGINES];