From patchwork Thu Nov 15 07:58:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 1747411 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 E0CD4DF2AB for ; Thu, 15 Nov 2012 08:05:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB0FC9E7FA for ; Thu, 15 Nov 2012 00:05:24 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B5C09E759 for ; Thu, 15 Nov 2012 00:05:12 -0800 (PST) Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 15 Nov 2012 00:05:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,255,1352102400"; d="scan'208";a="168644400" Received: from xhh-hsw32.sh.intel.com ([10.239.36.99]) by AZSMGA002.ch.intel.com with ESMTP; 15 Nov 2012 00:05:10 -0800 From: "Xiang, Haihao" To: intel-gfx@lists.freedesktop.org Date: Thu, 15 Nov 2012 15:58:09 +0800 Message-Id: <1352966290-25762-1-git-send-email-haihao.xiang@intel.com> X-Mailer: git-send-email 1.7.9.5 Subject: [Intel-gfx] [PATCH 1/2] gem_ring_sync_loop: check the rings supported by the kernel 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 From: "Xiang, Haihao" Signed-off-by: Xiang, Haihao --- tests/gem_ring_sync_loop.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/tests/gem_ring_sync_loop.c b/tests/gem_ring_sync_loop.c index b689bcd..2875cf3 100644 --- a/tests/gem_ring_sync_loop.c +++ b/tests/gem_ring_sync_loop.c @@ -55,15 +55,46 @@ static drm_intel_bo *target_buffer; #define MI_COND_BATCH_BUFFER_END (0x36<<23 | 1) #define MI_DO_COMPARE (1<<21) +static int +get_num_rings(int fd) +{ + int num_rings = 1; /* render ring is always available */ + drm_i915_getparam_t gp; + int ret, tmp; + + memset(&gp, 0, sizeof(gp)); + gp.value = &tmp; + + gp.param = I915_PARAM_HAS_BSD; + ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); + + if ((ret == 0) & (*gp.value > 0)) + num_rings++; + else + goto skip; + + gp.param = I915_PARAM_HAS_BLT; + ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); + + if ((ret == 0) & (*gp.value > 0)) + num_rings++; + else + goto skip; + +skip: + return num_rings; +} + static void -store_dword_loop(void) +store_dword_loop(int fd) { int i; + int num_rings = get_num_rings(fd); srandom(0xdeadbeef); for (i = 0; i < 0x100000; i++) { - int ring = random() % 3 + 1; + int ring = random() % num_rings + 1; if (ring == I915_EXEC_RENDER) { BEGIN_BATCH(4); @@ -127,7 +158,7 @@ int main(int argc, char **argv) exit(-1); } - store_dword_loop(); + store_dword_loop(fd); drm_intel_bo_unreference(target_buffer); intel_batchbuffer_free(batch);