[Intel-gfx] [PATCH i-g-t] benchmarks/gem_busy: Fix compile error

2016-09-06 Thread Derek Morton
The benchmark was failing with:
gem_busy.c:158:8: error: implicit declaration of function 'intel_gen'
is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gen = intel_gen(intel_get_drm_devid(fd));

The root cause was due to the local lib directory not being specified
in benchmarks/Android.mk, resulting in intel_chipset.h from drm being
used instead.

This patch adds the lib path to the LOCAL_C_INCLUDES

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 benchmarks/Android.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index 147f5db..c0fa09f 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -1,6 +1,7 @@
 LOCAL_PATH := $(call my-dir)
 
 include $(LOCAL_PATH)/Makefile.sources
+IGT_LOCAL_C_INCLUDES = $(LOCAL_PATH)/../lib
 
 ##
 
@@ -9,6 +10,7 @@ define add_benchmark
 
 LOCAL_SRC_FILES := $1.c
 
+LOCAL_C_INCLUDES = ${IGT_LOCAL_C_INCLUDES}
 LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM
 LOCAL_CFLAGS += -DANDROID -UNDEBUG -include "check-ndebug.h"
 LOCAL_CFLAGS += -std=gnu99
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] gem_busy: Remove from android builds without cairo

2016-08-23 Thread Derek Morton
The test has just developed cairo dependancies (or is at least now
dependant on igt_kms.h) so add it to the list of tests that are only
built if cairo is available.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/Android.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/Android.mk b/tests/Android.mk
index 3186a2a..74d6d47 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -58,6 +58,7 @@ else
 gem_render_copy \
 pm_lpsp \
drm_read \
+   gem_busy \
gem_exec_blt \
prime_mmap_kms
 
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] gem_largeobject: Fix for clang compiler

2016-08-04 Thread Derek Morton
The clang compiler generates a build error for binaries with >128MB
data segments because "The gap between stack and binary is only
guarenteed to be 128MB on x86_64"

Simple solution is to allocate the required memory from the heap.

[v2: moved malloc to after skip_on_simulation]

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_largeobject.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/gem_largeobject.c b/tests/gem_largeobject.c
index c001c17..518396f 100644
--- a/tests/gem_largeobject.c
+++ b/tests/gem_largeobject.c
@@ -39,7 +39,7 @@
 /* Should take 64 pages to store the page pointers on 64 bit */
 #define OBJ_SIZE (128 * 1024 * 1024)
 
-unsigned char data[OBJ_SIZE];
+unsigned char *data;
 
 static void
 test_large_object(int fd)
@@ -79,7 +79,12 @@ igt_simple_main
 
igt_skip_on_simulation();
 
+   data = malloc(OBJ_SIZE);
+   igt_assert(data);
+
fd = drm_open_driver(DRIVER_INTEL);
 
test_large_object(fd);
+
+   free(data);
 }
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] gem_largeobject: Fix for clang compiler

2016-08-04 Thread Derek Morton
The clang compiler generates a build error for binaries with >128MB
data segments because "The gap between stack and binary is only
guarenteed to be 128MB on x86_64"

Simple solution is to allocate the required memory from the heap.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_largeobject.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/gem_largeobject.c b/tests/gem_largeobject.c
index c001c17..4f323bb 100644
--- a/tests/gem_largeobject.c
+++ b/tests/gem_largeobject.c
@@ -39,7 +39,7 @@
 /* Should take 64 pages to store the page pointers on 64 bit */
 #define OBJ_SIZE (128 * 1024 * 1024)
 
-unsigned char data[OBJ_SIZE];
+unsigned char *data;
 
 static void
 test_large_object(int fd)
@@ -77,6 +77,9 @@ igt_simple_main
 {
int fd;
 
+   data = malloc(OBJ_SIZE);
+   igt_assert(data);
+
igt_skip_on_simulation();
 
fd = drm_open_driver(DRIVER_INTEL);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/Android.mk: Update cairo dependant test list

2016-05-24 Thread Derek Morton
drm_read
gem_exec_blt
prime_mmap_kms
Have cairo dependency through igt_kms.c so add to skip_tests_list
to fix android build errors.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/Android.mk | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/Android.mk b/tests/Android.mk
index 8457125..3186a2a 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -56,7 +56,10 @@ else
 # the following tests depend on cairo, so skip them
 skip_tests_list += \
 gem_render_copy \
-pm_lpsp
+pm_lpsp \
+   drm_read \
+   gem_exec_blt \
+   prime_mmap_kms
 
 # All kms tests depend on cairo
 tmp_list := $(foreach test_name, $(TESTS_progs),\
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v4 4/5] tests/gem_scheduler: Add subtests to test batch priority behaviour

2016-03-30 Thread Derek Morton
Add subtests to test each ring to check batch buffers of a higher
priority will be executed before batch buffers of a lower priority.

v2: Addressed review comments from Daniele Ceraolo Spurio

v4: Changed priorities to +/-200  - Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_scheduler.c | 57 ++-
 1 file changed, 47 insertions(+), 10 deletions(-)

diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
index 704dbb1..504607f 100644
--- a/tests/gem_scheduler.c
+++ b/tests/gem_scheduler.c
@@ -39,7 +39,8 @@
 
 IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
  "batch buffers of the same priority are executed in "
- "submission order. Read-read tests ensure "
+ "submission order. Priority tests ensure higher priority "
+ "batch buffers are executed first. Read-read tests ensure 
"
  "batch buffers with a read dependency to the same buffer "
  "object do not block each other. Write-write dependency "
  "tests ensure batch buffers with a write dependency to a "
@@ -61,7 +62,7 @@ static struct ring {
 } rings[] = {
{ "render", I915_EXEC_RENDER, false },
{ "bsd",I915_EXEC_BSD , false },
-   { "bsd2",I915_EXEC_BSD | 2<<13, false },
+   { "bsd2",   I915_EXEC_BSD | 2<<13, false },
{ "blt",I915_EXEC_BLT, false },
{ "vebox",  I915_EXEC_VEBOX, false },
 };
@@ -70,7 +71,7 @@ static struct ring {
 
 static void check_rings(int fd) {
int loop;
-   for (loop=0; loop < NBR_RINGS; loop++) {
+   for (loop = 0; loop < NBR_RINGS; loop++) {
if (gem_has_ring(fd, rings[loop].id)) {
if (rings[loop].id == (I915_EXEC_BSD | 2<<13)) {
rings[loop].exists = gem_has_bsd2(fd);
@@ -145,11 +146,23 @@ static void init_context(int *fd, drm_intel_bufmgr 
**bufmgr, int ringid)
intel_batchbuffer_free(noop_bb);
 }
 
-/* Basic test. Check batch buffers of the same priority and with no 
dependencies
- * are executed in the order they are submitted.
+static void set_priority(int fd, int value)
+{
+   struct local_i915_gem_context_param param;
+   param.context = 0; /* Default context */
+   param.size = 0;
+   param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+   param.value = (uint64_t)value;
+   gem_context_set_param(fd, );
+}
+
+/* If 'priority' is 0, check batch buffers of the same priority and with
+ * no dependencies are executed in the order they are submitted.
+ * If 'priority' is set !0, check batch buffers of higher priority are
+ * executed before batch buffers of lower priority.
  */
 #define NBR_BASIC_FDs (3)
-static void run_test_basic(int in_flight, int ringid)
+static void run_test_basic(int in_flight, int ringid, int priority)
 {
int fd[NBR_BASIC_FDs];
int loop;
@@ -169,6 +182,13 @@ static void run_test_basic(int in_flight, int ringid)
for (loop = 0; loop < NBR_BASIC_FDs; loop++)
init_context(&(fd[loop]), &(bufmgr[loop]), ringid);
 
+   /* For high priority set priority of second context to overtake first
+* For low priority set priority of first context to be overtaxen by 
second
+*/
+   if(priority > 0)
+   set_priority(fd[2], priority);
+   else if(priority < 0)
+   set_priority(fd[1], priority);
 
/* Create buffer objects */
delay_bo = create_and_check_bo(bufmgr[0], "delay bo");
@@ -212,9 +232,14 @@ static void run_test_basic(int in_flight, int ringid)
igt_assert_f(igt_compare_timestamps(delay_buf[2], ts1_buf[0]),
 "Delay ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 ")\n",
 delay_buf[2], ts1_buf[0]);
-   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
-"TS1 ts (0x%08" PRIx32 ") > TS2 ts (0x%08" PRIx32 ")\n",
-ts1_buf[0], ts2_buf[0]);
+   if(priority)
+   igt_assert_f(igt_compare_timestamps(ts2_buf[0], ts1_buf[0]),
+"TS2 ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 
")\n",
+ts2_buf[0], ts1_buf[0]);
+   else
+   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
+"TS1 ts (0x%08" PRIx32 ") > TS2 ts (0x%08" PRIx32 
")\n",
+ts1_buf[0], ts2_buf[0]);
 
/* Cleanup */
for (loop = 0; loop < in_flight; loop++

[Intel-gfx] [PATCH i-g-t v4 5/5] gem_scheduler: Added subtests to test priority starving

2016-03-30 Thread Derek Morton
When a batch is selected for execution all other batch buffers in the
scheduler queue get a small priority increase to prevent starving due
to continuous submissions by a high priority user.
Added a subtest to check this behaviour.

Requested by Joonas Lahtinen during scheduler code review

v4: Addressed review comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_scheduler.c | 134 ++
 1 file changed, 134 insertions(+)

diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
index 504607f..5d8fecf 100644
--- a/tests/gem_scheduler.c
+++ b/tests/gem_scheduler.c
@@ -257,6 +257,134 @@ static void run_test_basic(int in_flight, int ringid, int 
priority)
free(in_flight_bbs);
 }
 
+
+/* Test priority starving behaviour.
+   When a batch is selected for execution all other batch buffers in the
+   scheduler queue get a small priority increase to prevent starving due
+   to continuous submissions by a high priority user.
+ * Submit two delay batch buffers then fill the in flight queue. Submit a
+ * slightly reduced priority batch buffer and a normal priority batch buffer.
+ * When the first delay batch buffer completes and the next is put in flight 
all
+ * other batch buffers in the scheduler queue should get a small priority
+ * increase.
+ * Submit another normal priority batch buffer. It should not overtake the
+ * reduced priority batch buffer whose priority has been increased.
+ */
+#define NBR_PRIO_STARVE_FDs (4)
+static void run_test_priority_starve(int in_flight, int ringid)
+{
+   int fd[NBR_PRIO_STARVE_FDs];
+   int loop;
+   drm_intel_bufmgr *bufmgr[NBR_PRIO_STARVE_FDs];
+   uint32_t *delay_buf, *delay2_buf, *ts1_buf, *ts2_buf, *ts3_buf;
+   struct intel_batchbuffer *ts1_bb, *ts2_bb, *ts3_bb;
+   struct intel_batchbuffer **in_flight_bbs;
+   uint32_t calibrated_1s;
+   drm_intel_bo *delay_bo, *delay2_bo ,*ts1_bo, *ts2_bo, *ts3_bo;
+
+   in_flight_bbs = malloc(in_flight * sizeof(struct intel_batchbuffer *));
+   igt_assert(in_flight_bbs);
+
+   /* Need multiple i915 fd's. Scheduler will not change execution order of
+* batch buffers from the same context.
+*/
+   for(loop = 0; loop < NBR_PRIO_STARVE_FDs; loop++)
+   init_context(&(fd[loop]), &(bufmgr[loop]), ringid);
+
+   /* Lower priority of first timestamp batch buffer
+* Second timestamp batch buffer should overtake the first
+* Overtaken batch should then get a priority increase so the third does
+* not overtake it.
+*/
+   set_priority(fd[1], -1);
+
+   /* Create buffer objects */
+   delay_bo = create_and_check_bo(bufmgr[0], "delay bo");
+   delay2_bo = create_and_check_bo(bufmgr[0], "delay bo2");
+   ts1_bo = create_and_check_bo(bufmgr[1], "ts1 bo");
+   ts2_bo = create_and_check_bo(bufmgr[2], "ts2 bo");
+   ts3_bo = create_and_check_bo(bufmgr[3], "ts3 bo");
+
+   calibrated_1s = igt_calibrate_delay_bb(fd[0], bufmgr[0], ringid);
+
+   /* Batch buffers to fill the in flight queue */
+   in_flight_bbs[0] = create_delay_bb(fd[0], bufmgr[0], ringid, 
calibrated_1s, delay_bo);
+   in_flight_bbs[1] = create_delay_bb(fd[0], bufmgr[0], ringid, 
calibrated_1s, delay2_bo);
+   for(loop = 2; loop < in_flight; loop++)
+   in_flight_bbs[loop] = create_noop_bb(fd[0], bufmgr[0], 5);
+
+   /* Extra batch buffers in the scheduler queue */
+   ts1_bb = create_timestamp_bb(fd[1], bufmgr[1], ringid, ts1_bo, NULL, 
false);
+   ts2_bb = create_timestamp_bb(fd[2], bufmgr[2], ringid, ts2_bo, NULL, 
false);
+   ts3_bb = create_timestamp_bb(fd[3], bufmgr[3], ringid, ts3_bo, NULL, 
false);
+
+   /* Flush batchbuffers */
+   for(loop = 0; loop < in_flight; loop++)
+   intel_batchbuffer_flush_on_ring(in_flight_bbs[loop], ringid);
+   intel_batchbuffer_flush_on_ring(ts1_bb, ringid);
+   intel_batchbuffer_flush_on_ring(ts2_bb, ringid);
+
+   /* This will not return until the bo has finished executing */
+   drm_intel_bo_map(delay_bo, 0);
+   /* Once the first delay is complete and any bumping has occured, submit
+* the final batch buffer
+*/
+   intel_batchbuffer_flush_on_ring(ts3_bb, ringid);
+
+   drm_intel_bo_map(delay2_bo, 0);
+   drm_intel_bo_map(ts1_bo, 0);
+   drm_intel_bo_map(ts2_bo, 0);
+   drm_intel_bo_map(ts3_bo, 0);
+
+   delay_buf = delay_bo->virtual;
+   delay2_buf = delay2_bo->virtual;
+   ts1_buf = ts1_bo->virtual;
+   ts2_buf = ts2_bo->virtual;
+   ts3_buf = ts3_bo->virtual;
+
+   igt_debug("Delay Timestamp = 0x%08" PRIx32 "\n", delay_buf[2]);
+   igt_debug("Delay Timestamp = 0x%08" PRIx32 "\n", delay2_buf[2]);
+   igt_debug("T

[Intel-gfx] [PATCH i-g-t v4 3/5] igt/gem_ctx_param_basic: Updated to support scheduler priority interface

2016-03-30 Thread Derek Morton
From: John Harrison 

The GPU scheduler has added an execution priority level to the context
object. There is an IOCTL interface to allow user apps/libraries to
set this priority. This patch updates the context paramter IOCTL test
to include the new interface.

For: VIZ-1587
Signed-off-by: John Harrison 
---
 lib/ioctl_wrappers.h|  1 +
 tests/gem_ctx_param_basic.c | 34 +-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index d986f61..3b8a015 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -109,6 +109,7 @@ struct local_i915_gem_context_param {
 #define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1
 #define LOCAL_CONTEXT_PARAM_NO_ZEROMAP 0x2
 #define LOCAL_CONTEXT_PARAM_GTT_SIZE   0x3
+#define LOCAL_CONTEXT_PARAM_PRIORITY   0x4
uint64_t value;
 };
 void gem_context_require_ban_period(int fd);
diff --git a/tests/gem_ctx_param_basic.c b/tests/gem_ctx_param_basic.c
index b75800c..585a1a8 100644
--- a/tests/gem_ctx_param_basic.c
+++ b/tests/gem_ctx_param_basic.c
@@ -147,10 +147,42 @@ igt_main
TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
}
 
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+
+   igt_subtest("priority-root-set") {
+   ctx_param.context = ctx;
+   ctx_param.value = 2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = -2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = 512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_subtest("priority-non-root-set") {
+   igt_fork(child, 1) {
+   igt_drop_root();
+
+   ctx_param.context = ctx;
+   ctx_param.value = 512;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EPERM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_waitchildren();
+   }
+
/* NOTE: This testcase intentionally tests for the next free parameter
 * to catch ABI extensions. Don't "fix" this testcase without adding all
 * the tests for the new param first. */
-   ctx_param.param = LOCAL_CONTEXT_PARAM_GTT_SIZE + 1;
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY + 1;
 
igt_subtest("invalid-param-get") {
ctx_param.context = ctx;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v4 2/5] tests/gem_scheduler: Add gem_scheduler test

2016-03-30 Thread Derek Morton
This is intended to test the scheduler behaviour is correct.
The subtests are
-basic
Tests that batch buffers of the same priority submitted to a ring
execute in the order they are submitted.
-read
Submits a batch buffer with a read dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a read dependency
to the same buffer object. Ensure they execute before the batch buffer
being held up behind the long running batch buffer.
-write
Submits a batch buffer with a write dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a write dependency
to the same buffer object. Submit batch buffers with no interdependencies
to all rings. Ensure the batch buffers that have write dependencies are
executed in submission order but the batch buffers without interdependencies
do not get held up.

v2: Addressed review comments from Daniele Ceraolo Spurio

v3: Added logic to use generic BSD ring if there is 1 and BSD1 / BSD2 if there
are 2.

v4: Addressed more review comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/Makefile.sources |   1 +
 tests/gem_scheduler.c  | 451 +
 2 files changed, 452 insertions(+)
 create mode 100644 tests/gem_scheduler.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 26e487a..cdbb37c 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -68,6 +68,7 @@ TESTS_progs_M = \
gem_request_retire \
gem_reset_stats \
gem_ringfill \
+   gem_scheduler \
gem_set_tiling_vs_blt \
gem_shrink \
gem_softpin \
diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
new file mode 100644
index 000..704dbb1
--- /dev/null
+++ b/tests/gem_scheduler.c
@@ -0,0 +1,451 @@
+/*
+ * Copyright © 2016 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 <derek.j.mor...@intel.com>
+ *
+ */
+
+#include "igt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
+ "batch buffers of the same priority are executed in "
+ "submission order. Read-read tests ensure "
+ "batch buffers with a read dependency to the same buffer "
+ "object do not block each other. Write-write dependency "
+ "tests ensure batch buffers with a write dependency to a "
+ "buffer object will be executed in submission order but "
+ "will not block execution of other independant batch "
+ "buffers.");
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+
+/* Create an array of rings to test. Need to test rings concurrently and
+ * explicitly so this array differs from intel_execution_engines as it
+ * excludes the default engine and is updated by check_rings() to handle either
+ * BSD or BSD1 and BSD2.
+ */
+static struct ring {
+   const char *name;
+   int id;
+   bool exists;
+} rings[] = {
+   { "render", I915_EXEC_RENDER, false },
+   { "bsd",I915_EXEC_BSD , false },
+   { "bsd2",I915_EXEC_BSD | 2<<13, false },
+   { "blt",I915_EXEC_BLT, false },
+   { "vebox",  I915_EXEC_VEBOX, false },
+};
+
+#define NBR_RINGS (sizeof(rings)/sizeof(struct ring))
+
+static void check_rings(int fd) {
+   int loop;
+   for (loop=0; loop < NBR_RINGS

[Intel-gfx] [PATCH i-g-t v4 1/5] lib/intel_batchbuffer: Add functions to be used in the scheduler test

2016-03-30 Thread Derek Morton
Adds functions to create a number of different batch buffers to perform
several functions including:
Batch buffer which will run for a long duration to provide a delay on a
specified ring.
Function to calibrate the delay batch buffer to run for a specified period
of time.
Function to create a batch buffer which writes timestamps to a buffer object.
Function to compare timestamps allowing for wrapping of the values.

v2: Moved code to intel_batchbuffer (Daniel Vetter)
Addressed review comments from Daniele Ceraolo Spurio

v4: Addressed more comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/intel_batchbuffer.c | 372 +++-
 lib/intel_batchbuffer.h |  14 ++
 2 files changed, 381 insertions(+), 5 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 692521f..aa4eeaf 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -1,8 +1,8 @@
 /**
- * 
+ *
  * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
- * 
+ *
  * 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
@@ -10,11 +10,11 @@
  * distribute, sub license, 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 NON-INFRINGEMENT.
@@ -22,7 +22,7 @@
  * 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.
- * 
+ *
  **/
 
 #include 
@@ -30,6 +30,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "drm.h"
 #include "drmtest.h"
@@ -42,6 +44,7 @@
 #include "ioctl_wrappers.h"
 #include "media_spin.h"
 #include "gpgpu_fill.h"
+#include "igt_gt.h"
 
 #include 
 
@@ -817,3 +820,362 @@ igt_media_spinfunc_t igt_get_media_spinfunc(int devid)
 
return spin;
 }
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+#define DWORDS_TO_BYTES(x) ((x)*4)
+
+#define MI_STORE_REGISTER_MEM(LENGTH)   ((0x024 << 23) | ((LENGTH - 2) & 0xff))
+#define MI_MATH(NrInst) ((0x01A << 23) | ((NrInst - 1) & 0x3f))
+#define MI_CONDITIONAL_BATCH_BUFFER_END ((0x036 << 23) | (1 << 21) | 2)
+#define MI_COPY_MEM_MEM ((0x02E << 23) | (3))
+
+#define ALU_LOAD(TO, FROM)  ((0x080 << 20) | ((TO) << 10) | (FROM))
+#define ALU_SUB ( 0x101 << 20)
+#define ALU_STORE(TO, FROM) ((0x180 << 20) | ((TO) << 10) | (FROM))
+
+#define TIMESTAMP_offset  (0x358) /* Elapsed time from system start */
+#define ALU_GPU_R0_LSB_offset (0x600)
+#define ALU_GPU_R0_MSB_offset (0x604)
+#define ALU_GPU_R1_LSB_offset (0x608)
+#define ALU_GPU_R1_MSB_offset (0x60C)
+#define ALU_GPU_R2_LSB_offset (0x610)
+#define ALU_GPU_R2_MSB_offset (0x614)
+
+#define ALU_R0_ENCODING   (0x00)
+#define ALU_R1_ENCODING   (0x01)
+#define ALU_SRCA_ENCODING (0x20)
+#define ALU_SRCB_ENCODING (0x21)
+#define ALU_ACCU_ENCODING (0x31)
+
+static int bb_address_size_dw(int gen)
+{
+   if (gen >= 8)
+   return 2;
+   else
+   return 1;
+}
+
+static uint32_t get_mmio_base(int ringid)
+{
+   switch (ringid) {
+   case I915_EXEC_RENDER:
+   return 0x02000;
+   case I915_EXEC_BSD:
+   case I915_EXEC_BSD | 1<<13: /* BSD1 */
+   return 0x12000;
+   case I915_EXEC_BSD | 2<<13: /* BSD2 */
+   return 0x1c000;
+   case I915_EXEC_BLT:
+   return 0x22000;
+   case I915_EXEC_VEBOX:
+   return 0x1A000;
+   default:
+   igt_assert_f(0, "Invalid ringid %d passed to 
get_mmio_base()\n", ringid);
+   }
+}
+
+/**
+ * igt_batch_used
+ * @batch batchbuffer to get offset from
+ *
+ * This returns the number of bytes of the batchbuffer that have been used.
+ * e.g. The offset into the batchbuffer that the next OUT_BATCH would write to.
+ *
+ * Returns:
+ * The number of bytes of the batchbuffer that have been used.
+ */
+uint32_t igt_batch_used(struct intel_batchbuffer *batch)
+{
+   return batch->ptr - bat

[Intel-gfx] [PATCH i-g-t v4 0/5] Scheduler tests

2016-03-30 Thread Derek Morton
This patch set adds scheduler tests.
Patch 1 adds library code used by the tests. There are other tests under
development which are planned to reuse some of these libraries.
Patch 2 adds some basic tests, read dependency tests and write dependency tests.
Patch 3 Is the patch previously submitted by John Harrison to update
gem_ctx_param_basic with ioctls to set context priorities. It is included as
part of this patch set as Patch 6 & 7 are dependant on it.
Patch 4 adds subtests to check sheduler behaviour for batch buffers submitted at
differing priorities.
Patch 5 adds subtests to check priority starving behaviour.

v2: Updates for comments from  and Daniel Vetter
Added tests requested by Joonas Lahtinen

v3: Removed the patch to update gem_has_ring() and updated the test to
use BSD if there is 1 ring and BSD1 / BSD2 if there are two.

v4: Removed patch to make gem_has_ring() non static as another patch has 
already done so.
Addressed more comments from Daniele Ceraolo Spurio

Derek Morton (4):
  lib/intel_batchbuffer: Add functions to be used in the scheduler test
  tests/gem_scheduler: Add gem_scheduler test
  tests/gem_scheduler: Add subtests to test batch priority behaviour
  gem_scheduler: Added subtests to test priority starving

John Harrison (1):
  igt/gem_ctx_param_basic: Updated to support scheduler priority
interface

 lib/intel_batchbuffer.c | 372 +-
 lib/intel_batchbuffer.h |  14 +
 lib/ioctl_wrappers.h|   1 +
 tests/Makefile.sources  |   1 +
 tests/gem_ctx_param_basic.c |  34 ++-
 tests/gem_scheduler.c   | 622 
 6 files changed, 1038 insertions(+), 6 deletions(-)
 create mode 100644 tests/gem_scheduler.c

-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] benchmarks/gem_syslatency: Add extra android guard to attr_setaffinity_np

2016-03-10 Thread Derek Morton
Android defines __USE_GNU but does not provide pthread_attr_setaffinity_np()
so added an extra guard arround pthread_attr_setaffinity_np().

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 benchmarks/gem_syslatency.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index f09050c..6cad3a0 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -189,6 +189,7 @@ static void *sys_wait(void *arg)
 static void bind_cpu(pthread_attr_t *attr, int cpu)
 {
 #ifdef __USE_GNU
+#ifndef ANDROID
cpu_set_t mask;
 
if (cpu == -1)
@@ -199,6 +200,7 @@ static void bind_cpu(pthread_attr_t *attr, int cpu)
 
pthread_attr_setaffinity_np(attr, sizeof(mask), );
 #endif
+#endif
 }
 
 static void rtprio(pthread_attr_t *attr, int prio)
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3 6/6] gem_scheduler: Added subtests to test priority bumping

2016-03-10 Thread Derek Morton
When a higher priority batch buffer bumps a lower priority batch
buffer all batch buffers in the scheduler queue get a small priority
increase. Added a subtest to check this behaviour.

Requested by Joonas Lahtinen during scheduler code review

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_scheduler.c | 134 ++
 1 file changed, 134 insertions(+)

diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
index 126ee97..0fbc6e9 100644
--- a/tests/gem_scheduler.c
+++ b/tests/gem_scheduler.c
@@ -254,6 +254,134 @@ static void run_test_basic(int in_flight, int ringid, int 
priority)
free(in_flight_bbs);
 }
 
+
+/* Test priority bump behaviour.
+ * When a batch buffer is bumped by a higher priority batch buffer all other
+ * batch buffers in the scheduler queue get their priority increased slightly.
+ * Submit two delay batch buffers then fill the in flight queue. Submit a
+ * slightly reduced priority batch buffer and a normal priority batch buffer.
+ * When the first delay batch buffer completes priority bumping should occur.
+ * Submit another normal priority batch buffer. It should not overtake the
+ * reduced priority batch buffer as its priority has been bumped.
+ */
+#define NBR_PRIO_BUMP_FDs (4)
+static void run_test_priority_bump(int in_flight, int ringid)
+{
+   int fd[NBR_PRIO_BUMP_FDs];
+   int loop;
+   drm_intel_bufmgr *bufmgr[NBR_PRIO_BUMP_FDs];
+   uint32_t *delay_buf, *delay2_buf, *ts1_buf, *ts2_buf, *ts3_buf;
+   struct intel_batchbuffer *ts1_bb, *ts2_bb, *ts3_bb;
+   struct intel_batchbuffer **in_flight_bbs;
+   uint32_t calibrated_1s;
+   drm_intel_bo *delay_bo, *delay2_bo ,*ts1_bo, *ts2_bo, *ts3_bo;
+
+   in_flight_bbs = malloc(in_flight * sizeof(struct intel_batchbuffer *));
+   igt_assert(in_flight_bbs);
+
+   /* Need multiple i915 fd's. Scheduler will not change execution order of
+* batch buffers from the same context.
+*/
+   for(loop=0; loop < NBR_PRIO_BUMP_FDs; loop++)
+   init_context(&(fd[loop]), &(bufmgr[loop]), ringid);
+
+   /* Lower priority of first timestamp batch buffer
+* Second timestamp batch buffer should overtake the first
+* Second should then get bumped so the third does not overtake it
+*/
+   set_priority(fd[1], -1);
+
+   /* Create buffer objects */
+   delay_bo = create_and_check_bo(bufmgr[0], "delay bo");
+   delay2_bo = create_and_check_bo(bufmgr[0], "delay bo2");
+   ts1_bo = create_and_check_bo(bufmgr[1], "ts1 bo");
+   ts2_bo = create_and_check_bo(bufmgr[2], "ts2 bo");
+   ts3_bo = create_and_check_bo(bufmgr[3], "ts23 bo");
+
+   /* Put some non zero values in the delay bo */
+   {
+   uint32_t data=0x;
+   drm_intel_bo_subdata(delay_bo, 0, 4, );
+   drm_intel_bo_subdata(delay2_bo, 0, 4, );
+   }
+
+   calibrated_1s = igt_calibrate_delay_bb(fd[0], bufmgr[0], ringid);
+
+   /* Batch buffers to fill the in flight queue */
+   in_flight_bbs[0] = create_delay_bb(fd[0], bufmgr[0], ringid, 
calibrated_1s, delay_bo);
+   in_flight_bbs[1] = create_delay_bb(fd[0], bufmgr[0], ringid, 
calibrated_1s, delay2_bo);
+   for(loop = 2; loop < in_flight; loop++)
+   in_flight_bbs[loop] = create_noop_bb(fd[0], bufmgr[0], 5);
+
+   /* Extra batch buffers in the scheduler queue */
+   ts1_bb = create_timestamp_bb(fd[1], bufmgr[1], ringid, ts1_bo, NULL, 
false);
+   ts2_bb = create_timestamp_bb(fd[2], bufmgr[2], ringid, ts2_bo, NULL, 
false);
+   ts3_bb = create_timestamp_bb(fd[3], bufmgr[3], ringid, ts3_bo, NULL, 
false);
+
+   /* Flush batchbuffers */
+   for(loop = 0; loop < in_flight; loop++)
+   intel_batchbuffer_flush_on_ring(in_flight_bbs[loop], ringid);
+   intel_batchbuffer_flush_on_ring(ts1_bb, ringid);
+   intel_batchbuffer_flush_on_ring(ts2_bb, ringid);
+
+   /* This will not return until the bo has finished executing */
+   drm_intel_bo_map(delay_bo, 0);
+   /* Once the first delay is complete and any bumping has occured, submit
+* the final batch buffer
+*/
+   intel_batchbuffer_flush_on_ring(ts3_bb, ringid);
+
+   drm_intel_bo_map(delay2_bo, 0);
+   drm_intel_bo_map(ts1_bo, 0);
+   drm_intel_bo_map(ts2_bo, 0);
+   drm_intel_bo_map(ts3_bo, 0);
+
+   delay_buf = delay_bo->virtual;
+   delay2_buf = delay2_bo->virtual;
+   ts1_buf = ts1_bo->virtual;
+   ts2_buf = ts2_bo->virtual;
+   ts3_buf = ts3_bo->virtual;
+
+   igt_debug("Delay Timestamp = 0x%08" PRIx32 "\n", delay_buf[2]);
+   igt_debug("Delay Timestamp = 0x%08" PRIx32 "\n", delay2_buf[2]);
+   igt_debug("TS1 Timestamp = 0x%08" PRIx32 "\n"

[Intel-gfx] [PATCH i-g-t v3 5/6] tests/gem_scheduler: Add subtests to test batch priority behaviour

2016-03-10 Thread Derek Morton
Add subtests to test each ring to check batch buffers of a higher
priority will be executed before batch buffers of a lower priority.

v2: Addressed review comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_scheduler.c | 53 +++
 1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
index 436440a..126ee97 100644
--- a/tests/gem_scheduler.c
+++ b/tests/gem_scheduler.c
@@ -39,7 +39,8 @@
 
 IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
  "batch buffers of the same priority are executed in "
- "submission order. Read-read tests ensure "
+ "submission order. Priority tests ensure higher priority "
+ "batch buffers are executed first. Read-read tests ensure 
"
  "batch buffers with a read dependency to the same buffer "
  "object do not block each other. Write-write dependency "
  "tests ensure batch buffers with a write dependency to a "
@@ -136,11 +137,23 @@ static void init_context(int *fd, drm_intel_bufmgr 
**bufmgr, int ringid)
intel_batchbuffer_free(noop_bb);
 }
 
-/* Basic test. Check batch buffers of the same priority and with no 
dependencies
- * are executed in the order they are submitted.
+static void set_priority(int fd, int value)
+{
+   struct local_i915_gem_context_param param;
+   param.context = 0; /* Default context */
+   param.size = 0;
+   param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+   param.value = (uint64_t)value;
+   gem_context_set_param(fd, );
+}
+
+/* If 'priority' is 0, check batch buffers of the same priority and with
+ * no dependencies are executed in the order they are submitted.
+ * If 'priority' is set !0, check batch buffers of higher priority are
+ * executed before batch buffers of lower priority.
  */
 #define NBR_BASIC_FDs (3)
-static void run_test_basic(int in_flight, int ringid)
+static void run_test_basic(int in_flight, int ringid, int priority)
 {
int fd[NBR_BASIC_FDs];
int loop;
@@ -160,6 +173,13 @@ static void run_test_basic(int in_flight, int ringid)
for(loop=0; loop < NBR_BASIC_FDs; loop++)
init_context(&(fd[loop]), &(bufmgr[loop]), ringid);
 
+   /* For high priority set priority of second context to overtake first
+* For low priority set priority of first context to be overtaxen by 
second
+*/
+   if(priority > 0)
+   set_priority(fd[2], priority);
+   else if(priority < 0)
+   set_priority(fd[1], priority);
 
/* Create buffer objects */
delay_bo = create_and_check_bo(bufmgr[0], "delay bo");
@@ -209,9 +229,14 @@ static void run_test_basic(int in_flight, int ringid)
igt_assert_f(igt_compare_timestamps(delay_buf[2], ts1_buf[0]),
 "Delay ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 ")\n",
 delay_buf[2], ts1_buf[0]);
-   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
-"TS1 ts (0x%08" PRIx32 ") > TS2 ts (0x%08" PRIx32 ")\n",
-ts1_buf[0], ts2_buf[0]);
+   if(priority)
+   igt_assert_f(igt_compare_timestamps(ts2_buf[0], ts1_buf[0]),
+"TS2 ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 
")\n",
+ts2_buf[0], ts1_buf[0]);
+   else
+   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
+"TS1 ts (0x%08" PRIx32 ") > TS2 ts (0x%08" PRIx32 
")\n",
+ts1_buf[0], ts2_buf[0]);
 
/* Cleanup */
for(loop = 0; loop < in_flight; loop++)
@@ -438,7 +463,19 @@ igt_main
for (loop=0; loop < NBR_RINGS; loop++)
igt_subtest_f("%s-basic", rings[loop].name) {
gem_require_ring(fd, rings[loop].id);
-   run_test_basic(in_flight, rings[loop].id);
+   run_test_basic(in_flight, rings[loop].id, false);
+   }
+
+   for (loop=0; loop < NBR_RINGS; loop++)
+   igt_subtest_f("%s-priority-high", rings[loop].name) {
+   gem_require_ring(fd, rings[loop].id);
+   run_test_basic(in_flight, rings[loop].id, 1000);
+   }
+
+   for (loop=0; loop < NBR_RINGS; loop++)
+   igt_subtest_f("%s-priority-low", rings[loop].name) {
+   gem_require_ring(fd, rings[loop].id);
+   run_test_basic(in_flight, rings[loop].id, -1000);
}
 
for (loop=0; loop < NBR_RINGS; loop++)
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3 4/6] igt/gem_ctx_param_basic: Updated to support scheduler priority interface

2016-03-10 Thread Derek Morton
From: John Harrison 

The GPU scheduler has added an execution priority level to the context
object. There is an IOCTL interface to allow user apps/libraries to
set this priority. This patch updates the context paramter IOCTL test
to include the new interface.

For: VIZ-1587
Signed-off-by: John Harrison 
---
 lib/ioctl_wrappers.h|  1 +
 tests/gem_ctx_param_basic.c | 34 +-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index e095c41..9e6337e 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -107,6 +107,7 @@ struct local_i915_gem_context_param {
 #define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1
 #define LOCAL_CONTEXT_PARAM_NO_ZEROMAP 0x2
 #define LOCAL_CONTEXT_PARAM_GTT_SIZE   0x3
+#define LOCAL_CONTEXT_PARAM_PRIORITY   0x4
uint64_t value;
 };
 void gem_context_require_ban_period(int fd);
diff --git a/tests/gem_ctx_param_basic.c b/tests/gem_ctx_param_basic.c
index b75800c..585a1a8 100644
--- a/tests/gem_ctx_param_basic.c
+++ b/tests/gem_ctx_param_basic.c
@@ -147,10 +147,42 @@ igt_main
TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
}
 
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+
+   igt_subtest("priority-root-set") {
+   ctx_param.context = ctx;
+   ctx_param.value = 2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = -2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = 512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_subtest("priority-non-root-set") {
+   igt_fork(child, 1) {
+   igt_drop_root();
+
+   ctx_param.context = ctx;
+   ctx_param.value = 512;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EPERM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_waitchildren();
+   }
+
/* NOTE: This testcase intentionally tests for the next free parameter
 * to catch ABI extensions. Don't "fix" this testcase without adding all
 * the tests for the new param first. */
-   ctx_param.param = LOCAL_CONTEXT_PARAM_GTT_SIZE + 1;
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY + 1;
 
igt_subtest("invalid-param-get") {
ctx_param.context = ctx;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3 3/6] tests/gem_scheduler: Add gem_scheduler test

2016-03-10 Thread Derek Morton
This is intended to test the scheduler behaviour is correct.
The subtests are
-basic
Tests that batch buffers of the same priority submitted to a ring
execute in the order they are submitted.
-read
Submits a batch buffer with a read dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a read dependency
to the same buffer object. Ensure they execute before the batch buffer
being held up behind the long running batch buffer.
-write
Submits a batch buffer with a write dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a write dependency
to the same buffer object. Submit batch buffers with no interdependencies
to all rings. Ensure the batch buffers that have write dependencies are
executed in submission order but the batch buffers without interdependencies
do not get held up.

v2: Addressed review comments from Daniele Ceraolo Spurio

v3: Added logic to use generic BSD ring if there is 1 and BSD1 / BSD2 if there
are 2.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/Makefile.sources |   1 +
 tests/gem_scheduler.c  | 459 +
 2 files changed, 460 insertions(+)
 create mode 100644 tests/gem_scheduler.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index f8b18b0..c88e045 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -66,6 +66,7 @@ TESTS_progs_M = \
gem_request_retire \
gem_reset_stats \
gem_ringfill \
+   gem_scheduler \
gem_set_tiling_vs_blt \
gem_softpin \
gem_stolen \
diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
new file mode 100644
index 000..436440a
--- /dev/null
+++ b/tests/gem_scheduler.c
@@ -0,0 +1,459 @@
+/*
+ * Copyright © 2016 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 <derek.j.mor...@intel.com>
+ *
+ */
+
+#include "igt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
+ "batch buffers of the same priority are executed in "
+ "submission order. Read-read tests ensure "
+ "batch buffers with a read dependency to the same buffer "
+ "object do not block each other. Write-write dependency "
+ "tests ensure batch buffers with a write dependency to a "
+ "buffer object will be executed in submission order but "
+ "will not block execution of other independant batch "
+ "buffers.");
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+
+static struct ring {
+   const char *name;
+   int id;
+   bool exists;
+} rings[] = {
+   { "render", I915_EXEC_RENDER, false },
+   { "bsd",I915_EXEC_BSD , false },
+   { "bsd2",I915_EXEC_BSD | 2<<13, false },
+   { "blt",I915_EXEC_BLT, false },
+   { "vebox",  I915_EXEC_VEBOX, false },
+};
+
+#define NBR_RINGS (sizeof(rings)/sizeof(struct ring))
+
+static void check_rings(int fd) {
+   int loop;
+   for(loop=0; loop < NBR_RINGS; loop++) {
+   if(gem_has_ring(fd, rings[loop].id)) {
+   if(rings[loop].id == (I915_EXEC_BSD | 2<<13)) {
+   rings[loop].exists = gem_has_bsd2(fd);
+   }
+   else {
+   

[Intel-gfx] [PATCH i-g-t v3 2/6] lib/intel_batchbuffer: Add functions to be used in the scheduler test

2016-03-10 Thread Derek Morton
Adds functions to create a number of different batch buffers to perform
several functions including:
Batch buffer which will run for a long duration to provide a delay on a
specified ring.
Function to calibrate the delay batch buffer to run for a specified period
of time.
Function to create a batch buffer which writes timestamps to a buffer object.
Function to compare timestamps allowing for wrapping of the values.

v2: Moved code to intel_batchbuffer (Daniel Vetter)
Addressed review comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/intel_batchbuffer.c | 384 +++-
 lib/intel_batchbuffer.h |  14 ++
 2 files changed, 393 insertions(+), 5 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 692521f..30e78c5 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -1,8 +1,8 @@
 /**
- * 
+ *
  * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
- * 
+ *
  * 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
@@ -10,11 +10,11 @@
  * distribute, sub license, 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 NON-INFRINGEMENT.
@@ -22,7 +22,7 @@
  * 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.
- * 
+ *
  **/
 
 #include 
@@ -30,6 +30,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "drm.h"
 #include "drmtest.h"
@@ -42,6 +44,7 @@
 #include "ioctl_wrappers.h"
 #include "media_spin.h"
 #include "gpgpu_fill.h"
+#include "igt_gt.h"
 
 #include 
 
@@ -817,3 +820,374 @@ igt_media_spinfunc_t igt_get_media_spinfunc(int devid)
 
return spin;
 }
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+#define DWORDS_TO_BYTES(x) ((x)*4)
+
+#define MI_STORE_REGISTER_MEM(LENGTH)   ((0x024 << 23) | ((LENGTH - 2) & 0xff))
+#define MI_MATH(NrInst) ((0x01A << 23) | ((NrInst - 1) & 0x3f))
+#define MI_CONDITIONAL_BATCH_BUFFER_END ((0x036 << 23) | (1 << 21) | 2)
+#define MI_COPY_MEM_MEM ((0x02E << 23) | (3))
+
+#define ALU_LOAD(TO, FROM)  ((0x080 << 20) | ((TO) << 10) | (FROM))
+#define ALU_SUB ( 0x101 << 20)
+#define ALU_STORE(TO, FROM) ((0x180 << 20) | ((TO) << 10) | (FROM))
+
+#define TIMESTAMP_offset  (0x358) /* Elapsed time from system start */
+#define CTX_TIMESTAMP_offset  (0x3A8) /* Elapsed Time from context creation */
+#define ALU_GPU_R0_LSB_offset (0x600)
+#define ALU_GPU_R0_MSB_offset (0x604)
+#define ALU_GPU_R1_LSB_offset (0x608)
+#define ALU_GPU_R1_MSB_offset (0x60C)
+#define ALU_GPU_R2_LSB_offset (0x610)
+#define ALU_GPU_R2_MSB_offset (0x614)
+
+#define ALU_R0_ENCODING   (0x00)
+#define ALU_R1_ENCODING   (0x01)
+#define ALU_SRCA_ENCODING (0x20)
+#define ALU_SRCB_ENCODING (0x21)
+#define ALU_ACCU_ENCODING (0x31)
+
+static int bb_address_size_dw(int fd)
+{
+   if (intel_gen(intel_get_drm_devid(fd)) >= 8)
+   return 2;
+   else
+   return 1;
+}
+
+static uint32_t get_mmio_base(int ringid)
+{
+   switch (ringid) {
+   case I915_EXEC_RENDER:
+   return 0x02000;
+   case I915_EXEC_BSD:
+   case I915_EXEC_BSD | 1<<13: /* BSD1 */
+   return 0x12000;
+   case I915_EXEC_BSD | 2<<13: /* BSD2 */
+   return 0x1c000;
+   case I915_EXEC_BLT:
+   return 0x22000;
+   case I915_EXEC_VEBOX:
+   return 0x1A000;
+   default:
+   igt_assert_f(0, "Invalid ringid %d passed to 
get_mmio_base()\n", ringid);
+   }
+}
+
+/**
+ * igt_batch_used
+ * @batch batchbuffer to get offset from
+ *
+ * This returns the number of bytes of the batchbuffer that have been used.
+ * e.g. The offset into the batchbuffer that the next OUT_BATCH would write to.
+ *
+ * Returns:
+ * The number of bytes of the batchbuffer that have been used.
+ */
+uint32_t igt_batch_used(struct intel_batch

[Intel-gfx] [PATCH i-g-t v3 1/6] ioctl_wrappers: make gem_has_ring non static

2016-03-10 Thread Derek Morton
For tests that use multiple rings to test interactions it is
useful to know if a ring exists without triggering the test to skip.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/ioctl_wrappers.c | 2 +-
 lib/ioctl_wrappers.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 5d49729..f42e2c9 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1396,7 +1396,7 @@ void gem_require_caching(int fd)
errno = 0;
 }
 
-static int gem_has_ring(int fd, int ring)
+int gem_has_ring(int fd, int ring)
 {
uint32_t bbe = MI_BATCH_BUFFER_END;
struct drm_i915_gem_execbuffer2 execbuf;
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index f59eafb..e095c41 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -150,6 +150,7 @@ uint64_t gem_global_aperture_size(int fd);
 uint64_t gem_mappable_aperture_size(void);
 bool gem_has_softpin(int fd);
 
+int gem_has_ring(int fd, int ring);
 /* check functions which auto-skip tests by calling igt_skip() */
 void gem_require_caching(int fd);
 void gem_require_ring(int fd, int ring_id);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3 0/6] Scheduler tests

2016-03-10 Thread Derek Morton
This patch set adds scheduler tests.
Patch 1 Makes gem_has_ring() non static as the test will need to call it
Patch 2 adds library code used by the tests. There are other tests under
development which are planned to reuse some of these libraries.
Patch 3 adds some basic tests, read dependency tests and write dependency tests.
Patch 4 Is the patch previously submitted by John Harrison to update
gem_ctx_param_basic with ioctls to set context priorities. It is included as
part of this patch set as Patch 6 & 7 are dependant on it.
Patch 5 adds subtests to check sheduler behaviour for batch buffers submitted at
differing priorities.
Patch 6 adds subtests to check priority bumping behaviour.

v2: Updates for comments from Daniele Ceraolo Spurio and Daniel Vetter
Added tests requested by Joonas Lahtinen

v3: Removed the patch to update gem_has_ring() and updated the test to
use BSD if there is 1 ring and BSD1 / BSD2 if there are two.

Derek Morton (5):
  ioctl_wrappers: make gem_has_ring non static
  lib/intel_batchbuffer: Add functions to be used in the scheduler test
  tests/gem_scheduler: Add gem_scheduler test
  tests/gem_scheduler: Add subtests to test batch priority behaviour
  gem_scheduler: Added subtests to test priority bumping

John Harrison (1):
  igt/gem_ctx_param_basic: Updated to support scheduler priority
interface

 lib/intel_batchbuffer.c | 384 ++-
 lib/intel_batchbuffer.h |  14 +
 lib/ioctl_wrappers.c|   2 +-
 lib/ioctl_wrappers.h|   2 +
 tests/Makefile.sources  |   1 +
 tests/gem_ctx_param_basic.c |  34 ++-
 tests/gem_scheduler.c   | 630 
 7 files changed, 1060 insertions(+), 7 deletions(-)
 create mode 100644 tests/gem_scheduler.c

-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2 3/7] lib/intel_batchbuffer: Add functions to be used in the scheduler test

2016-03-02 Thread Derek Morton
Adds functions to create a number of different batch buffers to perform
several functions including:
Batch buffer which will run for a long duration to provide a delay on a
specified ring.
Function to calibrate the delay batch buffer to run for a specified period
of time.
Function to create a batch buffer which writes timestamps to a buffer object.
Function to compare timestamps allowing for wrapping of the values.

v2: Moved code to intel_batchbuffer (Daniel Vetter)
Addressed review comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/intel_batchbuffer.c | 384 +++-
 lib/intel_batchbuffer.h |  14 ++
 2 files changed, 393 insertions(+), 5 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 692521f..30e78c5 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -1,8 +1,8 @@
 /**
- * 
+ *
  * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
- * 
+ *
  * 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
@@ -10,11 +10,11 @@
  * distribute, sub license, 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 NON-INFRINGEMENT.
@@ -22,7 +22,7 @@
  * 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.
- * 
+ *
  **/
 
 #include 
@@ -30,6 +30,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "drm.h"
 #include "drmtest.h"
@@ -42,6 +44,7 @@
 #include "ioctl_wrappers.h"
 #include "media_spin.h"
 #include "gpgpu_fill.h"
+#include "igt_gt.h"
 
 #include 
 
@@ -817,3 +820,374 @@ igt_media_spinfunc_t igt_get_media_spinfunc(int devid)
 
return spin;
 }
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+#define DWORDS_TO_BYTES(x) ((x)*4)
+
+#define MI_STORE_REGISTER_MEM(LENGTH)   ((0x024 << 23) | ((LENGTH - 2) & 0xff))
+#define MI_MATH(NrInst) ((0x01A << 23) | ((NrInst - 1) & 0x3f))
+#define MI_CONDITIONAL_BATCH_BUFFER_END ((0x036 << 23) | (1 << 21) | 2)
+#define MI_COPY_MEM_MEM ((0x02E << 23) | (3))
+
+#define ALU_LOAD(TO, FROM)  ((0x080 << 20) | ((TO) << 10) | (FROM))
+#define ALU_SUB ( 0x101 << 20)
+#define ALU_STORE(TO, FROM) ((0x180 << 20) | ((TO) << 10) | (FROM))
+
+#define TIMESTAMP_offset  (0x358) /* Elapsed time from system start */
+#define CTX_TIMESTAMP_offset  (0x3A8) /* Elapsed Time from context creation */
+#define ALU_GPU_R0_LSB_offset (0x600)
+#define ALU_GPU_R0_MSB_offset (0x604)
+#define ALU_GPU_R1_LSB_offset (0x608)
+#define ALU_GPU_R1_MSB_offset (0x60C)
+#define ALU_GPU_R2_LSB_offset (0x610)
+#define ALU_GPU_R2_MSB_offset (0x614)
+
+#define ALU_R0_ENCODING   (0x00)
+#define ALU_R1_ENCODING   (0x01)
+#define ALU_SRCA_ENCODING (0x20)
+#define ALU_SRCB_ENCODING (0x21)
+#define ALU_ACCU_ENCODING (0x31)
+
+static int bb_address_size_dw(int fd)
+{
+   if (intel_gen(intel_get_drm_devid(fd)) >= 8)
+   return 2;
+   else
+   return 1;
+}
+
+static uint32_t get_mmio_base(int ringid)
+{
+   switch (ringid) {
+   case I915_EXEC_RENDER:
+   return 0x02000;
+   case I915_EXEC_BSD:
+   case I915_EXEC_BSD | 1<<13: /* BSD1 */
+   return 0x12000;
+   case I915_EXEC_BSD | 2<<13: /* BSD2 */
+   return 0x1c000;
+   case I915_EXEC_BLT:
+   return 0x22000;
+   case I915_EXEC_VEBOX:
+   return 0x1A000;
+   default:
+   igt_assert_f(0, "Invalid ringid %d passed to 
get_mmio_base()\n", ringid);
+   }
+}
+
+/**
+ * igt_batch_used
+ * @batch batchbuffer to get offset from
+ *
+ * This returns the number of bytes of the batchbuffer that have been used.
+ * e.g. The offset into the batchbuffer that the next OUT_BATCH would write to.
+ *
+ * Returns:
+ * The number of bytes of the batchbuffer that have been used.
+ */
+uint32_t igt_batch_used(struct intel_batch

[Intel-gfx] [PATCH i-g-t v2 7/7] gem_scheduler: Added subtests to test priority bumping

2016-03-02 Thread Derek Morton
When a higher priority batch buffer bumps a lower priority batch
buffer all batch buffers in the scheduler queue get a small priority
increase. Added a subtest to check this behaviour.

Requested by Joonas Lahtinen during scheduler code review

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_scheduler.c | 134 ++
 1 file changed, 134 insertions(+)

diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
index 171b0a3..0e2a4b4 100644
--- a/tests/gem_scheduler.c
+++ b/tests/gem_scheduler.c
@@ -246,6 +246,134 @@ static void run_test_basic(int in_flight, int ringid, int 
priority)
free(in_flight_bbs);
 }
 
+
+/* Test priority bump behaviour.
+ * When a batch buffer is bumped by a higher priority batch buffer all other
+ * batch buffers in the scheduler queue get their priority increased slightly.
+ * Submit two delay batch buffers then fill the in flight queue. Submit a
+ * slightly reduced priority batch buffer and a normal priority batch buffer.
+ * When the first delay batch buffer completes priority bumping should occur.
+ * Submit another normal priority batch buffer. It should not overtake the
+ * reduced priority batch buffer as its priority has been bumped.
+ */
+#define NBR_PRIO_BUMP_FDs (4)
+static void run_test_priority_bump(int in_flight, int ringid)
+{
+   int fd[NBR_PRIO_BUMP_FDs];
+   int loop;
+   drm_intel_bufmgr *bufmgr[NBR_PRIO_BUMP_FDs];
+   uint32_t *delay_buf, *delay2_buf, *ts1_buf, *ts2_buf, *ts3_buf;
+   struct intel_batchbuffer *ts1_bb, *ts2_bb, *ts3_bb;
+   struct intel_batchbuffer **in_flight_bbs;
+   uint32_t calibrated_1s;
+   drm_intel_bo *delay_bo, *delay2_bo ,*ts1_bo, *ts2_bo, *ts3_bo;
+
+   in_flight_bbs = malloc(in_flight * sizeof(struct intel_batchbuffer *));
+   igt_assert(in_flight_bbs);
+
+   /* Need multiple i915 fd's. Scheduler will not change execution order of
+* batch buffers from the same context.
+*/
+   for(loop=0; loop < NBR_PRIO_BUMP_FDs; loop++)
+   init_context(&(fd[loop]), &(bufmgr[loop]), ringid);
+
+   /* Lower priority of first timestamp batch buffer
+* Second timestamp batch buffer should overtake the first
+* Second should then get bumped so the third does not overtake it
+*/
+   set_priority(fd[1], -1);
+
+   /* Create buffer objects */
+   delay_bo = create_and_check_bo(bufmgr[0], "delay bo");
+   delay2_bo = create_and_check_bo(bufmgr[0], "delay bo2");
+   ts1_bo = create_and_check_bo(bufmgr[1], "ts1 bo");
+   ts2_bo = create_and_check_bo(bufmgr[2], "ts2 bo");
+   ts3_bo = create_and_check_bo(bufmgr[3], "ts23 bo");
+
+   /* Put some non zero values in the delay bo */
+   {
+   uint32_t data=0x;
+   drm_intel_bo_subdata(delay_bo, 0, 4, );
+   drm_intel_bo_subdata(delay2_bo, 0, 4, );
+   }
+
+   calibrated_1s = igt_calibrate_delay_bb(fd[0], bufmgr[0], ringid);
+
+   /* Batch buffers to fill the in flight queue */
+   in_flight_bbs[0] = create_delay_bb(fd[0], bufmgr[0], ringid, 
calibrated_1s, delay_bo);
+   in_flight_bbs[1] = create_delay_bb(fd[0], bufmgr[0], ringid, 
calibrated_1s, delay2_bo);
+   for(loop = 2; loop < in_flight; loop++)
+   in_flight_bbs[loop] = create_noop_bb(fd[0], bufmgr[0], 5);
+
+   /* Extra batch buffers in the scheduler queue */
+   ts1_bb = create_timestamp_bb(fd[1], bufmgr[1], ringid, ts1_bo, NULL, 
false);
+   ts2_bb = create_timestamp_bb(fd[2], bufmgr[2], ringid, ts2_bo, NULL, 
false);
+   ts3_bb = create_timestamp_bb(fd[3], bufmgr[3], ringid, ts3_bo, NULL, 
false);
+
+   /* Flush batchbuffers */
+   for(loop = 0; loop < in_flight; loop++)
+   intel_batchbuffer_flush_on_ring(in_flight_bbs[loop], ringid);
+   intel_batchbuffer_flush_on_ring(ts1_bb, ringid);
+   intel_batchbuffer_flush_on_ring(ts2_bb, ringid);
+
+   /* This will not return until the bo has finished executing */
+   drm_intel_bo_map(delay_bo, 0);
+   /* Once the first delay is complete and any bumping has occured, submit
+* the final batch buffer
+*/
+   intel_batchbuffer_flush_on_ring(ts3_bb, ringid);
+
+   drm_intel_bo_map(delay2_bo, 0);
+   drm_intel_bo_map(ts1_bo, 0);
+   drm_intel_bo_map(ts2_bo, 0);
+   drm_intel_bo_map(ts3_bo, 0);
+
+   delay_buf = delay_bo->virtual;
+   delay2_buf = delay2_bo->virtual;
+   ts1_buf = ts1_bo->virtual;
+   ts2_buf = ts2_bo->virtual;
+   ts3_buf = ts3_bo->virtual;
+
+   igt_debug("Delay Timestamp = 0x%08" PRIx32 "\n", delay_buf[2]);
+   igt_debug("Delay Timestamp = 0x%08" PRIx32 "\n", delay2_buf[2]);
+   igt_debug("TS1 Timestamp = 0x%08" PRIx32 "\n"

[Intel-gfx] [PATCH i-g-t v2 1/7] ioctl_wrappers: make gem_has_ring non static

2016-03-02 Thread Derek Morton
For tests that use multiple rings to test interactions it is
useful to know if a ring exists without triggering the test to skip.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/ioctl_wrappers.c | 2 +-
 lib/ioctl_wrappers.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 5d49729..f42e2c9 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1396,7 +1396,7 @@ void gem_require_caching(int fd)
errno = 0;
 }
 
-static int gem_has_ring(int fd, int ring)
+int gem_has_ring(int fd, int ring)
 {
uint32_t bbe = MI_BATCH_BUFFER_END;
struct drm_i915_gem_execbuffer2 execbuf;
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index f59eafb..e095c41 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -150,6 +150,7 @@ uint64_t gem_global_aperture_size(int fd);
 uint64_t gem_mappable_aperture_size(void);
 bool gem_has_softpin(int fd);
 
+int gem_has_ring(int fd, int ring);
 /* check functions which auto-skip tests by calling igt_skip() */
 void gem_require_caching(int fd);
 void gem_require_ring(int fd, int ring_id);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2 6/7] tests/gem_scheduler: Add subtests to test batch priority behaviour

2016-03-02 Thread Derek Morton
Add subtests to test each ring to check batch buffers of a higher
priority will be executed before batch buffers of a lower priority.

v2: Addressed review comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_scheduler.c | 53 +++
 1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
index 762b69f..171b0a3 100644
--- a/tests/gem_scheduler.c
+++ b/tests/gem_scheduler.c
@@ -39,7 +39,8 @@
 
 IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
  "batch buffers of the same priority are executed in "
- "submission order. Read-read tests ensure "
+ "submission order. Priority tests ensure higher priority "
+ "batch buffers are executed first. Read-read tests ensure 
"
  "batch buffers with a read dependency to the same buffer "
  "object do not block each other. Write-write dependency "
  "tests ensure batch buffers with a write dependency to a "
@@ -128,11 +129,23 @@ static void init_context(int *fd, drm_intel_bufmgr 
**bufmgr, int ringid)
intel_batchbuffer_free(noop_bb);
 }
 
-/* Basic test. Check batch buffers of the same priority and with no 
dependencies
- * are executed in the order they are submitted.
+static void set_priority(int fd, int value)
+{
+   struct local_i915_gem_context_param param;
+   param.context = 0; /* Default context */
+   param.size = 0;
+   param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+   param.value = (uint64_t)value;
+   gem_context_set_param(fd, );
+}
+
+/* If 'priority' is 0, check batch buffers of the same priority and with
+ * no dependencies are executed in the order they are submitted.
+ * If 'priority' is set !0, check batch buffers of higher priority are
+ * executed before batch buffers of lower priority.
  */
 #define NBR_BASIC_FDs (3)
-static void run_test_basic(int in_flight, int ringid)
+static void run_test_basic(int in_flight, int ringid, int priority)
 {
int fd[NBR_BASIC_FDs];
int loop;
@@ -152,6 +165,13 @@ static void run_test_basic(int in_flight, int ringid)
for(loop=0; loop < NBR_BASIC_FDs; loop++)
init_context(&(fd[loop]), &(bufmgr[loop]), ringid);
 
+   /* For high priority set priority of second context to overtake first
+* For low priority set priority of first context to be overtaxen by 
second
+*/
+   if(priority > 0)
+   set_priority(fd[2], priority);
+   else if(priority < 0)
+   set_priority(fd[1], priority);
 
/* Create buffer objects */
delay_bo = create_and_check_bo(bufmgr[0], "delay bo");
@@ -201,9 +221,14 @@ static void run_test_basic(int in_flight, int ringid)
igt_assert_f(igt_compare_timestamps(delay_buf[2], ts1_buf[0]),
 "Delay ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 ")\n",
 delay_buf[2], ts1_buf[0]);
-   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
-"TS1 ts (0x%08" PRIx32 ") > TS2 ts (0x%08" PRIx32 ")\n",
-ts1_buf[0], ts2_buf[0]);
+   if(priority)
+   igt_assert_f(igt_compare_timestamps(ts2_buf[0], ts1_buf[0]),
+"TS2 ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 
")\n",
+ts2_buf[0], ts1_buf[0]);
+   else
+   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
+"TS1 ts (0x%08" PRIx32 ") > TS2 ts (0x%08" PRIx32 
")\n",
+ts1_buf[0], ts2_buf[0]);
 
/* Cleanup */
for(loop = 0; loop < in_flight; loop++)
@@ -430,7 +455,19 @@ igt_main
for (loop=0; loop < NBR_RINGS; loop++)
igt_subtest_f("%s-basic", rings[loop].name) {
gem_require_ring(fd, rings[loop].id);
-   run_test_basic(in_flight, rings[loop].id);
+   run_test_basic(in_flight, rings[loop].id, false);
+   }
+
+   for (loop=0; loop < NBR_RINGS; loop++)
+   igt_subtest_f("%s-priority-high", rings[loop].name) {
+   gem_require_ring(fd, rings[loop].id);
+   run_test_basic(in_flight, rings[loop].id, 1000);
+   }
+
+   for (loop=0; loop < NBR_RINGS; loop++)
+   igt_subtest_f("%s-priority-low", rings[loop].name) {
+   gem_require_ring(fd, rings[loop].id);
+   run_test_basic(in_flight, rings[loop].id, -1000);
}
 
for (loop=0; loop < NBR_RINGS; loop++)
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2 2/7] lib/ioctl_wrappers: Separate ring BSD1 from BSD2 checks

2016-03-02 Thread Derek Morton
Some platforms have ring BSD available but no BSD2.
Because of the current verification, tests involving ring BSD1
will be skipped if no BSD2 is available.

Decoupling the checks will allow running the BSD1 specific tests
on these platforms.

Based on a patch originally submitted by Gabriel Feceoru to
patchwork-hook-test branch.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/ioctl_wrappers.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index f42e2c9..a4c6aa4 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1432,8 +1432,10 @@ void gem_require_ring(int fd, int ring_id)
 
/* silly ABI, the kernel thinks everyone who has BSD also has BSD2 */
if ((ring_id & ~(3<<13)) == I915_EXEC_BSD) {
-   if (ring_id & (3 << 13))
+   if (ring_id & (2 << 13))
igt_require(gem_has_bsd2(fd));
+   if (ring_id & (1 << 13))
+   igt_require(gem_has_bsd(fd));
}
 }
 
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2 5/7] igt/gem_ctx_param_basic: Updated to support scheduler priority interface

2016-03-02 Thread Derek Morton
From: John Harrison 

The GPU scheduler has added an execution priority level to the context
object. There is an IOCTL interface to allow user apps/libraries to
set this priority. This patch updates the context paramter IOCTL test
to include the new interface.

For: VIZ-1587
Signed-off-by: John Harrison 
---
 lib/ioctl_wrappers.h|  1 +
 tests/gem_ctx_param_basic.c | 34 +-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index e095c41..9e6337e 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -107,6 +107,7 @@ struct local_i915_gem_context_param {
 #define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1
 #define LOCAL_CONTEXT_PARAM_NO_ZEROMAP 0x2
 #define LOCAL_CONTEXT_PARAM_GTT_SIZE   0x3
+#define LOCAL_CONTEXT_PARAM_PRIORITY   0x4
uint64_t value;
 };
 void gem_context_require_ban_period(int fd);
diff --git a/tests/gem_ctx_param_basic.c b/tests/gem_ctx_param_basic.c
index b75800c..585a1a8 100644
--- a/tests/gem_ctx_param_basic.c
+++ b/tests/gem_ctx_param_basic.c
@@ -147,10 +147,42 @@ igt_main
TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
}
 
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+
+   igt_subtest("priority-root-set") {
+   ctx_param.context = ctx;
+   ctx_param.value = 2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = -2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = 512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_subtest("priority-non-root-set") {
+   igt_fork(child, 1) {
+   igt_drop_root();
+
+   ctx_param.context = ctx;
+   ctx_param.value = 512;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EPERM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_waitchildren();
+   }
+
/* NOTE: This testcase intentionally tests for the next free parameter
 * to catch ABI extensions. Don't "fix" this testcase without adding all
 * the tests for the new param first. */
-   ctx_param.param = LOCAL_CONTEXT_PARAM_GTT_SIZE + 1;
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY + 1;
 
igt_subtest("invalid-param-get") {
ctx_param.context = ctx;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2 4/7] tests/gem_scheduler: Add gem_scheduler test

2016-03-02 Thread Derek Morton
This is intended to test the scheduler behaviour is correct.
The subtests are
-basic
Tests that batch buffers of the same priority submitted to a ring
execute in the order they are submitted.
-read
Submits a batch buffer with a read dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a read dependency
to the same buffer object. Ensure they execute before the batch buffer
being held up behind the long running batch buffer.
-write
Submits a batch buffer with a write dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a write dependency
to the same buffer object. Submit batch buffers with no interdependencies
to all rings. Ensure the batch buffers that have write dependencies are
executed in submission order but the batch buffers without interdependencies
do not get held up.

v2: Addressed review comments from Daniele Ceraolo Spurio

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/Makefile.sources |   1 +
 tests/gem_scheduler.c  | 451 +
 2 files changed, 452 insertions(+)
 create mode 100644 tests/gem_scheduler.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index f8b18b0..c88e045 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -66,6 +66,7 @@ TESTS_progs_M = \
gem_request_retire \
gem_reset_stats \
gem_ringfill \
+   gem_scheduler \
gem_set_tiling_vs_blt \
gem_softpin \
gem_stolen \
diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
new file mode 100644
index 000..762b69f
--- /dev/null
+++ b/tests/gem_scheduler.c
@@ -0,0 +1,451 @@
+/*
+ * Copyright © 2016 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 <derek.j.mor...@intel.com>
+ *
+ */
+
+#include "igt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
+ "batch buffers of the same priority are executed in "
+ "submission order. Read-read tests ensure "
+ "batch buffers with a read dependency to the same buffer "
+ "object do not block each other. Write-write dependency "
+ "tests ensure batch buffers with a write dependency to a "
+ "buffer object will be executed in submission order but "
+ "will not block execution of other independant batch "
+ "buffers.");
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+
+static struct ring {
+   const char *name;
+   int id;
+   bool exists;
+} rings[] = {
+   { "render", I915_EXEC_RENDER, false },
+   { "bsd1",I915_EXEC_BSD | 1<<13, false },
+   { "bsd2",I915_EXEC_BSD | 2<<13, false },
+   { "blt",I915_EXEC_BLT, false },
+   { "vebox",  I915_EXEC_VEBOX, false },
+};
+
+#define NBR_RINGS (sizeof(rings)/sizeof(struct ring))
+
+static void check_rings(int fd) {
+   int loop;
+   for(loop=0; loop < NBR_RINGS; loop++) {
+   if(gem_has_ring(fd, rings[loop].id)) {
+   if(rings[loop].id == (I915_EXEC_BSD | 2<<13))
+   rings[loop].exists = gem_has_bsd2(fd);
+   else
+   rings[loop].exists = true;
+   }
+   }
+}
+
+static drm_intel_bo *create_and_check_bo(drm_intel_bufmgr *bufm

[Intel-gfx] [PATCH i-g-t v2 0/7] Scheduler tests

2016-03-02 Thread Derek Morton
This patch set adds scheduler tests.
Patch 1 Makes gem_has_ring() non static as the test will need to call it
Patch 2 Separate ring BSD1 from BSD2 in gem_require_ring() to prevent the
BSD1 specific tests from skipping if there is no BSD2 ring. Based on a patch
originally submitted by Gabriel Feceoru.
Patch 3 adds library code used by the tests. There are other tests under
development which are planned to reuse some of these libraries.
Patch 4 adds some basic tests, read dependency tests and write dependency tests.
Patch 5 Is the patch previously submitted by John Harrison to update
gem_ctx_param_basic with ioctls to set context priorities. It is included as
part of this patch set as Patch 6 & 7 are dependant on it.
Patch 6 adds tests to check sheduler behaviour for batch buffers submitted at
differing priorities.
Patch 7 adds tests to check priority bumping behaviour.

v2: Updates for comments from Daniele Ceraolo Spurio and Daniel Vetter
Added tests requested by Joonas Lahtinen

Derek Morton (6):
  ioctl_wrappers: make gem_has_ring non static
  lib/ioctl_wrappers: Separate ring BSD1 from BSD2 checks
  lib/intel_batchbuffer: Add functions to be used in the scheduler test
  tests/gem_scheduler: Add gem_scheduler test
  tests/gem_scheduler: Add subtests to test batch priority behaviour
  gem_scheduler: Added subtests to test priority bumping

John Harrison (1):
  igt/gem_ctx_param_basic: Updated to support scheduler priority
interface

 lib/intel_batchbuffer.c | 384 ++-
 lib/intel_batchbuffer.h |  14 +
 lib/ioctl_wrappers.c|   6 +-
 lib/ioctl_wrappers.h|   2 +
 tests/Makefile.sources  |   1 +
 tests/gem_ctx_param_basic.c |  34 ++-
 tests/gem_scheduler.c   | 622 
 7 files changed, 1055 insertions(+), 8 deletions(-)
 create mode 100644 tests/gem_scheduler.c

-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] lib/igt_core.c: Add partial match functionality to run-subtests

2016-02-19 Thread Derek Morton
Add the ability to specify a substring of the subtest using --run-subtests.

This allows 'string' to be used as an abbreviation of the wildcard expression
'*string*' when defining which subtests should run.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/igt_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8e0bd2e..1e31a25 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -215,7 +215,7 @@
  * description of allowed wildcard expressions.
  * Some examples of allowed wildcard expressions are:
  *
- * - '*basic*' match any subtest containing basic
+ * - '*basic*' match any subtest containing basic. This expression may be 
abbreviated to just 'basic'.
  * - 'basic-???' match any subtest named basic- with 3 characters after -
  * - 'basic-[0-9]' match any subtest named basic- with a single number after -
  * - 'basic-[^0-9]' match any subtest named basic- with a single non numerical 
character after -
@@ -827,7 +827,8 @@ bool __igt_run_subtest(const char *subtest_name)
}
 
if (run_single_subtest) {
-   if (uwildmat(subtest_name, run_single_subtest) == 0)
+   if ((uwildmat(subtest_name, run_single_subtest) == 0) &&
+   (NULL == strstr(subtest_name, run_single_subtest)))
return false;
else
run_single_subtest_found = true;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t 0/4] Scheduler tests

2016-02-12 Thread Derek Morton
This patch set adds scheduler tests.
Patch 1 adds library code used by the tests. There are other tests under
development which are planned to reuse some of these libraries.
Patch 2 adds some basic tests, read dependency tests and write dependency tests.
Patch 3 Is the patch previously submitted by John Harrison to update
gem_ctx_param_basic with ioctls to set context priorities. It is included as
part of this patch set as Patch 4 is dependant on it.
Patch 4 adds tests to check sheduler behaviour for batch buffers submitted at
differing priorities.

Derek Morton (3):
  lib/igt_bb_factory: Add igt_bb_factory library
  tests/gem_scheduler: Add gem_scheduler test
  tests/gem_scheduler: Add subtests to test batch priority behaviour

John Harrison (1):
  igt/gem_ctx_param_basic: Updated to support scheduler priority
interface

 lib/Makefile.sources|   2 +
 lib/igt.h   |   1 +
 lib/igt_bb_factory.c| 401 +
 lib/igt_bb_factory.h|  47 +
 lib/ioctl_wrappers.h|   1 +
 tests/Makefile.sources  |   1 +
 tests/gem_ctx_param_basic.c |  34 +++-
 tests/gem_scheduler.c   | 431 
 8 files changed, 917 insertions(+), 1 deletion(-)
 create mode 100644 lib/igt_bb_factory.c
 create mode 100644 lib/igt_bb_factory.h
 create mode 100644 tests/gem_scheduler.c

-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t 2/4] tests/gem_scheduler: Add gem_scheduler test

2016-02-12 Thread Derek Morton
This is intended to test the scheduler behaviour is correct.
The subtests are
-basic
Tests that batch buffers of the same priority submitted to a ring
execute in the order they are submitted.
-read
Submits a batch buffer with a read dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a read dependency
to the same buffer object. Ensure they execute before the batch buffer
being held up behind the long running batch buffer.
-write
Submits a batch buffer with a write dependency to a buffer object to
a ring which is held in the scheduler queue by a long running batch
buffer. Submit batch buffers to other rings that have a write dependency
to the same buffer object. Submit batch buffers with no interdependencies
to all rings. Ensure the batch buffers that have write dependencies are
executed in submission order but the batch buffers without interdependencies
do not get held up.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/Makefile.sources |   1 +
 tests/gem_scheduler.c  | 409 +
 2 files changed, 410 insertions(+)
 create mode 100644 tests/gem_scheduler.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index df92586..439f62c 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -66,6 +66,7 @@ TESTS_progs_M = \
gem_request_retire \
gem_reset_stats \
gem_ringfill \
+   gem_scheduler \
gem_set_tiling_vs_blt \
gem_softpin \
gem_stolen \
diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
new file mode 100644
index 000..4824c13
--- /dev/null
+++ b/tests/gem_scheduler.c
@@ -0,0 +1,409 @@
+/*
+ * Copyright © 2016 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 <derek.j.mor...@intel.com>
+ *
+ */
+
+#include "igt.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
+ "batch buffers of the same priority are executed in "
+ "submission order. Read-read tests ensure "
+ "batch buffers with a read dependency to the same buffer "
+ "object do not block each other. Write-write dependency "
+ "tests ensure batch buffers with a write dependency to a "
+ "buffer object will be executed in submission order but "
+ "will not block execution of other independant batch "
+ "buffers.");
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+
+struct ring {
+   const char *name;
+   int id;
+} rings[] = {
+   { "render", I915_EXEC_RENDER },
+   { "bsd",I915_EXEC_BSD },
+   { "blt",I915_EXEC_BLT },
+   { "vebox",  I915_EXEC_VEBOX },
+};
+
+#define NBR_RINGS (sizeof(rings)/sizeof(struct ring))
+
+/* Basic test. Check batch buffers of the same priority and with no 
dependencies
+ * are executed in the order they are submitted.
+ */
+#define NBR_BASIC_FDs (3)
+static void run_test_basic(int in_flight, int ringid)
+{
+   int fd[NBR_BASIC_FDs];
+   int loop;
+   drm_intel_bufmgr *bufmgr[NBR_BASIC_FDs];
+   uint32_t *delay_buf, *ts1_buf, *ts2_buf;
+   struct intel_batchbuffer *ts1_bb, *ts2_bb;
+   struct intel_batchbuffer **in_flight_bbs;
+   uint32_t calibrated_1s;
+   drm_intel_bo *delay_bo, *ts1_bo, *ts2_bo;
+
+   in_flight_bbs = malloc(in_flight * sizeof(struct intel_batchbuffer *));
+   igt_assert(in_flight_bbs);
+
+   /* Need

[Intel-gfx] [PATCH i-g-t 1/4] lib/igt_bb_factory: Add igt_bb_factory library

2016-02-12 Thread Derek Morton
Adds functions to create a number of different batch buffers to perform
several functions including:
Batch buffer which will run for a long duration to provide a delay on a
specified ring.
Function to calibrate the delay batch buffer to run for a specified period
of time.
Function to create a batch buffer which writes timestamps to a buffer object.
Function to compare timestamps allowing for wrapping of the values.

Intended for use by the gem_scheduler test initially but will be used by other
tests in development.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/Makefile.sources |   2 +
 lib/igt.h|   1 +
 lib/igt_bb_factory.c | 401 +++
 lib/igt_bb_factory.h |  47 ++
 4 files changed, 451 insertions(+)
 create mode 100644 lib/igt_bb_factory.c
 create mode 100644 lib/igt_bb_factory.h

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 4999868..c560b3e 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -7,6 +7,8 @@ libintel_tools_la_SOURCES = \
i915_reg.h  \
i915_pciids.h   \
igt.h   \
+   igt_bb_factory.c\
+   igt_bb_factory.h\
igt_debugfs.c   \
igt_debugfs.h   \
igt_aux.c   \
diff --git a/lib/igt.h b/lib/igt.h
index 3be2551..0f29420 100644
--- a/lib/igt.h
+++ b/lib/igt.h
@@ -36,6 +36,7 @@
 #include "igt_gt.h"
 #include "igt_kms.h"
 #include "igt_stats.h"
+#include "igt_bb_factory.h"
 #include "instdone.h"
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
diff --git a/lib/igt_bb_factory.c b/lib/igt_bb_factory.c
new file mode 100644
index 000..eea63c6
--- /dev/null
+++ b/lib/igt_bb_factory.c
@@ -0,0 +1,401 @@
+/*
+ * Copyright © 2016 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 <derek.j.mor...@intel.com>
+ *
+ */
+
+#include "igt.h"
+#include "intel_batchbuffer.h"
+#include 
+#include 
+#include 
+
+#define SEC_TO_NSEC (1000 * 1000 * 1000)
+#define DWORDS_TO_BYTES(x) ((x)*4)
+
+#define MI_STORE_REGISTER_MEM(LENGTH)   ((0x024 << 23) | ((LENGTH - 2) & 0xff))
+#define MI_MATH(NrInst) ((0x01A << 23) | ((NrInst - 1) & 0x3f))
+#define MI_CONDITIONAL_BATCH_BUFFER_END ((0x036 << 23) | (1 << 21) | 2)
+#define MI_COPY_MEM_MEM ((0x02E << 23) | (3))
+
+#define ALU_LOAD(TO, FROM)  ((0x080 << 20) | ((TO) << 10) | (FROM))
+#define ALU_SUB ( 0x101 << 20)
+#define ALU_STORE(TO, FROM) ((0x180 << 20) | ((TO) << 10) | (FROM))
+
+#define TIMESTAMP_offset  (0x358) /* Elapsed time from system start */
+#define CTX_TIMESTAMP_offset  (0x3A8) /* Elapsed Time from context creation */
+#define ALU_GPU_R0_LSB_offset (0x600)
+#define ALU_GPU_R0_MSB_offset (0x604)
+#define ALU_GPU_R1_LSB_offset (0x608)
+#define ALU_GPU_R1_MSB_offset (0x60C)
+#define ALU_GPU_R2_LSB_offset (0x610)
+#define ALU_GPU_R2_MSB_offset (0x614)
+
+#define ALU_R0_ENCODING   (0x00)
+#define ALU_R1_ENCODING   (0x01)
+#define ALU_SRCA_ENCODING (0x20)
+#define ALU_SRCB_ENCODING (0x21)
+#define ALU_ACCU_ENCODING (0x31)
+
+/**
+ * SECTION:igt_bb_factory
+ * @short_description: Utility functions for creating batch buffers
+ * @title: Batch Buffer Factory
+ * @include: igt.h
+ *
+ * This library implements functions for creating batch buffers which may be
+ * useful to multiple tests.
+ */
+
+static void check_gen_8(int fd)
+{
+   static bool checked = false;
+   if(!checked) {
+   igt_require(intel_gen(intel_get_drm_devid(fd)) >= 8);
+   checked = true;
+   }
+}
+
+static int bb_address_size_dw(int fd)
+{
+   if (intel_ge

[Intel-gfx] [PATCH i-g-t 3/4] igt/gem_ctx_param_basic: Updated to support scheduler priority interface

2016-02-12 Thread Derek Morton
From: John Harrison 

The GPU scheduler has added an execution priority level to the context
object. There is an IOCTL interface to allow user apps/libraries to
set this priority. This patch updates the context paramter IOCTL test
to include the new interface.

For: VIZ-1587
Signed-off-by: John Harrison 
---
 lib/ioctl_wrappers.h|  1 +
 tests/gem_ctx_param_basic.c | 34 +-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 4d913c5..f1ef739 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -106,6 +106,7 @@ struct local_i915_gem_context_param {
 #define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1
 #define LOCAL_CONTEXT_PARAM_NO_ZEROMAP 0x2
 #define LOCAL_CONTEXT_PARAM_GTT_SIZE   0x3
+#define LOCAL_CONTEXT_PARAM_PRIORITY   0x4
uint64_t value;
 };
 void gem_context_require_ban_period(int fd);
diff --git a/tests/gem_ctx_param_basic.c b/tests/gem_ctx_param_basic.c
index b75800c..585a1a8 100644
--- a/tests/gem_ctx_param_basic.c
+++ b/tests/gem_ctx_param_basic.c
@@ -147,10 +147,42 @@ igt_main
TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
}
 
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+
+   igt_subtest("priority-root-set") {
+   ctx_param.context = ctx;
+   ctx_param.value = 2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = -2048;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EINVAL);
+   ctx_param.value = 512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_subtest("priority-non-root-set") {
+   igt_fork(child, 1) {
+   igt_drop_root();
+
+   ctx_param.context = ctx;
+   ctx_param.value = 512;
+   TEST_FAIL(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, EPERM);
+   ctx_param.value = -512;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   ctx_param.value = 0;
+   TEST_SUCCESS(LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM);
+   }
+
+   igt_waitchildren();
+   }
+
/* NOTE: This testcase intentionally tests for the next free parameter
 * to catch ABI extensions. Don't "fix" this testcase without adding all
 * the tests for the new param first. */
-   ctx_param.param = LOCAL_CONTEXT_PARAM_GTT_SIZE + 1;
+   ctx_param.param = LOCAL_CONTEXT_PARAM_PRIORITY + 1;
 
igt_subtest("invalid-param-get") {
ctx_param.context = ctx;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t 4/4] tests/gem_scheduler: Add subtests to test batch priority behaviour

2016-02-12 Thread Derek Morton
Add subtests to test each ring to check batch buffers of a higher
priority will be executed before batch buffers of a lower priority.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_scheduler.c | 34 --
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/tests/gem_scheduler.c b/tests/gem_scheduler.c
index 4824c13..febde01 100644
--- a/tests/gem_scheduler.c
+++ b/tests/gem_scheduler.c
@@ -39,7 +39,8 @@
 
 IGT_TEST_DESCRIPTION("Check scheduler behaviour. Basic tests ensure 
independant "
  "batch buffers of the same priority are executed in "
- "submission order. Read-read tests ensure "
+ "submission order. Priority tests ensure higher priority "
+ "batch buffers are executed first. Read-read tests ensure 
"
  "batch buffers with a read dependency to the same buffer "
  "object do not block each other. Write-write dependency "
  "tests ensure batch buffers with a write dependency to a "
@@ -61,11 +62,13 @@ struct ring {
 
 #define NBR_RINGS (sizeof(rings)/sizeof(struct ring))
 
-/* Basic test. Check batch buffers of the same priority and with no 
dependencies
- * are executed in the order they are submitted.
+/* If 'priority' is set false, check batch buffers of the same priority and 
with
+ * no dependencies are executed in the order they are submitted.
+ * If 'priority' is set true, check batch buffers of higher priority are
+ * executed before batch buffers of lower priority.
  */
 #define NBR_BASIC_FDs (3)
-static void run_test_basic(int in_flight, int ringid)
+static void run_test_basic(int in_flight, int ringid, bool priority)
 {
int fd[NBR_BASIC_FDs];
int loop;
@@ -95,6 +98,15 @@ static void run_test_basic(int in_flight, int ringid)
intel_batchbuffer_free(noop_bb);
}
 
+   if(priority) {
+   struct local_i915_gem_context_param param;
+   param.context = 0; /* Default context */
+   param.size = 0;
+   param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
+   param.value = 1000;
+   gem_context_set_param(fd[2], );
+   }
+
/* Create buffer objects */
delay_bo = drm_intel_bo_alloc(bufmgr[0], "delay bo", BATCH_SZ, 
BATCH_SZ);
igt_assert(delay_bo);
@@ -146,7 +158,12 @@ static void run_test_basic(int in_flight, int ringid)
igt_assert_f(igt_compare_timestamps(delay_buf[2], ts1_buf[0]),
 "Delay ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 ")\n",
 delay_buf[2], ts1_buf[0]);
-   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
+   if(priority)
+   igt_assert_f(igt_compare_timestamps(ts2_buf[0], ts1_buf[0]),
+"TS2 ts (0x%08" PRIx32 ") > TS1 ts (0x%08" PRIx32 
")\n",
+ts2_buf[0], ts1_buf[0]);
+   else
+   igt_assert_f(igt_compare_timestamps(ts1_buf[0], ts2_buf[0]),
 "TS1 ts (0x%08" PRIx32 ") > TS2 ts (0x%08" PRIx32 ")\n",
 ts1_buf[0], ts2_buf[0]);
 
@@ -393,7 +410,12 @@ igt_main
 
for (loop=0; loop < NBR_RINGS; loop++)
igt_subtest_f("%s-basic", rings[loop].name) {
-   run_test_basic(in_flight, rings[loop].id);
+   run_test_basic(in_flight, rings[loop].id, false);
+   }
+
+   for (loop=0; loop < NBR_RINGS; loop++)
+   igt_subtest_f("%s-priority", rings[loop].name) {
+   run_test_basic(in_flight, rings[loop].id, true);
}
 
for (loop=0; loop < NBR_RINGS; loop++)
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3] lib/igt_core.c: Expand --run-subtest functionality.

2016-02-04 Thread Derek Morton
Added extended wildcard support when specifying --run-subtest.

Wildcard format is as specified in rfc3977 and the uwildmat() implementation
is taken from libinn.
See https://tools.ietf.org/html/rfc3977#section-4 for a description of
allowed wildcard expressions.

v2: Use comma as list separator (Ville Syrjala)
support both ^ and ! as not operators (Dave Gordon)

v3: Updated to use uwildmat() (Dave Gordon)

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 COPYING |  21 +++
 lib/Makefile.sources|   2 +
 lib/igt_core.c  |  17 +-
 lib/uwildmat/uwildmat.c | 474 
 lib/uwildmat/uwildmat.h |  24 +++
 5 files changed, 536 insertions(+), 2 deletions(-)
 create mode 100644 lib/uwildmat/uwildmat.c
 create mode 100644 lib/uwildmat/uwildmat.h

diff --git a/COPYING b/COPYING
index b8f6753..16375f2 100644
--- a/COPYING
+++ b/COPYING
@@ -106,3 +106,24 @@ 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.
+
+Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
+2013, 2014 by Internet Systems Consortium, Inc. ("ISC")
+Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003 by The Internet Software Consortium and Rich Salz
+
+This code is derived from software contributed to the Internet Software
+Consortium by Rich Salz.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY
+SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 4999868..e33861e 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -60,6 +60,8 @@ libintel_tools_la_SOURCES =   \
igt_core.h  \
igt_draw.c  \
igt_draw.h  \
+   uwildmat/uwildmat.h \
+   uwildmat/uwildmat.c \
$(NULL)
 
 .PHONY: version.h.tmp
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 6b69bb7..8e0bd2e 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -56,7 +56,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "drmtest.h"
 #include "intel_chipset.h"
@@ -209,6 +209,19 @@
  * intel gpu to be present). Then individual subtests can be run with
  * "--run-subtest". Usage help for tests with subtests can be obtained with the
  * "--help" command line option.
+ *
+ * A wildcard expression can be given to --run-subtest to specify a subset of
+ * subtests to run. See https://tools.ietf.org/html/rfc3977#section-4 for a
+ * description of allowed wildcard expressions.
+ * Some examples of allowed wildcard expressions are:
+ *
+ * - '*basic*' match any subtest containing basic
+ * - 'basic-???' match any subtest named basic- with 3 characters after -
+ * - 'basic-[0-9]' match any subtest named basic- with a single number after -
+ * - 'basic-[^0-9]' match any subtest named basic- with a single non numerical 
character after -
+ * - 'basic*,advanced*' match any subtest starting basic or advanced
+ * - '*,!basic*' match any subtest not starting basic
+ * - 'basic*,!basic-render*' match any subtest starting basic but not starting 
basic-render
  */
 
 static unsigned int exit_handler_count;
@@ -814,7 +827,7 @@ bool __igt_run_subtest(const char *subtest_name)
}
 
if (run_single_subtest) {
-   if (fnmatch(run_single_subtest, subtest_name, 0) != 0)
+   if (uwildmat(subtest_name, run_single_subtest) == 0)
return false;
else
run_single_subtest_found = true;
diff --git a/lib/uwildmat/uwildmat.c b/lib/uwildmat/uwildmat.c
new file mode 100644
index 000..2d34742
--- /dev/null
+++ b/lib/uwildmat/uwildmat.c
@@ -0,0 +1,474 @@
+/* uwildmat.c is reused from libinn - 
https://launchpad.net/ubuntu/+source/inn2/2.5.4-1
+
+This provides wild card matching originally used in InterNetNews and is
+described in https://tools.ietf.org/html/rfc3977#section-4
+
+INN licence:
+INN as a whole and all code contained in it not otherwise marked with
+different licenses and/or copyrights is covered by the following copyright
+and license:
+
+   Copyright (c) 2004, 2005, 2006, 2007, 20

[Intel-gfx] [PATCH i-g-t v2] lib/igt_core.c: Expand --run-subtest functionality.

2016-01-28 Thread Derek Morton
Added support for specifying arbitary lists of subtests to run, or
to exclude from being run if prefixed by ^ or !.

subtest1,subtest2 Will run subtest1 and subtest2
^subtest1,subtest2 or !subtest1,subtest2 will run all subtests except
subtest1 and subtest2.

Any subtest string not starting ! or ^ and not containing a comma is
treated as a normal wildcard expression.

This is required mainly on android to exclude subtests that test
features that do not exist in the android driver while still being able
to run other subtests in the binary when a wildcard expression is
insufficient.

v2: Use comma as list separator (Ville Syrjala)
support both ^ and ! as not operators (Dave Gordon)

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/igt_core.c | 48 ++--
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 6b69bb7..5d243af 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -207,7 +207,15 @@
  * To do that obtain the lists of subtests with "--list-subtests", which can be
  * run as non-root and doesn't require the i915 driver to be loaded (or any
  * intel gpu to be present). Then individual subtests can be run with
- * "--run-subtest". Usage help for tests with subtests can be obtained with the
+ * "--run-subtest". --run-subtest accepts wildcard characters. A list of
+ * subtests to run may be specified by using ',' as a separator.
+ * A prefix of ^ or ! may be added to invert the logic, e.g. run all tests 
except...
+ *
+ * - --run-subtest basic* will run all subtests starting basic.
+ * - --run-subtest subtest1,subtest2 will run only subtest1 and subtest2
+ * - --run-subtest ^subtest1,subtest2 will run all those except subtest1 and 
subtest2
+ *
+ * Usage help for tests with subtests can be obtained with the
  * "--help" command line option.
  */
 
@@ -786,6 +794,41 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
extra_opt_handler, handler_data);
 }
 
+static bool check_testlist(const char *subtest_name)
+{
+   char *p;
+
+   /* Run subtests not in list
+* Look for subtest_name in list of form ^subtest1,subtest2,subtest3
+* or !test1,subtest2,subtest3
+* return true if not found.
+*/
+   if ((run_single_subtest[0] == '^') || (run_single_subtest[0] == '!')) {
+   char prefix = run_single_subtest[0];
+   p = strstr(run_single_subtest, subtest_name);
+   if (!((p) &&
+((*(p-1) == prefix) || (*(p-1) == ',')) &&
+((*(p+strlen(subtest_name)) == ',') || 
(*(p+strlen(subtest_name)) == '\0'
+   return true;
+   }
+   /* Run subtests in list
+* Look for subtest_name in list of form subtest1,subtest2,subtest3
+* return true if found.
+*/
+   else if (strstr(run_single_subtest, ",")) {
+   p = strstr(run_single_subtest, subtest_name);
+   if ((p) &&
+   ((p == run_single_subtest) || (*(p-1) == ',')) &&
+   ((*(p+strlen(subtest_name)) == ',') || 
(*(p+strlen(subtest_name)) == '\0')))
+   return true;
+   }
+   /* Run subtests that match shell wildcard */
+   else if (fnmatch(run_single_subtest, subtest_name, 0) == 0)
+   return true;
+
+   return false;
+}
+
 /*
  * Note: Testcases which use these helpers MUST NOT output anything to stdout
  * outside of places protected by igt_run_subtest checks - the piglit
@@ -814,7 +857,8 @@ bool __igt_run_subtest(const char *subtest_name)
}
 
if (run_single_subtest) {
-   if (fnmatch(run_single_subtest, subtest_name, 0) != 0)
+
+   if (check_testlist(subtest_name) == false)
return false;
else
run_single_subtest_found = true;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] lib/igt_core.c: Expand --run-subtest functionality.

2016-01-27 Thread Derek Morton
Added support for specifying arbitary lists of subtests to run or
to exclude from being run by using : or ^ as a seperator.

:subtest1:subtest2: Will run subtest1 and subtest2
^subtest1^subtest2^ will run all subtests except subtest1 and subtest2

Any subtest string not starting : or ^ is treated as a normal wildcard
expression.

This is required mainly on android to exclude subtests that test
features that do not exist in the android driver while still being able
to run other subtests in the binary when a wildcard expression is
insufficient.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/igt_core.c | 42 --
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 6b69bb7..b9e7470 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -207,7 +207,15 @@
  * To do that obtain the lists of subtests with "--list-subtests", which can be
  * run as non-root and doesn't require the i915 driver to be loaded (or any
  * intel gpu to be present). Then individual subtests can be run with
- * "--run-subtest". Usage help for tests with subtests can be obtained with the
+ * "--run-subtest". --run-subtest accepts wildcard characters. A list of
+ * subtests to run may be specified by using : as a seperator. A list of
+ * subtests to exclude may be specified using ^ as a seperator.
+ *
+ * - --run-subtest basic* will run all subtests starting basic.
+ * - --run-subtest :subtest1:subtest2: will run only subtest1 and subtest2
+ * - --run-subtest ^subtest1^subtest2^ will run all except subtest1 and 
subtest2
+ *
+ * Usage help for tests with subtests can be obtained with the
  * "--help" command line option.
  */
 
@@ -786,6 +794,35 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
extra_opt_handler, handler_data);
 }
 
+static bool check_testlist(const char *subtest_name)
+{
+   char *p;
+
+   /* Run subtests in list
+* Look for subtest_name in list of form :subtest1:subtest2:subtest3:
+* return true if found.
+*/
+   if (run_single_subtest[0] == ':') {
+   p = strstr(run_single_subtest, subtest_name);
+   if ((p) && (*(p-1) == ':') && (*(p+strlen(subtest_name)) == ':' 
))
+   return true;
+   }
+   /* Run subtests not in list
+* Look for subtest_name in list of form ^test1^subtest2^subtest3^
+* return true if not found.
+*/
+   else if (run_single_subtest[0] == '^') {
+   p = strstr(run_single_subtest, subtest_name);
+   if (!((p) && (*(p-1) == '^') && (*(p+strlen(subtest_name)) == 
'^' )))
+   return true;
+   }
+   /* Run subtests that match shell wildcard */
+   else if (fnmatch(run_single_subtest, subtest_name, 0) == 0)
+   return true;
+
+   return false;
+}
+
 /*
  * Note: Testcases which use these helpers MUST NOT output anything to stdout
  * outside of places protected by igt_run_subtest checks - the piglit
@@ -814,7 +851,8 @@ bool __igt_run_subtest(const char *subtest_name)
}
 
if (run_single_subtest) {
-   if (fnmatch(run_single_subtest, subtest_name, 0) != 0)
+
+   if (check_testlist(subtest_name) == false)
return false;
else
run_single_subtest_found = true;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] tests/Android.mk: Make intel_residency CAIRO dependant

2016-01-26 Thread Derek Morton
intel_residency has a cairo dependency through igt_fb.c. Remove it
if ANDROID_HAS_CAIRO is not defined.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tools/Android.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/Android.mk b/tools/Android.mk
index da4f3c0..5f64184 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -64,6 +64,7 @@ skip_tools_list := \
 
 ifneq ("${ANDROID_HAS_CAIRO}", "1")
 skip_tools_list += intel_display_crc
+skip_tools_list += intel_residency
 endif
 
 tools_list := $(filter-out $(skip_tools_list),$(bin_PROGRAMS))
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] tools/Android.mk: Add zlib support

2016-01-11 Thread Derek Morton
IGT does not build for Android due to a zlib dependency being added
to intel_error_decode.c in a recent patch.
This patch fixes the error by updating the Android makefile to add
the path to the zlib library and using any LDFLAGS specified in
Makefile.sources.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tools/Android.mk | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/Android.mk b/tools/Android.mk
index 934d3a1..da4f3c0 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -23,9 +23,14 @@ define add_tool
 LOCAL_CFLAGS += -Wno-error=return-type
 # Excessive complaining for established cases. Rely on the Linux version 
warnings.
 LOCAL_CFLAGS += -Wno-sign-compare
+ifeq ($($(1)_LDFLAGS),)
+else
+LOCAL_LDFLAGS += $($(1)_LDFLAGS)
+endif
 
 LOCAL_C_INCLUDES = $(LOCAL_PATH)/../lib
 LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/PRIVATE/drm/include/drm
+LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/zlib
 
 LOCAL_MODULE := $1_tool
 LOCAL_MODULE_TAGS := optional
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] igt_core: Fix logging to display extended line

2015-12-23 Thread Derek Morton
line[strlen(line)] will always evaluate to NULL so line_continuation
was always true. That prevented the program name, pid and log level
ever being printed.
Changed to [strlen(line) - 1] so the last character before the null
terminator is compared with '\n' to determine line_continuation.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/igt_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 84cf8d2..221ed7e 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1748,7 +1748,7 @@ void igt_vlog(const char *domain, enum igt_log_level 
level, const char *format,
goto out;
}
 
-   line_continuation = line[strlen(line)] != '\n';
+   line_continuation = line[strlen(line) - 1] != '\n';
 
/* append log buffer */
_igt_log_buffer_append(formatted_line);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3] gem_flink_race/prime_self_import: Improve test reliability

2015-12-14 Thread Derek Morton
gem_flink_race and prime_self_import have subtests which read the
number of open gem objects from debugfs to determine if objects have
leaked during the test. However the test can fail sporadically if
the number of gem objects changes due to other process activity.
This patch introduces a change to check the number of gem objects
several times to filter out any fluctuations.

v2: Moved the common code to a library and made the loop android
specific (Daniel Vetter)
v3: Renamed get_stable_obj_count -> igt_get_stable_obj_count

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/igt_debugfs.c | 58 +++
 lib/igt_debugfs.h |  6 +
 tests/gem_flink_race.c| 25 +++-
 tests/prime_self_import.c | 31 +
 4 files changed, 73 insertions(+), 47 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 2c3b1cf..4322e8e 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -667,3 +667,61 @@ void igt_enable_prefault(void)
 {
igt_prefault_control(true);
 }
+
+static int get_object_count(void)
+{
+   FILE *file;
+   int ret, scanned;
+
+   igt_drop_caches_set(DROP_RETIRE | DROP_ACTIVE);
+
+   file = igt_debugfs_fopen("i915_gem_objects", "r");
+
+   scanned = fscanf(file, "%i objects", );
+   igt_assert_eq(scanned, 1);
+
+   return ret;
+}
+
+/**
+ * igt_get_stable_obj_count:
+ * @driver: fd to drm/i915 GEM driver
+ *
+ * This puts the driver into a stable (quiescent) state and then returns the
+ * current number of gem buffer objects as reported in the i915_gem_objects
+ * debugFS interface.
+ */
+int igt_get_stable_obj_count(int driver)
+{
+   int obj_count;
+   gem_quiescent_gpu(driver);
+   obj_count = get_object_count();
+   /* The test relies on the system being in the same state before and
+* after the test so any difference in the object count is a result of
+* leaks during the test. gem_quiescent_gpu() mostly achieves this but
+* on android occasionally obj_count can still change briefly.
+* The loop ensures obj_count has remained stable over several checks
+*/
+#ifdef ANDROID
+   {
+   int loop_count = 0;
+   int prev_obj_count = obj_count;
+   while (loop_count < 4) {
+   usleep(20);
+   gem_quiescent_gpu(driver);
+   obj_count = get_object_count();
+   if (obj_count == prev_obj_count) {
+   loop_count++;
+   } else {
+   igt_debug("loop_count=%d, obj_count=%d, 
prev_obj_count=%d\n",
+   loop_count, obj_count, prev_obj_count);
+   loop_count = 0;
+   prev_obj_count = obj_count;
+   }
+
+   }
+   }
+#endif
+   return obj_count;
+}
+
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index bbf7f69..24018eb 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -165,4 +165,10 @@ void igt_drop_caches_set(uint64_t val);
 void igt_disable_prefault(void);
 void igt_enable_prefault(void);
 
+/*
+ * Put the driver into a stable (quiescent) state and get the current number of
+ * gem buffer objects
+ */
+int igt_get_stable_obj_count(int driver);
+
 #endif /* __IGT_DEBUGFS_H__ */
diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c
index b17ef85..30e33f6 100644
--- a/tests/gem_flink_race.c
+++ b/tests/gem_flink_race.c
@@ -44,28 +44,11 @@ IGT_TEST_DESCRIPTION("Check for flink/open vs. gem close 
races.");
  * in the flink name and corresponding reference getting leaked.
  */
 
-/* We want lockless and I'm to lazy to dig out an atomic libarary. On x86 this
+/* We want lockless and I'm to lazy to dig out an atomic library. On x86 this
  * works, too. */
 volatile int pls_die = 0;
 int fd;
 
-static int get_object_count(void)
-{
-   FILE *file;
-   int scanned, ret;
-
-   igt_drop_caches_set(DROP_RETIRE | DROP_ACTIVE);
-
-   file = igt_debugfs_fopen("i915_gem_objects", "r");
-
-   scanned = fscanf(file, "%i objects", );
-   igt_assert_eq(scanned, 1);
-   igt_debug("Reports %d objects\n", ret);
-
-   return ret;
-}
-
-
 static void *thread_fn_flink_name(void *p)
 {
struct drm_gem_open open_struct;
@@ -164,8 +147,7 @@ static void test_flink_close(void)
 * up the counts */
fake = drm_open_driver(DRIVER_INTEL);
 
-   gem_quiescent_gpu(fake);
-   obj_count = get_object_count();
+   obj_count = igt_get_stable_obj_count(fake);
 
num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -190,8 +172,7 @@ static void test_flink_close(void)
 
close(fd);
 
-   gem_quiescent_gpu(fake);
-   obj_

[Intel-gfx] [PATCH i-g-t v2] gem_flink_race/prime_self_import: Improve test reliability

2015-12-11 Thread Derek Morton
gem_flink_race and prime_self_import have subtests which read the
number of open gem objects from debugfs to determine if objects have
leaked during the test. However the test can fail sporadically if
the number of gem objects changes due to other process activity.
This patch introduces a change to check the number of gem objects
several times to filter out any fluctuations.

v2: Moved the common code to a library and made the loop android
specific (Daniel Vetter)

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 lib/igt_debugfs.c | 57 +++
 lib/igt_debugfs.h |  6 +
 tests/gem_flink_race.c| 25 +++--
 tests/prime_self_import.c | 31 +-
 4 files changed, 72 insertions(+), 47 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 2c3b1cf..b467b09 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -667,3 +667,60 @@ void igt_enable_prefault(void)
 {
igt_prefault_control(true);
 }
+
+static int get_object_count(void)
+{
+   FILE *file;
+   int ret, scanned;
+
+   igt_drop_caches_set(DROP_RETIRE | DROP_ACTIVE);
+
+   file = igt_debugfs_fopen("i915_gem_objects", "r");
+
+   scanned = fscanf(file, "%i objects", );
+   igt_assert_eq(scanned, 1);
+
+   return ret;
+}
+
+/**
+ * get_stable_obj_count:
+ * @driver: fd to drm/i915 GEM driver
+ *
+ * This puts the driver into a stable (quiescent) state and then returns the
+ * current number of gem buffer objects as reported in the i915_gem_objects
+ * debugFS interface.
+ */
+int get_stable_obj_count(int driver)
+{
+   int obj_count;
+   gem_quiescent_gpu(driver);
+   obj_count = get_object_count();
+   /* The test relies on the system being in the same state before and
+  after the test so any difference in the object count is a result of
+  leaks during the test. gem_quiescent_gpu() mostly achieves this but
+  on android occasionally obj_count can still change briefly.
+  The loop ensures obj_count has remained stable over several checks */
+#ifdef ANDROID
+   {
+   int loop_count = 0;
+   int prev_obj_count = obj_count;
+   while (loop_count < 4) {
+   usleep(20);
+   gem_quiescent_gpu(driver);
+   obj_count = get_object_count();
+   if (obj_count == prev_obj_count) {
+   loop_count++;
+   } else {
+   igt_debug("loop_count=%d, obj_count=%d, 
prev_obj_count=%d\n",
+   loop_count, obj_count, prev_obj_count);
+   loop_count = 0;
+   prev_obj_count = obj_count;
+   }
+
+   }
+   }
+#endif
+   return obj_count;
+}
+
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index bbf7f69..09e73a8 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -165,4 +165,10 @@ void igt_drop_caches_set(uint64_t val);
 void igt_disable_prefault(void);
 void igt_enable_prefault(void);
 
+/*
+ * Put the driver into a stable (quiescent) state and get the current number of
+ * gem buffer objects
+ */
+int get_stable_obj_count(int driver);
+
 #endif /* __IGT_DEBUGFS_H__ */
diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c
index b17ef85..757cbca 100644
--- a/tests/gem_flink_race.c
+++ b/tests/gem_flink_race.c
@@ -44,28 +44,11 @@ IGT_TEST_DESCRIPTION("Check for flink/open vs. gem close 
races.");
  * in the flink name and corresponding reference getting leaked.
  */
 
-/* We want lockless and I'm to lazy to dig out an atomic libarary. On x86 this
+/* We want lockless and I'm to lazy to dig out an atomic library. On x86 this
  * works, too. */
 volatile int pls_die = 0;
 int fd;
 
-static int get_object_count(void)
-{
-   FILE *file;
-   int scanned, ret;
-
-   igt_drop_caches_set(DROP_RETIRE | DROP_ACTIVE);
-
-   file = igt_debugfs_fopen("i915_gem_objects", "r");
-
-   scanned = fscanf(file, "%i objects", );
-   igt_assert_eq(scanned, 1);
-   igt_debug("Reports %d objects\n", ret);
-
-   return ret;
-}
-
-
 static void *thread_fn_flink_name(void *p)
 {
struct drm_gem_open open_struct;
@@ -164,8 +147,7 @@ static void test_flink_close(void)
 * up the counts */
fake = drm_open_driver(DRIVER_INTEL);
 
-   gem_quiescent_gpu(fake);
-   obj_count = get_object_count();
+   obj_count = get_stable_obj_count(fake);
 
num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -190,8 +172,7 @@ static void test_flink_close(void)
 
close(fd);
 
-   gem_quiescent_gpu(fake);
-   obj_count = get_object_count() - obj_count;
+   obj_count = get_stable_obj_

[Intel-gfx] [PATCH i-g-t] gem_flink_race/prime_self_import: Improve test reliability

2015-12-08 Thread Derek Morton
gem_flink_race and prime_self_import have subtests which read the
number of open gem objects from debugfs to determine if objects have
leaked during the test. However the test can fail sporadically if
the number of gem objects changes due to other process activity.
This patch introduces a change to check the number of gem objects
several times to filter out any fluctuations.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_flink_race.c| 34 +-
 tests/prime_self_import.c | 43 +--
 2 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c
index b17ef85..0552e12 100644
--- a/tests/gem_flink_race.c
+++ b/tests/gem_flink_race.c
@@ -44,7 +44,7 @@ IGT_TEST_DESCRIPTION("Check for flink/open vs. gem close 
races.");
  * in the flink name and corresponding reference getting leaked.
  */
 
-/* We want lockless and I'm to lazy to dig out an atomic libarary. On x86 this
+/* We want lockless and I'm to lazy to dig out an atomic library. On x86 this
  * works, too. */
 volatile int pls_die = 0;
 int fd;
@@ -65,6 +65,32 @@ static int get_object_count(void)
return ret;
 }
 
+static int get_stable_obj_count(int driver)
+{
+   /* The test relies on the system being in the same state before and
+  after the test so any difference in the object count is a result of
+  leaks during the test. gem_quiescent_gpu() mostly achieves this but
+  occasionally obj_count can still change. The loop ensures obj_count
+  has remained stable over several checks */
+   int obj_count, prev_obj_count;
+   int loop_count = 0;
+   gem_quiescent_gpu(driver);
+   prev_obj_count = get_object_count();
+   while (loop_count < 4) {
+   usleep(20);
+   gem_quiescent_gpu(driver);
+   obj_count = get_object_count();
+   if (obj_count == prev_obj_count) {
+   loop_count++;
+   } else {
+   igt_debug("loop_count=%d, obj_count=%d, 
prev_obj_count=%d\n", loop_count, obj_count, prev_obj_count);
+   loop_count = 0;
+   prev_obj_count = obj_count;
+   }
+
+   }
+   return obj_count;
+}
 
 static void *thread_fn_flink_name(void *p)
 {
@@ -164,8 +190,7 @@ static void test_flink_close(void)
 * up the counts */
fake = drm_open_driver(DRIVER_INTEL);
 
-   gem_quiescent_gpu(fake);
-   obj_count = get_object_count();
+   obj_count = get_stable_obj_count(fake);
 
num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -190,8 +215,7 @@ static void test_flink_close(void)
 
close(fd);
 
-   gem_quiescent_gpu(fake);
-   obj_count = get_object_count() - obj_count;
+   obj_count = get_stable_obj_count(fake) - obj_count;
 
igt_info("leaked %i objects\n", obj_count);
 
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c
index 91fe231..977c7b2 100644
--- a/tests/prime_self_import.c
+++ b/tests/prime_self_import.c
@@ -47,7 +47,7 @@
 #include "drm.h"
 
 IGT_TEST_DESCRIPTION("Check whether prime import/export works on the same"
-" device.");
+" device... but with different fds.");
 
 #define BO_SIZE (16*1024)
 
@@ -157,7 +157,7 @@ static void test_with_one_bo_two_files(void)
dma_buf_fd2 = prime_handle_to_fd(fd2, handle_open);
handle_import = prime_fd_to_handle(fd2, dma_buf_fd2);
 
-   /* dma-buf selfimporting an flink bo should give the same handle */
+   /* dma-buf self importing an flink bo should give the same handle */
igt_assert_eq_u32(handle_import, handle_open);
 
close(fd1);
@@ -226,6 +226,33 @@ static int get_object_count(void)
return ret;
 }
 
+static int get_stable_obj_count(int driver)
+{
+   /* The test relies on the system being in the same state before and
+  after the test so any difference in the object count is a result of
+  leaks during the test. gem_quiescent_gpu() mostly achieves this but
+  occasionally obj_count can still change. The loop ensures obj_count
+  has remained stable over several checks */
+   int obj_count, prev_obj_count;
+   int loop_count = 0;
+   gem_quiescent_gpu(driver);
+   prev_obj_count = get_object_count();
+   while (loop_count < 4) {
+   usleep(20);
+   gem_quiescent_gpu(driver);
+   obj_count = get_object_count();
+   if (obj_count == prev_obj_count) {
+   loop_count++;
+   } else {
+   igt_debug("loop_count=%d, obj_count=%d, 
prev_obj_count=%d\n", loop_count, obj_count, prev_obj_count);
+   loop_count = 0;
+ 

[Intel-gfx] [PATCH i-g-t v3] tests/gem_exec_nop: Improved test run time

2015-11-11 Thread Derek Morton
Reduced the Sleep period to 200mS and reduced the repetition count to 7
to decrease the test run time significantly.

v2: Changed uS to us
v3: removed the output formatting change as the issue will be addressed
in a seperate patch from Thomas Wood.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_exec_nop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index a287d08..fcc9625 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -133,7 +133,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
gem_sync(fd, handle);
 
for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) {
-   const int reps = 13;
+   const int reps = 7;
igt_stats_t stats;
int n;
 
@@ -142,7 +142,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
for (n = 0; n < reps; n++) {
struct timespec start, end;
int loops = count;
-   sleep(1); /* wait for the hw to go back to sleep */
+   usleep(20); /* wait 200mS for the hw to go back to 
sleep */
clock_gettime(CLOCK_MONOTONIC, );
while (loops--)
do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, 
);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] tests/gem_exec_nop: Improved test run time

2015-11-05 Thread Derek Morton
Reduced the Sleep period to 200mS and reduced the repetition count to 7
to decrease the test run time significantly.

Also fixed a non ascii character that messed up the results table formatting.

v2: Changed uS to us

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_exec_nop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index a287d08..998e0eb 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -133,7 +133,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
gem_sync(fd, handle);
 
for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) {
-   const int reps = 13;
+   const int reps = 7;
igt_stats_t stats;
int n;
 
@@ -142,7 +142,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
for (n = 0; n < reps; n++) {
struct timespec start, end;
int loops = count;
-   sleep(1); /* wait for the hw to go back to sleep */
+   usleep(20); /* wait 200mS for the hw to go back to 
sleep */
clock_gettime(CLOCK_MONOTONIC, );
while (loops--)
do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, 
);
@@ -151,7 +151,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
igt_stats_push(, elapsed(, , count));
}
 
-   igt_info("Time to exec x %d:%7.3fµs (ring=%s)\n",
+   igt_info("Time to exec x %d:%7.3fus (ring=%s)\n",
 count, igt_stats_get_trimean()/1000, ring_name);
fflush(stdout);
 
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/gem_exec_nop: Improved test run time

2015-11-03 Thread Derek Morton
Reduced the Sleep period to 200mS and reduced the repetition count to 7
to decrease the test run time significantly.

Also fixed a non ascii character that messed up the results table formatting.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/gem_exec_nop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index a287d08..5028145 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -133,7 +133,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
gem_sync(fd, handle);
 
for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) {
-   const int reps = 13;
+   const int reps = 7;
igt_stats_t stats;
int n;
 
@@ -142,7 +142,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
for (n = 0; n < reps; n++) {
struct timespec start, end;
int loops = count;
-   sleep(1); /* wait for the hw to go back to sleep */
+   usleep(20); /* wait 200mS for the hw to go back to 
sleep */
clock_gettime(CLOCK_MONOTONIC, );
while (loops--)
do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, 
);
@@ -151,7 +151,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, 
const char *ring_nam
igt_stats_push(, elapsed(, , count));
}
 
-   igt_info("Time to exec x %d:%7.3fµs (ring=%s)\n",
+   igt_info("Time to exec x %d:%7.3fuS (ring=%s)\n",
 count, igt_stats_get_trimean()/1000, ring_name);
fflush(stdout);
 
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests: Add gem_exec_nop_concurrent test

2015-10-15 Thread 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.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 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 000..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 <derek.j.mor...@intel.com>
+ *
+ * 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(_exec, 0, sizeof(gem_exec));
+   gem_exec[0].handle = handle;
+
+   memset(, 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.flags = ring->ring_id;
+   do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, );
+   }
+   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 

[Intel-gfx] [PATCH i-g-t v2] tests/core_prop_blob: Fix core_prop_blob for android

2015-10-14 Thread Derek Morton
core_prop_blob was using ioctls not in the android kernel. Added a
igt_require_propblob() function and local defines/structures so the
test will compile and skip on kernels where the feature is unsupported.

v2: moved igt_require_propblob() to core_prop_blob.c (Daniel Vetter)
Moved gem_blt.c to a seperate patch (Thomas Wood)

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tests/core_prop_blob.c | 71 --
 1 file changed, 52 insertions(+), 19 deletions(-)

diff --git a/tests/core_prop_blob.c b/tests/core_prop_blob.c
index d704158..4dc6d7d 100644
--- a/tests/core_prop_blob.c
+++ b/tests/core_prop_blob.c
@@ -25,18 +25,35 @@
  *   Daniel Stone <dani...@collabora.com>
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
 #include 
 
-#include "drmtest.h"
-#include "igt_debugfs.h"
-#include "igt_kms.h"
-#include "igt_aux.h"
-
 IGT_TEST_DESCRIPTION("Tests behaviour of mass-data 'blob' properties.");
 
+struct local_drm_mode_get_blob {
+   uint32_t blob_id;
+   uint32_t length;
+   uint64_t data;
+};
+struct local_drm_mode_create_blob {
+   uint64_t data;
+   uint32_t length;
+   uint32_t blob_id;
+};
+struct local_drm_mode_destroy_blob {
+   uint32_t blob_id;
+};
+
+#define LOCAL_DRM_IOCTL_MODE_GETPROPBLOB   DRM_IOWR(0xAC, \
+   struct local_drm_mode_get_blob)
+#define LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOBDRM_IOWR(0xBD, \
+   struct 
local_drm_mode_create_blob)
+#define LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB   DRM_IOWR(0xBE, \
+   struct 
local_drm_mode_destroy_blob)
+
 static const struct drm_mode_modeinfo test_mode_valid = {
.clock = 1234,
.hdisplay = 640,
@@ -61,22 +78,35 @@ static const struct drm_mode_modeinfo test_mode_valid = {
return errno; \
 }
 
+static void igt_require_propblob(int fd)
+{
+   struct local_drm_mode_create_blob c;
+   struct local_drm_mode_destroy_blob d;
+   uint32_t blob_data;
+   c.data = _data;
+   c.length = sizeof(blob_data);
+
+   igt_require(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, ) == 0);
+   d.blob_id = c.blob_id;
+   igt_require(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, ) == 
0);
+}
+
 static int
 validate_prop(int fd, uint32_t prop_id)
 {
-   struct drm_mode_get_blob get;
+   struct local_drm_mode_get_blob get;
struct drm_mode_modeinfo ret_mode;
 
get.blob_id = prop_id;
get.length = 0;
get.data = (uintptr_t) 0;
-   ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_GETPROPBLOB, );
+   ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_GETPROPBLOB, );
 
if (get.length != sizeof(test_mode_valid))
return ENOMEM;
 
get.data = (uintptr_t) _mode;
-   ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_GETPROPBLOB, );
+   ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_GETPROPBLOB, );
 
if (memcmp(_mode, _mode_valid, sizeof(test_mode_valid)) != 0)
return EINVAL;
@@ -87,12 +117,12 @@ validate_prop(int fd, uint32_t prop_id)
 static uint32_t
 create_prop(int fd)
 {
-   struct drm_mode_create_blob create;
+   struct local_drm_mode_create_blob create;
 
create.length = sizeof(test_mode_valid);
create.data = (uintptr_t) _mode_valid;
 
-   do_ioctl(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, );
+   do_ioctl(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, );
igt_assert_neq_u32(create.blob_id, 0);
 
return create.blob_id;
@@ -101,10 +131,10 @@ create_prop(int fd)
 static int
 destroy_prop(int fd, uint32_t prop_id)
 {
-   struct drm_mode_destroy_blob destroy;
+   struct local_drm_mode_destroy_blob destroy;
 
destroy.blob_id = prop_id;
-   ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, );
+   ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, );
 
return 0;
 }
@@ -112,8 +142,8 @@ destroy_prop(int fd, uint32_t prop_id)
 static void
 test_validate(int fd)
 {
-   struct drm_mode_create_blob create;
-   struct drm_mode_get_blob get;
+   struct local_drm_mode_create_blob create;
+   struct local_drm_mode_get_blob get;
char too_small[32];
uint32_t prop_id;
 
@@ -122,24 +152,24 @@ test_validate(int fd)
/* Outlandish size. */
create.length = 0x1;
create.data = (uintptr_t) _small;
-   do_ioctl_err(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, , EFAULT);
+   do_ioctl_err(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, , EFAULT);
 
/* Outlandish address. */
create.length = sizeof(test_mode_valid);
create.data = (uintptr_t) 0xdeadbeee;
-   do_ioctl_err(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, , EFAULT);
+   do_ioctl_err(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, , EFAULT);
 
/* When we 

[Intel-gfx] [PATCH i-g-t] benchmarks/gem_blt: Include igt.h in gem_blt.c

2015-10-14 Thread Derek Morton
To fix a build error on android

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 benchmarks/gem_blt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
index 181a5f1..8ab5302 100644
--- a/benchmarks/gem_blt.c
+++ b/benchmarks/gem_blt.c
@@ -25,6 +25,7 @@
  *
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
@@ -39,9 +40,6 @@
 #include 
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_chipset.h"
 
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] core_prop_blob ioctl_wrappers: Fix new tests/benchmarks for android

2015-10-13 Thread Derek Morton
Changes since #1b492e311 have broken the Android build. This patch
fixes the build for Android.

core_prop_blob was using ioctls not in the android kernel. Added a
igt_require_propblob() function and local defines/structures so the
test will compile and skip on kernels where the feature is unsupported.

gem_blt - included igt.h

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 benchmarks/gem_blt.c   |  4 +---
 lib/ioctl_wrappers.c   | 13 +
 lib/ioctl_wrappers.h   | 22 ++
 tests/core_prop_blob.c | 37 ++---
 4 files changed, 54 insertions(+), 22 deletions(-)

diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
index 181a5f1..8ab5302 100644
--- a/benchmarks/gem_blt.c
+++ b/benchmarks/gem_blt.c
@@ -25,6 +25,7 @@
  *
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
@@ -39,9 +40,6 @@
 #include 
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_chipset.h"
 
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 80e1ec6..cf34f25 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1219,6 +1219,19 @@ void igt_require_fb_modifiers(int fd)
igt_require(has_modifiers);
 }
 
+void igt_require_propblob(int fd)
+{
+   struct local_drm_mode_create_blob c;
+   struct local_drm_mode_destroy_blob d;
+   uint32_t blob_data;
+   c.data = _data;
+   c.length = sizeof(blob_data);
+
+   igt_require(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, ) == 0);
+   d.blob_id = c.blob_id;
+   igt_require(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, ) == 
0);
+}
+
 int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height,
uint32_t stride, uint32_t pixel_format, uint64_t modifier,
uint32_t flags, uint32_t *buf_id)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index f4deca6..aeb224c 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -149,6 +149,20 @@ struct local_drm_mode_fb_cmd2 {
uint64_t modifier[4];
 };
 
+struct local_drm_mode_get_blob {
+   uint32_t blob_id;
+   uint32_t length;
+   uint64_t data;
+};
+struct local_drm_mode_create_blob {
+   uint64_t data;
+   uint32_t length;
+   uint32_t blob_id;
+};
+struct local_drm_mode_destroy_blob {
+   uint32_t blob_id;
+};
+
 #define LOCAL_DRM_MODE_FB_MODIFIERS(1<<1)
 
 #define LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL  0x01
@@ -165,9 +179,17 @@ struct local_drm_mode_fb_cmd2 {
 #define LOCAL_DRM_IOCTL_MODE_ADDFB2DRM_IOWR(0xB8, \
 struct local_drm_mode_fb_cmd2)
 
+#define LOCAL_DRM_IOCTL_MODE_GETPROPBLOB   DRM_IOWR(0xAC, \
+   struct local_drm_mode_get_blob)
+#define LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOBDRM_IOWR(0xBD, \
+   struct 
local_drm_mode_create_blob)
+#define LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB   DRM_IOWR(0xBE, \
+   struct 
local_drm_mode_destroy_blob)
+
 #define LOCAL_DRM_CAP_ADDFB2_MODIFIERS 0x10
 
 void igt_require_fb_modifiers(int fd);
+void igt_require_propblob(int fd);
 
 /**
  * __kms_addfb:
diff --git a/tests/core_prop_blob.c b/tests/core_prop_blob.c
index d704158..ff56482 100644
--- a/tests/core_prop_blob.c
+++ b/tests/core_prop_blob.c
@@ -25,16 +25,12 @@
  *   Daniel Stone <dani...@collabora.com>
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
 #include 
 
-#include "drmtest.h"
-#include "igt_debugfs.h"
-#include "igt_kms.h"
-#include "igt_aux.h"
-
 IGT_TEST_DESCRIPTION("Tests behaviour of mass-data 'blob' properties.");
 
 static const struct drm_mode_modeinfo test_mode_valid = {
@@ -64,19 +60,19 @@ static const struct drm_mode_modeinfo test_mode_valid = {
 static int
 validate_prop(int fd, uint32_t prop_id)
 {
-   struct drm_mode_get_blob get;
+   struct local_drm_mode_get_blob get;
struct drm_mode_modeinfo ret_mode;
 
get.blob_id = prop_id;
get.length = 0;
get.data = (uintptr_t) 0;
-   ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_GETPROPBLOB, );
+   ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_GETPROPBLOB, );
 
if (get.length != sizeof(test_mode_valid))
return ENOMEM;
 
get.data = (uintptr_t) _mode;
-   ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_GETPROPBLOB, );
+   ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_GETPROPBLOB, );
 
if (memcmp(_mode, _mode_valid, sizeof(test_mode_valid)) != 0)
return EINVAL;
@@ -87,12 +83,12 @@ validate_prop(int fd, uint32_t prop_id)
 static uint32_t
 create_prop(int fd)
 {
-   struct drm_mode_create_blob create;
+ 

[Intel-gfx] [PATCH i-g-t] benchmarks: Fix build errors on Android M-Dessert

2015-10-01 Thread Derek Morton
Android M-Dessert treats implicit declaration of function warnings
as errors resulting in igt failing to build.

This patch fixes the errors by including missing header files as
required. Mostly this involved including igt.h in the benchmarks.

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 benchmarks/intel_upload_blit_large.c | 7 +--
 benchmarks/intel_upload_blit_large_gtt.c | 8 +---
 benchmarks/intel_upload_blit_large_map.c | 8 +---
 benchmarks/intel_upload_blit_small.c | 8 +---
 tools/intel_reg_decode.c | 1 +
 5 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/benchmarks/intel_upload_blit_large.c 
b/benchmarks/intel_upload_blit_large.c
index 1984bfd..12bbae3 100644
--- a/benchmarks/intel_upload_blit_large.c
+++ b/benchmarks/intel_upload_blit_large.c
@@ -44,6 +44,7 @@
  * The current workload doing this path is pixmap upload for non-KMS.
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
@@ -57,12 +58,6 @@
 #include 
 #include 
 
-#include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_io.h"
-#include "intel_chipset.h"
-
 #define OBJECT_WIDTH   1280
 #define OBJECT_HEIGHT  720
 
diff --git a/benchmarks/intel_upload_blit_large_gtt.c 
b/benchmarks/intel_upload_blit_large_gtt.c
index d62a01e..0b704b5 100644
--- a/benchmarks/intel_upload_blit_large_gtt.c
+++ b/benchmarks/intel_upload_blit_large_gtt.c
@@ -44,6 +44,7 @@
  * The current workload doing this path is pixmap upload in 2D with KMS.
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
@@ -53,13 +54,6 @@
 #include 
 #include 
 #include 
-#include "drm.h"
-#include "i915_drm.h"
-#include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_io.h"
-#include "intel_chipset.h"
 
 #define OBJECT_WIDTH   1280
 #define OBJECT_HEIGHT  720
diff --git a/benchmarks/intel_upload_blit_large_map.c 
b/benchmarks/intel_upload_blit_large_map.c
index 03bf760..ae05434 100644
--- a/benchmarks/intel_upload_blit_large_map.c
+++ b/benchmarks/intel_upload_blit_large_map.c
@@ -47,6 +47,7 @@
  * suitable)
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
@@ -56,13 +57,6 @@
 #include 
 #include 
 #include 
-#include "drm.h"
-#include "i915_drm.h"
-#include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_io.h"
-#include "intel_chipset.h"
 
 #define OBJECT_WIDTH   1280
 #define OBJECT_HEIGHT  720
diff --git a/benchmarks/intel_upload_blit_small.c 
b/benchmarks/intel_upload_blit_small.c
index ac557a4..7e3346e 100644
--- a/benchmarks/intel_upload_blit_small.c
+++ b/benchmarks/intel_upload_blit_small.c
@@ -40,6 +40,7 @@
  * frame.
  */
 
+#include "igt.h"
 #include 
 #include 
 #include 
@@ -49,13 +50,6 @@
 #include 
 #include 
 #include 
-#include "drm.h"
-#include "i915_drm.h"
-#include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_io.h"
-#include "intel_chipset.h"
 
 /* Happens to be 128k, the size of the VBOs used by i965's Mesa driver. */
 #define OBJECT_WIDTH   256
diff --git a/tools/intel_reg_decode.c b/tools/intel_reg_decode.c
index 4f97d99..bb8f5b3 100644
--- a/tools/intel_reg_decode.c
+++ b/tools/intel_reg_decode.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "intel_chipset.h"
 #include "intel_reg.h"
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tools/Android.mk: Fix compile error in intel_reg.c

2015-09-09 Thread Derek Morton
The patch "tools: install the register definition files" caused
a build error on android as it added 'PKGDATADIR' which was not
defined in the Android build environment. This patch adds that
define to tools/Android.mk. It also copies the files it points
to so they are actually in the target file system.
---
 tools/Android.mk | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/Android.mk b/tools/Android.mk
index 0a196e4..aae7db5 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -34,11 +34,18 @@ define add_tool
   libdrm\
   libdrm_intel
 
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/intel/validation/core/igt/tools
+LOCAL_CFLAGS += 
-DPKGDATADIR=\"/system/vendor/intel/validation/core/igt/tools\"
 include $(BUILD_EXECUTABLE)
 endef
 
 ##
 
+# Copy the register files
+$(shell mkdir -p 
$(TARGET_OUT_VENDOR)/intel/validation/core/igt/tools/registers)
+$(shell cp $(LOCAL_PATH)/registers/* 
$(TARGET_OUT_VENDOR)/intel/validation/core/igt/tools/registers)
+
+
 skip_tools_list := \
 intel_framebuffer_dump \
 intel_reg_dumper \
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] tools/Android.mk: Fix compile error in intel_reg.c

2015-09-09 Thread Derek Morton
The patch "tools: install the register definition files" caused
a build error on android as it added 'PKGDATADIR' which was not
defined in the Android build environment. This patch adds that
define to tools/Android.mk. It also copies the files it points
to so they are actually in the target file system.

v2: Added local variable for tool path

Signed-off-by: Derek Morton <derek.j.mor...@intel.com>
---
 tools/Android.mk | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/Android.mk b/tools/Android.mk
index 0a196e4..934d3a1 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -2,6 +2,8 @@ LOCAL_PATH := $(call my-dir)
 
 include $(LOCAL_PATH)/Makefile.sources
 
+LOCAL_TOOLS_DIR := intel/validation/core/igt/tools
+
 ##
 
 define add_tool
@@ -34,11 +36,21 @@ define add_tool
   libdrm\
   libdrm_intel
 
+# Tools dir on host
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/$(LOCAL_TOOLS_DIR)
+# Tools dir on target.
+LOCAL_CFLAGS += -DPKGDATADIR=\"/system/vendor/$(LOCAL_TOOLS_DIR)\"
+
 include $(BUILD_EXECUTABLE)
 endef
 
 ##
 
+# Copy the register files
+$(shell mkdir -p $(TARGET_OUT_VENDOR)/$(LOCAL_TOOLS_DIR)/registers)
+$(shell cp $(LOCAL_PATH)/registers/* 
$(TARGET_OUT_VENDOR)/$(LOCAL_TOOLS_DIR)/registers)
+
+
 skip_tools_list := \
 intel_framebuffer_dump \
 intel_reg_dumper \
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] benckmarks/Android.mk: Fix building benchmarks for Android

2015-08-13 Thread Derek Morton
The commit benchmarks: Do not install to system-wide bin/ changed
the benchmark file list from bin_PROGRAMS to benchmarks_PROGRAMS.
However Android.mk was not updated, resulting in IGT failing to
build for Android.
This commit adds that change. It also adds LOCAL_MODULE_PATH to
specify where the built benchmarks should be put.

v2: I discovered that the existing definitions of LOCAL_MODULE_PATH
were creating what should have been an invalid path. Not sure how it
was ever working previously, but fixed now.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 benchmarks/Android.mk | 3 ++-
 lib/tests/Android.mk  | 2 +-
 tests/Android.mk  | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index da11c44..207a177 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -19,6 +19,7 @@ define add_benchmark
 
 LOCAL_MODULE := $1_benchmark
 LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := 
$(TARGET_OUT_VENDOR)/intel/validation/core/igt/benchmarks
 
 LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
 
@@ -31,6 +32,6 @@ endef
 
 ##
 
-benchmark_list := $(bin_PROGRAMS)
+benchmark_list := $(benchmarks_PROGRAMS)
 
 $(foreach item,$(benchmark_list),$(eval $(call add_benchmark,$(item
diff --git a/lib/tests/Android.mk b/lib/tests/Android.mk
index 7ad0300..df8e159 100644
--- a/lib/tests/Android.mk
+++ b/lib/tests/Android.mk
@@ -18,7 +18,7 @@ define add_test
 LOCAL_SHARED_LIBRARIES := ${IGT_LOCAL_SHARED_LIBRARIES}
 
 LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := 
$(ANDROID_PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/intel/validation/core/igt
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/intel/validation/core/igt
 
 include $(BUILD_EXECUTABLE)
 endef
diff --git a/tests/Android.mk b/tests/Android.mk
index 10ef3e2..8457125 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -20,7 +20,7 @@ define add_test
 LOCAL_MODULE_TAGS := optional
 # ask linker to define a specific symbol; we use this to identify IGT tests
 LOCAL_LDFLAGS := -Wl,--defsym=$2=0
-LOCAL_MODULE_PATH := 
$(ANDROID_PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/intel/validation/core/igt
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/intel/validation/core/igt
 
 include $(BUILD_EXECUTABLE)
 endef
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] benckmarks/Android.mk: Fix building benchmarks for Android

2015-08-13 Thread Derek Morton
The commit benchmarks: Do not install to system-wide bin/ changed
the benchmark file list from bin_PROGRAMS to benchmarks_PROGRAMS.
However Android.mk was not updated, resulting in IGT failing to
build for Android.
This commit adds that change. It also adds LOCAL_MODULE_PATH to
specify where the built benchmarks should be put.
---
 benchmarks/Android.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index da11c44..ed9a903 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -19,6 +19,7 @@ define add_benchmark
 
 LOCAL_MODULE := $1_benchmark
 LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := 
$(ANDROID_PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/intel/validation/core/igt/benchmarks
 
 LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
 
@@ -31,6 +32,6 @@ endef
 
 ##
 
-benchmark_list := $(bin_PROGRAMS)
+benchmark_list := $(benchmarks_PROGRAMS)
 
 $(foreach item,$(benchmark_list),$(eval $(call add_benchmark,$(item
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] benckmarks/Android.mk: Fix building benchmarks for Android

2015-08-13 Thread Derek Morton
The commit benchmarks: Do not install to system-wide bin/ changed
the benchmark file list from bin_PROGRAMS to benchmarks_PROGRAMS.
However Android.mk was not updated, resulting in IGT failing to
build for Android.
This commit adds that change. It also adds LOCAL_MODULE_PATH to
specify where the built benchmarks should be put.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 benchmarks/Android.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index da11c44..ed9a903 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -19,6 +19,7 @@ define add_benchmark
 
 LOCAL_MODULE := $1_benchmark
 LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := 
$(ANDROID_PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/intel/validation/core/igt/benchmarks
 
 LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
 
@@ -31,6 +32,6 @@ endef
 
 ##
 
-benchmark_list := $(bin_PROGRAMS)
+benchmark_list := $(benchmarks_PROGRAMS)
 
 $(foreach item,$(benchmark_list),$(eval $(call add_benchmark,$(item
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] benchmarks/Android.mk, tools/Android.mk: Fix android build error

2015-08-06 Thread Derek Morton
Recently added tools / benckmarks have the same module name as
existing tests. Android does not allow duplicate modules. This
patch appends _benchmark and _tool to the module names used when
building benckmarks and tools to prevent complie errors due to
clashes with tests of the same name.

v2: Don't add test/benchmark to the module name if the source
already has the suffix.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 benchmarks/Android.mk | 6 +-
 tools/Android.mk  | 6 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index 14fc0a7..f75888d 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -17,7 +17,11 @@ define add_benchmark
 # Excessive complaining for established cases. Rely on the Linux version 
warnings.
 LOCAL_CFLAGS += -Wno-sign-compare
 
-LOCAL_MODULE := $1
+ifneq (,$(findstring benchmark,$1))
+LOCAL_MODULE := $1
+else
+LOCAL_MODULE := $1_benchmark
+endif
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
diff --git a/tools/Android.mk b/tools/Android.mk
index 6617f28..c8b5744 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -25,7 +25,11 @@ define add_tool
 LOCAL_C_INCLUDES = $(LOCAL_PATH)/../lib
 LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/PRIVATE/drm/include/drm
 
-LOCAL_MODULE := $1
+ifneq (,$(findstring tool,$1))
+LOCAL_MODULE := $1
+else
+LOCAL_MODULE := $1_tool
+endif
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/gem_render_linear_blits: Increase min swap required

2015-07-29 Thread Derek Morton
The swap-thrash subtest had a requirement that swap memory be
present but no minimum amount was specified. The subtest allowed
for half the total swap memory for overhead. Some android systems
have a only a small amount of swap space and half this was not
enough resulting in OOM errors. It was not possible to determine
the exact amount of memory the test would require in all
configurations to guarentee swap memory would be used but not
trigger an OOM error.
As a minimum reccomended swap partition on Linux is 256Mb the
subtest was updated to require this.

Also fixed a couple of small memory leaks.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tests/gem_render_linear_blits.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index f83c6d4..5dd210d 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -184,6 +184,9 @@ static void run_test (int fd, int count)
}
intel_batchbuffer_free(batch);
drm_intel_bufmgr_destroy(bufmgr);
+
+   free(bo);
+   free(start_val);
 }
 
 igt_main
@@ -210,7 +213,12 @@ igt_main
 
igt_subtest(swap-thrash) {
uint64_t swap_mb = intel_get_total_swap_mb();
-   igt_require(swap_mb  0);
+   /* The calculation of count allows 1/2 the swap memory as
+  overhead. However on Android systems with a very small swap
+  partition this is not enough resulting in OOM errors.
+  As 256Mb is a minimum recomended size for a swap partition
+  on Linux, skip the subtest if less than this. */
+   igt_require(swap_mb  255);
count = ((intel_get_avail_ram_mb() + (swap_mb / 2)) * 
1024*1024) / SIZE;
intel_require_memory(count, SIZE, CHECK_RAM | CHECK_SWAP);
run_test(fd, count);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] benchmarks/Android.mk, tools/Android.mk: Fix android build error

2015-07-27 Thread Derek Morton
Recently added tools / benckmarks have the same module name as
existing tests. Android does not allow duplicate modules. This
patch appends _benchmark and _tool to the module names used when
building benckmarks and tools to prevent clashes with tests of
the same name.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 benchmarks/Android.mk | 2 +-
 tools/Android.mk  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index 14fc0a7..da11c44 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -17,7 +17,7 @@ define add_benchmark
 # Excessive complaining for established cases. Rely on the Linux version 
warnings.
 LOCAL_CFLAGS += -Wno-sign-compare
 
-LOCAL_MODULE := $1
+LOCAL_MODULE := $1_benchmark
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
diff --git a/tools/Android.mk b/tools/Android.mk
index 6617f28..0a196e4 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -25,7 +25,7 @@ define add_tool
 LOCAL_C_INCLUDES = $(LOCAL_PATH)/../lib
 LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/PRIVATE/drm/include/drm
 
-LOCAL_MODULE := $1
+LOCAL_MODULE := $1_tool
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] benchmark/: fix gem_exec_nop complie error on android

2015-07-24 Thread Derek Morton
There are two versions of gem_exec_nop.c in benchmarks and tests
which causes the build system to have two build modules with
the same name.
This patch renames benchmarks/gem_exec_nop.c to
benchmarks/gem_exec_nop_benchmark.c using the existing
gem_userptr_benchmark.c as a naming convention.

v2: Also rename gem_mmap to gem_mmap_benchmark. Another file
which breaks android which was added after this patch was 1st
submitted.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 benchmarks/Makefile.sources |   9 +-
 benchmarks/gem_exec_nop.c   | 153 -
 benchmarks/gem_exec_nop_benchmark.c | 153 +
 benchmarks/gem_mmap.c   | 165 
 benchmarks/gem_mmap_benchmark.c | 165 
 5 files changed, 325 insertions(+), 320 deletions(-)
 delete mode 100644 benchmarks/gem_exec_nop.c
 create mode 100644 benchmarks/gem_exec_nop_benchmark.c
 delete mode 100644 benchmarks/gem_mmap.c
 create mode 100644 benchmarks/gem_mmap_benchmark.c

diff --git a/benchmarks/Makefile.sources b/benchmarks/Makefile.sources
index 7ad95a5..35722b5 100644
--- a/benchmarks/Makefile.sources
+++ b/benchmarks/Makefile.sources
@@ -1,11 +1,16 @@
+# If you copy a test to benckmarks, rename it _benchmark
+# The andriod build will fail when trying to build multiple binaries with
+# the same name.
+
 bin_PROGRAMS =  \
intel_upload_blit_large \
intel_upload_blit_large_gtt \
intel_upload_blit_large_map \
intel_upload_blit_small \
-   gem_exec_nop\
-   gem_mmap\
+   gem_exec_nop_benchmark  \
+   gem_mmap_benchmark  \
gem_prw \
gem_userptr_benchmark   \
kms_vblank  \
$(NULL)
+
diff --git a/benchmarks/gem_exec_nop.c b/benchmarks/gem_exec_nop.c
deleted file mode 100644
index 2a3abd2..000
--- a/benchmarks/gem_exec_nop.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright © 2011 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:
- *Chris Wilson ch...@chris-wilson.co.uk
- *
- */
-
-#include unistd.h
-#include stdlib.h
-#include stdint.h
-#include stdio.h
-#include string.h
-#include fcntl.h
-#include inttypes.h
-#include errno.h
-#include sys/stat.h
-#include sys/ioctl.h
-#include sys/time.h
-#include time.h
-
-#include drm.h
-#include ioctl_wrappers.h
-#include drmtest.h
-#include intel_io.h
-#include igt_stats.h
-
-#define LOCAL_I915_EXEC_NO_RELOC (111)
-#define LOCAL_I915_EXEC_HANDLE_LUT (112)
-
-static uint64_t elapsed(const struct timespec *start,
-   const struct timespec *end,
-   int loop)
-{
-   return (10ULL*(end-tv_sec - start-tv_sec) + (end-tv_nsec - 
start-tv_nsec))/loop;
-}
-
-static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-   int err = 0;
-   if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf))
-   err = -errno;
-   return err;
-}
-
-static uint32_t batch(int fd)
-{
-   const uint32_t buf[] = {MI_BATCH_BUFFER_END};
-   uint32_t handle = gem_create(fd, 4096);
-   gem_write(fd, handle, 0, buf, sizeof(buf));
-   return handle;
-}
-
-static int loop(unsigned ring, int reps)
-{
-   struct drm_i915_gem_execbuffer2 execbuf;
-   struct drm_i915_gem_exec_object2 gem_exec;
-   int count, fd;
-
-   fd = drm_open_any();
-
-   memset(gem_exec, 0, sizeof(gem_exec));
-   gem_exec.handle = batch(fd);
-
-   memset(execbuf, 0, sizeof(execbuf));
-   execbuf.buffers_ptr = (uintptr_t)gem_exec;
-   execbuf.buffer_count = 1;
-   execbuf.flags = ring;
-   execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
-   execbuf.flags

[Intel-gfx] [PATCH i-g-t] tools/Makefile.sources: fix igt_stats complie error on android

2015-07-23 Thread Derek Morton
There are two versions of igt_stats.c in tools and lib\tests
which causes the build system to have two build modules with
the same name.
This patch specifies a different target name for the tool so
there is no clash.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tools/Makefile.sources | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/Makefile.sources b/tools/Makefile.sources
index 8ca9351..d19ef96 100644
--- a/tools/Makefile.sources
+++ b/tools/Makefile.sources
@@ -5,7 +5,7 @@ noinst_PROGRAMS = \
$(NULL)
 
 bin_PROGRAMS = \
-   igt_stats   \
+   igt_statistics  \
intel_audio_dump\
intel_reg   \
intel_backlight \
@@ -63,3 +63,9 @@ intel_l3_parity_SOURCES = \
intel_l3_parity.h   \
intel_l3_udev_listener.c
 
+# Android does not like building multiple targets with the same name
+# tools/igt_stats.c clashes with lib/tests/igt_stats.c. Simplest fix is to
+# specify a different target name here.
+igt_statistics_SOURCES =   \
+   igt_stats.c
+
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] benchmark/: fix gem_exec_nop complie error on android

2015-07-23 Thread Derek Morton
There are two versions of gem_exec_nop.c in benchmarks and tests
which causes the build system to have two build modules with
the same name.
This patch renames benchmarks/gem_exec_nop.c to
benchmarks/gem_exec_nop_benchmark.c using the existing
gem_userptr_benchmark.c as a naming convention.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 benchmarks/Makefile.sources |   6 +-
 benchmarks/gem_exec_nop.c   | 153 
 benchmarks/gem_exec_nop_benchmark.c | 153 
 3 files changed, 158 insertions(+), 154 deletions(-)
 delete mode 100644 benchmarks/gem_exec_nop.c
 create mode 100644 benchmarks/gem_exec_nop_benchmark.c

diff --git a/benchmarks/Makefile.sources b/benchmarks/Makefile.sources
index d8a7440..ab2dc89 100644
--- a/benchmarks/Makefile.sources
+++ b/benchmarks/Makefile.sources
@@ -1,7 +1,11 @@
+# If you copy a test to benckmarks, rename it _benchmark
+# The andriod build will fail when trying to build multiple binaries with
+# the same name.
+
 bin_PROGRAMS =  \
intel_upload_blit_large \
intel_upload_blit_large_gtt \
intel_upload_blit_large_map \
intel_upload_blit_small \
-   gem_exec_nop\
+   gem_exec_nop_benchmark  \
gem_userptr_benchmark
diff --git a/benchmarks/gem_exec_nop.c b/benchmarks/gem_exec_nop.c
deleted file mode 100644
index 2a3abd2..000
--- a/benchmarks/gem_exec_nop.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright © 2011 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:
- *Chris Wilson ch...@chris-wilson.co.uk
- *
- */
-
-#include unistd.h
-#include stdlib.h
-#include stdint.h
-#include stdio.h
-#include string.h
-#include fcntl.h
-#include inttypes.h
-#include errno.h
-#include sys/stat.h
-#include sys/ioctl.h
-#include sys/time.h
-#include time.h
-
-#include drm.h
-#include ioctl_wrappers.h
-#include drmtest.h
-#include intel_io.h
-#include igt_stats.h
-
-#define LOCAL_I915_EXEC_NO_RELOC (111)
-#define LOCAL_I915_EXEC_HANDLE_LUT (112)
-
-static uint64_t elapsed(const struct timespec *start,
-   const struct timespec *end,
-   int loop)
-{
-   return (10ULL*(end-tv_sec - start-tv_sec) + (end-tv_nsec - 
start-tv_nsec))/loop;
-}
-
-static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
-{
-   int err = 0;
-   if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf))
-   err = -errno;
-   return err;
-}
-
-static uint32_t batch(int fd)
-{
-   const uint32_t buf[] = {MI_BATCH_BUFFER_END};
-   uint32_t handle = gem_create(fd, 4096);
-   gem_write(fd, handle, 0, buf, sizeof(buf));
-   return handle;
-}
-
-static int loop(unsigned ring, int reps)
-{
-   struct drm_i915_gem_execbuffer2 execbuf;
-   struct drm_i915_gem_exec_object2 gem_exec;
-   int count, fd;
-
-   fd = drm_open_any();
-
-   memset(gem_exec, 0, sizeof(gem_exec));
-   gem_exec.handle = batch(fd);
-
-   memset(execbuf, 0, sizeof(execbuf));
-   execbuf.buffers_ptr = (uintptr_t)gem_exec;
-   execbuf.buffer_count = 1;
-   execbuf.flags = ring;
-   execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
-   execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
-   if (__gem_execbuf(fd, execbuf)) {
-   execbuf.flags = ring;
-   if (__gem_execbuf(fd, execbuf))
-   return 77;
-   }
-
-   for (count = 1; count = 116; count = 1) {
-   igt_stats_t stats;
-   int n;
-
-   igt_stats_init_with_size(stats, reps);
-
-   for (n = 0; n  reps; n++) {
-   struct timespec start, end;
-   int loops = count;
-   sleep(1); /* wait for the hw to go back to sleep

[Intel-gfx] [PATCH i-g-t v3] Android.mk: Disable tools that do not build for android

2015-07-17 Thread Derek Morton
Disable the tools / demo code that do not currently build
for android until they can be fixed.

Affected tools / demos
intel_display_crc
intel_sprite_on

v2: intel_display_crc compiled conditionally on ANDROID_HAS_CAIRO
flag.
v3: removed intel_reg from the skip list as Thomas has prepared
a patch to fix it for Android.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 Android.mk   | 2 +-
 tools/Android.mk | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Android.mk b/Android.mk
index 1ab3e64..681d114 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,2 +1,2 @@
-include $(call all-named-subdir-makefiles, lib tests tools benchmarks demos)
+include $(call all-named-subdir-makefiles, lib tests tools benchmarks)
 
diff --git a/tools/Android.mk b/tools/Android.mk
index 39f4512..b5f8008 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -41,6 +41,10 @@ skip_tools_list := \
 intel_vga_read \
 intel_vga_write
 
+ifneq (${ANDROID_HAS_CAIRO}, 1)
+skip_tools_list += intel_display_crc
+endif
+
 tools_list := $(filter-out $(skip_tools_list),$(bin_PROGRAMS))
 
 $(foreach item,$(tools_list),$(eval $(call add_tool,$(item
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3] Android.mk: Disable tools that do not build for android

2015-07-17 Thread Derek Morton
Disable the tools / demo code that do not currently build
for android until they can be fixed.

Affected tools / demos
intel_display_crc
intel_sprite_on

v2: intel_display_crc compiled conditionally on ANDROID_HAS_CAIRO
flag.
v3: removed intel_reg from the skip list as Thomas has prepared
a patch to fix it for Android.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 Android.mk   | 2 +-
 tools/Android.mk | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Android.mk b/Android.mk
index 1ab3e64..681d114 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,2 +1,2 @@
-include $(call all-named-subdir-makefiles, lib tests tools benchmarks demos)
+include $(call all-named-subdir-makefiles, lib tests tools benchmarks)
 
diff --git a/tools/Android.mk b/tools/Android.mk
index 39f4512..4be0032 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -37,10 +37,15 @@ endef
 
 skip_tools_list := \
 intel_framebuffer_dump \
+intel_reg \
 intel_reg_dumper \
 intel_vga_read \
 intel_vga_write
 
+ifneq (${ANDROID_HAS_CAIRO}, 1)
+skip_tools_list += intel_display_crc
+endif
+
 tools_list := $(filter-out $(skip_tools_list),$(bin_PROGRAMS))
 
 $(foreach item,$(tools_list),$(eval $(call add_tool,$(item
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/gem_fenced_exec_thrash.c: Fix memory leaks

2015-06-26 Thread Derek Morton
gem_fenced_exec_thrash was not freeing any resources between
subtests. On 1Gb android systems this resulted in the test
failing with an OOM error.

Added cleanup code to free BOs at the end of each subtest.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tests/gem_fenced_exec_thrash.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/tests/gem_fenced_exec_thrash.c b/tests/gem_fenced_exec_thrash.c
index 75f251c..c0e820f 100644
--- a/tests/gem_fenced_exec_thrash.c
+++ b/tests/gem_fenced_exec_thrash.c
@@ -215,6 +215,18 @@ static void run_test(int fd, int num_fences, int 
expected_errno,
 
if (flags  INTERRUPTIBLE)
igt_stop_signal_helper();
+
+   /* Cleanup */
+   for (n = 0; n  2*num_fences; n++)
+   gem_close(fd, exec[0][n].handle);
+
+   for (i = 0; i  2; i++)
+   gem_close(fd, exec[i][2*num_fences].handle);
+
+   if (flags  BUSY_LOAD) {
+   intel_batchbuffer_free(batch);
+   drm_intel_bufmgr_destroy(bufmgr);
+   }
 }
 
 int fd;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3] tests/gem_fence_thrash.c: Reduce memory usage

2015-06-24 Thread Derek Morton
On android platforms with 1Gb RAM gem_fence_thrash was failing
with an out of memory error.
This patch causes gem_close() to be called when a handle is
no longer required rather than relying on the cleanup when
the fd is closed. This greatly improves the memory footprint
of the test allowing it to run on 1Mb systems.

Also fixed a leak of the 'threads' variable.

v2: Simplified as per Chris Wilson's suggestion.
v3: Added calls to munmap() from bo_copy()

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tests/gem_fence_thrash.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 6447e13..f4ccfc0 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -63,7 +63,7 @@ static void *
 bo_create (int fd, int tiling)
 {
void *ptr;
-   int handle;
+   uint32_t handle;
 
handle = gem_create(fd, OBJECT_SIZE);
 
@@ -80,6 +80,7 @@ bo_create (int fd, int tiling)
 
/* XXX: mmap_gtt pulls the bo into the GTT read domain. */
gem_sync(fd, handle);
+   gem_close(fd, handle);
 
return ptr;
 }
@@ -100,6 +101,9 @@ bo_copy (void *_arg)
sched_yield ();
}
 
+   munmap(a, OBJECT_SIZE);
+   munmap(b, OBJECT_SIZE);
+
return NULL;
 }
 
@@ -188,6 +192,8 @@ static int run_test(int threads_per_fence, void *f, int 
tiling,
 
for (n = 0; n  num_threads; n++)
pthread_join (threads[n], NULL);
+
+   free(threads);
} else {
void *(*func)(void *) = f;
igt_assert(func(t) == (void *)0);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/gem_fence_thrash.c: Reduce memory usage

2015-06-23 Thread Derek Morton
On android platforms with 1Gb RAM gem_fence_thrash was failing
with an out of memory error.
This patch causes gem_close() to be called when a thread is
finished with its handles rather than relying on the cleanup
when the fd is closed. This greatly improves the memory footprint
of the test allowing it to run on 1Mb systems.

Also fixed a leak of the 'threads' variable.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tests/gem_fence_thrash.c | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 6447e13..bfb2e6d 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -60,26 +60,25 @@ struct test {
 };
 
 static void *
-bo_create (int fd, int tiling)
+bo_create (int fd, int tiling, uint32_t *handle)
 {
void *ptr;
-   int handle;
 
-   handle = gem_create(fd, OBJECT_SIZE);
+   *handle = gem_create(fd, OBJECT_SIZE);
 
/* dirty cpu caches a bit ... */
-   ptr = gem_mmap__cpu(fd, handle, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+   ptr = gem_mmap__cpu(fd, *handle, 0, OBJECT_SIZE, PROT_READ | 
PROT_WRITE);
igt_assert(ptr);
memset(ptr, 0, OBJECT_SIZE);
munmap(ptr, OBJECT_SIZE);
 
-   gem_set_tiling(fd, handle, tiling, 1024);
+   gem_set_tiling(fd, *handle, tiling, 1024);
 
-   ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+   ptr = gem_mmap(fd, *handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
igt_assert(ptr);
 
/* XXX: mmap_gtt pulls the bo into the GTT read domain. */
-   gem_sync(fd, handle);
+   gem_sync(fd, *handle);
 
return ptr;
 }
@@ -91,15 +90,19 @@ bo_copy (void *_arg)
int fd = t-fd;
int n;
char *a, *b;
+   uint32_t ha, hb;
 
-   a = bo_create (fd, t-tiling);
-   b = bo_create (fd, t-tiling);
+   a = bo_create (fd, t-tiling, ha);
+   b = bo_create (fd, t-tiling, hb);
 
for (n = 0; n  1000; n++) {
memcpy (a, b, OBJECT_SIZE);
sched_yield ();
}
 
+   gem_close(fd, ha);
+   gem_close(fd, hb);
+
return NULL;
 }
 
@@ -112,15 +115,18 @@ _bo_write_verify(struct test *t)
uint32_t v;
unsigned int dwords = OBJECT_SIZE  2;
const char *tile_str[] = { none, x, y };
+   uint32_t *h;
 
igt_assert(t-tiling = 0  t-tiling = I915_TILING_Y);
igt_assert_lt(0, t-num_surfaces);
 
s = calloc(sizeof(*s), t-num_surfaces);
igt_assert(s);
+   h = calloc(sizeof(*h), t-num_surfaces);
+   igt_assert(h);
 
for (k = 0; k  t-num_surfaces; k++)
-   s[k] = bo_create(fd, t-tiling);
+   s[k] = bo_create(fd, t-tiling, (h[k]));
 
for (k = 0; k  t-num_surfaces; k++) {
volatile uint32_t *a = s[k];
@@ -141,10 +147,13 @@ _bo_write_verify(struct test *t)
}
}
 
-   for (k = 0; k  t-num_surfaces; k++)
+   for (k = 0; k  t-num_surfaces; k++) {
munmap(s[k], OBJECT_SIZE);
+   gem_close(fd, h[k]);
+   }
 
free(s);
+   free(h);
 }
 
 static void *
@@ -188,6 +197,8 @@ static int run_test(int threads_per_fence, void *f, int 
tiling,
 
for (n = 0; n  num_threads; n++)
pthread_join (threads[n], NULL);
+
+   free(threads);
} else {
void *(*func)(void *) = f;
igt_assert(func(t) == (void *)0);
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] Android.mk: Disable tools that do not build for android

2015-06-15 Thread Derek Morton
Disable the tools / demo code that do not currently build
for android until they can be fixed.

Affected tools / demos
intel_reg
intel_display_crc
intel_sprite_on

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 Android.mk   | 2 +-
 tools/Android.mk | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Android.mk b/Android.mk
index 1ab3e64..681d114 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,2 +1,2 @@
-include $(call all-named-subdir-makefiles, lib tests tools benchmarks demos)
+include $(call all-named-subdir-makefiles, lib tests tools benchmarks)
 
diff --git a/tools/Android.mk b/tools/Android.mk
index 39f4512..fd2800e 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -36,7 +36,9 @@ endef
 ##
 
 skip_tools_list := \
+intel_display_crc \
 intel_framebuffer_dump \
+intel_reg \
 intel_reg_dumper \
 intel_vga_read \
 intel_vga_write
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] Android.mk: Disable tools that do not build for android

2015-06-15 Thread Derek Morton
Disable the tools / demo code that do not currently build
for android until they can be fixed.

Affected tools / demos
intel_reg
intel_display_crc
intel_sprite_on

v2: intel_display_crc compiled conditionally on ANDROID_HAS_CAIRO
flag.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 Android.mk   | 2 +-
 tools/Android.mk | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Android.mk b/Android.mk
index 1ab3e64..681d114 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,2 +1,2 @@
-include $(call all-named-subdir-makefiles, lib tests tools benchmarks demos)
+include $(call all-named-subdir-makefiles, lib tests tools benchmarks)
 
diff --git a/tools/Android.mk b/tools/Android.mk
index 39f4512..4be0032 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -37,10 +37,15 @@ endef
 
 skip_tools_list := \
 intel_framebuffer_dump \
+intel_reg \
 intel_reg_dumper \
 intel_vga_read \
 intel_vga_write
 
+ifneq (${ANDROID_HAS_CAIRO}, 1)
+skip_tools_list += intel_display_crc
+endif
+
 tools_list := $(filter-out $(skip_tools_list),$(bin_PROGRAMS))
 
 $(foreach item,$(tools_list),$(eval $(call add_tool,$(item
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v4] lib/tests/igt_segfault Add unit test to test segfault handling

2015-06-12 Thread Derek Morton
Unit test to check a segfaulting subtest is handled correctly.

v2: Added script to check subtest results
v3: Removed script. Updated test to use fork to monitor return status.
v4: Added igt_segfault to .gitignore

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/tests/.gitignore   |   1 +
 lib/tests/Makefile.sources |   1 +
 lib/tests/igt_segfault.c   | 139 +
 3 files changed, 141 insertions(+)
 create mode 100644 lib/tests/igt_segfault.c

diff --git a/lib/tests/.gitignore b/lib/tests/.gitignore
index a745a23..729568b 100644
--- a/lib/tests/.gitignore
+++ b/lib/tests/.gitignore
@@ -5,6 +5,7 @@ igt_list_only
 igt_no_exit
 igt_no_exit_list_only
 igt_no_subtest
+igt_segfault
 igt_simple_test_subtests
 igt_simulation
 igt_timeout
diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
index 10e0617..5fa0b31 100644
--- a/lib/tests/Makefile.sources
+++ b/lib/tests/Makefile.sources
@@ -8,6 +8,7 @@ check_PROGRAMS = \
igt_simple_test_subtests \
igt_timeout \
igt_invalid_subtest_name \
+   igt_segfault \
$(NULL)
 
 check_SCRIPTS = \
diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c
new file mode 100644
index 000..b420b1a
--- /dev/null
+++ b/lib/tests/igt_segfault.c
@@ -0,0 +1,139 @@
+/*
+ * 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 derek.j.mor...@intel.com
+ *
+ */
+
+/*
+ * Testcase: Test the framework catches a segfault and returns an error.
+ *
+ * 1. Test a crashing simple test is reported.
+ * 2. Test a crashing subtest is reported.
+ * 3. Test a crashing subtest following a passing subtest is reported.
+ * 4. Test a crashing subtest preceeding a passing subtest is reported.
+ */
+
+#include stdlib.h
+#include sys/wait.h
+#include sys/types.h
+#include assert.h
+#include errno.h
+
+#include drmtest.h
+#include igt_core.h
+
+/*
+ * We need to hide assert from the cocci igt test refactor spatch.
+ *
+ * IMPORTANT: Test infrastructure tests are the only valid places where using
+ * assert is allowed.
+ */
+#define internal_assert assert
+
+bool simple;
+bool runa;
+bool runc;
+char test[] = test;
+char *argv_run[] = { test };
+
+static int do_fork(void)
+{
+   int pid, status;
+   int argc;
+   void (*crashme)(void) = NULL;
+
+   switch (pid = fork()) {
+   case -1:
+   internal_assert(0);
+   case 0:
+   if (simple) {
+   argc = 1;
+   igt_simple_init(argc, argv_run);
+   crashme();
+
+   igt_exit();
+   } else {
+
+   argc = 1;
+   igt_subtest_init(argc, argv_run);
+
+   if(runa)
+   igt_subtest(A)
+   ;
+
+   igt_subtest(B)
+   crashme();
+
+   if(runc)
+   igt_subtest(C)
+   ;
+
+   igt_exit();
+   }
+   default:
+   while (waitpid(pid, status, 0) == -1 
+  errno == EINTR)
+   ;
+
+   if(WIFSIGNALED(status))
+   return WTERMSIG(status) + 128;
+
+   return WEXITSTATUS(status);
+   }
+}
+
+int main(int argc, char **argv)
+{
+   /* Test Crash in simple test is reported */
+   simple = true;
+   runa=false;
+   runc=false;
+   igt_info(Simple test.\n);
+   fflush(stdout);
+   internal_assert(do_fork() == SIGSEGV + 128);
+
+   /* Test crash in a single subtest is reported */
+   simple = false;
+   igt_info(Single subtest.\n);
+   fflush(stdout);
+   internal_assert(do_fork

[Intel-gfx] [PATCH i-g-t v5] libs/igt_core.c: Fix compile warnings in igt_core.c

2015-06-12 Thread Derek Morton
Fixed variables incorrectly declared as int instead of size_t.

v2: Addressed comments from Tim Gore
v3: Removed 'unused parameter' changes
v4: Changed to size_t
v5: Moved declarations out of for loops

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/igt_core.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249..eb0cb21 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1104,7 +1104,9 @@ static pid_t helper_process_pids[] =
 
 static void reset_helper_process_list(void)
 {
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
+   size_t i;
+
+   for (i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
helper_process_pids[i] = -1;
helper_process_count = 0;
 }
@@ -1121,8 +1123,10 @@ static int __waitpid(pid_t pid)
 
 static void fork_helper_exit_handler(int sig)
 {
+   size_t i;
+
/* Inside a signal handler, play safe */
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
+   for (i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
pid_t pid = helper_process_pids[i];
if (pid != -1) {
kill(pid, SIGTERM);
@@ -1376,10 +1380,10 @@ static void restore_sig_handler(int sig_num)
 
 static void restore_all_sig_handler(void)
 {
-   int i;
+   size_t i;
 
for (i = 0; i  ARRAY_SIZE(orig_sig); i++)
-   restore_sig_handler(i);
+   restore_sig_handler((int)i);
 }
 
 static void call_exit_handlers(int sig)
@@ -1419,7 +1423,7 @@ static bool crash_signal(int sig)
 
 static void fatal_sig_handler(int sig)
 {
-   int i;
+   size_t i;
 
for (i = 0; i  ARRAY_SIZE(handled_signals); i++) {
if (handled_signals[i].number != sig)
@@ -1481,7 +1485,7 @@ static void fatal_sig_handler(int sig)
  */
 void igt_install_exit_handler(igt_exit_handler_t fn)
 {
-   int i;
+   size_t i;
 
for (i = 0; i  exit_handler_count; i++)
if (exit_handler_fn[i] == fn)
@@ -1521,7 +1525,7 @@ err:
 void igt_disable_exit_handler(void)
 {
sigset_t set;
-   int i;
+   size_t i;
 
if (exit_handler_disabled)
return;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v4] lib/tests/igt_segfault Add unit test to test segfault handling

2015-05-28 Thread Derek Morton
Unit test to check a segfaulting subtest is handled correctly.

v2: Added script to check subtest results
v3: Removed script. Updated test to use fork to monitor return status.
v4: Added igt_segfault to .gitignore

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/tests/.gitignore   |   1 +
 lib/tests/Makefile.sources |   1 +
 lib/tests/igt_segfault.c   | 139 +
 3 files changed, 141 insertions(+)
 create mode 100644 lib/tests/igt_segfault.c

diff --git a/lib/tests/.gitignore b/lib/tests/.gitignore
index a745a23..729568b 100644
--- a/lib/tests/.gitignore
+++ b/lib/tests/.gitignore
@@ -5,6 +5,7 @@ igt_list_only
 igt_no_exit
 igt_no_exit_list_only
 igt_no_subtest
+igt_segfault
 igt_simple_test_subtests
 igt_simulation
 igt_timeout
diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
index 10e0617..5fa0b31 100644
--- a/lib/tests/Makefile.sources
+++ b/lib/tests/Makefile.sources
@@ -8,6 +8,7 @@ check_PROGRAMS = \
igt_simple_test_subtests \
igt_timeout \
igt_invalid_subtest_name \
+   igt_segfault \
$(NULL)
 
 check_SCRIPTS = \
diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c
new file mode 100644
index 000..b420b1a
--- /dev/null
+++ b/lib/tests/igt_segfault.c
@@ -0,0 +1,139 @@
+/*
+ * 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 derek.j.mor...@intel.com
+ *
+ */
+
+/*
+ * Testcase: Test the framework catches a segfault and returns an error.
+ *
+ * 1. Test a crashing simple test is reported.
+ * 2. Test a crashing subtest is reported.
+ * 3. Test a crashing subtest following a passing subtest is reported.
+ * 4. Test a crashing subtest preceeding a passing subtest is reported.
+ */
+
+#include stdlib.h
+#include sys/wait.h
+#include sys/types.h
+#include assert.h
+#include errno.h
+
+#include drmtest.h
+#include igt_core.h
+
+/*
+ * We need to hide assert from the cocci igt test refactor spatch.
+ *
+ * IMPORTANT: Test infrastructure tests are the only valid places where using
+ * assert is allowed.
+ */
+#define internal_assert assert
+
+bool simple;
+bool runa;
+bool runc;
+char test[] = test;
+char *argv_run[] = { test };
+
+static int do_fork(void)
+{
+   int pid, status;
+   int argc;
+   void (*crashme)(void) = NULL;
+
+   switch (pid = fork()) {
+   case -1:
+   internal_assert(0);
+   case 0:
+   if (simple) {
+   argc = 1;
+   igt_simple_init(argc, argv_run);
+   crashme();
+
+   igt_exit();
+   } else {
+
+   argc = 1;
+   igt_subtest_init(argc, argv_run);
+
+   if(runa)
+   igt_subtest(A)
+   ;
+
+   igt_subtest(B)
+   crashme();
+
+   if(runc)
+   igt_subtest(C)
+   ;
+
+   igt_exit();
+   }
+   default:
+   while (waitpid(pid, status, 0) == -1 
+  errno == EINTR)
+   ;
+
+   if(WIFSIGNALED(status))
+   return WTERMSIG(status) + 128;
+
+   return WEXITSTATUS(status);
+   }
+}
+
+int main(int argc, char **argv)
+{
+   /* Test Crash in simple test is reported */
+   simple = true;
+   runa=false;
+   runc=false;
+   igt_info(Simple test.\n);
+   fflush(stdout);
+   internal_assert(do_fork() == SIGSEGV + 128);
+
+   /* Test crash in a single subtest is reported */
+   simple = false;
+   igt_info(Single subtest.\n);
+   fflush(stdout);
+   internal_assert(do_fork

[Intel-gfx] [PATCH i-g-t v2] lib/tests/igt_segfault.c Add unit test to test segfault handling

2015-05-27 Thread Derek Morton
Unit test to check a segfaulting subtest is handled correctly.

v2: Added script to check subtest results

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/tests/Makefile.sources  |  3 ++
 lib/tests/igt_segfault.c| 57 ++
 lib/tests/igt_segfault_check.sh | 61 +
 3 files changed, 121 insertions(+)
 create mode 100644 lib/tests/igt_segfault.c
 create mode 100755 lib/tests/igt_segfault_check.sh

diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
index 10e0617..5e601fe 100644
--- a/lib/tests/Makefile.sources
+++ b/lib/tests/Makefile.sources
@@ -8,10 +8,12 @@ check_PROGRAMS = \
igt_simple_test_subtests \
igt_timeout \
igt_invalid_subtest_name \
+   igt_segfault \
$(NULL)
 
 check_SCRIPTS = \
igt_command_line.sh \
+   igt_segfault_check.sh \
$(NULL)
 
 TESTS = \
@@ -29,4 +31,5 @@ XFAIL_TESTS = \
igt_simple_test_subtests \
igt_timeout \
igt_invalid_subtest_name \
+   igt_segfault \
$(NULL)
diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c
new file mode 100644
index 000..19bb3c2
--- /dev/null
+++ b/lib/tests/igt_segfault.c
@@ -0,0 +1,57 @@
+/*
+ * 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 derek.j.mor...@intel.com
+ *
+ */
+
+/*
+ *
+ * Testcase: Test the framework catches a segfault and returns an error.
+ *
+ * The test consists of three subtests. The first and third should pass
+ * while the second should cause a segfault.
+ * The overall result should be a failure with two subtests passing.
+ *
+ */
+
+#include drmtest.h
+
+igt_main
+{
+   void (*crashme)(void) = NULL;
+
+   igt_subtest(A) {
+   igt_info(Simple passing subtest.\n);
+   }
+
+   igt_subtest(B) {
+   igt_info(Cause a segfault.\n);
+   crashme();
+   }
+
+   igt_subtest(C) {
+   igt_info(2nd Simple passing subtest.\n);
+   }
+}
+
diff --git a/lib/tests/igt_segfault_check.sh b/lib/tests/igt_segfault_check.sh
new file mode 100755
index 000..89d0c94
--- /dev/null
+++ b/lib/tests/igt_segfault_check.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# 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 derek.j.mor...@intel.com
+#
+
+#
+# Testcase: Test the subtest results of igt_segfault.
+#
+
+if [ -x $top_builddir/tests/igt_segfault ]; then
+   OP=$($top_builddir/tests/igt_segfault)
+   A_MATCH='Subtest A: SUCCESS'
+   B_MATCH='Subtest B: CRASH'
+   C_MATCH='Subtest C: SUCCESS'
+   RESULT='Failed : 1'
+
+   if [[ $OP == *$A_MATCH* ]]; then
+   if [[ $OP == *$B_MATCH

[Intel-gfx] [PATCH i-g-t v3] lib/tests/igt_segfault.c Add unit test to test segfault handling

2015-05-27 Thread Derek Morton
Unit test to check a segfaulting subtest is handled correctly.

v2: Added script to check subtest results
v3: Removed script. Updated test to use fork to monitor return status.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/tests/Makefile.sources |   1 +
 lib/tests/igt_segfault.c   | 139 +
 2 files changed, 140 insertions(+)
 create mode 100644 lib/tests/igt_segfault.c

diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
index 10e0617..5fa0b31 100644
--- a/lib/tests/Makefile.sources
+++ b/lib/tests/Makefile.sources
@@ -8,6 +8,7 @@ check_PROGRAMS = \
igt_simple_test_subtests \
igt_timeout \
igt_invalid_subtest_name \
+   igt_segfault \
$(NULL)
 
 check_SCRIPTS = \
diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c
new file mode 100644
index 000..b420b1a
--- /dev/null
+++ b/lib/tests/igt_segfault.c
@@ -0,0 +1,139 @@
+/*
+ * 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 derek.j.mor...@intel.com
+ *
+ */
+
+/*
+ * Testcase: Test the framework catches a segfault and returns an error.
+ *
+ * 1. Test a crashing simple test is reported.
+ * 2. Test a crashing subtest is reported.
+ * 3. Test a crashing subtest following a passing subtest is reported.
+ * 4. Test a crashing subtest preceeding a passing subtest is reported.
+ */
+
+#include stdlib.h
+#include sys/wait.h
+#include sys/types.h
+#include assert.h
+#include errno.h
+
+#include drmtest.h
+#include igt_core.h
+
+/*
+ * We need to hide assert from the cocci igt test refactor spatch.
+ *
+ * IMPORTANT: Test infrastructure tests are the only valid places where using
+ * assert is allowed.
+ */
+#define internal_assert assert
+
+bool simple;
+bool runa;
+bool runc;
+char test[] = test;
+char *argv_run[] = { test };
+
+static int do_fork(void)
+{
+   int pid, status;
+   int argc;
+   void (*crashme)(void) = NULL;
+
+   switch (pid = fork()) {
+   case -1:
+   internal_assert(0);
+   case 0:
+   if (simple) {
+   argc = 1;
+   igt_simple_init(argc, argv_run);
+   crashme();
+
+   igt_exit();
+   } else {
+
+   argc = 1;
+   igt_subtest_init(argc, argv_run);
+
+   if(runa)
+   igt_subtest(A)
+   ;
+
+   igt_subtest(B)
+   crashme();
+
+   if(runc)
+   igt_subtest(C)
+   ;
+
+   igt_exit();
+   }
+   default:
+   while (waitpid(pid, status, 0) == -1 
+  errno == EINTR)
+   ;
+
+   if(WIFSIGNALED(status))
+   return WTERMSIG(status) + 128;
+
+   return WEXITSTATUS(status);
+   }
+}
+
+int main(int argc, char **argv)
+{
+   /* Test Crash in simple test is reported */
+   simple = true;
+   runa=false;
+   runc=false;
+   igt_info(Simple test.\n);
+   fflush(stdout);
+   internal_assert(do_fork() == SIGSEGV + 128);
+
+   /* Test crash in a single subtest is reported */
+   simple = false;
+   igt_info(Single subtest.\n);
+   fflush(stdout);
+   internal_assert(do_fork() == SIGSEGV + 128);
+
+   /* Test crash in a subtest following a pass is reported */
+   simple = false;
+   runa=true;
+   igt_info(Passing then crashing subtest.\n);
+   fflush(stdout);
+   internal_assert(do_fork() == SIGSEGV + 128);
+
+   /* Test crash in a subtest preceeding a pass is reported */
+   simple = false;
+   runa=false

[Intel-gfx] [PATCH i-g-t] lib: Enable building unit tests on android

2015-05-26 Thread Derek Morton
Add a make file for android so the unit tests can be built.
Enabled asserts for the library code so the unit test behaviour
is correct.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/Android.mk   |  4 +++-
 lib/tests/Android.mk | 41 +
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 lib/tests/Android.mk

diff --git a/lib/Android.mk b/lib/Android.mk
index 1a7cf33..badec1e 100644
--- a/lib/Android.mk
+++ b/lib/Android.mk
@@ -25,7 +25,7 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
 LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES
 LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM
 LOCAL_CFLAGS += -DANDROID -DHAVE_LINUX_KD_H
-LOCAL_CFLAGS += -std=gnu99
+LOCAL_CFLAGS += -std=gnu99 -UNDEBUG
 LOCAL_MODULE:= libintel_gpu_tools
 
 LOCAL_SHARED_LIBRARIES := libpciaccess  \
@@ -48,3 +48,5 @@ LOCAL_SRC_FILES := $(filter-out 
$(skip_lib_list),$(libintel_tools_la_SOURCES))
 
 include $(BUILD_STATIC_LIBRARY)
 
+include $(call first-makefiles-under, $(LOCAL_PATH))
+
diff --git a/lib/tests/Android.mk b/lib/tests/Android.mk
new file mode 100644
index 000..7ad0300
--- /dev/null
+++ b/lib/tests/Android.mk
@@ -0,0 +1,41 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/Makefile.sources
+
+##
+# each igt test is a separate executable. define a function to build one of 
these tests
+define add_test
+include $(CLEAR_VARS)
+
+# specific to this test
+LOCAL_SRC_FILES := $1.c
+LOCAL_MODULE := $1
+
+# common to all tests
+LOCAL_CFLAGS += ${IGT_LOCAL_CFLAGS}
+LOCAL_C_INCLUDES = ${IGT_LOCAL_C_INCLUDES}
+LOCAL_STATIC_LIBRARIES := ${IGT_LOCAL_STATIC_LIBRARIES}
+LOCAL_SHARED_LIBRARIES := ${IGT_LOCAL_SHARED_LIBRARIES}
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := 
$(ANDROID_PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/intel/validation/core/igt
+
+include $(BUILD_EXECUTABLE)
+endef
+
+# set local compilation flags for IGT tests
+IGT_LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM -DANDROID -UNDEBUG
+IGT_LOCAL_CFLAGS += -std=gnu99
+# FIXME: drop once Bionic correctly annotates noreturn on pthread_exit
+IGT_LOCAL_CFLAGS += -Wno-error=return-type
+
+# set local includes
+IGT_LOCAL_C_INCLUDES = $(LOCAL_PATH)/../lib
+IGT_LOCAL_C_INCLUDES += ${ANDROID_BUILD_TOP}/external/PRIVATE/drm/include/drm
+
+# set local libraries
+IGT_LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
+IGT_LOCAL_SHARED_LIBRARIES := libpciaccess libdrm libdrm_intel
+
+$(foreach item,$(check_PROGRAMS),$(eval $(call add_test,$(item
+
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] lib/tests/igt_segfault.c Add unit test to test segfault handling

2015-05-26 Thread Derek Morton
Unit test to check a segfaulting subtest is handled correctly.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/tests/Makefile.sources |  2 ++
 lib/tests/igt_segfault.c   | 57 ++
 2 files changed, 59 insertions(+)
 create mode 100644 lib/tests/igt_segfault.c

diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
index 10e0617..04ce4e6 100644
--- a/lib/tests/Makefile.sources
+++ b/lib/tests/Makefile.sources
@@ -8,6 +8,7 @@ check_PROGRAMS = \
igt_simple_test_subtests \
igt_timeout \
igt_invalid_subtest_name \
+   igt_segfault \
$(NULL)
 
 check_SCRIPTS = \
@@ -29,4 +30,5 @@ XFAIL_TESTS = \
igt_simple_test_subtests \
igt_timeout \
igt_invalid_subtest_name \
+   igt_segfault \
$(NULL)
diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c
new file mode 100644
index 000..19bb3c2
--- /dev/null
+++ b/lib/tests/igt_segfault.c
@@ -0,0 +1,57 @@
+/*
+ * 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 derek.j.mor...@intel.com
+ *
+ */
+
+/*
+ *
+ * Testcase: Test the framework catches a segfault and returns an error.
+ *
+ * The test consists of three subtests. The first and third should pass
+ * while the second should cause a segfault.
+ * The overall result should be a failure with two subtests passing.
+ *
+ */
+
+#include drmtest.h
+
+igt_main
+{
+   void (*crashme)(void) = NULL;
+
+   igt_subtest(A) {
+   igt_info(Simple passing subtest.\n);
+   }
+
+   igt_subtest(B) {
+   igt_info(Cause a segfault.\n);
+   crashme();
+   }
+
+   igt_subtest(C) {
+   igt_info(2nd Simple passing subtest.\n);
+   }
+}
+
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3] libs/igt_core.c: Fix compile warnings in igt_core.c

2015-05-20 Thread Derek Morton
Fixed variables incorrectly declared as signed instead of unsigned.

v2: Addressed comments from Tim Gore
v3: Removed 'unused parameter' changes

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/igt_core.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249..04da285 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1104,7 +1104,7 @@ static pid_t helper_process_pids[] =
 
 static void reset_helper_process_list(void)
 {
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
+   for (unsigned int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
helper_process_pids[i] = -1;
helper_process_count = 0;
 }
@@ -1122,7 +1122,7 @@ static int __waitpid(pid_t pid)
 static void fork_helper_exit_handler(int sig)
 {
/* Inside a signal handler, play safe */
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
+   for (unsigned int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
pid_t pid = helper_process_pids[i];
if (pid != -1) {
kill(pid, SIGTERM);
@@ -1376,10 +1376,10 @@ static void restore_sig_handler(int sig_num)
 
 static void restore_all_sig_handler(void)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  ARRAY_SIZE(orig_sig); i++)
-   restore_sig_handler(i);
+   restore_sig_handler((int)i);
 }
 
 static void call_exit_handlers(int sig)
@@ -1419,7 +1419,7 @@ static bool crash_signal(int sig)
 
 static void fatal_sig_handler(int sig)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  ARRAY_SIZE(handled_signals); i++) {
if (handled_signals[i].number != sig)
@@ -1481,7 +1481,7 @@ static void fatal_sig_handler(int sig)
  */
 void igt_install_exit_handler(igt_exit_handler_t fn)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  exit_handler_count; i++)
if (exit_handler_fn[i] == fn)
@@ -1521,7 +1521,7 @@ err:
 void igt_disable_exit_handler(void)
 {
sigset_t set;
-   int i;
+   unsigned int i;
 
if (exit_handler_disabled)
return;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v4] libs/igt_core.c: Fix compile warnings in igt_core.c

2015-05-20 Thread Derek Morton
Fixed variables incorrectly declared as int instead of size_t.

v2: Addressed comments from Tim Gore
v3: Removed 'unused parameter' changes
v4: Changed to size_t

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/igt_core.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249..f24b09e 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1104,7 +1104,7 @@ static pid_t helper_process_pids[] =
 
 static void reset_helper_process_list(void)
 {
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
+   for (size_t i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
helper_process_pids[i] = -1;
helper_process_count = 0;
 }
@@ -1122,7 +1122,7 @@ static int __waitpid(pid_t pid)
 static void fork_helper_exit_handler(int sig)
 {
/* Inside a signal handler, play safe */
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
+   for (size_t i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
pid_t pid = helper_process_pids[i];
if (pid != -1) {
kill(pid, SIGTERM);
@@ -1376,10 +1376,10 @@ static void restore_sig_handler(int sig_num)
 
 static void restore_all_sig_handler(void)
 {
-   int i;
+   size_t i;
 
for (i = 0; i  ARRAY_SIZE(orig_sig); i++)
-   restore_sig_handler(i);
+   restore_sig_handler((int)i);
 }
 
 static void call_exit_handlers(int sig)
@@ -1419,7 +1419,7 @@ static bool crash_signal(int sig)
 
 static void fatal_sig_handler(int sig)
 {
-   int i;
+   size_t i;
 
for (i = 0; i  ARRAY_SIZE(handled_signals); i++) {
if (handled_signals[i].number != sig)
@@ -1481,7 +1481,7 @@ static void fatal_sig_handler(int sig)
  */
 void igt_install_exit_handler(igt_exit_handler_t fn)
 {
-   int i;
+   size_t i;
 
for (i = 0; i  exit_handler_count; i++)
if (exit_handler_fn[i] == fn)
@@ -1521,7 +1521,7 @@ err:
 void igt_disable_exit_handler(void)
 {
sigset_t set;
-   int i;
+   size_t i;
 
if (exit_handler_disabled)
return;
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] libs/igt_core.c: Fix compile warnings in igt_core.c

2015-05-19 Thread Derek Morton
Fixed variables incorrectly declared as signed instead of unsigned.

Fixed 'unused parameter' warning from signal handlers that were
not using the signal parameter.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/igt_core.c | 24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249..fb0b634 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -440,6 +440,8 @@ static void low_mem_killer_disable(bool disable)
 bool igt_exit_called;
 static void common_exit_handler(int sig)
 {
+   (void)sig; /* Not used, suppress warning */
+
if (!igt_only_list_subtests()) {
low_mem_killer_disable(false);
}
@@ -1104,7 +1106,7 @@ static pid_t helper_process_pids[] =
 
 static void reset_helper_process_list(void)
 {
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
+   for (unsigned int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
helper_process_pids[i] = -1;
helper_process_count = 0;
 }
@@ -1121,8 +1123,10 @@ static int __waitpid(pid_t pid)
 
 static void fork_helper_exit_handler(int sig)
 {
+   (void)sig; /* Not used, suppress warning */
+
/* Inside a signal handler, play safe */
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
+   for (unsigned int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
pid_t pid = helper_process_pids[i];
if (pid != -1) {
kill(pid, SIGTERM);
@@ -1227,6 +1231,8 @@ static void children_exit_handler(int sig)
 {
int status;
 
+   (void)sig; /* Not used, suppress warning */
+
/* The exit handler can be called from a fatal signal, so play safe */
while (num_test_children--  wait(status))
;
@@ -1376,16 +1382,18 @@ static void restore_sig_handler(int sig_num)
 
 static void restore_all_sig_handler(void)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  ARRAY_SIZE(orig_sig); i++)
-   restore_sig_handler(i);
+   restore_sig_handler((int)i);
 }
 
 static void call_exit_handlers(int sig)
 {
int i;
 
+   (void)sig; /* Not used, suppress warning */
+
if (!exit_handler_count) {
return;
}
@@ -1419,7 +1427,7 @@ static bool crash_signal(int sig)
 
 static void fatal_sig_handler(int sig)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  ARRAY_SIZE(handled_signals); i++) {
if (handled_signals[i].number != sig)
@@ -1481,7 +1489,7 @@ static void fatal_sig_handler(int sig)
  */
 void igt_install_exit_handler(igt_exit_handler_t fn)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  exit_handler_count; i++)
if (exit_handler_fn[i] == fn)
@@ -1521,7 +1529,7 @@ err:
 void igt_disable_exit_handler(void)
 {
sigset_t set;
-   int i;
+   unsigned int i;
 
if (exit_handler_disabled)
return;
@@ -1724,6 +1732,8 @@ out:
 
 static void igt_alarm_handler(int signal)
 {
+   (void)signal; /* Not used, suppress warning */
+
igt_info(Timed out\n);
 
/* exit with failure status */
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] libs/igt_core.c: Fix compile warnings in igt_core.c

2015-05-19 Thread Derek Morton
Fixed variables incorrectly declared as signed instead of unsigned.

Fixed 'unused parameter' warning from signal handlers that were
not using the signal parameter.

v2: Addressed comments from Tim Gore

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/igt_core.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249..62b1e6a 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1104,7 +1104,7 @@ static pid_t helper_process_pids[] =
 
 static void reset_helper_process_list(void)
 {
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
+   for (unsigned int i = 0; i  ARRAY_SIZE(helper_process_pids); i++)
helper_process_pids[i] = -1;
helper_process_count = 0;
 }
@@ -1121,8 +1121,10 @@ static int __waitpid(pid_t pid)
 
 static void fork_helper_exit_handler(int sig)
 {
+   (void)sig; /* Not used, suppress warning */
+
/* Inside a signal handler, play safe */
-   for (int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
+   for (unsigned int i = 0; i  ARRAY_SIZE(helper_process_pids); i++) {
pid_t pid = helper_process_pids[i];
if (pid != -1) {
kill(pid, SIGTERM);
@@ -1227,6 +1229,8 @@ static void children_exit_handler(int sig)
 {
int status;
 
+   (void)sig; /* Not used, suppress warning */
+
/* The exit handler can be called from a fatal signal, so play safe */
while (num_test_children--  wait(status))
;
@@ -1376,10 +1380,10 @@ static void restore_sig_handler(int sig_num)
 
 static void restore_all_sig_handler(void)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  ARRAY_SIZE(orig_sig); i++)
-   restore_sig_handler(i);
+   restore_sig_handler((int)i);
 }
 
 static void call_exit_handlers(int sig)
@@ -1419,7 +1423,7 @@ static bool crash_signal(int sig)
 
 static void fatal_sig_handler(int sig)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  ARRAY_SIZE(handled_signals); i++) {
if (handled_signals[i].number != sig)
@@ -1481,7 +1485,7 @@ static void fatal_sig_handler(int sig)
  */
 void igt_install_exit_handler(igt_exit_handler_t fn)
 {
-   int i;
+   unsigned int i;
 
for (i = 0; i  exit_handler_count; i++)
if (exit_handler_fn[i] == fn)
@@ -1521,7 +1525,7 @@ err:
 void igt_disable_exit_handler(void)
 {
sigset_t set;
-   int i;
+   unsigned int i;
 
if (exit_handler_disabled)
return;
@@ -1724,6 +1728,8 @@ out:
 
 static void igt_alarm_handler(int signal)
 {
+   (void)signal; /* Not used, suppress warning */
+
igt_info(Timed out\n);
 
/* exit with failure status */
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] lib/igt_core.c: Flag the test as failing after a segfault

2015-05-18 Thread Derek Morton
fatal_signal_handler() was trapping fatal errors but not
flagging the test as failing or setting an exit code.
The result was that the test would return Ok or Skipped
depending on what the other subtests did even though one
of the subtests had segfaulted.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 lib/igt_core.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249..b29f7e3 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1433,8 +1433,15 @@ static void fatal_sig_handler(int sig)
igt_assert_eq(write(STDERR_FILENO, .\n, 2), 2);
}
 
-   if (in_subtest  crash_signal(sig))
+   if (in_subtest  crash_signal(sig)) {
+   /* Linux standard to return exit code as 128 + signal */
+   if (!failed_one)
+   igt_exitcode = 128 + sig;
+
+   failed_one = true;
+
exit_subtest(CRASH);
+   }
break;
}
 
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/Android.mk: Treat all KMS tests as Cairo dependent

2015-05-15 Thread Derek Morton
If ANDROID_HAS_CAIRO is not set, automatically add all
kms tests to the skip_tests_list.

Building for android currently fails due to the addition of
new kms tests. Rather than just adding the new tests to the
exclusion list, autogenerating a list of all kms tests and
excluding them will reduce future maintainance.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tests/Android.mk | 36 +++-
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/tests/Android.mk b/tests/Android.mk
index fac9931..10ef3e2 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -55,32 +55,18 @@ ifeq (${ANDROID_HAS_CAIRO}, 1)
 else
 # the following tests depend on cairo, so skip them
 skip_tests_list += \
-kms_3d \
-kms_plane \
-kms_addfb \
-kms_cursor_crc \
-kms_flip \
-kms_flip_tiling \
-kms_pipe_crc_basic \
-kms_psr_sink_crc \
-kms_fbc_crc \
-kms_setmode \
-kms_sink_crc_basic \
 gem_render_copy \
-pm_lpsp \
-kms_fence_pin_leak \
-kms_mmio_vs_cs_flip \
-kms_render \
-kms_universal_plane \
-kms_rotation_crc \
-kms_force_connector \
-kms_flip_event_leak \
-kms_crtc_background_color \
-kms_plane_scaling \
-kms_panel_fitting \
-kms_pwrite_crc \
-kms_pipe_b_c_ivb \
-kms_legacy_colorkey
+pm_lpsp
+
+# All kms tests depend on cairo
+tmp_list := $(foreach test_name, $(TESTS_progs),\
+$(if $(findstring kms_,$(test_name)),$(test_name)))
+skip_tests_list += $(tmp_list)
+
+tmp_list := $(foreach test_name, $(TESTS_progs_M),\
+$(if $(findstring kms_,$(test_name)),$(test_name)))
+skip_tests_list += $(tmp_list)
+
 IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0
 endif
 
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v2] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure

2015-05-14 Thread Derek Morton
On android with small memory footprints gem_cpu_reloc can fail
due to OOM.

Refactor gem_cpu_reloc into 2 tests, a basic test which performs
10 relocations and a full test which skips if there is insufficient
memory.

Changed the memory required test to better estimate the actual
RAM used.

v2: Addresed comments from Thomas Wood

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tests/gem_cpu_reloc.c | 52 ++-
 1 file changed, 39 insertions(+), 13 deletions(-)

diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index 058089c..45449ff 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -159,16 +159,14 @@ uint32_t gen8_batch[] = {
 uint32_t *batch = gen6_batch;
 uint32_t batch_size = sizeof(gen6_batch);
 
-igt_simple_main
+static void run_test(int fd, int count)
 {
const uint32_t hang[] = {-1, -1, -1, -1};
const uint32_t end[] = {MI_BATCH_BUFFER_END, 0};
-   uint64_t aper_size;
uint32_t noop;
uint32_t *handles;
-   int fd, i, count;
+   int i;
 
-   fd = drm_open_any();
noop = intel_get_drm_devid(fd);
 
use_blt = 0;
@@ -180,13 +178,6 @@ igt_simple_main
batch_size += 2 * 4;
}
 
-   aper_size = gem_mappable_aperture_size();
-   count = aper_size / 4096 * 2;
-   if (igt_run_in_simulation())
-   count = 10;
-
-   intel_require_memory(1+count, 4096, CHECK_RAM);
-
handles = malloc (count * sizeof(uint32_t));
igt_assert(handles);
 
@@ -246,6 +237,41 @@ igt_simple_main
igt_progress(gem_cpu_reloc: , 2*count+i, 3*count);
}
 
-   igt_info(Test suceeded, cleanup up - this might take a while.\n);
-   close(fd);
+   igt_info(Subtest suceeded, cleanup up - this might take a while.\n);
+   for (i = 0; i  count; i++) {
+   gem_close(fd, handles[i]);
+   }
+   gem_close(fd, noop);
+   free(handles);
+}
+
+igt_main
+{
+   uint64_t aper_size;
+   int fd, count;
+
+   igt_fixture {
+   fd = drm_open_any();
+   }
+
+   igt_subtest(basic) {
+   run_test (fd, 10);
+   }
+
+   igt_skip_on_simulation();
+
+   igt_subtest(full) {
+   aper_size = gem_mappable_aperture_size();
+   count = aper_size / 4096 * 2;
+
+   /* count + 2 (noop  bad) buffers. A gem object appears to
+   require about 2kb + buffer + kernel overhead */
+   intel_require_memory(2+count, 2048+4096, CHECK_RAM);
+
+   run_test (fd, count);
+   }
+
+   igt_fixture {
+   close(fd);
+   }
 }
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure

2015-05-12 Thread Derek Morton
On android with small memory footprints gem_cpu_reloc can fail
due to OOM.

Refactor gem_cpu_reloc into 2 tests, a basic test which performs
10 relocations and a full test which skips if there is insufficient
memory.

Changed the memory required test to better estimate the actual
RAM used.

Signed-off-by: Derek Morton derek.j.mor...@intel.com
---
 tests/gem_cpu_reloc.c | 48 
 1 file changed, 36 insertions(+), 12 deletions(-)

diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index 058089c..2f5fc60 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -159,16 +159,14 @@ uint32_t gen8_batch[] = {
 uint32_t *batch = gen6_batch;
 uint32_t batch_size = sizeof(gen6_batch);
 
-igt_simple_main
+void run_test(int fd, int count)
 {
const uint32_t hang[] = {-1, -1, -1, -1};
const uint32_t end[] = {MI_BATCH_BUFFER_END, 0};
-   uint64_t aper_size;
uint32_t noop;
uint32_t *handles;
-   int fd, i, count;
+   int i;
 
-   fd = drm_open_any();
noop = intel_get_drm_devid(fd);
 
use_blt = 0;
@@ -180,13 +178,6 @@ igt_simple_main
batch_size += 2 * 4;
}
 
-   aper_size = gem_mappable_aperture_size();
-   count = aper_size / 4096 * 2;
-   if (igt_run_in_simulation())
-   count = 10;
-
-   intel_require_memory(1+count, 4096, CHECK_RAM);
-
handles = malloc (count * sizeof(uint32_t));
igt_assert(handles);
 
@@ -246,6 +237,39 @@ igt_simple_main
igt_progress(gem_cpu_reloc: , 2*count+i, 3*count);
}
 
-   igt_info(Test suceeded, cleanup up - this might take a while.\n);
+   igt_info(Subtest suceeded, cleanup up - this might take a while.\n);
+   for (i = 0; i  count; i++) {
+   gem_close(fd, handles[i]);
+   }
+   gem_close(fd, noop);
+   free(handles);
+}
+
+igt_main
+{
+   uint64_t aper_size;
+   int fd, count;
+
+   igt_fixture {
+   fd = drm_open_any();
+   }
+
+   igt_subtest(basic) {
+   run_test (fd, 10);
+   }
+
+   igt_skip_on_simulation();
+
+   igt_subtest(full) {
+   aper_size = gem_mappable_aperture_size();
+   count = aper_size / 4096 * 2;
+
+   /* count + 2 (noop  bad) buffers. A gem object appears to
+   require about 2kb + buffer + kernel overhead */
+   intel_require_memory(2+count, 2048+4096, CHECK_RAM);
+
+   run_test (fd, count);
+   }
+
close(fd);
 }
-- 
1.9.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx