From patchwork Thu Oct 15 08:05:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Derek Morton X-Patchwork-Id: 7403731 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2106ABEEA4 for ; Thu, 15 Oct 2015 08:05:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B454205B6 for ; Thu, 15 Oct 2015 08:05:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A18A6205EF for ; Thu, 15 Oct 2015 08:05:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 759076E04F; Thu, 15 Oct 2015 01:05:52 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id EFD7D6E04F for ; Thu, 15 Oct 2015 01:05:50 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 15 Oct 2015 01:05:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,684,1437462000"; d="scan'208";a="793381986" Received: from djmorton-linux2.isw.intel.com ([10.102.226.90]) by orsmga001.jf.intel.com with ESMTP; 15 Oct 2015 01:05:48 -0700 From: Derek Morton To: intel-gfx@lists.freedesktop.org Date: Thu, 15 Oct 2015 09:05:44 +0100 Message-Id: <1444896344-34927-1-git-send-email-derek.j.morton@intel.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Cc: thomas.wood@intel.com Subject: [Intel-gfx] [PATCH i-g-t] tests: Add gem_exec_nop_concurrent test 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 This test is based on gem_exec_nop but submits nop batch buffers concurrently from different threads to check for ring hangs and other issues during concurrent submissions. Signed-off-by: Derek Morton --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/gem_exec_nop_concurrent.c | 172 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 tests/gem_exec_nop_concurrent.c diff --git a/tests/.gitignore b/tests/.gitignore index dc8bb53..0ad36f3 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -46,6 +46,7 @@ gem_exec_blt gem_exec_faulting_reloc gem_exec_lut_handle gem_exec_nop +gem_exec_nop_concurrent gem_exec_params gem_exec_parse gem_fd_exhaustion diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 2e2e088..aece831 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -27,6 +27,7 @@ TESTS_progs_M = \ gem_exec_bad_domains \ gem_exec_faulting_reloc \ gem_exec_nop \ + gem_exec_nop_concurrent \ gem_exec_params \ gem_exec_parse \ gem_fenced_exec_thrash \ diff --git a/tests/gem_exec_nop_concurrent.c b/tests/gem_exec_nop_concurrent.c new file mode 100644 index 0000000..578f651 --- /dev/null +++ b/tests/gem_exec_nop_concurrent.c @@ -0,0 +1,172 @@ +/* + * Copyright © 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Derek Morton + * + * This test is based on gem_exec_nop but submits nop batch buffers concurrently + * from different threads to check for ring hangs and other issues during + * concurrent submissions. + * + */ + +#include "igt.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "drm.h" + +#define LOCAL_I915_EXEC_NO_RELOC (1<<11) +#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) + +#define LOCAL_I915_EXEC_VEBOX (4<<0) + +IGT_TEST_DESCRIPTION( + "This Test will submit nop batch buffers concurrently to the same ring " + "and different rings in an attempt to trigger ring hangs."); + +const uint32_t batch[2] = {MI_BATCH_BUFFER_END}; + +struct ring +{ + unsigned ring_id; + const char *ring_name; + bool direction; +}; + +static void loop(int fd, uint32_t handle, int child_nbr, struct ring* ring, bool up) +{ + struct drm_i915_gem_execbuffer2 execbuf; + struct drm_i915_gem_exec_object2 gem_exec[1]; + int count; + int max_count = SLOW_QUICK(15, 4); + + gem_require_ring(fd, ring->ring_id); + + memset(&gem_exec, 0, sizeof(gem_exec)); + gem_exec[0].handle = handle; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)gem_exec; + execbuf.buffer_count = 1; + execbuf.flags = ring->ring_id; + execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; + execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf)) { + execbuf.flags = ring->ring_id; + do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf); + } + gem_sync(fd, handle); + + for (count = 0; count <= max_count; count++) { + const int reps = 7; + int n, nbr_loops; + + if (up) + nbr_loops = 1 << count; + else + nbr_loops = 1 << (max_count - count); + + igt_info("Thread %d: starting submitting batches of %d batch buffers (ring=%s)\n", + child_nbr, nbr_loops, ring->ring_name); + fflush(stdout); + + for (n = 0; n < reps; n++) { + int loops = nbr_loops; + + while (loops--) + do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf); + gem_sync(fd, handle); + } + + igt_info("Thread %d: finished submitting batches of %d batch buffers (ring=%s)\n", + child_nbr, nbr_loops, ring->ring_name); + fflush(stdout); + } +} + +static void run_forked(struct ring rings[]) +{ + int nbr_rings = 0; + while (rings[nbr_rings].ring_name != NULL) + nbr_rings++; + + igt_fork(child, nbr_rings) { + int fd; + uint32_t handle; + + fd = drm_open_driver(DRIVER_INTEL); + + handle = gem_create(fd, 4096); + gem_write(fd, handle, 0, batch, sizeof(batch)); + + igt_info("Starting thread %d on ring %s\n", child, rings[child].ring_name); + fflush(stdout); + loop(fd, handle, child, &rings[child], rings[child].direction); + + gem_close(fd, handle); + + close(fd); + } + igt_waitchildren(); +} + +igt_main +{ + struct ring all_rings[] = { + {I915_EXEC_RENDER, "render", 1}, + {I915_EXEC_BSD, "bsd", 1}, + {I915_EXEC_BLT, "blt", 1}, + {LOCAL_I915_EXEC_VEBOX, "vebox", 1}, + { 0, NULL, 0 }, + }, + rings[] = { + { 0, NULL, 1 }, + { 0, NULL, 0 }, + { 0, NULL, 0 }, + }, *t1, *t2; + + for (t1 = all_rings; t1->ring_name; t1++) { + rings[0].ring_id = t1->ring_id; + rings[0].ring_name = t1->ring_name; + + for (t2 = all_rings; t2->ring_name; t2++) { + rings[1].ring_id = t2->ring_id; + rings[1].ring_name = t2->ring_name; + + igt_subtest_f("%s-%s",t1->ring_name, t2->ring_name) + run_forked(rings); + } + } + igt_subtest("all-rings") + run_forked(all_rings); + +}