Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01FC8C35E01 for ; Tue, 25 Feb 2020 19:07:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB16B2082F for ; Tue, 25 Feb 2020 19:07:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB16B2082F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34FC36EB90; Tue, 25 Feb 2020 19:07:49 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6CC36EB90 for ; Tue, 25 Feb 2020 19:07:47 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2020 11:07:46 -0800 X-IronPort-AV: E=Sophos;i="5.70,485,1574150400"; d="scan'208";a="231123915" Received: from pmulhall-mobl.ger.corp.intel.com (HELO [10.251.85.135]) ([10.251.85.135]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Feb 2020 11:07:45 -0800 To: Chris Wilson , intel-gfx@lists.freedesktop.org References: <20200224100007.4024184-1-chris@chris-wilson.co.uk> <20200224100007.4024184-3-chris@chris-wilson.co.uk> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc Message-ID: <452b0706-4b0d-9548-0456-081c0d950dbc@linux.intel.com> Date: Tue, 25 Feb 2020 19:07:43 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200224100007.4024184-3-chris@chris-wilson.co.uk> Content-Language: en-US Subject: Re: [Intel-gfx] [PATCH 03/14] drm/i915: Flush idle barriers when waiting X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 24/02/2020 09:59, Chris Wilson wrote: > If we do find ourselves with an idle barrier inside our active while > waiting, attempt to flush it by emitting a pulse using the kernel > context. > > Signed-off-by: Chris Wilson > Cc: Steve Carbonari > --- > drivers/gpu/drm/i915/i915_active.c | 42 ++++++++++++++---- > drivers/gpu/drm/i915/selftests/i915_active.c | 46 ++++++++++++++++++++ > 2 files changed, 79 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c > index 9ccb931a733e..fae7e3820592 100644 > --- a/drivers/gpu/drm/i915/i915_active.c > +++ b/drivers/gpu/drm/i915/i915_active.c > @@ -7,6 +7,7 @@ > #include > > #include "gt/intel_context.h" > +#include "gt/intel_engine_heartbeat.h" > #include "gt/intel_engine_pm.h" > #include "gt/intel_ring.h" > > @@ -460,26 +461,49 @@ static void enable_signaling(struct i915_active_fence *active) > dma_fence_put(fence); > } > > -int i915_active_wait(struct i915_active *ref) > +static int flush_barrier(struct active_node *it) > { > - struct active_node *it, *n; > - int err = 0; > + struct intel_engine_cs *engine; > > - might_sleep(); > + if (!is_barrier(&it->base)) > + return 0; > > - if (!i915_active_acquire_if_busy(ref)) > + engine = __barrier_to_engine(it); > + smp_rmb(); /* serialise with add_active_barriers */ > + if (!is_barrier(&it->base)) > return 0; What is the purpose of the first !is_barrier check? Just to kind of look better by not calling __bariier_to_engine on the wrong thing? > > - /* Flush lazy signals */ > + return intel_engine_flush_barriers(engine); > +} > + > +static int flush_lazy_signals(struct i915_active *ref) > +{ > + struct active_node *it, *n; > + int err = 0; > + > enable_signaling(&ref->excl); > rbtree_postorder_for_each_entry_safe(it, n, &ref->tree, node) { > - if (is_barrier(&it->base)) /* unconnected idle barrier */ > - continue; > + err = flush_barrier(it); /* unconnected idle barrier? */ > + if (err) > + break; > > enable_signaling(&it->base); > } > - /* Any fence added after the wait begins will not be auto-signaled */ > > + return err; > +} > + > +int i915_active_wait(struct i915_active *ref) > +{ > + int err; > + > + might_sleep(); > + > + if (!i915_active_acquire_if_busy(ref)) > + return 0; > + > + /* Any fence added after the wait begins will not be auto-signaled */ > + err = flush_lazy_signals(ref); > i915_active_release(ref); > if (err) > return err; > diff --git a/drivers/gpu/drm/i915/selftests/i915_active.c b/drivers/gpu/drm/i915/selftests/i915_active.c > index ef572a0c2566..067e30b8927f 100644 > --- a/drivers/gpu/drm/i915/selftests/i915_active.c > +++ b/drivers/gpu/drm/i915/selftests/i915_active.c > @@ -201,11 +201,57 @@ static int live_active_retire(void *arg) > return err; > } > > +static int live_active_barrier(void *arg) > +{ > + struct drm_i915_private *i915 = arg; > + struct intel_engine_cs *engine; > + struct live_active *active; > + int err = 0; > + > + /* Check that we get a callback when requests retire upon waiting */ > + > + active = __live_alloc(i915); > + if (!active) > + return -ENOMEM; > + > + err = i915_active_acquire(&active->base); > + if (err) > + goto out; > + > + for_each_uabi_engine(engine, i915) { > + err = i915_active_acquire_preallocate_barrier(&active->base, > + engine); > + if (err) > + break; > + > + i915_active_acquire_barrier(&active->base); > + } > + > + i915_active_release(&active->base); > + > + if (err == 0) > + err = i915_active_wait(&active->base); > + > + if (err == 0 && !READ_ONCE(active->retired)) { > + pr_err("i915_active not retired after flushing barriers!\n"); > + err = -EINVAL; > + } > + > +out: > + __live_put(active); > + > + if (igt_flush_test(i915)) > + err = -EIO; > + > + return err; > +} > + > int i915_active_live_selftests(struct drm_i915_private *i915) > { > static const struct i915_subtest tests[] = { > SUBTEST(live_active_wait), > SUBTEST(live_active_retire), > + SUBTEST(live_active_barrier), > }; > > if (intel_gt_is_wedged(&i915->gt)) > Reviewed-by: Tvrtko Ursulin Regards, Tvrtko _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx