From patchwork Thu Jun 7 09:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10451555 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 3FCA96037F for ; Thu, 7 Jun 2018 09:59:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 313212994A for ; Thu, 7 Jun 2018 09:59:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25C2929B6B; Thu, 7 Jun 2018 09:59:19 +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 D5B8C2994A for ; Thu, 7 Jun 2018 09:59:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 576906F1F5; Thu, 7 Jun 2018 09:59:18 +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 628536F1F2 for ; Thu, 7 Jun 2018 09:59:14 +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 11970949-1500050 for multiple; Thu, 07 Jun 2018 10:58:27 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Thu, 07 Jun 2018 10:58:26 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Jun 2018 10:57:59 +0100 Message-Id: <20180607095815.10938-5-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607095815.10938-1-chris@chris-wilson.co.uk> References: <20180607095815.10938-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 04/20] 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 3df802cc3710..93b5f4a8316d 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -1591,6 +1591,7 @@ static int switch_context(struct i915_request *rq) to_ctx->ppgtt ?: rq->i915->mm.aliasing_ppgtt; struct i915_gem_context *from_ctx = engine->legacy_active_context; struct i915_hw_ppgtt *from_mm = engine->legacy_active_ppgtt; + unsigned int unwind_mm = 0; u32 hw_flags = 0; int ret, i; @@ -1604,7 +1605,11 @@ static int switch_context(struct i915_request *rq) if (ret) goto err; - to_mm->pd_dirty_rings &= ~intel_engine_flag(engine); + if (to_mm->pd_dirty_rings & intel_engine_flag(engine)) { + unwind_mm = intel_engine_flag(engine); + to_mm->pd_dirty_rings &= ~unwind_mm; + } + engine->legacy_active_ppgtt = to_mm; if (to_ctx == from_ctx) { @@ -1651,6 +1656,8 @@ static int switch_context(struct i915_request *rq) err_ctx: engine->legacy_active_context = from_ctx; err_mm: + if (unwind_mm) + to_mm->pd_dirty_rings |= unwind_mm; engine->legacy_active_ppgtt = from_mm; err: return ret;