From patchwork Wed Jun 6 06:27:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10449715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 923F260146 for ; Wed, 6 Jun 2018 06:28:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8519329834 for ; Wed, 6 Jun 2018 06:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A33F2984D; Wed, 6 Jun 2018 06:28:03 +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 2CDC129834 for ; Wed, 6 Jun 2018 06:28:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04BD26E542; Wed, 6 Jun 2018 06:28:02 +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 B76376E542 for ; Wed, 6 Jun 2018 06:27:59 +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 11956696-1500050 for multiple; Wed, 06 Jun 2018 07:27:52 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Wed, 06 Jun 2018 07:27:54 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 6 Jun 2018 07:27:09 +0100 Message-Id: <20180606062710.29984-17-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180606062710.29984-1-chris@chris-wilson.co.uk> References: <20180606062710.29984-1-chris@chris-wilson.co.uk> X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH 16/17] drm/i915/ringbuffer: Force restore of mm after failed context switch 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 interrupt the context switch and unwind, we leave the to_mm believing that we have cleared the dirty bit for this engine (but the LRI will never take place). Just in case we immediately reload the same context, mark this engine as dirty so that we force the LRI to reload the PD. Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: Mika Kuoppala Cc: Matthew Auld --- drivers/gpu/drm/i915/intel_ringbuffer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index fb8d6217b03c..991187e1864a 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -1598,6 +1598,7 @@ static int switch_context(struct i915_request *rq) to_gen6_ppgtt(to_ctx->ppgtt ?: rq->i915->mm.aliasing_ppgtt); struct i915_gem_context *from_ctx = engine->legacy_active_context; struct gen6_hw_ppgtt *from_mm = engine->legacy_active_ppgtt; + unsigned int unwind_mm = 0; u32 hw_flags = 0; int ret, i; @@ -1611,8 +1612,13 @@ static int switch_context(struct i915_request *rq) if (ret) goto err; - to_mm->base.pd_dirty_rings &= ~intel_engine_flag(engine); + if (to_mm->base.pd_dirty_rings & intel_engine_flag(engine)) { + unwind_mm = intel_engine_flag(engine); + to_mm->base.pd_dirty_rings &= ~unwind_mm; + } + engine->legacy_active_ppgtt = to_mm; + hw_flags = MI_FORCE_RESTORE; } @@ -1655,6 +1661,8 @@ static int switch_context(struct i915_request *rq) err_ctx: engine->legacy_active_context = from_ctx; err_mm: + if (unwind_mm) + to_mm->base.pd_dirty_rings |= unwind_mm; engine->legacy_active_ppgtt = from_mm; err: return ret;