[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

intel-gpu-tools: Changes to 'debian-unstable'



 COPYING                                                 |   20 
 MAINTAINERS                                             |    2 
 Makefile.am                                             |   10 
 NEWS                                                    |   42 
 README                                                  |    7 
 benchmarks/.gitignore                                   |    2 
 benchmarks/Makefile.am                                  |    4 
 benchmarks/Makefile.sources                             |    2 
 benchmarks/gem_blt.c                                    |   81 -
 benchmarks/gem_create.c                                 |    9 
 benchmarks/gem_exec_ctx.c                               |  111 -
 benchmarks/gem_exec_nop.c                               |   62 
 benchmarks/gem_latency.c                                |  613 +++++++++
 benchmarks/gem_mmap.c                                   |   62 
 benchmarks/gem_userptr_benchmark.c                      |   55 
 benchmarks/gem_wait.c                                   |  303 ----
 configure.ac                                            |   51 
 debian/changelog                                        |    7 
 debian/control                                          |    2 
 docs/reference/intel-gpu-tools/Makefile.am              |    6 
 docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml |    1 
 lib/Makefile.am                                         |    6 
 lib/Makefile.sources                                    |    5 
 lib/drmtest.c                                           |   16 
 lib/drmtest.h                                           |    1 
 lib/igt.h                                               |    1 
 lib/igt_aux.c                                           |   36 
 lib/igt_aux.h                                           |    4 
 lib/igt_core.c                                          |   42 
 lib/igt_core.h                                          |    5 
 lib/igt_debugfs.c                                       |  207 ++-
 lib/igt_debugfs.h                                       |   13 
 lib/igt_draw.c                                          |   16 
 lib/igt_edid_template.h                                 |   74 +
 lib/igt_fb.c                                            |  261 +++-
 lib/igt_fb.h                                            |   15 
 lib/igt_gt.c                                            |  295 ++++
 lib/igt_gt.h                                            |   28 
 lib/igt_kms.c                                           |  199 +--
 lib/igt_kms.h                                           |    4 
 lib/igt_pm.c                                            |  233 +++
 lib/igt_pm.h                                            |   31 
 lib/igt_vc4.c                                           |  129 ++
 lib/igt_vc4.h                                           |   31 
 lib/intel_os.c                                          |   81 -
 lib/ioctl_wrappers.c                                    |  396 +++++-
 lib/ioctl_wrappers.h                                    |   56 
 lib/uwildmat/uwildmat.c                                 |  475 +++++++
 lib/uwildmat/uwildmat.h                                 |   24 
 scripts/list-workarounds                                |   74 -
 tests/.gitignore                                        |  172 --
 tests/Makefile.am                                       |   16 
 tests/Makefile.sources                                  |   19 
 tests/check_drm_clients                                 |    2 
 tests/debugfs_emon_crash                                |    2 
 tests/drm_lib.sh                                        |   29 
 tests/drv_debugfs_reader                                |    2 
 tests/drv_hangman.c                                     |  275 +---
 tests/drv_missed_irq_hang                               |   14 
 tests/drv_module_reload_basic                           |    8 
 tests/eviction_common.c                                 |   57 
 tests/gem_bad_reloc.c                                   |   28 
 tests/gem_busy.c                                        |  248 +++
 tests/gem_concurrent_all.c                              | 1023 +++++++++++-----
 tests/gem_create.c                                      |  166 ++
 tests/gem_cs_prefetch.c                                 |  178 +-
 tests/gem_cs_tlb.c                                      |  160 +-
 tests/gem_ctx_exec.c                                    |    6 
 tests/gem_ctx_thrash.c                                  |  463 ++++---
 tests/gem_eio.c                                         |   41 
 tests/gem_evict_alignment.c                             |   31 
 tests/gem_evict_everything.c                            |   45 
 tests/gem_exec_alignment.c                              |  149 ++
 tests/gem_exec_basic.c                                  |   62 
 tests/gem_exec_nop.c                                    |  167 --
 tests/gem_exec_params.c                                 |   39 
 tests/gem_exec_parse.c                                  |   10 
 tests/gem_exec_reloc.c                                  |  242 +++
 tests/gem_fenced_exec_thrash.c                          |   12 
 tests/gem_flink_race.c                                  |   25 
 tests/gem_gtt_hog.c                                     |    2 
 tests/gem_mmap_gtt.c                                    |   76 +
 tests/gem_mmap_wc.c                                     |   29 
 tests/gem_partial_pwrite_pread.c                        |   78 -
 tests/gem_ppgtt.c                                       |   20 
 tests/gem_pread.c                                       |  108 +
 tests/gem_pread_after_blit.c                            |    4 
 tests/gem_pwrite.c                                      |   59 
 tests/gem_read_read_speed.c                             |   30 
 tests/gem_reloc_vs_gpu.c                                |    8 
 tests/gem_reset_stats.c                                 |  891 ++++---------
 tests/gem_ring_sync_loop.c                              |  107 -
 tests/gem_ringfill.c                                    |  329 ++---
 tests/gem_softpin.c                                     |  488 +++++++
 tests/gem_stolen.c                                      |  360 +++++
 tests/gem_storedw_batches_loop.c                        |    2 
 tests/gem_storedw_loop.c                                |  181 +-
 tests/gem_streaming_writes.c                            |   19 
 tests/gem_sync.c                                        |  187 ++
 tests/gem_userptr_blits.c                               |  185 +-
 tests/gem_wait.c                                        |   36 
 tests/gem_workarounds.c                                 |  119 -
 tests/kms_3d.c                                          |    4 
 tests/kms_atomic.c                                      |   44 
 tests/kms_chv_cursor_fail.c                             |  429 ++++++
 tests/kms_draw_crc.c                                    |    4 
 tests/kms_fbcon_fbt.c                                   |    2 
 tests/kms_flip.c                                        |   26 
 tests/kms_flip_tiling.c                                 |   27 
 tests/kms_force_connector.c                             |  180 --
 tests/kms_force_connector_basic.c                       |  254 +++
 tests/kms_frontbuffer_tracking.c                        |  190 ++
 tests/kms_mmap_write_crc.c                              |  313 ++++
 tests/kms_panel_fitting.c                               |   42 
 tests/kms_pipe_crc_basic.c                              |   34 
 tests/kms_plane_scaling.c                               |   60 
 tests/kms_psr_sink_crc.c                                |   91 -
 tests/kms_pwrite_crc.c                                  |    9 
 tests/kms_render.c                                      |    2 
 tests/kms_rotation_crc.c                                |    2 
 tests/kms_setmode.c                                     |   13 
 tests/kms_sysfs_edid_timing                             |    4 
 tests/pm_lpsp.c                                         |   38 
 tests/pm_rpm.c                                          |  108 -
 tests/pm_rps.c                                          |   14 
 tests/pm_sseu.c                                         |    2 
 tests/prime_mmap.c                                      |  519 ++++++++
 tests/prime_mmap_coherency.c                            |  246 +++
 tests/prime_self_import.c                               |   31 
 tests/sysfs_l3_parity                                   |    6 
 tests/test_rte_check                                    |    2 
 tests/testdisplay.c                                     |   32 
 tests/testdisplay.h                                     |    2 
 tests/testdisplay_hotplug.c                             |    2 
 tests/tools_test                                        |    2 
 tests/vc4_create_bo.c                                   |   89 +
 tests/vc4_wait_bo.c                                     |  123 +
 tests/vc4_wait_seqno.c                                  |   66 +
 tools/.gitignore                                        |    1 
 tools/Android.mk                                        |    6 
 tools/Makefile.sources                                  |    2 
 tools/aubdump.c                                         |   55 
 tools/hsw_compute_wrpll.c                               |    2 
 tools/intel_bios.h                                      |   19 
 tools/intel_bios_reader.c                               |  644 +++++-----
 tools/intel_error_decode.c                              |  209 ++-
 tools/intel_firmware_decode.c                           |    3 
 tools/intel_gpu_top.c                                   |    2 
 tools/intel_opregion_decode.c                           |    6 
 tools/intel_residency.c                                 |  713 +++++++++++
 150 files changed, 11547 insertions(+), 4346 deletions(-)

New commits:
commit 9ce84522c1526e0a6688570675fe994aa8ed071f
Author: Timo Aaltonen <tjaalton@debian.org>
Date:   Thu Mar 10 22:01:30 2016 +0200

    release to unstable

diff --git a/debian/changelog b/debian/changelog
index ef8c60d..569a547 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,9 @@
-intel-gpu-tools (1.14-1) UNRELEASED; urgency=medium
+intel-gpu-tools (1.14-1) unstable; urgency=medium
 
   * New upstream release.
   * control: Add libxv-dev and python-docutils to build-depends.
 
- -- Timo Aaltonen <tjaalton@debian.org>  Thu, 10 Mar 2016 21:27:21 +0200
+ -- Timo Aaltonen <tjaalton@debian.org>  Thu, 10 Mar 2016 22:01:06 +0200
 
 intel-gpu-tools (1.13-1) unstable; urgency=medium
 

commit 08bf6d05557f3a3e5ea5894e30e9716f8d45e354
Author: Timo Aaltonen <tjaalton@debian.org>
Date:   Thu Mar 10 22:01:03 2016 +0200

    control: Add libxv-dev and python-docutils to build-depends.

diff --git a/debian/changelog b/debian/changelog
index 61aeeba..ef8c60d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+intel-gpu-tools (1.14-1) UNRELEASED; urgency=medium
+
+  * New upstream release.
+  * control: Add libxv-dev and python-docutils to build-depends.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Thu, 10 Mar 2016 21:27:21 +0200
+
 intel-gpu-tools (1.13-1) unstable; urgency=medium
 
   * New upstream release.
diff --git a/debian/control b/debian/control
index f02d77e..bda4490 100644
--- a/debian/control
+++ b/debian/control
@@ -18,7 +18,9 @@ Build-Depends:
  libudev-dev,
  libunwind-dev,
  libxrandr-dev,
+ libxv-dev,
  pkg-config,
+ python-docutils,
  quilt,
  x11proto-dri2-dev,
  xutils-dev (>= 1:7.6+6)

commit 1112abe5ece9b2a991c9af2d11b6943784e0e657
Author: Marius Vlad <marius.c.vlad@intel.com>
Date:   Tue Mar 1 18:01:33 2016 +0200

    Bump again to 1.14, as Chris managed to push before I got chance to do a
    release. Modified REAMDE to include link for doing releases.
    
    Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>

diff --git a/README b/README
index c7195d9..d302af3 100644
--- a/README
+++ b/README
@@ -141,3 +141,10 @@ everything (package names may vary):
 	python-docutils
 	x11proto-dri2-dev
 	xutils-dev
+
+Releases for maintainers
+------------------------
+
+(1.14)
+
+http://www.x.org/wiki/Development/Documentation/ReleaseHOWTO/

commit f3751d53bda785810acf85692e809627360252bf
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Mar 1 15:06:43 2016 +0000

    benchmarks/gem_blt: Measure the throughput of synchronous copies
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
index 0d1c54d..cfd3e12 100644
--- a/benchmarks/gem_blt.c
+++ b/benchmarks/gem_blt.c
@@ -178,7 +178,9 @@ static int gem_linear_blt(int fd,
 	return (b+2 - batch) * sizeof(uint32_t);
 }
 
-static int run(int object, int batch, int time, int reps)
+#define SYNC 0x1
+
+static int run(int object, int batch, int time, int reps, unsigned flags)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 exec[3];
@@ -257,6 +259,10 @@ static int run(int object, int batch, int time, int reps)
 
 	/* Guess how many loops we need for 0.1s */
 	count = baseline((uint64_t)object * batch, 100);
+	if (flags & SYNC) {
+		time *= count / 2;
+		count = 1;
+	}
 
 	while (reps--) {
 		double min = HUGE_VAL;
@@ -289,9 +295,10 @@ int main(int argc, char **argv)
 	int reps = 13;
 	int time = 2000;
 	int batch = 1;
+	unsigned flags = 0;
 	int c;
 
-	while ((c = getopt (argc, argv, "s:b:r:t:")) != -1) {
+	while ((c = getopt (argc, argv, "Ss:b:r:t:")) != -1) {
 		switch (c) {
 		case 's':
 			size = atoi(optarg);
@@ -299,6 +306,10 @@ int main(int argc, char **argv)
 				size = 4096;
 			break;
 
+		case 'S':
+			flags |= SYNC;
+			break;
+
 		case 't':
 			time = atoi(optarg);
 			if (time < 1)
@@ -322,5 +333,5 @@ int main(int argc, char **argv)
 		}
 	}
 
-	return run(size, batch, time, reps);
+	return run(size, batch, time, reps, flags);
 }

commit b59bcb811a402c716302f61ca8d4d9af6a967807
Author: Marius Vlad <marius.c.vlad@intel.com>
Date:   Tue Mar 1 17:03:55 2016 +0200

    NEWS: Updates and bump release to 1.14.
    
    Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>

diff --git a/NEWS b/NEWS
index 0ccac8a..a42382f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,45 @@
+Release 1.14 (2016-03-01)
+-------------------------
+
+- New test: gem_create validate parameters for GEM_CREATE ioctl
+(Ankitprasad Sharma)
+
+- New test: gem_softpin exercise the userptr ioctl to create shared
+buffers between CPU and GPU (Vinay Belgaumkar)
+
+- New tests: prime_mmap_coherency/kms_mmap_write_crc cache coherency
+tests (Tiago Vignatti)
+
+- New test: prime_mmap mmap() on dma-buf fds (Rob Bradford)
+
+- New test: gem_exec_reloc sanity check of execbuf-ioctl relocations (Chris
+Wilson)
+
+- New test: gem_exec_basic sanity check of execbuf-ioctl rings (Chris Wilson)
+
+- improved igt_hang_ring() infrastructure for generic hang injection support in
+the core library (Chris Wilson)
+
+- new igt_pm library to collect power management testing helpers (David
+Weinehall)
+
+- lig/igt_vc4: VC4 support library (Eric Anholt)
+
+- kms_frontbuffer_tracking: included in BAT (Paulo Zanoni)
+
+- kms_psr_sink_crc: Add BAT test for PSR active (Rodrigo Vivi)
+
+- gem_wait: test superseded by gem_latency in benchmarks (Chris Wilson)
+
+- igt_core: Fix logging to display extended line (Derek Morton)
+
+- igt_core: Expand --run-subtest functionality (Derek Morton)
+
+- kms_force_connector_basic: various fixes and included in BAT set (Daniel
+Vetter)
+
+- Many other improvements and bug fixes.
+
 Release 1.13 (2015-12-02)
 -------------------------
 
diff --git a/configure.ac b/configure.ac
index cfbcbf3..e523b7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ([2.60])
 AC_INIT([intel-gpu-tools],
-	[1.13],
+	[1.14],
 	[https://bugs.freedesktop.org/enter_bug.cgi?product=DRI&component=DRM/Intel],
 	[intel-gpu-tools])
 

commit 95ca7644dbed799744b877d3b451d86c286627fe
Author: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Date:   Tue Mar 1 11:01:33 2016 +0000

    tests/drv_hangman: test for acthd increasing through invalid VM space
    
    The hangcheck logic will not flag an hang if acthd keeps increasing.
    However, if a malformed batch jumps to an invalid offset in the ppgtt it
    can potentially continue executing through the whole address space
    without triggering the hangcheck mechanism.
    
    This patch adds a test to simulate the issue. I've kept the test running
    for more than 10 minutes before killing it on a BDW and no hang occurred.
    I've sampled i915_hangcheck_info a few times during the run and got the
    following:
    
    Hangcheck active, fires in 468ms
    render ring:
    	seqno = fffff55e [current fffff55e]
    	ACTHD = 0x47df685ecc [current 0x4926b81d90]
    	max ACTHD = 0x47df685ecc
    	score = 0
    	action = 2
    	instdone read = 0xffd7ffff 0xffffffff 0xffffffff 0xffffffff
    	instdone accu = 0x00000000 0x00000000 0x00000000 0x00000000
    
    Hangcheck active, fires in 424ms
    render ring:
    	seqno = fffff55e [current fffff55e]
    	ACTHD = 0x6c953d3a34 [current 0x6de5e76fa4]
    	max ACTHD = 0x6c953d3a34
    	score = 0
    	action = 2
    	instdone read = 0xffd7ffff 0xffffffff 0xffffffff 0xffffffff
    	instdone accu = 0x00000000 0x00000000 0x00000000 0x00000000
    
    Hangcheck active, fires in 1692ms
    render ring:
    	seqno = fffff55e [current fffff55e]
    	ACTHD = 0x1f49b0366dc [current 0x1f4dcbd88ec]
    	max ACTHD = 0x1f49b0366dc
    	score = 0
    	action = 2
    	instdone read = 0xffd7ffff 0xffffffff 0xffffffff 0xffffffff
    	instdone accu = 0x00000000 0x00000000 0x00000000 0x00000000
    
    v2: use the new gem_wait() function (Chris)
    
    v3: switch to unterminated batch and rename test, remove redundant
        check, update test requirements (Chris), update top comment
    
    v4: force gpu reset if the hang detection fails (Mika)
    
    Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
    Cc: Arun Siluvery <arun.siluvery@linux.intel.com>
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
    [Mika: removed batch_len=8]
    Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>

diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
index a4f187a..6ac743f 100644
--- a/tests/drv_hangman.c
+++ b/tests/drv_hangman.c
@@ -284,6 +284,46 @@ static void test_error_state_capture(unsigned ring_id,
 	check_error_state(gen, cmd_parser, ring_name, offset);
 }
 
+
+/* This test covers the case where we end up in an uninitialised area of the
+ * ppgtt and keep executing through it. This is particularly relevant if 48b
+ * ppgtt is enabled because the ppgtt is massively bigger compared to the 32b
+ * case and it takes a lot more time to wrap, so the acthd can potentially keep
+ * increasing for a long time
+ */
+#define NSEC_PER_SEC	1000000000L
+static void hangcheck_unterminated(void)
+{
+	int fd;
+	/* timeout needs to be greater than ~5*hangcheck */
+	int64_t timeout_ns = 100 * NSEC_PER_SEC; /* 100 seconds */
+	struct drm_i915_gem_execbuffer2 execbuf;
+	struct drm_i915_gem_exec_object2 gem_exec;
+	uint32_t handle;
+
+	fd = drm_open_driver(DRIVER_INTEL);
+	igt_require(gem_uses_full_ppgtt(fd));
+	igt_require_hang_ring(fd, 0);
+
+	handle = gem_create(fd, 4096);
+
+	memset(&gem_exec, 0, sizeof(gem_exec));
+	gem_exec.handle = handle;
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = (uintptr_t)&gem_exec;
+	execbuf.buffer_count = 1;
+
+	gem_execbuf(fd, &execbuf);
+	if (gem_wait(fd, handle, &timeout_ns) != 0) {
+		/* need to manually trigger an hang to clean before failing */
+		igt_force_gpu_reset();
+		igt_assert_f(0, "unterminated batch did not trigger an hang!");
+	}
+
+	close(fd);
+}
+
 igt_main
 {
 	const struct intel_execution_engine *e;
@@ -310,4 +350,7 @@ igt_main
 			test_error_state_capture(e->exec_id | e->flags,
 						 e->full_name);
 	}
+
+	igt_subtest("hangcheck-unterminated")
+		hangcheck_unterminated();
 }

commit 03c7f84eb1c95b9761bbff3c9fcaed8472c3c6fb
Author: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Date:   Tue Mar 1 11:01:32 2016 +0000

    lib: move i915_wedged_set to ig_gt.c
    
    Upcoming tests will call it to recover from bad states caused by
    hangcheck bugs.the function was renamed to igt_force_gpu_reset to have a
    naming closer to other hang-related functions in the same file.
    
    The value written to the debugfs has also been changed to -1; this makes
    no differences with the current implementation but copes with upcoming
    TDR changes (still under discussion) that should allow the resetting of
    a mask of rings.
    
    Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
    Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 9f8634b..7235519 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -269,6 +269,29 @@ void igt_post_hang_ring(int fd, struct igt_hang_ring arg)
 	}
 }
 
+/**
+ * igt_force_gpu_reset:
+ *
+ * forces a gpu reset using the i915_wedged debugfs interface. To be used to
+ * recover from situations where the hangcheck didn't trigger and/or the gpu is
+ * stuck, either because the test manually disabled gpu resets or because the
+ * test hit an hangcheck bug
+ */
+void igt_force_gpu_reset(void)
+{
+	int fd, ret;
+
+	igt_debug("Triggering GPU reset\n");
+
+	fd = igt_debugfs_open("i915_wedged", O_RDWR);
+	igt_require(fd >= 0);
+
+	ret = write(fd, "-1\n", 3);
+	close(fd);
+
+	igt_assert_eq(ret, 3);
+}
+
 /* GPU abusers */
 static struct igt_helper_process hang_helper;
 static void __attribute__((noreturn))
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index b7c5c4a..ad993c1 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -48,6 +48,8 @@ struct igt_hang_ring igt_hang_ctx(int fd,
 struct igt_hang_ring igt_hang_ring(int fd, int ring);
 void igt_post_hang_ring(int fd, struct igt_hang_ring arg);
 
+void igt_force_gpu_reset(void);
+
 void igt_fork_hang_helper(void);
 void igt_stop_hang_helper(void);
 
diff --git a/tests/gem_eio.c b/tests/gem_eio.c
index d209816..ab3facc 100644
--- a/tests/gem_eio.c
+++ b/tests/gem_eio.c
@@ -58,24 +58,9 @@ static bool i915_reset_control(bool enable)
 	return ret;
 }
 
-static bool i915_wedged_set(void)
-{
-	int fd, ret;
-
-	igt_debug("Triggering GPU reset\n");
-
-	fd = igt_debugfs_open("i915_wedged", O_RDWR);
-	igt_require(fd >= 0);
-
-	ret = write(fd, "1\n", 2) == 2;
-	close(fd);
-
-	return ret;
-}
-
 static void trigger_reset(int fd)
 {
-	igt_assert(i915_wedged_set());
+	igt_force_gpu_reset();
 
 	/* And just check the gpu is indeed running again */
 	igt_debug("Checking that the GPU recovered\n");

commit 094e0cbabb9615c87d8e813a91f158fe439b536d
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Mar 1 13:22:03 2016 +0000

    igt/gem_concurrent_blit: Deglobalify num_buffers
    
    More num_buffers onto the local struct passed down into the tests to
    avoid the issue with having to modify the global value inside the tests
    leading to hilarity if the test asserts.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/tests/gem_concurrent_all.c b/tests/gem_concurrent_all.c
index 8718f16..a987ed8 100644
--- a/tests/gem_concurrent_all.c
+++ b/tests/gem_concurrent_all.c
@@ -54,18 +54,18 @@ IGT_TEST_DESCRIPTION("Test of pread/pwrite/mmap behavior when writing to active"
 		     " buffers.");
 
 int fd, devid, gen;
-struct intel_batchbuffer *batch;
 int all;
 int pass;
 
 struct buffers {
 	const struct access_mode *mode;
 	drm_intel_bufmgr *bufmgr;
+	struct intel_batchbuffer *batch;
 	drm_intel_bo **src, **dst;
 	drm_intel_bo *snoop, *spare;
 	uint32_t *tmp;
 	int width, height, size;
-	int count;
+	int count, num_buffers;
 };
 
 #define MIN_BUFFERS 3
@@ -284,6 +284,8 @@ userptr_cmp_bo(struct buffers *b, drm_intel_bo *bo, uint32_t val)
 static void
 userptr_release_bo(drm_intel_bo *bo)
 {
+	igt_assert(bo->virtual);
+
 	munmap(bo->virtual, bo->size);
 	bo->virtual = NULL;
 
@@ -388,6 +390,7 @@ static void
 dmabuf_release_bo(drm_intel_bo *bo)
 {
 	struct dmabuf *dmabuf = bo->virtual;
+	igt_assert(dmabuf);
 
 	munmap(dmabuf->map, bo->size);
 	close(dmabuf->fd);
@@ -468,6 +471,8 @@ wc_create_bo(drm_intel_bufmgr *bufmgr, int width, int height)
 static void
 wc_release_bo(drm_intel_bo *bo)
 {
+	igt_assert(bo->virtual);
+
 	munmap(bo->virtual, bo->size);
 	bo->virtual = NULL;
 
@@ -668,15 +673,17 @@ const struct access_mode {
 	},
 };
 
-int num_buffers;
 igt_render_copyfunc_t rendercopy;
 
-static void *buffers_init(struct buffers *data,
-			  const struct access_mode *mode,
-			  int width, int height,
-			  int _fd, int enable_reuse)
+static void buffers_init(struct buffers *data,
+			 const struct access_mode *mode,
+			 int num_buffers,
+			 int width, int height,
+			 int _fd, int enable_reuse)
 {
+	memset(data, 0, sizeof(*data));
 	data->mode = mode;
+	data->num_buffers = num_buffers;
 	data->count = 0;
 
 	data->width = width;
@@ -694,15 +701,17 @@ static void *buffers_init(struct buffers *data,
 
 	if (enable_reuse)
 		drm_intel_bufmgr_gem_enable_reuse(data->bufmgr);
-	return intel_batchbuffer_alloc(data->bufmgr, devid);
+	data->batch = intel_batchbuffer_alloc(data->bufmgr, devid);
+	igt_assert(data->batch);
 }
 
 static void buffers_destroy(struct buffers *data)
 {
-	if (data->count == 0)
+	int count = data->count;
+	if (count == 0)
 		return;
 
-	for (int i = 0; i < data->count; i++) {
+	for (int i = 0; i < count; i++) {
 		data->mode->release_bo(data->src[i]);
 		data->mode->release_bo(data->dst[i]);
 	}
@@ -711,13 +720,14 @@ static void buffers_destroy(struct buffers *data)
 	data->count = 0;
 }
 
-static void buffers_create(struct buffers *data,
-			   int count)
+static void buffers_create(struct buffers *data)
 {
+	int count = data->num_buffers;
 	int width = data->width, height = data->height;
 	igt_assert(data->bufmgr);
 
 	buffers_destroy(data);
+	igt_assert(data->count == 0);
 
 	for (int i = 0; i < count; i++) {
 		data->src[i] =
@@ -739,12 +749,11 @@ static void buffers_fini(struct buffers *data)
 
 	free(data->tmp);
 	free(data->src);
-	data->src = NULL;
-	data->dst = NULL;
 
-	intel_batchbuffer_free(batch);
+	intel_batchbuffer_free(data->batch);
 	drm_intel_bufmgr_destroy(data->bufmgr);
-	data->bufmgr = NULL;
+
+	memset(data, 0, sizeof(*data));
 }
 
 typedef void (*do_copy)(struct buffers *b, drm_intel_bo *dst, drm_intel_bo *src);
@@ -768,7 +777,7 @@ static void render_copy_bo(struct buffers *b, drm_intel_bo *dst, drm_intel_bo *s
 	drm_intel_bo_get_tiling(dst, &d.tiling, &swizzle);
 	drm_intel_bo_get_tiling(src, &s.tiling, &swizzle);
 
-	rendercopy(batch, NULL,
+	rendercopy(b->batch, NULL,
 		   &s, 0, 0,
 		   b->width, b->height,
 		   &d, 0, 0);
@@ -776,7 +785,7 @@ static void render_copy_bo(struct buffers *b, drm_intel_bo *dst, drm_intel_bo *s
 
 static void blt_copy_bo(struct buffers *b, drm_intel_bo *dst, drm_intel_bo *src)
 {
-	intel_blt_copy(batch,
+	intel_blt_copy(b->batch,
 		       src, 0, 0, 4*b->width,
 		       dst, 0, 0, 4*b->width,
 		       b->width, b->height, 32);
@@ -1244,32 +1253,26 @@ static void __run_forked(struct buffers *buffers,
 			 do_hang do_hang_func)
 
 {
-	const int old_num_buffers = num_buffers;
+	int _num_buffers = buffers->num_buffers;
 
-	num_buffers /= num_children;
-	num_buffers += MIN_BUFFERS;
+	_num_buffers /= num_children;
+	_num_buffers += MIN_BUFFERS;
 
 	igt_fork(child, num_children) {
 		/* recreate process local variables */
-		buffers->count = 0;
 		fd = drm_open_driver(DRIVER_INTEL);
+		buffers_init(buffers, buffers->mode, _num_buffers,
+			     buffers->width, buffers->height,
+			     fd, true);
 
-		batch = buffers_init(buffers, buffers->mode,
-				     buffers->width, buffers->height,
-				     fd, true);
-
-		buffers_create(buffers, num_buffers);
+		buffers_create(buffers);
 		for (pass = 0; pass < loops; pass++)
 			do_test_func(buffers, do_copy_func, do_hang_func);
 		pass = 0;
-
-		buffers_fini(buffers);
 	}
 
 	igt_waitchildren();
 	igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
-
-	num_buffers = old_num_buffers;
 }
 
 static void run_forked(struct buffers *buffers,
@@ -1336,6 +1339,7 @@ static void rcs_require(void)
 static void
 run_basic_modes(const char *prefix,
 		const struct access_mode *mode,
+		const int num_buffers,
 		const char *suffix,
 		run_wrap run_wrap_func)
 {
@@ -1369,27 +1373,27 @@ run_basic_modes(const char *prefix,
 			struct buffers buffers;
 
 			igt_fixture
-				batch = buffers_init(&buffers, mode,
-						     512, 512, fd,
-						     run_wrap_func != run_child);
+				buffers_init(&buffers, mode, num_buffers,
+					     512, 512, fd,
+					     run_wrap_func != run_child);
 
 			igt_subtest_f("%s-%s-%s-sanitycheck0%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers, do_basic0,
 					      p->copy, h->hang);
 			}
 
 			igt_subtest_f("%s-%s-%s-sanitycheck1%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers, do_basic1,
 					      p->copy, h->hang);
 			}
 
 			igt_subtest_f("%s-%s-%s-sanitycheckN%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers, do_basicN,
 					      p->copy, h->hang);
 			}
@@ -1397,7 +1401,7 @@ run_basic_modes(const char *prefix,
 			/* try to overwrite the source values */
 			igt_subtest_f("%s-%s-%s-overwrite-source-one%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_overwrite_source__one,
 					      p->copy, h->hang);
@@ -1405,7 +1409,7 @@ run_basic_modes(const char *prefix,
 
 			igt_subtest_f("%s-%s-%s-overwrite-source%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_overwrite_source,
 					      p->copy, h->hang);
@@ -1413,7 +1417,7 @@ run_basic_modes(const char *prefix,
 
 			igt_subtest_f("%s-%s-%s-overwrite-source-read-bcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_overwrite_source_read_bcs,
 					      p->copy, h->hang);
@@ -1422,7 +1426,7 @@ run_basic_modes(const char *prefix,
 			igt_subtest_f("%s-%s-%s-overwrite-source-read-rcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
 				igt_require(rendercopy);
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_overwrite_source_read_rcs,
 					      p->copy, h->hang);
@@ -1430,7 +1434,7 @@ run_basic_modes(const char *prefix,
 
 			igt_subtest_f("%s-%s-%s-overwrite-source-rev%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_overwrite_source__rev,
 					      p->copy, h->hang);
@@ -1440,7 +1444,7 @@ run_basic_modes(const char *prefix,
 			igt_subtest_f("%s-%s-%s-intermix-rcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
 				igt_require(rendercopy);
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_intermix_rcs,
 					      p->copy, h->hang);
@@ -1448,7 +1452,7 @@ run_basic_modes(const char *prefix,
 			igt_subtest_f("%s-%s-%s-intermix-bcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
 				igt_require(rendercopy);
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_intermix_bcs,
 					      p->copy, h->hang);
@@ -1456,7 +1460,7 @@ run_basic_modes(const char *prefix,
 			igt_subtest_f("%s-%s-%s-intermix-both%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
 				igt_require(rendercopy);
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_intermix_both,
 					      p->copy, h->hang);
@@ -1465,7 +1469,7 @@ run_basic_modes(const char *prefix,
 			/* try to read the results before the copy completes */
 			igt_subtest_f("%s-%s-%s-early-read%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_early_read,
 					      p->copy, h->hang);
@@ -1474,7 +1478,7 @@ run_basic_modes(const char *prefix,
 			/* concurrent reads */
 			igt_subtest_f("%s-%s-%s-read-read-bcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_read_read_bcs,
 					      p->copy, h->hang);
@@ -1482,7 +1486,7 @@ run_basic_modes(const char *prefix,
 			igt_subtest_f("%s-%s-%s-read-read-rcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
 				igt_require(rendercopy);
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_read_read_rcs,
 					      p->copy, h->hang);
@@ -1491,7 +1495,7 @@ run_basic_modes(const char *prefix,
 			/* split copying between rings */
 			igt_subtest_f("%s-%s-%s-write-read-bcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_write_read_bcs,
 					      p->copy, h->hang);
@@ -1499,7 +1503,7 @@ run_basic_modes(const char *prefix,
 			igt_subtest_f("%s-%s-%s-write-read-rcs%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
 				igt_require(rendercopy);
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_write_read_rcs,
 					      p->copy, h->hang);
@@ -1508,7 +1512,7 @@ run_basic_modes(const char *prefix,
 			/* and finally try to trick the kernel into loosing the pending write */
 			igt_subtest_f("%s-%s-%s-gpu-read-after-write%s%s", prefix, mode->name, p->prefix, suffix, h->suffix) {
 				p->require();
-				buffers_create(&buffers, num_buffers);
+				buffers_create(&buffers);
 				run_wrap_func(&buffers,
 					      do_gpu_read_after_write,
 					      p->copy, h->hang);
@@ -1521,7 +1525,10 @@ run_basic_modes(const char *prefix,
 }
 
 static void
-run_modes(const char *style, const struct access_mode *mode, unsigned allow_mem)
+run_modes(const char *style,
+	  const struct access_mode *mode,
+	  const int num_buffers,
+	  unsigned allow_mem)
 {
 	if (!igt_only_list_subtests()) {
 		if (mode->require && !mode->require())
@@ -1534,13 +1541,15 @@ run_modes(const char *style, const struct access_mode *mode, unsigned allow_mem)
 			return;
 	}
 
-	run_basic_modes(style, mode, "", run_single);
-	run_basic_modes(style, mode, "-child", run_child);
-	run_basic_modes(style, mode, "-forked", run_forked);
+	run_basic_modes(style, mode, num_buffers, "", run_single);
+	run_basic_modes(style, mode, num_buffers, "-child", run_child);
+	run_basic_modes(style, mode, num_buffers, "-forked", run_forked);
 
 	igt_fork_signal_helper();
-	run_basic_modes(style, mode, "-interruptible", run_interruptible);
-	run_basic_modes(style, mode, "-bomb", run_bomb);
+	run_basic_modes(style, mode, num_buffers,
+			"-interruptible", run_interruptible);
+	run_basic_modes(style, mode, num_buffers,
+			"-bomb", run_bomb);
 	igt_stop_signal_helper();
 }
 
@@ -1558,6 +1567,7 @@ igt_main
 	}, *c;
 	uint64_t pin_sz = 0;
 	void *pinned = NULL;
+	int num_buffers = 0;
 	int i;
 
 	igt_skip_on_simulation();
@@ -1582,7 +1592,7 @@ igt_main
 		if (c->require()) {
 			snprintf(name, sizeof(name), "%s%s", c->name, "tiny");


Reply to: