From 33c0ffbd2c14f2cf3d22d788859a91c32abf565d Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:10:54 +0000 Subject: [PATCH i-g-t 01/21] Replace ALIGN macro by round_up. These are equivalent in the Linux kernel. NetBSD defines ALIGN to mean something else in . --- benchmarks/gem_userptr_benchmark.c | 4 ++-- lib/drmtest.h | 4 ++-- lib/intel_os.c | 2 +- lib/media_fill_gen7.c | 2 +- lib/media_fill_gen8.c | 2 +- lib/media_fill_gen8lp.c | 2 +- lib/media_fill_gen9.c | 4 ++-- lib/rendercopy_gen6.c | 2 +- lib/rendercopy_gen7.c | 4 ++-- lib/rendercopy_gen8.c | 2 +- lib/rendercopy_gen9.c | 2 +- overlay/kms/kms-overlay.c | 14 +++++++------- overlay/x11/x11-overlay.c | 12 ++++++------ tests/gem_ctx_thrash.c | 4 ++-- tests/gem_exec_parse.c | 2 +- tests/gem_userptr_blits.c | 4 ++-- tools/null_state_gen/intel_batchbuffer.h | 2 +- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/benchmarks/gem_userptr_benchmark.c b/benchmarks/gem_userptr_benchmark.c index 4d7442b..2fba5ec 100644 --- a/benchmarks/gem_userptr_benchmark.c +++ b/benchmarks/gem_userptr_benchmark.c @@ -389,7 +389,7 @@ static void test_single(int fd) MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); assert(ptr != MAP_FAILED); - bo_ptr = (char *)ALIGN((unsigned long)ptr, PAGE_SIZE); + bo_ptr = (char *)round_up((unsigned long)ptr, PAGE_SIZE); start_test(test_duration_sec); @@ -422,7 +422,7 @@ static void test_multiple(int fd, unsigned int batch, int random) MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); assert(ptr != MAP_FAILED); - bo_ptr = (char *)ALIGN((unsigned long)ptr, PAGE_SIZE); + bo_ptr = (char *)round_up((unsigned long)ptr, PAGE_SIZE); for (i = 0; i < batch; i++) map[i] = i; diff --git a/lib/drmtest.h b/lib/drmtest.h index 508cc83..1fefa8c 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -62,13 +62,13 @@ static inline void *igt_mmap64(void *addr, size_t length, int prot, int flags, #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) /** - * ALIGN: + * round_up: * @v: value to be aligned * @a: alignment unit in bytes * * Macro to align a value @v to a specified unit @a. */ -#define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1)) +#define round_up(v, a) (((v) + (a)-1) & ~((a)-1)) int drm_get_card(void); int __drm_open_any(void); diff --git a/lib/intel_os.c b/lib/intel_os.c index 1badd3e..5ee5b71 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -223,7 +223,7 @@ void intel_require_memory(uint32_t count, uint32_t size, unsigned mode) required = count; required *= size + KERNEL_BO_OVERHEAD; - required = ALIGN(required, 4096); + required = round_up(required, 4096); igt_debug("Checking %u surfaces of size %u bytes (total %llu) against %s%s\n", count, size, (long long)required, diff --git a/lib/media_fill_gen7.c b/lib/media_fill_gen7.c index 7113fda..bb469f0 100644 --- a/lib/media_fill_gen7.c +++ b/lib/media_fill_gen7.c @@ -49,7 +49,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->ptr = batch->buffer + offset; return offset; } diff --git a/lib/media_fill_gen8.c b/lib/media_fill_gen8.c index 4a8fe5a..f3b152e 100644 --- a/lib/media_fill_gen8.c +++ b/lib/media_fill_gen8.c @@ -33,7 +33,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->ptr = batch->buffer + offset; return offset; } diff --git a/lib/media_fill_gen8lp.c b/lib/media_fill_gen8lp.c index 1f8a4ad..524fc2a 100644 --- a/lib/media_fill_gen8lp.c +++ b/lib/media_fill_gen8lp.c @@ -33,7 +33,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->ptr = batch->buffer + offset; return offset; } diff --git a/lib/media_fill_gen9.c b/lib/media_fill_gen9.c index 3fd2181..c88242b 100644 --- a/lib/media_fill_gen9.c +++ b/lib/media_fill_gen9.c @@ -7,7 +7,7 @@ #include -#define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1)) +#define round_up(x, y) (((x) + (y)-1) & ~((y)-1)) static const uint32_t media_kernel[][4] = { { 0x00400001, 0x20202288, 0x00000020, 0x00000000 }, @@ -33,7 +33,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->ptr = batch->buffer + offset; return offset; } diff --git a/lib/rendercopy_gen6.c b/lib/rendercopy_gen6.c index 8c24cf8..303fc60 100644 --- a/lib/rendercopy_gen6.c +++ b/lib/rendercopy_gen6.c @@ -58,7 +58,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->ptr = batch->buffer + offset; return offset; } diff --git a/lib/rendercopy_gen7.c b/lib/rendercopy_gen7.c index 3b92406..f9a5f92 100644 --- a/lib/rendercopy_gen7.c +++ b/lib/rendercopy_gen7.c @@ -42,7 +42,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->state = batch->buffer + offset; return offset; } @@ -578,7 +578,7 @@ void gen7_render_copyfunc(struct intel_batchbuffer *batch, OUT_BATCH(MI_BATCH_BUFFER_END); batch_end = batch->ptr - batch->buffer; - batch_end = ALIGN(batch_end, 8); + batch_end = round_up(batch_end, 8); igt_assert(batch_end < BATCH_STATE_SPLIT); gen7_render_flush(batch, context, batch_end); diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c index baed762..8e11f15 100644 --- a/lib/rendercopy_gen8.c +++ b/lib/rendercopy_gen8.c @@ -139,7 +139,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->ptr = batch->buffer + offset; return offset; } diff --git a/lib/rendercopy_gen9.c b/lib/rendercopy_gen9.c index b7b133c..9b2fd01 100644 --- a/lib/rendercopy_gen9.c +++ b/lib/rendercopy_gen9.c @@ -140,7 +140,7 @@ static uint32_t batch_align(struct intel_batchbuffer *batch, uint32_t align) { uint32_t offset = batch_used(batch); - offset = ALIGN(offset, align); + offset = round_up(offset, align); batch->ptr = batch->buffer + offset; return offset; } diff --git a/overlay/kms/kms-overlay.c b/overlay/kms/kms-overlay.c index cfb3d5a..f137239 100644 --- a/overlay/kms/kms-overlay.c +++ b/overlay/kms/kms-overlay.c @@ -40,8 +40,8 @@ #include "../overlay.h" //#include "rgb2yuv.h" -#ifndef ALIGN -#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1)) +#ifndef round_up +#define round_up(i,m) (((i) + (m) - 1) & ~((m) - 1)) #endif struct kms_image { @@ -260,13 +260,13 @@ kms_overlay_create(struct config *config, int *width, int *height) goto err_fd; priv->image.format = DRM_FORMAT_XRGB8888; - priv->image.width = ALIGN(*width, 4); - priv->image.height = ALIGN(*height, 2); - priv->image.stride = ALIGN(4*priv->image.width, 64); - priv->image.size = ALIGN(priv->image.stride * priv->image.height, 4096); + priv->image.width = round_up(*width, 4); + priv->image.height = round_up(*height, 2); + priv->image.stride = round_up(4*priv->image.width, 64); + priv->image.size = round_up(priv->image.stride * priv->image.height, 4096); create.handle = 0; - create.size = ALIGN(priv->image.size, 4096); + create.size = round_up(priv->image.size, 4096); drmIoctl(priv->fd, DRM_IOCTL_I915_GEM_CREATE, &create); if (create.handle == 0) goto err_fd; diff --git a/overlay/x11/x11-overlay.c b/overlay/x11/x11-overlay.c index 38d58b0..0245bca 100644 --- a/overlay/x11/x11-overlay.c +++ b/overlay/x11/x11-overlay.c @@ -41,8 +41,8 @@ #include "position.h" #include "rgb2yuv.h" -#ifndef ALIGN -#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1)) +#ifndef round_up +#define round_up(i,m) (((i) + (m) - 1) & ~((m) - 1)) #endif #define FOURCC_XVMC (('C' << 24) + ('M' << 16) + ('V' << 8) + 'X') @@ -174,9 +174,9 @@ x11_overlay_create(struct config *config, int *width, int *height) if (image == NULL) { image = XvCreateImage(dpy, port, FOURCC_XVMC, NULL, w, h); if (image->pitches[0] == 4) { - image->pitches[0] = ALIGN(image->width, 1024); - image->pitches[1] = ALIGN(image->width/2, 1024); - image->pitches[2] = ALIGN(image->width/2, 1024); + image->pitches[0] = round_up(image->width, 1024); + image->pitches[1] = round_up(image->width/2, 1024); + image->pitches[2] = round_up(image->width/2, 1024); image->offsets[0] = 0; image->offsets[1] = image->pitches[0] * image->height; image->offsets[2] = image->offsets[1] + image->pitches[1] * image->height/2; @@ -198,7 +198,7 @@ x11_overlay_create(struct config *config, int *width, int *height) } create.handle = 0; - create.size = ALIGN(create.size, 4096); + create.size = round_up(create.size, 4096); drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create); if (create.handle == 0) goto err_image; diff --git a/tests/gem_ctx_thrash.c b/tests/gem_ctx_thrash.c index b4818f4..21dd88f 100644 --- a/tests/gem_ctx_thrash.c +++ b/tests/gem_ctx_thrash.c @@ -170,8 +170,8 @@ processes(void) /* tweak rlimits to allow us to create this many files */ igt_assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0); - if (rlim.rlim_cur < ALIGN(num_ctx + 1024, 1024)) { - rlim.rlim_cur = ALIGN(num_ctx + 1024, 1024); + if (rlim.rlim_cur < round_up(num_ctx + 1024, 1024)) { + rlim.rlim_cur = round_up(num_ctx + 1024, 1024); if (rlim.rlim_cur > rlim.rlim_max) rlim.rlim_max = rlim.rlim_cur; igt_assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0); diff --git a/tests/gem_exec_parse.c b/tests/gem_exec_parse.c index fff166a..8d671f2 100644 --- a/tests/gem_exec_parse.c +++ b/tests/gem_exec_parse.c @@ -176,7 +176,7 @@ static void exec_split_batch(int fd, uint32_t *cmds, */ execbuf.batch_start_offset = actual_start_offset & ~0x7; execbuf.batch_len = - ALIGN(size + actual_start_offset - execbuf.batch_start_offset, + round_up(size + actual_start_offset - execbuf.batch_start_offset, 0x8); execbuf.cliprects_ptr = 0; execbuf.num_cliprects = 0; diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c index 9217c2a..726ae1c 100644 --- a/tests/gem_userptr_blits.c +++ b/tests/gem_userptr_blits.c @@ -1117,7 +1117,7 @@ static void test_unmap(int fd, int expected) MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); igt_assert(ptr != MAP_FAILED); - bo_ptr = (char *)ALIGN((unsigned long)ptr, PAGE_SIZE); + bo_ptr = (char *)round_up((unsigned long)ptr, PAGE_SIZE); for (i = 0; i < num_obj; i++, bo_ptr += sizeof(linear)) { ret = gem_userptr(fd, bo_ptr, sizeof(linear), 0, &bo[i]); @@ -1152,7 +1152,7 @@ static void test_unmap_after_close(int fd) MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); igt_assert(ptr != MAP_FAILED); - bo_ptr = (char *)ALIGN((unsigned long)ptr, PAGE_SIZE); + bo_ptr = (char *)round_up((unsigned long)ptr, PAGE_SIZE); for (i = 0; i < num_obj; i++, bo_ptr += sizeof(linear)) { ret = gem_userptr(fd, bo_ptr, sizeof(linear), 0, &bo[i]); diff --git a/tools/null_state_gen/intel_batchbuffer.h b/tools/null_state_gen/intel_batchbuffer.h index 8b87c02..bf4bd4c 100644 --- a/tools/null_state_gen/intel_batchbuffer.h +++ b/tools/null_state_gen/intel_batchbuffer.h @@ -37,7 +37,7 @@ #define MAX_ITEMS 1024 #define MAX_STRLEN 256 -#define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1)) +#define round_up(x, y) (((x) + (y)-1) & ~((y)-1)) typedef enum { UNINITIALIZED, -- 1.8.3.1 From c02cfd6c7f2ae36b73145e3bd3c60e86ff41dc0f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:15:37 +0000 Subject: [PATCH i-g-t 02/21] If mmap64 is not available, define it to be mmap. The BSDs have 64-bit-safe mmap natively, no need for weird extra syscalls to work around it. --- configure.ac | 1 + lib/drmtest.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 16d6a2e..8f9f5f5 100644 --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,7 @@ AC_CHECK_MEMBERS([struct sysinfo.totalram],[],[],[AC_INCLUDES_DEFAULT ]) AC_CHECK_TYPES([sighandler_t],[],[],[AC_INCLUDES_DEFAULT #include ]) +AC_CHECK_FUNCS([mmap64]) AC_CHECK_FUNCS([swapctl]) AC_CHECK_FUNCS([asprintf]) diff --git a/lib/drmtest.h b/lib/drmtest.h index 508cc83..38e5c37 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -51,6 +51,10 @@ static inline void *igt_mmap64(void *addr, size_t length, int prot, int flags, return __mmap2(addr, length, prot, flags, fd, offset >> 12); } #endif +#else +#ifndef HAVE_MMAP64 +#define mmap64 mmap +#endif #endif /** -- 1.8.3.1 From 5b28cc5865d94b593152001abb38b65075bec446 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:20:11 +0000 Subject: [PATCH i-g-t 03/21] Cast char to unsigned char before passing to ctype(3) macros. The argument type is int, and range of values admitted is those representable by unsigned char, and EOF, which is an int. Negative char values not equal to EOF lead to undefined behaviour. --- lib/igt_core.c | 2 +- overlay/config.c | 4 ++-- tools/intel_reg_dumper.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 8f75e48..92d5a0f 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -737,7 +737,7 @@ bool __igt_run_subtest(const char *subtest_name) /* check the subtest name only contains a-z, A-Z, 0-9, '-' and '_' */ for (i = 0; subtest_name[i] != '\0'; i++) if (subtest_name[i] != '_' && subtest_name[i] != '-' - && !isalnum(subtest_name[i])) { + && !isalnum((unsigned char)subtest_name[i])) { igt_critical("Invalid subtest name \"%s\".\n", subtest_name); igt_exit(); diff --git a/overlay/config.c b/overlay/config.c index b6bd8dc..71158b4 100644 --- a/overlay/config.c +++ b/overlay/config.c @@ -39,7 +39,7 @@ static const char *skip_whitespace(const char *s, const char *end) { - while (s < end && isspace(*s)) + while (s < end && isspace((unsigned char)*s)) s++; return s; } @@ -49,7 +49,7 @@ static const char *trim_whitespace(const char *s, const char *end) if (end == NULL) return end; - while (end > s && isspace(*--end)) + while (end > s && isspace((unsigned char)*--end)) ; return end + 1; diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c index 0b6d887..6279a06 100644 --- a/tools/intel_reg_dumper.c +++ b/tools/intel_reg_dumper.c @@ -2587,7 +2587,7 @@ static void str_to_upper(char *str) { while(*str) { - *str = toupper(*str); + *str = toupper((unsigned char)*str); str++; } } -- 1.8.3.1 From 4884f3811e8f25382ce18be271f8f94163ed825b Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:35:59 +0000 Subject: [PATCH i-g-t 04/21] Check for clock_nanosleep and fall back to nanosleep. --- configure.ac | 1 + tools/intel_gpu_frequency.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 16d6a2e..1c55383 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,7 @@ AC_CHECK_TYPES([sighandler_t],[],[],[AC_INCLUDES_DEFAULT #include ]) AC_CHECK_FUNCS([swapctl]) AC_CHECK_FUNCS([asprintf]) +AC_CHECK_FUNCS([clock_nanosleep]) # Initialize libtool AC_DISABLE_STATIC diff --git a/tools/intel_gpu_frequency.c b/tools/intel_gpu_frequency.c index c5359c0..452f3f7 100644 --- a/tools/intel_gpu_frequency.c +++ b/tools/intel_gpu_frequency.c @@ -119,7 +119,11 @@ static void wait_freq_settle(void) /* FIXME: Lazy sleep without check. */ ts.tv_sec = 0; ts.tv_nsec = 20000; +#ifdef HAVE_CLOCK_NANOSLEEP clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL); +#else + nanosleep(&ts, NULL); +#endif } static void set_frequency(struct freq_info *freq_info, int val) -- 1.8.3.1 From 8e8a56862e7d2e3212900c2b99b965423caeabab Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:37:13 +0000 Subject: [PATCH i-g-t 05/21] Fix return type, omit unused variables in gen?_setup_null_render_state. --- tools/null_state_gen/intel_renderstate_gen7.c | 2 -- tools/null_state_gen/intel_renderstate_gen8.c | 5 +---- tools/null_state_gen/intel_renderstate_gen9.c | 5 +---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/tools/null_state_gen/intel_renderstate_gen7.c b/tools/null_state_gen/intel_renderstate_gen7.c index a48fb27..4f89f24 100644 --- a/tools/null_state_gen/intel_renderstate_gen7.c +++ b/tools/null_state_gen/intel_renderstate_gen7.c @@ -417,8 +417,6 @@ gen7_emit_null_depth_buffer(struct intel_batchbuffer *batch) void gen7_setup_null_render_state(struct intel_batchbuffer *batch) { - int ret; - OUT_BATCH(GEN7_PIPELINE_SELECT | PIPELINE_SELECT_3D); gen7_emit_state_base_address(batch); diff --git a/tools/null_state_gen/intel_renderstate_gen8.c b/tools/null_state_gen/intel_renderstate_gen8.c index 2d7a4b0..58ba6fa 100644 --- a/tools/null_state_gen/intel_renderstate_gen8.c +++ b/tools/null_state_gen/intel_renderstate_gen8.c @@ -322,11 +322,8 @@ static void gen8_emit_primitive(struct intel_batchbuffer *batch) OUT_BATCH(0); /* index buffer offset, ignored */ } -int gen8_setup_null_render_state(struct intel_batchbuffer *batch) +void gen8_setup_null_render_state(struct intel_batchbuffer *batch) { - int ret; - int i; - #define GEN8_PIPE_CONTROL_GLOBAL_GTT (1 << 24) OUT_BATCH(GEN6_PIPE_CONTROL | (6 - 2)); diff --git a/tools/null_state_gen/intel_renderstate_gen9.c b/tools/null_state_gen/intel_renderstate_gen9.c index 6f808f8..855b3f5 100644 --- a/tools/null_state_gen/intel_renderstate_gen9.c +++ b/tools/null_state_gen/intel_renderstate_gen9.c @@ -342,9 +342,8 @@ static void gen9_emit_state_base_address(struct intel_batchbuffer *batch) { * Generate the batch buffer commands needed to initialize the 3D engine * to its "golden state". */ -int gen9_setup_null_render_state(struct intel_batchbuffer *batch) +void gen9_setup_null_render_state(struct intel_batchbuffer *batch) { - int ret; int i; #define GEN8_PIPE_CONTROL_GLOBAL_GTT (1 << 24) @@ -472,6 +471,4 @@ int gen9_setup_null_render_state(struct intel_batchbuffer *batch) gen8_emit_primitive(batch); OUT_BATCH(MI_BATCH_BUFFER_END); - - return ret; } -- 1.8.3.1 From ccf5105bb1def3ccde01e7c4b50c39147a6aafb1 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:39:06 +0000 Subject: [PATCH i-g-t 06/21] Make glib and udev optional. --- configure.ac | 7 ++++++- lib/tests/Makefile.am | 4 ++-- tests/Makefile.am | 6 +++--- tests/Makefile.sources | 7 ++++++- tools/Makefile.sources | 7 ++++++- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 16d6a2e..d28503f 100644 --- a/configure.ac +++ b/configure.ac @@ -104,7 +104,12 @@ PKG_CHECK_MODULES(LIBUDEV, [libudev], [udev=yes], [udev=no]) if test x"$udev" = xyes; then AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection]) fi -PKG_CHECK_MODULES(GLIB, glib-2.0) +AM_CONDITIONAL(HAVE_UDEV, [test "x$udev" = xyes]) +PKG_CHECK_MODULES(GLIB, glib-2.0, [glib=yes], [glib=no]) +if test x"$glib" = xyes; then + AC_DEFINE(HAVE_GLIB,1,[Enable glib]) +fi +AM_CONDITIONAL(HAVE_GLIB, [test "x$glib" = xyes]) # can we build the assembler? AS_IF([test x"$LEX" != "x:" -a x"$YACC" != xyacc], diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am index bab0fcb..e53f3b6 100644 --- a/lib/tests/Makefile.am +++ b/lib/tests/Makefile.am @@ -15,5 +15,5 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \ LDADD = ../libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) -LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS) -AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) +LDADD += $(CAIRO_LIBS) +AM_CFLAGS += $(CAIRO_CFLAGS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 5efc8d8..04a258f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -39,10 +39,10 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \ -DIGT_DATADIR=\""$(abs_srcdir)"\" \ $(NULL) -LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) +LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) -LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS) -AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) +LDADD += $(CAIRO_LIBS) +AM_CFLAGS += $(CAIRO_CFLAGS) drm_import_export_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) drm_import_export_LDADD = $(LDADD) -lpthread diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 51e8376..324e7c0 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -226,13 +226,18 @@ scripts = \ IMAGES = pass.png 1080p-left.png 1080p-right.png +if HAVE_GLIB +TESTS_progs += testdisplay + testdisplay_SOURCES = \ testdisplay.c \ testdisplay.h \ testdisplay_hotplug.c \ $(NULL) -TESTS_progs += testdisplay +testdisplay_CFLAGS = $(GLIB_CFLAGS) +testdisplay_LDADD = $(GLIB_LIBS) +endif common_files = \ eviction_common.c \ diff --git a/tools/Makefile.sources b/tools/Makefile.sources index b16af8a..9dcff8f 100644 --- a/tools/Makefile.sources +++ b/tools/Makefile.sources @@ -22,7 +22,6 @@ bin_PROGRAMS = \ intel_infoframes \ intel_iosf_sb_read \ intel_iosf_sb_write \ - intel_l3_parity \ intel_lid \ intel_opregion_decode \ intel_panel_fitter \ @@ -48,8 +47,14 @@ intel_bios_reader_SOURCES = \ intel_bios_reader.c \ intel_bios.h +if HAVE_UDEV +bin_PROGRAMS += intel_l3_parity + intel_l3_parity_SOURCES = \ intel_l3_parity.c \ intel_l3_parity.h \ intel_l3_udev_listener.c +intel_l3_parity_CFLAGS = $(LIBUDEV_CFLAGS) +intel_l3_parity_LDADD = $(LIBUDEV_LIBS) +endif -- 1.8.3.1 From 6285dd2e1ed8877c5b1dfeb8573e61f3bf7b26ff Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:55:31 +0000 Subject: [PATCH i-g-t 07/21] Disable overlay if there's no . Also, fix enable_overlay_xvlib for BUILD_OVERLAY in configure.ac. --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 16d6a2e..c3a7a94 100644 --- a/configure.ac +++ b/configure.ac @@ -86,10 +86,12 @@ PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.52 libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) PKG_CHECK_MODULES(OVERLAY_XVLIB, [xv x11 xext dri2proto >= 2.6], enable_overlay_xvlib=yes, enable_overlay_xvlib=no) PKG_CHECK_MODULES(OVERLAY_XLIB, [cairo-xlib dri2proto >= 2.6], enable_overlay_xlib=yes, enable_overlay_xlib=no) +dnl XXX Find what of the overlay can be built on non-Linux. +AC_CHECK_HEADER([linux/perf_event.h], [], [enable_overlay_xvlib=no; enable_overlay_xlib=no]) AM_CONDITIONAL(BUILD_OVERLAY_XVLIB, [test "x$enable_overlay_xvlib" = xyes]) AM_CONDITIONAL(BUILD_OVERLAY_XLIB, [test "x$enable_overlay_xlib" = xyes]) -AM_CONDITIONAL(BUILD_OVERLAY, [test "x$enable_overlay_xlib" = xyes -o "x$enable_overlay_xvlib"]) +AM_CONDITIONAL(BUILD_OVERLAY, [test "x$enable_overlay_xlib" = xyes -o "x$enable_overlay_xvlib" = xyes]) if test x$enable_overlay_xvlib = xyes; then AC_DEFINE(HAVE_OVERLAY_XVLIB, 1, [Enable XV backend]) fi -- 1.8.3.1 From 7943ef2c5d53126b85fa6068ecc037d16f4e7374 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:57:22 +0000 Subject: [PATCH i-g-t 08/21] Attempt to mount debugfs only on Linux. --- lib/igt_debugfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index a2cec45..68181e9 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -88,6 +88,7 @@ typedef struct { static bool __igt_debugfs_init(igt_debugfs_t *debugfs) { +#ifdef __linux__ const char *path = "/sys/kernel/debug"; struct stat st; int n; @@ -116,6 +117,7 @@ find_minor: } debugfs->dri_path[0] = '\0'; +#endif return false; } -- 1.8.3.1 From a1127f25bead64d14c153c928a1a01851a750e17 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 04:26:52 +0000 Subject: [PATCH i-g-t 09/21] Make pm_rpm i2c edid stuff #ifdef __linux__. Adapting this code to non-Linux i2c interfaces left as an exercise for the reader. --- tests/pm_rpm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index db8f427..6f1ae7d 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -37,8 +37,10 @@ #include #include #include +#ifdef __linux__ #include #include +#endif #include @@ -585,6 +587,7 @@ static int count_drm_valid_edids(struct mode_set_data *data) static bool i2c_edid_is_valid(int fd) { +#ifdef __linux__ int rc; unsigned char edid[128] = {}; struct i2c_msg msgs[] = { @@ -607,6 +610,10 @@ static bool i2c_edid_is_valid(int fd) rc = ioctl(fd, I2C_RDWR, &msgset); return (rc >= 0) ? edid_is_valid(edid) : false; +#else + /* XXX */ + return true; +#endif } static int count_i2c_valid_edids(void) -- 1.8.3.1 From b9a392a0f96b8dc38aceef5a7fbd49e96a90dff3 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 04:30:58 +0000 Subject: [PATCH i-g-t 10/21] struct timeval needs in kms_universal_plane.c. --- tests/kms_universal_plane.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c index 077a948..64ba463 100644 --- a/tests/kms_universal_plane.c +++ b/tests/kms_universal_plane.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "drmtest.h" #include "igt_debugfs.h" -- 1.8.3.1 From 75389b3911465a1981e11c9360e28593962394bf Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 10:17:21 +0000 Subject: [PATCH i-g-t 11/21] Tag BAD_GTT_DEST with ULL suffix so it doesn't get truncated. --- tests/gem_bad_blit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/gem_bad_blit.c b/tests/gem_bad_blit.c index 593167c..366b182 100644 --- a/tests/gem_bad_blit.c +++ b/tests/gem_bad_blit.c @@ -60,7 +60,7 @@ static drm_intel_bufmgr *bufmgr; struct intel_batchbuffer *batch; -#define BAD_GTT_DEST ((256*1024*1024)) /* past end of aperture */ +#define BAD_GTT_DEST ((256*1024*1024ULL)) /* past end of aperture */ static void bad_blit(drm_intel_bo *src_bo, uint32_t devid) -- 1.8.3.1 From f788d933447a389bc983d011f895427c7a8ebbc1 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 10:22:31 +0000 Subject: [PATCH i-g-t 12/21] Use intmax_t for formatting struct timeval fields. time_t is not long everywhere. (Example: it is int64_t on all NetBSD platforms since NetBSD 6, even where long is int32_t.) suseconds_t is not necessarily long either. It may be signed, but in this case tv_usec is not going to be negative so using uintmax_t is fine. (Could use uint32_t instead of uintmax_t here, since we need only values in [0, 1000000).) --- tools/intel_gpu_time.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/intel_gpu_time.c b/tools/intel_gpu_time.c index 56d65fe..5f4a62a 100644 --- a/tools/intel_gpu_time.c +++ b/tools/intel_gpu_time.c @@ -101,10 +101,16 @@ int main(int argc, char **argv) waitpid(child, &status, 0); getrusage(RUSAGE_CHILDREN, &rusage); - printf("user: %ld.%06lds, sys: %ld.%06lds, elapsed: %ld.%06lds, CPU: %.1f%%, GPU: %.1f%%\n", - rusage.ru_utime.tv_sec, rusage.ru_utime.tv_usec, - rusage.ru_stime.tv_sec, rusage.ru_stime.tv_usec, - end.tv_sec, end.tv_usec, + printf("user: %"PRIdMAX".%06"PRIuMAX"s," + " sys: %"PRIdMAX".%06"PRIuMAX"s," + " elapsed: %"PRIdMAX".%06"PRIuMAX"s," + " CPU: %.1f%%, GPU: %.1f%%\n", + (intmax_t)rusage.ru_utime.tv_sec, + (uintmax_t)rusage.ru_utime.tv_usec, + (intmax_t)rusage.ru_stime.tv_sec, + (uintmax_t)rusage.ru_stime.tv_usec, + (intmax_t)end.tv_sec, + (uintmax_t)end.tv_usec, 100*(rusage.ru_utime.tv_sec + 1e-6*rusage.ru_utime.tv_usec + rusage.ru_stime.tv_sec + 1e-6*rusage.ru_stime.tv_usec) / (end.tv_sec + 1e-6*end.tv_usec), 100 - ring_idle * 100. / ring_time); -- 1.8.3.1 From f1668b89bc1ddf29b96f8fc578116c9133c6d481 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 10:27:37 +0000 Subject: [PATCH i-g-t 13/21] Adapt intel_vga_read/write to work on NetBSD. --- tools/intel_vga_read.c | 2 +- tools/intel_vga_write.c | 2 +- tools/iopl.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 tools/iopl.h diff --git a/tools/intel_vga_read.c b/tools/intel_vga_read.c index e635c59..0fc3930 100644 --- a/tools/intel_vga_read.c +++ b/tools/intel_vga_read.c @@ -30,9 +30,9 @@ #include #include #include -#include #include "intel_io.h" #include "intel_chipset.h" +#include "iopl.h" static uint8_t read_reg(uint32_t reg, bool use_mmio) { diff --git a/tools/intel_vga_write.c b/tools/intel_vga_write.c index 4fb09d6..b6e4536 100644 --- a/tools/intel_vga_write.c +++ b/tools/intel_vga_write.c @@ -30,9 +30,9 @@ #include #include #include -#include #include "intel_io.h" #include "intel_chipset.h" +#include "iopl.h" static void write_reg(uint32_t reg, uint8_t val, bool use_mmio) { diff --git a/tools/iopl.h b/tools/iopl.h new file mode 100644 index 0000000..cb9f0bb --- /dev/null +++ b/tools/iopl.h @@ -0,0 +1,63 @@ +/* + * 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: + * Taylor R Campbell + * + */ + +#ifndef IGT_IOPL_H +#define IGT_IOPL_H + +#if defined(__linux__) +#include +#elif defined(__NetBSD__) +# include +# include + +static inline uint8_t +inb(uint16_t port) +{ + uint8_t v; + + __asm__ __volatile__ ("inb %1,%0" : "=a"(v) : "Nd"(port)); + + return v; +} + +static inline void +outb(uint8_t v, uint16_t port) +{ + + __asm__ __volatile__ ("outb %0,%1" : : "a"(v), "Nd"(port)); +} + +# if defined(__i386__) +# define iopl i386_iopl +# elif defined(__x86_64__) +# define iopl x86_64_iopl +# else +# error Unknown kind of x86. (Intel GPU is x86-only!) +# endif +#endif + +#endif /* IGT_IOPL_H */ -- 1.8.3.1 From 2b8ea3269d6746d5abeb1ec781ccd7bb888f45ff Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 10:30:22 +0000 Subject: [PATCH i-g-t 14/21] Report lwp id in test_thread on NetBSD. --- tests/drm_import_export.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c index 57b13dd..b43a383 100644 --- a/tests/drm_import_export.c +++ b/tests/drm_import_export.c @@ -39,6 +39,10 @@ #include #include #include +#include +#ifdef __NetBSD__ +#include +#endif #include "igt_core.h" #include "drmtest.h" @@ -121,8 +125,10 @@ static void start_test(void) static void * test_thread(void * par) { -#ifdef __linux__ +#if defined(__linux__) igt_debug("start %ld\n", syscall(SYS_gettid)); +#elif defined(__NetBSD__) + igt_debug("start %"PRIuMAX"\n", (uintmax_t)_lwp_self()); #else igt_debug("start %ld\n", (long) pthread_self()); #endif -- 1.8.3.1 From d05c11074f590a343e8242c5fc28eb82bfc5eccb Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 11:01:41 +0000 Subject: [PATCH i-g-t 15/21] Make is_local_tid fail on NetBSD, since we always use current pid. --- tests/core_get_client_auth.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/core_get_client_auth.c b/tests/core_get_client_auth.c index bbfdddf..1107ba6 100644 --- a/tests/core_get_client_auth.c +++ b/tests/core_get_client_auth.c @@ -52,7 +52,12 @@ static bool is_local_tid(pid_t tid) { #ifndef __linux__ +#ifdef __NetBSD__ + /* NetBSD always returns getpid(), never a thread id. */ + return false; +#else return pthread_self() == tid; +#endif #elif !defined(ANDROID) /* On Linux systems, drmGetClient() would return the thread ID instead of the actual process ID */ -- 1.8.3.1 From 6ce810cbb01cb50a96089aa6a975ecc082fc2693 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 11:03:39 +0000 Subject: [PATCH i-g-t 16/21] Teach set_vt_mode to work on NetBSD. --- lib/igt_kms.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 9c131f0..fe4b61c 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -299,6 +299,7 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id) return pfci.pipe; } +#if defined(__linux__) /* * Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was * found and nothing was done. @@ -336,6 +337,42 @@ err: return -errno; } +#elif defined(__NetBSD__) +#include +#include +#define KD_GRAPHICS WSDISPLAYIO_MODE_DUMBFB +static signed long +set_vt_mode(unsigned long mode) +{ + const unsigned newmode = mode; + unsigned oldmode; + int fd; + int ret; + + fd = open("/dev/ttyE0", O_RDWR); + if (fd < 0) { + ret = -errno; + goto out0; + } + + if (ioctl(fd, WSDISPLAYIO_GMODE, &oldmode) == -1) { + ret = -errno; + goto out1; + } + if (ioctl(fd, WSDISPLAYIO_SMODE, &newmode) == -1) { + ret = -errno; + goto out1; + } + + /* Success! */ + ret = oldmode; + +out1: (void)close(fd); +out0: return ret; +} +#else +#error Unable to set VT mode on this operating system. +#endif static unsigned long orig_vt_mode = -1UL; -- 1.8.3.1 From 1ba691bf46933814f803fe127bf4995157869e8f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 11:04:06 +0000 Subject: [PATCH i-g-t 17/21] Teach intel_os.c to query NetBSD for memory statistics. No obvious way to get the current amount of usable RAM (not clear there's an easy answer to that, given caches that can be flushed / pages that can be swapped), so use 1/4 total RAM instead. --- lib/intel_os.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/intel_os.c b/lib/intel_os.c index 1badd3e..6f0ae85 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -119,6 +119,14 @@ intel_get_avail_ram_mb(void) npages = sysconf(_SC_AVPHYS_PAGES); retval = (uint64_t) pagesize * npages; +#elif defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES) + long pagesize, npages; + + pagesize = sysconf(_SC_PAGESIZE); + npages = sysconf(_SC_PHYS_PAGES); + + /* XXX Bogusly assume one quarter of RAM is available. */ + retval = (uint64_t) pagesize * npages / 4; #else #error "Unknown how to get available RAM for this OS" #endif @@ -146,7 +154,7 @@ intel_get_total_swap_mb(void) retval = sysinf.freeswap; retval *= sysinf.mem_unit; -#elif defined(HAVE_SWAPCTL) /* Solaris */ +#elif defined(HAVE_SWAPCTL) && defined(SC_GETNSWP) /* Solaris */ long pagesize = sysconf(_SC_PAGESIZE); uint64_t totalpages = 0; swaptbl_t *swt; @@ -184,6 +192,39 @@ intel_get_total_swap_mb(void) free(buf); retval = (uint64_t) pagesize * totalpages; +#elif defined(HAVE_SWAPCTL) && defined(SWAP_NSWAP) /* NetBSD */ + struct swapent *swap; + uint64_t nblks; + int nswap; + unsigned i; + + if ((nswap = swapctl(SWAP_NSWAP, NULL, 0)) < 0) { + igt_warn("swapctl: SWAP_NSWAP"); + return 0; + } + if (nswap == 0) + return 0; + swap = calloc(nswap, sizeof(*swap)); + if (swapctl(SWAP_STATS, swap, nswap) < 0) { + igt_warn("swapctl: SWAP_STATS"); + free(swap); + return 0; + } + nblks = 0; + for (i = 0; i < nswap; i++) { + if (swap[i].se_nblks < 0) + continue; + if (swap[i].se_nblks > UINT64_MAX - nblks) { + nblks = UINT64_MAX; + continue; + } + nblks += swap[i].se_nblks; + } + + /* units of 512 */ + if (nblks > (UINT64_MAX / 512)) + return UINT64_MAX; + return nblks * 512; #else #warning "Unknown how to get swap size for this OS" return 0; -- 1.8.3.1 From f890348d9c5a25576995fe1c91fa45d9ea8d6952 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:27:59 +0000 Subject: [PATCH i-g-t 18/21] Suppress miscellaneous GCC warnings. - Add __attribute__((noreturn)) to routines that exit. - Don't shadow `signal' in igt_alarm_handler. - Initialize variables that might be skipped in igt_fixture. - Ifdef out intel_batch_num_state, which is unused. --- lib/igt_core.c | 4 +++- tests/drm_read.c | 2 +- tests/gem_concurrent_blit.c | 2 +- tests/gem_tiled_swapping.c | 5 +++++ tools/intel_display_poller.c | 2 ++ tools/intel_gpu_frequency.c | 2 ++ tools/null_state_gen/intel_batchbuffer.c | 2 ++ tools/null_state_gen/intel_null_state_gen.c | 2 +- 8 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 8f75e48..5faeacb 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1654,7 +1654,9 @@ out: free(line); } -static void igt_alarm_handler(int signal) +static void igt_alarm_handler(int) __attribute__((noreturn)); + +static void igt_alarm_handler(int signo) { /* exit with timeout status */ igt_fail(IGT_EXIT_TIMEOUT); diff --git a/tests/drm_read.c b/tests/drm_read.c index 334f26a..1d75c03 100644 --- a/tests/drm_read.c +++ b/tests/drm_read.c @@ -196,7 +196,7 @@ static int pipe0_enabled(int fd) igt_main { - int fd; + int fd = -1; /* XXXGCC */ signal(SIGALRM, sighandler); siginterrupt(SIGALRM, 1); diff --git a/tests/gem_concurrent_blit.c b/tests/gem_concurrent_blit.c index e1693ba..bdf5b5e 100644 --- a/tests/gem_concurrent_blit.c +++ b/tests/gem_concurrent_blit.c @@ -740,7 +740,7 @@ run_basic_modes(const struct access_mode *mode, { NULL, NULL }, }, *h; drm_intel_bo *src[MAX_NUM_BUFFERS], *dst[MAX_NUM_BUFFERS], *dummy = NULL; - drm_intel_bufmgr *bufmgr; + drm_intel_bufmgr *bufmgr = NULL; /* XXXGCC */ for (h = hangs; h->suffix; h++) { diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c index 2361dfc..44a147d 100644 --- a/tests/gem_tiled_swapping.c +++ b/tests/gem_tiled_swapping.c @@ -183,6 +183,11 @@ igt_main struct thread *threads; int fd, n, count, num_threads; + threads = NULL; /* XXXGCC */ + fd = -1; /* XXXGCC */ + count = -1; /* XXXGCC */ + num_threads = -1; /* XXXGCC */ + igt_fixture { size_t lock_size; diff --git a/tools/intel_display_poller.c b/tools/intel_display_poller.c index 2eab6c4..455dd8c 100644 --- a/tools/intel_display_poller.c +++ b/tools/intel_display_poller.c @@ -1121,6 +1121,8 @@ static const char *test_name(enum test test, int pipe, int bit, bool test_pixel_ } } +static void usage(const char *) __attribute__((noreturn)); + static void usage(const char *name) { fprintf(stderr, "Usage: %s [options]\n" diff --git a/tools/intel_gpu_frequency.c b/tools/intel_gpu_frequency.c index c5359c0..ab1e392 100644 --- a/tools/intel_gpu_frequency.c +++ b/tools/intel_gpu_frequency.c @@ -142,6 +142,8 @@ static int get_frequency(struct freq_info *freq_info) return val; } +static void usage(const char *) __attribute__((noreturn)); + static void usage(const char *prog) { diff --git a/tools/null_state_gen/intel_batchbuffer.c b/tools/null_state_gen/intel_batchbuffer.c index a31ea38..c743c07 100644 --- a/tools/null_state_gen/intel_batchbuffer.c +++ b/tools/null_state_gen/intel_batchbuffer.c @@ -164,10 +164,12 @@ unsigned intel_batch_num_cmds(struct intel_batchbuffer *batch) return bb_area_items(batch->cmds); } +#if 0 /* XXX unused */ static unsigned intel_batch_num_state(struct intel_batchbuffer *batch) { return bb_area_items(batch->state); } +#endif struct bb_item *intel_batch_cmd_get(struct intel_batchbuffer *batch, unsigned i) { diff --git a/tools/null_state_gen/intel_null_state_gen.c b/tools/null_state_gen/intel_null_state_gen.c index 8024ac3..6e5dcf4 100644 --- a/tools/null_state_gen/intel_null_state_gen.c +++ b/tools/null_state_gen/intel_null_state_gen.c @@ -52,7 +52,7 @@ static void print_usage(char *s) static int print_state(int gen, struct intel_batchbuffer *batch) { int i; - unsigned long cmds; + unsigned long cmds = ~(unsigned long)0; /* XXXGCC */ fprintf(stderr, "Generating for gen%d\n", gen); -- 1.8.3.1 From 06d56dfe308b90e3a86f1d28747dc82cb3b6b96a Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 02:32:10 +0000 Subject: [PATCH i-g-t 19/21] Use __typeof__, not typeof, in case system headers don't supply it. --- lib/igt_aux.h | 2 +- tools/skl_ddb_allocation.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 0c361f2..95c57ec 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -93,7 +93,7 @@ void intel_require_memory(uint32_t count, uint32_t size, unsigned mode); #define max(a, b) ((a) > (b) ? (a) : (b)) #define igt_swap(a, b) do { \ - typeof(a) _tmp = (a); \ + __typeof__(a) _tmp = (a); \ (a) = (b); \ (b) = _tmp; \ } while (0) diff --git a/tools/skl_ddb_allocation.c b/tools/skl_ddb_allocation.c index c7bfb27..2b95a1f 100644 --- a/tools/skl_ddb_allocation.c +++ b/tools/skl_ddb_allocation.c @@ -35,7 +35,7 @@ * */ #define container_of(ptr, type, member) ({ \ - typeof( ((type *)0)->member ) *__mptr = (ptr); \ + __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) #define div_u64(a, b) ((a) / (b)) -- 1.8.3.1 From 9c559e73bb7d41f664e2880b83bf5946e49fdfae Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 11:02:47 +0000 Subject: [PATCH i-g-t 20/21] Fall back to pthread_kill if pthread_sigqueue is missing. --- configure.ac | 1 + lib/igt_core.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 16d6a2e..6921d09 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,7 @@ AC_CHECK_MEMBERS([struct sysinfo.totalram],[],[],[AC_INCLUDES_DEFAULT AC_CHECK_TYPES([sighandler_t],[],[],[AC_INCLUDES_DEFAULT #include ]) AC_CHECK_FUNCS([swapctl]) +AC_CHECK_FUNCS([pthread_sigqueue]) AC_CHECK_FUNCS([asprintf]) # Initialize libtool diff --git a/lib/igt_core.c b/lib/igt_core.c index 8f75e48..d35697a 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1379,17 +1379,19 @@ static void fatal_sig_handler(int sig) call_exit_handlers(sig); { -#ifdef __linux__ +#if defined(__linux__) /* Workaround cached PID and TID races on glibc and Bionic libc. */ pid_t pid = syscall(SYS_getpid); pid_t tid = syscall(SYS_gettid); syscall(SYS_tgkill, pid, tid, sig); -#else +#elif defined(HAVE_PTHREAD_SIGQUEUE) pthread_t tid = pthread_self(); union sigval value = { .sival_ptr = NULL }; pthread_sigqueue(tid, sig, value); +#else + pthread_kill(pthread_self(), sig); #endif } } -- 1.8.3.1 From cbe660c9f44b6e428b7102735a0761f4700ecc2a Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 4 Mar 2015 17:39:23 +0000 Subject: [PATCH i-g-t 21/21] Make cairo optional too, not just on Android. --- configure.ac | 6 ++- lib/Makefile.am | 7 +-- lib/Makefile.sources | 9 +++- lib/igt_fb.h | 9 +++- tests/Makefile.am | 4 -- tests/Makefile.sources | 114 +++++++++++++++++++++++++++++++++++++++---------- tools/Makefile.am | 4 +- tools/Makefile.sources | 12 ++++-- 8 files changed, 124 insertions(+), 41 deletions(-) diff --git a/configure.ac b/configure.ac index d28503f..3e789a7 100644 --- a/configure.ac +++ b/configure.ac @@ -99,7 +99,11 @@ fi PKG_CHECK_MODULES(XRANDR, xrandr >= 1.3, AC_DEFINE(HAVE_XRANDR, 1, [Have libXrandr]), [have_xrandr=no]) # for testdisplay -PKG_CHECK_MODULES(CAIRO, [cairo >= 1.12.0]) +PKG_CHECK_MODULES(CAIRO, [cairo >= 1.12.0], [cairo=yes], [cairo=no]) +if test "x$cairo" = xyes; then + AC_DEFINE(HAVE_CAIRO,1,[Enable cairo-based framebuffer graphics]) +fi +AM_CONDITIONAL(HAVE_CAIRO, [test "x$cairo" = xyes]) PKG_CHECK_MODULES(LIBUDEV, [libudev], [udev=yes], [udev=no]) if test x"$udev" = xyes; then AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection]) diff --git a/lib/Makefile.am b/lib/Makefile.am index a5a4390..542ed41 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -9,12 +9,9 @@ noinst_LTLIBRARIES = libintel_tools.la noinst_HEADERS = check-ndebug.h AM_CPPFLAGS = -I$(top_srcdir) -AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \ +AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \ -DIGT_DATADIR=\""$(abs_top_srcdir)/tests"\" \ -DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \ -pthread - -LDADD = $(CAIRO_LIBS) -AM_CFLAGS += $(CAIRO_CFLAGS) - +LDADD = $(PCIACCESS_LIBS) diff --git a/lib/Makefile.sources b/lib/Makefile.sources index 76f353a..63f148c 100644 --- a/lib/Makefile.sources +++ b/lib/Makefile.sources @@ -46,12 +46,19 @@ libintel_tools_la_SOURCES = \ intel_iosf.c \ igt_kms.c \ igt_kms.h \ - igt_fb.c \ igt_fb.h \ igt_core.c \ igt_core.h \ $(NULL) +libintel_tools_la_CFLAGS = $(AM_CFLAGS) +libintel_tools_la_LIBADD = $(LDADD) +if HAVE_CAIRO +libintel_tools_la_SOURCES += igt_fb.c +libintel_tools_la_CFLAGS += $(CAIRO_CFLAGS) +libintel_tools_la_LIBADD += $(CAIRO_LIBS) +endif + .PHONY: version.h.tmp $(IGT_LIB_PATH)/version.h.tmp: diff --git a/lib/igt_fb.h b/lib/igt_fb.h index d9fb6bb..f5664b1 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -28,8 +28,13 @@ #ifndef __IGT_FB_H__ #define __IGT_FB_H__ -/* cairo is assumed available on linux. On Android we check for ANDROID_HAS_CAIRO */ -#if (!defined(ANDROID)) || (defined(ANDROID) && ANDROID_HAS_CAIRO) +#include "config.h" + +/* + * On non-Android configure checks for Cairo. On Android we check for + * ANDROID_HAS_CAIRO. + */ +#if (!defined(ANDROID) && defined(HAVE_CAIRO)) || (defined(ANDROID) && ANDROID_HAS_CAIRO) #include #else typedef struct _cairo_surface cairo_surface_t; diff --git a/tests/Makefile.am b/tests/Makefile.am index 04a258f..3961e8a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -41,9 +41,6 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \ LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) -LDADD += $(CAIRO_LIBS) -AM_CFLAGS += $(CAIRO_CFLAGS) - drm_import_export_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) drm_import_export_LDADD = $(LDADD) -lpthread gem_close_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) @@ -74,7 +71,6 @@ gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) gem_userptr_blits_LDADD = $(LDADD) -lpthread gem_wait_LDADD = $(LDADD) -lrt -kms_flip_LDADD = $(LDADD) -lrt -lpthread prime_nv_test_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS) prime_nv_test_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS) diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 324e7c0..b2fe907 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -65,21 +65,6 @@ TESTS_progs_M = \ gem_userptr_blits \ gem_write_read_ring_switch \ kms_addfb \ - kms_cursor_crc \ - kms_fbc_crc \ - kms_flip \ - kms_flip_event_leak \ - kms_flip_tiling \ - kms_mmio_vs_cs_flip \ - kms_pipe_crc_basic \ - kms_plane \ - kms_psr_sink_crc \ - kms_render \ - kms_rotation_crc \ - kms_setmode \ - kms_universal_plane \ - pm_lpsp \ - pm_rpm \ pm_rps \ pm_rc6_residency \ prime_self_import \ @@ -119,7 +104,6 @@ TESTS_progs = \ gem_gpgpu_fill \ gem_pin \ gem_reg_read \ - gem_render_copy \ gem_render_linear_blits \ gem_render_tiled_blits \ gem_ring_sync_copy \ @@ -150,11 +134,6 @@ TESTS_progs = \ gen3_render_tiledx_blits \ gen3_render_tiledy_blits \ gen7_forcewake_mt \ - kms_3d \ - kms_fence_pin_leak \ - kms_force_connector \ - kms_pwrite_crc \ - kms_sink_crc_basic \ prime_udl \ $(NULL) @@ -226,6 +205,94 @@ scripts = \ IMAGES = pass.png 1080p-left.png 1080p-right.png +if HAVE_CAIRO +TESTS_progs += \ + gem_render_copy \ + kms_3d \ + kms_cursor_crc \ + kms_fbc_crc \ + kms_fence_pin_leak \ + kms_flip \ + kms_flip_event_leak \ + kms_flip_tiling \ + kms_force_connector \ + kms_mmio_vs_cs_flip \ + kms_pipe_crc_basic \ + kms_plane \ + kms_psr_sink_crc \ + kms_pwrite_crc \ + kms_render \ + kms_rotation_crc \ + kms_setmode \ + kms_sink_crc_basic \ + kms_universal_plane \ + pm_lpsp \ + pm_rpm \ + $(NULL) + +gem_render_copy_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +gem_render_copy_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_3d_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_3d_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_cursor_crc_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_cursor_crc_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_fbc_crc_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_fbc_crc_LDADD = $(LDADD) $(CAIRO_LIBS) -lrt -lpthread + +kms_fence_pin_leak_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_fence_pin_leak_LDADD = $(LDADD) $(CAIRO_LIBS) -lrt -lpthread + +kms_flip_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_flip_LDADD = $(LDADD) $(CAIRO_LIBS) -lrt -lpthread + +kms_flip_event_leak_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_flip_event_leak_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_flip_tiling_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_flip_tiling_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_force_connector_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_force_connector_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_mmio_vs_cs_flip_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_mmio_vs_cs_flip_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_pipe_crc_basic_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_pipe_crc_basic_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_plane_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_plane_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_psr_sink_crc_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_psr_sink_crc_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_pwrite_crc_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_pwrite_crc_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_render_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_render_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_rotation_crc_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_rotation_crc_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_setmode_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_setmode_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_sink_crc_basic_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_sink_crc_basic_LDADD = $(LDADD) $(CAIRO_LIBS) + +kms_universal_plane_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +kms_universal_plane_LDADD = $(LDADD) $(CAIRO_LIBS) + +pm_lpsp_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +pm_lpsp_LDADD = $(LDADD) $(CAIRO_LIBS) + +pm_rpm_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +pm_rpm_LDADD = $(LDADD) $(CAIRO_LIBS) + if HAVE_GLIB TESTS_progs += testdisplay @@ -235,8 +302,9 @@ testdisplay_SOURCES = \ testdisplay_hotplug.c \ $(NULL) -testdisplay_CFLAGS = $(GLIB_CFLAGS) -testdisplay_LDADD = $(GLIB_LIBS) +testdisplay_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) $(CAIRO_CFLAGS) +testdisplay_LDADD = $(LDADD) $(GLIB_LIBS) $(CAIRO_LIBS) +endif endif common_files = \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 64fa060..8ac7063 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -7,6 +7,6 @@ SUBDIRS += quick_dump endif AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib -AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) -LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUDEV_LIBS) +AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) +LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) diff --git a/tools/Makefile.sources b/tools/Makefile.sources index 9dcff8f..46035c5 100644 --- a/tools/Makefile.sources +++ b/tools/Makefile.sources @@ -15,7 +15,6 @@ bin_PROGRAMS = \ intel_error_decode \ intel_forcewaked \ intel_gpu_frequency \ - intel_framebuffer_dump \ intel_gpu_time \ intel_gpu_top \ intel_gtt \ @@ -55,6 +54,13 @@ intel_l3_parity_SOURCES = \ intel_l3_parity.h \ intel_l3_udev_listener.c -intel_l3_parity_CFLAGS = $(LIBUDEV_CFLAGS) -intel_l3_parity_LDADD = $(LIBUDEV_LIBS) +intel_l3_parity_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) +intel_l3_parity_LDADD = $(LDADD) $(LIBUDEV_LIBS) +endif + +if HAVE_CAIRO +bin_PROGRAMS += intel_framebuffer_dump + +intel_framebuffer_dump_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS) +intel_framebuffer_dump_LDADD = $(LDADD) $(CAIRO_LIBS) endif -- 1.8.3.1