From patchwork Wed Aug 22 13:27:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 10572955 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 478BA13B6 for ; Wed, 22 Aug 2018 13:28:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36FE62B3B2 for ; Wed, 22 Aug 2018 13:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 267A02B3BB; Wed, 22 Aug 2018 13:28:28 +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 D6D402B3B2 for ; Wed, 22 Aug 2018 13:28:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54A2B6E0C9; Wed, 22 Aug 2018 13:28:27 +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 C150A6E0C9 for ; Wed, 22 Aug 2018 13:28:25 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2018 06:28:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,274,1531810800"; d="scan'208";a="77436609" Received: from rosetta.fi.intel.com ([10.237.72.186]) by orsmga003.jf.intel.com with ESMTP; 22 Aug 2018 06:28:22 -0700 Received: by rosetta.fi.intel.com (Postfix, from userid 1000) id DDD99840480; Wed, 22 Aug 2018 16:27:14 +0300 (EEST) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Wed, 22 Aug 2018 16:27:14 +0300 Message-Id: <20180822132714.1240-1-mika.kuoppala@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822132428.24926-1-mika.kuoppala@linux.intel.com> References: <20180822132428.24926-1-mika.kuoppala@linux.intel.com> Subject: [Intel-gfx] [PATCH] drm/i915/gtt: Setup guards in scratch page 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: Matthew Auld MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP There have been cases where GPU engine has managed to run past execbuffer ending due to reasons unknown at that time: coherency problems, page table setup errors, hw glitches. Let's try to contain a wild engine head by putting batch buffer end commands into start and end of scratch page. v2: add more signature Cc: Chris Wilson Cc: Matthew Auld Signed-off-by: Mika Kuoppala --- drivers/gpu/drm/i915/i915_gem_gtt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 4137af4bd8f5..3c617874ee7c 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -617,6 +617,24 @@ static void fill_page_dma_32(struct i915_address_space *vm, fill_page_dma(vm, p, (u64)v << 32 | v); } +static void setup_scratch_page_guards(struct i915_address_space *vm) +{ + struct i915_page_dma const *p = &vm->scratch_page; + u32 *scratch; + const unsigned int size = BIT(p->order) << PAGE_SHIFT; + const unsigned int last_idx = size / sizeof(*scratch) - 1; + + scratch = kmap_atomic(p->page); + + scratch[0] = MI_BATCH_BUFFER_END; + scratch[1] = MI_BATCH_BUFFER_END; + + scratch[last_idx - 1] = MI_BATCH_BUFFER_END; + scratch[last_idx] = MI_BATCH_BUFFER_END; + + kunmap_atomic(scratch); +} + static int setup_scratch_page(struct i915_address_space *vm, gfp_t gfp) { @@ -665,6 +683,9 @@ setup_scratch_page(struct i915_address_space *vm, gfp_t gfp) vm->scratch_page.page = page; vm->scratch_page.daddr = addr; vm->scratch_page.order = order; + + setup_scratch_page_guards(vm); + return 0; unmap_page: