From patchwork Mon Nov 3 19:18:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bradley.d.volkin@intel.com X-Patchwork-Id: 5219441 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CCDEF9F39B for ; Mon, 3 Nov 2014 19:26:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B9EA20136 for ; Mon, 3 Nov 2014 19:26:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F3AAE2012B for ; Mon, 3 Nov 2014 19:26:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3550A6E388; Mon, 3 Nov 2014 11:26:32 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F9506E388 for ; Mon, 3 Nov 2014 11:26:30 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 03 Nov 2014 11:26:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,308,1413270000"; d="scan'208";a="625714015" Received: from bdvolkin-cube.ra.intel.com (HELO bdvolkin-ubuntu-desktop.ra.intel.com) ([10.10.34.148]) by fmsmga002.fm.intel.com with ESMTP; 03 Nov 2014 11:18:19 -0800 From: bradley.d.volkin@intel.com To: intel-gfx@lists.freedesktop.org Date: Mon, 3 Nov 2014 11:18:59 -0800 Message-Id: <1415042340-26404-1-git-send-email-bradley.d.volkin@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH 1/2] tests/gem_exec_parse: fix batch_len setting for cmd-crossing-page X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Brad Volkin The size of the batch buffer passed to the kernel is significantly larger than the size of the batch buffer passed to the function. A proposed optimization as part of the batch copy kernel series is to use batch_len for the copy and parse operations, which leads to a false "batch without MI_BATCH_BUFFER_END" failure for this test. To fix this, modify the test to set batch_start_offset and batch_len such that they define the range of actual commands in the batch, including a few of the surrounding nops for alignment purposes. v2: update batch_start_offset as well Signed-off-by: Brad Volkin --- tests/gem_exec_parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/gem_exec_parse.c b/tests/gem_exec_parse.c index 1dc9103..e48b83a 100644 --- a/tests/gem_exec_parse.c +++ b/tests/gem_exec_parse.c @@ -144,16 +144,18 @@ static void exec_split_batch(int fd, uint32_t *cmds, struct drm_i915_gem_exec_object2 objs[1]; uint32_t cmd_bo; uint32_t noop[1024] = { 0 }; + const int alloc_size = 4096 * 2; + const int actual_start_offset = 4096-sizeof(uint32_t); // Allocate and fill a 2-page batch with noops - cmd_bo = gem_create(fd, 4096 * 2); + cmd_bo = gem_create(fd, alloc_size); gem_write(fd, cmd_bo, 0, noop, sizeof(noop)); gem_write(fd, cmd_bo, 4096, noop, sizeof(noop)); // Write the provided commands such that the first dword // of the command buffer is the last dword of the first // page (i.e. the command is split across the two pages). - gem_write(fd, cmd_bo, 4096-sizeof(uint32_t), cmds, size); + gem_write(fd, cmd_bo, actual_start_offset, cmds, size); objs[0].handle = cmd_bo; objs[0].relocation_count = 0; @@ -166,8 +168,14 @@ static void exec_split_batch(int fd, uint32_t *cmds, execbuf.buffers_ptr = (uintptr_t)objs; execbuf.buffer_count = 1; - execbuf.batch_start_offset = 0; - execbuf.batch_len = size; + // NB: We want batch_start_offset and batch_len to point to the block + // of the actual commands (i.e. at the last dword of the first page), + // but have to adjust both the start offset and length to meet the + // kernel driver's requirements on the alignment of those fields. + execbuf.batch_start_offset = actual_start_offset & ~0x7; + execbuf.batch_len = + ALIGN(size + actual_start_offset - execbuf.batch_start_offset, + 0x8); execbuf.cliprects_ptr = 0; execbuf.num_cliprects = 0; execbuf.DR1 = 0;