From patchwork Thu Apr 11 17:43:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 2429791 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id D9C2FDF230 for ; Thu, 11 Apr 2013 17:45:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCE25E666E for ; Thu, 11 Apr 2013 10:45:16 -0700 (PDT) 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 ESMTP id 12C3CE6666 for ; Thu, 11 Apr 2013 10:43:47 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 11 Apr 2013 10:41:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,456,1363158000"; d="scan'208";a="316749203" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.168]) by orsmga002.jf.intel.com with SMTP; 11 Apr 2013 10:43:41 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 11 Apr 2013 20:43:40 +0300 From: ville.syrjala@linux.intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 11 Apr 2013 20:43:40 +0300 Message-Id: <1365702220-20155-1-git-send-email-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <20130409130500.GM3792@cantiga.alporthouse.com> References: <20130409130500.GM3792@cantiga.alporthouse.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] tests/gem_fenced_exec_thrash: Test with > max fences 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: , 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 From: Ville Syrjälä Make sure the kernel returns EDEADLK when the number of fences is exceeded for gen2-3. For gen4+ the test makes sure the kernel ignores the EXEC_OBJECT_NEEDS_FENCE flag. Note that I changed the code not to round the num_fences to an even number. Not sure why that was there, and if there's a reason for it, we need to add it back. Signed-off-by: Ville Syrjälä --- tests/gem_fenced_exec_thrash.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/tests/gem_fenced_exec_thrash.c b/tests/gem_fenced_exec_thrash.c index ca88c53..c8a2c58 100644 --- a/tests/gem_fenced_exec_thrash.c +++ b/tests/gem_fenced_exec_thrash.c @@ -38,6 +38,7 @@ #include #include "drmtest.h" +#include "intel_gpu_tools.h" #define WIDTH 1024 #define HEIGHT 1024 @@ -47,8 +48,6 @@ #define MAX_FENCES 32 -#define MI_BATCH_BUFFER_END (0xA<<23) - /* * Testcase: execbuf fence accounting * @@ -95,7 +94,7 @@ static int get_num_fences(int fd) printf ("total %d fences\n", val); assert(val > 4); - return val - 2; + return val; } static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t handle) @@ -106,23 +105,19 @@ static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t han reloc->write_domain = 0; } -int -main(int argc, char **argv) +static void run_test(int fd, int num_fences, int expected_errno) { struct drm_i915_gem_execbuffer2 execbuf[2]; - struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+1]; - struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES]; + struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+3]; + struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES+2]; - int fd = drm_open_any(); - int i, n, num_fences; + int i, n; int loop = 1000; memset(execbuf, 0, sizeof(execbuf)); memset(exec, 0, sizeof(exec)); memset(reloc, 0, sizeof(reloc)); - num_fences = get_num_fences(fd) & ~1; - assert(num_fences <= MAX_FENCES); for (n = 0; n < 2*num_fences; n++) { uint32_t handle = tiled_bo_create(fd); exec[1][2*num_fences - n-1].handle = exec[0][n].handle = handle; @@ -148,13 +143,30 @@ main(int argc, char **argv) ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf[0]); - assert(ret == 0); + assert(expected_errno ? + ret < 0 && errno == expected_errno : + ret == 0); ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf[1]); - assert(ret == 0); + assert(expected_errno ? + ret < 0 && errno == expected_errno : + ret == 0); } while (--loop); +} + +int +main(int argc, char **argv) +{ + int fd = drm_open_any(); + int num_fences = get_num_fences(fd); + uint32_t devid = intel_get_drm_devid(fd); + + assert(num_fences <= MAX_FENCES); + + run_test(fd, num_fences - 2, 0); + run_test(fd, num_fences + 1, intel_gen(devid) >= 4 ? 0 : EDEADLK); close(fd);