From patchwork Fri Jul 19 05:53:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Xiong Y" X-Patchwork-Id: 2830243 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 40F089F4D4 for ; Fri, 19 Jul 2013 05:52:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D54DE203E3 for ; Fri, 19 Jul 2013 05:52:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 76D4D203F1 for ; Fri, 19 Jul 2013 05:52:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 95140E6C01 for ; Thu, 18 Jul 2013 22:52:56 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id DC425E68C9 for ; Thu, 18 Jul 2013 22:50:19 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 18 Jul 2013 22:50:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,699,1367996400"; d="scan'208";a="372978997" Received: from panda-dev.bj.intel.com ([10.238.154.175]) by orsmga002.jf.intel.com with ESMTP; 18 Jul 2013 22:49:51 -0700 From: Xiong Zhang To: intel-gfx@lists.freedesktop.org Date: Fri, 19 Jul 2013 13:53:09 +0800 Message-Id: <1374213192-2456-2-git-send-email-xiong.y.zhang@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374213192-2456-1-git-send-email-xiong.y.zhang@intel.com> References: <1374213192-2456-1-git-send-email-xiong.y.zhang@intel.com> Subject: [Intel-gfx] [PATCH 2/5] lib/drmtest: move gem_linear_blt() to drm_test.c X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.6 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 Several test functions will call gem_linear_blt(), so move this function to drm_test.c. Signed-off-by: Xiong Zhang --- lib/drmtest.c | 75 ++++++++++++++++++++++++++++++++++++ lib/drmtest.h | 5 +++ tests/gem_exec_blt.c | 84 +---------------------------------------- tests/gem_exec_faulting_reloc.c | 84 +---------------------------------------- tests/gem_pin.c | 51 ++----------------------- 5 files changed, 88 insertions(+), 211 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index 713c5ff..7f79fd3 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -554,6 +554,81 @@ int gem_madvise(int fd, uint32_t handle, int state) return madv.retained; } + +int gem_linear_blt(uint32_t *batch, + uint32_t src, + uint32_t dst, + uint32_t length, + struct drm_i915_gem_relocation_entry *reloc) +{ + uint32_t *b = batch; + int height = length / (16 * 1024); + + assert(height <= 1<<16); + + if (height) { + b[0] = XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | XY_SRC_COPY_BLT_WRITE_RGB; + b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); + b[2] = 0; + b[3] = height << 16 | (4*1024); + b[4] = 0; + reloc->offset = (b-batch+4) * sizeof(uint32_t); + reloc->delta = 0; + reloc->target_handle = dst; + reloc->read_domains = I915_GEM_DOMAIN_RENDER; + reloc->write_domain = I915_GEM_DOMAIN_RENDER; + reloc->presumed_offset = 0; + reloc++; + + b[5] = 0; + b[6] = 16*1024; + b[7] = 0; + reloc->offset = (b-batch+7) * sizeof(uint32_t); + reloc->delta = 0; + reloc->target_handle = src; + reloc->read_domains = I915_GEM_DOMAIN_RENDER; + reloc->write_domain = 0; + reloc->presumed_offset = 0; + reloc++; + + b += 8; + length -= height * 16*1024; + } + + if (length) { + b[0] = XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | XY_SRC_COPY_BLT_WRITE_RGB; + b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); + b[2] = height << 16; + b[3] = (1+height) << 16 | (length / 4); + b[4] = 0; + reloc->offset = (b-batch+4) * sizeof(uint32_t); + reloc->delta = 0; + reloc->target_handle = dst; + reloc->read_domains = I915_GEM_DOMAIN_RENDER; + reloc->write_domain = I915_GEM_DOMAIN_RENDER; + reloc->presumed_offset = 0; + reloc++; + + b[5] = height << 16; + b[6] = 16*1024; + b[7] = 0; + reloc->offset = (b-batch+7) * sizeof(uint32_t); + reloc->delta = 0; + reloc->target_handle = src; + reloc->read_domains = I915_GEM_DOMAIN_RENDER; + reloc->write_domain = 0; + reloc->presumed_offset = 0; + reloc++; + + b += 8; + } + + b[0] = MI_BATCH_BUFFER_END; + b[1] = 0; + + return (b+2 - batch) * sizeof(uint32_t); +} + /* prime */ int prime_handle_to_fd(int fd, uint32_t handle) { diff --git a/lib/drmtest.h b/lib/drmtest.h index 80b344c..c179aed 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -36,6 +36,7 @@ #include "xf86drm.h" #include "xf86drmMode.h" #include "intel_batchbuffer.h" +#include "i915_drm.h" drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd, const char *name, uint32_t handle); @@ -72,6 +73,10 @@ uint64_t gem_aperture_size(int fd); uint64_t gem_mappable_aperture_size(void); int gem_madvise(int fd, uint32_t handle, int state); +int gem_linear_blt(uint32_t *batch, uint32_t src, + uint32_t dst, uint32_t length, + struct drm_i915_gem_relocation_entry *reloc); + /* feature test helpers */ bool gem_uses_aliasing_ppgtt(int fd); int gem_available_fences(int fd); diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c index eb5ae66..6a0f863 100644 --- a/tests/gem_exec_blt.c +++ b/tests/gem_exec_blt.c @@ -46,94 +46,14 @@ #define OBJECT_SIZE 16384 -#define COPY_BLT_CMD (2<<29|0x53<<22|0x6) -#define BLT_WRITE_ALPHA (1<<21) -#define BLT_WRITE_RGB (1<<20) -#define BLT_SRC_TILED (1<<15) -#define BLT_DST_TILED (1<<11) - -static int gem_linear_blt(uint32_t *batch, - uint32_t src, - uint32_t dst, - uint32_t length, - struct drm_i915_gem_relocation_entry *reloc) -{ - uint32_t *b = batch; - int height = length / (16 * 1024); - - assert(height <= 1<<16); - - if (height) { - b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; - b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); - b[2] = 0; - b[3] = height << 16 | (4*1024); - b[4] = 0; - reloc->offset = (b-batch+4) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = dst; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = I915_GEM_DOMAIN_RENDER; - reloc->presumed_offset = 0; - reloc++; - - b[5] = 0; - b[6] = 16*1024; - b[7] = 0; - reloc->offset = (b-batch+7) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = src; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = 0; - reloc->presumed_offset = 0; - reloc++; - - b += 8; - length -= height * 16*1024; - } - - if (length) { - b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; - b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); - b[2] = height << 16; - b[3] = (1+height) << 16 | (length / 4); - b[4] = 0; - reloc->offset = (b-batch+4) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = dst; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = I915_GEM_DOMAIN_RENDER; - reloc->presumed_offset = 0; - reloc++; - - b[5] = height << 16; - b[6] = 16*1024; - b[7] = 0; - reloc->offset = (b-batch+7) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = src; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = 0; - reloc->presumed_offset = 0; - reloc++; - - b += 8; - } - - b[0] = MI_BATCH_BUFFER_END; - b[1] = 0; - - return (b+2 - batch) * sizeof(uint32_t); -} - static int gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf, int loops) { int ret = 0; while (loops-- && ret == 0) { ret = drmIoctl(fd, - DRM_IOCTL_I915_GEM_EXECBUFFER2, - execbuf); + DRM_IOCTL_I915_GEM_EXECBUFFER2, + execbuf); } return ret; diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c index 863a1b0..2aef6ba 100644 --- a/tests/gem_exec_faulting_reloc.c +++ b/tests/gem_exec_faulting_reloc.c @@ -51,93 +51,13 @@ #define OBJECT_SIZE 16384 -#define COPY_BLT_CMD (2<<29|0x53<<22|0x6) -#define BLT_WRITE_ALPHA (1<<21) -#define BLT_WRITE_RGB (1<<20) -#define BLT_SRC_TILED (1<<15) -#define BLT_DST_TILED (1<<11) - -static int gem_linear_blt(uint32_t *batch, - uint32_t src, - uint32_t dst, - uint32_t length, - struct drm_i915_gem_relocation_entry *reloc) -{ - uint32_t *b = batch; - int height = length / (16 * 1024); - - assert(height <= 1<<16); - - if (height) { - b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; - b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); - b[2] = 0; - b[3] = height << 16 | (4*1024); - b[4] = 0; - reloc->offset = (b-batch+4) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = dst; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = I915_GEM_DOMAIN_RENDER; - reloc->presumed_offset = 0; - reloc++; - - b[5] = 0; - b[6] = 16*1024; - b[7] = 0; - reloc->offset = (b-batch+7) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = src; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = 0; - reloc->presumed_offset = 0; - reloc++; - - b += 8; - length -= height * 16*1024; - } - - if (length) { - b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; - b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); - b[2] = height << 16; - b[3] = (1+height) << 16 | (length / 4); - b[4] = 0; - reloc->offset = (b-batch+4) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = dst; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = I915_GEM_DOMAIN_RENDER; - reloc->presumed_offset = 0; - reloc++; - - b[5] = height << 16; - b[6] = 16*1024; - b[7] = 0; - reloc->offset = (b-batch+7) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = src; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = 0; - reloc->presumed_offset = 0; - reloc++; - - b += 8; - } - - b[0] = MI_BATCH_BUFFER_END; - b[1] = 0; - - return (b+2 - batch) * sizeof(uint32_t); -} - static void gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf) { int ret; ret = drmIoctl(fd, - DRM_IOCTL_I915_GEM_EXECBUFFER2, - execbuf); + DRM_IOCTL_I915_GEM_EXECBUFFER2, + execbuf); assert(ret == 0); } diff --git a/tests/gem_pin.c b/tests/gem_pin.c index edf5e60..cd19216 100644 --- a/tests/gem_pin.c +++ b/tests/gem_pin.c @@ -42,10 +42,6 @@ #include "intel_chipset.h" #include "intel_gpu_tools.h" -#define COPY_BLT_CMD (2<<29|0x53<<22|0x6) -#define BLT_WRITE_ALPHA (1<<21) -#define BLT_WRITE_RGB (1<<20) - static void exec(int fd, uint32_t handle, uint32_t offset) { struct drm_i915_gem_execbuffer2 execbuf; @@ -84,46 +80,6 @@ static void exec(int fd, uint32_t handle, uint32_t offset) assert(gem_exec[0].offset == offset); } -static int gem_linear_blt(uint32_t *batch, - uint32_t src, - uint32_t dst, - uint32_t length, - struct drm_i915_gem_relocation_entry *reloc) -{ - uint32_t *b = batch; - - b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; - b[1] = 0x66 << 16 | 1 << 25 | 1 << 24 | (4*1024); - b[2] = 0; - b[3] = (length / (4*1024)) << 16 | 1024; - b[4] = 0; - reloc->offset = (b-batch+4) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = dst; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = I915_GEM_DOMAIN_RENDER; - reloc->presumed_offset = 0; - reloc++; - - b[5] = 0; - b[6] = 4*1024; - b[7] = 0; - reloc->offset = (b-batch+7) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = src; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = 0; - reloc->presumed_offset = 0; - reloc++; - - b += 8; - - b[0] = MI_BATCH_BUFFER_END; - b[1] = 0; - - return (b+2 - batch) * sizeof(uint32_t); -} - static void make_busy(int fd, uint32_t handle) { struct drm_i915_gem_execbuffer2 execbuf; @@ -131,9 +87,10 @@ static void make_busy(int fd, uint32_t handle) struct drm_i915_gem_relocation_entry reloc[2]; uint32_t batch[20]; uint32_t tmp; - int count; + int count, len; tmp = gem_create(fd, 1024*1024); + len = gem_linear_blt(batch, tmp, tmp, 1024*1024, reloc); obj[0].handle = tmp; obj[0].relocation_count = 0; @@ -145,7 +102,7 @@ static void make_busy(int fd, uint32_t handle) obj[0].rsvd2 = 0; obj[1].handle = handle; - obj[1].relocation_count = 2; + obj[1].relocation_count = len > 40 ? 4 : 2; obj[1].relocs_ptr = (uintptr_t) reloc; obj[1].alignment = 0; obj[1].offset = 0; @@ -156,7 +113,7 @@ static void make_busy(int fd, uint32_t handle) execbuf.buffers_ptr = (uintptr_t)obj; execbuf.buffer_count = 2; execbuf.batch_start_offset = 0; - execbuf.batch_len = gem_linear_blt(batch, tmp, tmp, 1024*1024,reloc); + execbuf.batch_len = len; execbuf.cliprects_ptr = 0; execbuf.num_cliprects = 0; execbuf.DR1 = 0;