From patchwork Fri Mar 16 18:31:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jeff.mcgee@intel.com X-Patchwork-Id: 10289839 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 8E82D601BE for ; Fri, 16 Mar 2018 18:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F81628FEE for ; Fri, 16 Mar 2018 18:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7419D29075; Fri, 16 Mar 2018 18:45:49 +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=-4.2 required=2.0 tests=BAYES_00, 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 23BD528FEE for ; Fri, 16 Mar 2018 18:45:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 455986EBDF; Fri, 16 Mar 2018 18:45:48 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id C13896E03C for ; Fri, 16 Mar 2018 18:45:41 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2018 11:45:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,317,1517904000"; d="scan'208";a="25143767" Received: from jeffdesk.fm.intel.com ([10.1.27.184]) by fmsmga008.fm.intel.com with ESMTP; 16 Mar 2018 11:45:40 -0700 From: jeff.mcgee@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 16 Mar 2018 11:31:03 -0700 Message-Id: <20180316183105.16027-7-jeff.mcgee@intel.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316183105.16027-1-jeff.mcgee@intel.com> References: <20180316183105.16027-1-jeff.mcgee@intel.com> Subject: [Intel-gfx] [RFC 6/8] drm/i915: Repair the preemption context if hit by reset 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: , Cc: ben@bwidawsk.net, kalyan.kondapally@intel.com MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff McGee It is possible for the preemption context to be active on an engine when the engine is reset. The preemption context is not tracked via the request mechanism, so the normal reset handling will not detect this scenario and will not be able to fixup possible context corruption. So add some extra logic to do this. This patch is required to support the force preemption feature. Test: Run IGT gem_exec_fpreempt repeatedly. Change-Id: Ifd0f17726111f3b702dd900064b7f375bbb42808 Signed-off-by: Jeff McGee --- drivers/gpu/drm/i915/intel_lrc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index b2f838c484b0..581483886153 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -1619,6 +1619,25 @@ static void reset_common_ring(struct intel_engine_cs *engine, spin_unlock_irqrestore(&engine->timeline->lock, flags); + /* If a preemption was pending when the reset occurred, and no + * active request was found when the reset completed, it is + * possible that the preemption context was hit by the reset. + * We must assume that the context is corrupted so repair it. + */ + if (execlists_is_active(execlists, EXECLISTS_ACTIVE_PREEMPT) && + !request) { + struct i915_gem_context *ctx = engine->i915->preempt_context; + ce = &ctx->engine[engine->id]; + + execlists_init_reg_state(ce->lrc_reg_state, + ctx, engine, ce->ring); + ce->lrc_reg_state[CTX_RING_BUFFER_START+1] = + i915_ggtt_offset(ce->ring->vma); + ce->lrc_reg_state[CTX_RING_HEAD+1] = ce->ring->tail; + + return; + } + /* If the request was innocent, we leave the request in the ELSP * and will try to replay it on restarting. The context image may * have been corrupted by the reset, in which case we may have