All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/2] lib: Refactor construction of unique tokens
@ 2021-10-05 22:29 Ashutosh Dixit
  2021-10-05 22:29 ` [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax Ashutosh Dixit
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Ashutosh Dixit @ 2021-10-05 22:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Zbigniew Kempczynski, Chris Wilson

From: Chris Wilson <chris.p.wilson@intel.com>

Wrap all the igt_tokencat(prefix, __LINE) into its own igt_unique() to
reduce the clutter and make it easier to generate unique tokens for other
common macros.

Signed-off-by: Chris Wilson <chris.p.wilson@intel.com>
---
 lib/igt_core.h | 54 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/lib/igt_core.h b/lib/igt_core.h
index 8d433fc1655..6b8dbf348d8 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -147,12 +147,12 @@ __noreturn void __igt_fixture_end(void);
  * enumeration (e.g. when enumerating on systems without an intel gpu) such
  * blocks should be annotated with igt_fixture.
  */
-#define igt_fixture for (volatile int igt_tokencat(__tmpint,__LINE__) = 0; \
-			 igt_tokencat(__tmpint,__LINE__) < 1 && \
+#define igt_fixture for (volatile int igt_unique(__tmpint) = 0; \
+			 igt_unique(__tmpint) < 1 && \
 			 (STATIC_ANALYSIS_BUILD || \
 			 (__igt_fixture() && \
 			 (sigsetjmp(igt_subtest_jmpbuf, 1) == 0))); \
-			 igt_tokencat(__tmpint,__LINE__) ++, \
+			 igt_unique(__tmpint) ++, \
 			 __igt_fixture_complete())
 
 /* subtest infrastructure */
@@ -203,6 +203,16 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
  */
 #define igt_tokencat(x, y) __igt_tokencat2(x, y)
 
+/**
+ * igt_unique:
+ * @prefix: local identifier
+ *
+ * C preprocessor helper to generate a custom 'unique' token by appending
+ * the line number onto the token.
+ */
+#define igt_unique(prefix) \
+	igt_tokencat(igt_tokencat(__igt_unique__, prefix), __LINE__)
+
 /**
  * igt_subtest:
  * @name: name of the subtest
@@ -238,7 +248,7 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
  * static string.
  */
 #define igt_subtest_f(f...) \
-	__igt_subtest_f(igt_tokencat(__tmpchar, __LINE__), f)
+	__igt_subtest_f(igt_unique(__tmpchar), f)
 
 /**
  * igt_subtest_with_dynamic:
@@ -315,7 +325,7 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
  * format string instead of a static string.
  */
 #define igt_subtest_with_dynamic_f(f...) \
-	__igt_subtest_with_dynamic_f(igt_tokencat(__tmpchar, __LINE__), f)
+	__igt_subtest_with_dynamic_f(igt_unique(__tmpchar), f)
 
 /**
  * igt_dynamic:
@@ -358,7 +368,7 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
  * instead of a static string.
  */
 #define igt_dynamic_f(f...) \
-	__igt_dynamic_f(igt_tokencat(__tmpchar, __LINE__), f)
+	__igt_dynamic_f(igt_unique(__tmpchar), f)
 
 const char *igt_subtest_name(void);
 bool igt_only_list_subtests(void);
@@ -380,15 +390,15 @@ void __igt_subtest_group_restore(int, int);
  * clauses. If any common setup in a fixture fails, only the subtests in this
  * group will fail or skip. Subtest groups can be arbitrarily nested.
  */
-#define igt_subtest_group for (int igt_tokencat(__tmpint,__LINE__) = 0, \
-			       igt_tokencat(__save,__LINE__) = 0, \
-			       igt_tokencat(__desc,__LINE__) = 0; \
-			       igt_tokencat(__tmpint,__LINE__) < 1 && \
-			       (__igt_subtest_group_save(& igt_tokencat(__save,__LINE__), \
-							 & igt_tokencat(__desc,__LINE__) ), true); \
-			       igt_tokencat(__tmpint,__LINE__) ++, \
-			       __igt_subtest_group_restore(igt_tokencat(__save,__LINE__), \
-							   igt_tokencat(__desc,__LINE__)))
+#define igt_subtest_group for (int igt_unique(__tmpint) = 0, \
+			       igt_unique(__save) = 0, \
+			       igt_unique(__desc) = 0; \
+			       igt_unique(__tmpint) < 1 && \
+			       (__igt_subtest_group_save(& igt_unique(__save), \
+							 & igt_unique(__desc) ), true); \
+			       igt_unique(__tmpint) ++, \
+			       __igt_subtest_group_restore(igt_unique(__save), \
+							   igt_unique(__desc)))
 
 /**
  * igt_main_args:
@@ -404,15 +414,15 @@ void __igt_subtest_group_restore(int, int);
  * #igt_subtest_init_parse_opts.
  */
 #define igt_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \
-	static void igt_tokencat(__real_main, __LINE__)(void); \
+	static void igt_unique(__real_main)(void); \
 	int main(int argc, char **argv) { \
 		igt_subtest_init_parse_opts(&argc, argv, \
 					    short_opts, long_opts, help_str, \
 					    opt_handler, handler_data); \
-		igt_tokencat(__real_main, __LINE__)(); \
+		igt_unique(__real_main)(); \
 		igt_exit(); \
 	} \
-	static void igt_tokencat(__real_main, __LINE__)(void) \
+	static void igt_unique(__real_main)(void) \
 
 
 /**
@@ -460,15 +470,15 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
  * #igt_simple_init_parse_opts.
  */
 #define igt_simple_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \
-	static void igt_tokencat(__real_main, __LINE__)(void); \
+	static void igt_unique(__real_main)(void); \
 	int main(int argc, char **argv) { \
 		igt_simple_init_parse_opts(&argc, argv, \
 					   short_opts, long_opts, help_str, \
 					   opt_handler, handler_data);	\
-		igt_tokencat(__real_main, __LINE__)(); \
+		igt_unique(__real_main)(); \
 		igt_exit(); \
 	} \
-	static void igt_tokencat(__real_main, __LINE__)(void) \
+	static void igt_unique(__real_main)(void) \
 
 
 /**
@@ -490,7 +500,7 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
  */
 #define igt_constructor \
 	__attribute__((constructor)) \
-	static void igt_tokencat(__igt_constructor_l, __LINE__)(void)
+	static void igt_unique(__igt_constructor_l)(void)
 
 __noreturn __attribute__((format(printf, 1, 2)))
 void igt_skip(const char *f, ...);
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax
  2021-10-05 22:29 [igt-dev] [PATCH i-g-t 1/2] lib: Refactor construction of unique tokens Ashutosh Dixit
@ 2021-10-05 22:29 ` Ashutosh Dixit
  2021-10-06 18:11   ` Zbigniew Kempczyński
  2021-10-06 20:26   ` Zbigniew Kempczyński
  2021-10-05 23:16 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib: Refactor construction of unique tokens Patchwork
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 7+ messages in thread
From: Ashutosh Dixit @ 2021-10-05 22:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Zbigniew Kempczynski, Chris Wilson

From: Chris Wilson <chris@chris-wilson.co.uk>

Add typechecking to the min/max macros and make their locals truly
unique-ish to reduce the risk of shadowing.

v2: small bug fix, write also height coordinate on rotation
    test. (jheikkil)
v3: Fix up a couple of other max/max_t instances (Ashutosh)

Signed-off-by: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Chris Wilson <chris.p.wilson@intel.com>
---
 lib/i915/intel_memory_region.c     |  9 ++----
 lib/i915/intel_memory_region.h     |  2 +-
 lib/igt_aux.h                      | 48 ++++++++++++++++++++----------
 lib/igt_fb.c                       | 13 ++++----
 lib/intel_allocator.c              |  2 +-
 lib/intel_allocator_random.c       |  2 +-
 lib/intel_allocator_reloc.c        |  2 +-
 runner/resultgen.c                 |  7 +++--
 tests/i915/api_intel_bb.c          |  2 +-
 tests/i915/gem_eio.c               |  4 +--
 tests/i915/gem_exec_alignment.c    |  4 +--
 tests/i915/gem_exec_capture.c      |  2 +-
 tests/i915/gem_exec_fair.c         |  2 +-
 tests/i915/gem_stress.c            |  2 +-
 tests/i915/gem_tiled_swapping.c    |  5 ++--
 tests/i915/gem_userptr_blits.c     |  2 +-
 tests/i915/i915_pm_rc6_residency.c |  2 +-
 tests/i915/kms_big_fb.c            |  2 +-
 tests/i915/perf_pmu.c              |  2 +-
 tests/kms_atomic_transition.c      |  2 +-
 tests/kms_chamelium.c              |  2 +-
 tests/kms_content_protection.c     |  4 +--
 tests/kms_invalid_mode.c           |  4 +--
 tests/kms_multipipe_modeset.c      |  3 +-
 tests/kms_rotation_crc.c           | 21 ++++++++-----
 tests/kms_setmode.c                | 11 ++-----
 tests/sw_sync.c                    |  5 ++--
 tools/intel_vbt_decode.c           |  3 +-
 28 files changed, 93 insertions(+), 76 deletions(-)

diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index bc2f66dbff5..058b273dcf8 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -146,19 +146,16 @@ out:
  *
  * Returns: Number of found lmem regions.
  */
-uint8_t gem_get_lmem_region_count(int fd)
+unsigned int gem_get_lmem_region_count(int fd)
 {
 	struct drm_i915_query_memory_regions *query_info;
-	uint8_t num_regions;
-	uint8_t lmem_regions = 0;
+	unsigned int lmem_regions = 0;
 
 	query_info = gem_get_query_memory_regions(fd);
 	if (!query_info)
 		goto out;
 
-	num_regions = query_info->num_regions;
-
-	for (int i = 0; i < num_regions; i++) {
+	for (unsigned int i = 0; i < query_info->num_regions; i++) {
 		if (query_info->regions[i].region.memory_class == I915_MEMORY_CLASS_DEVICE)
 			lmem_regions += 1;
 	}
diff --git a/lib/i915/intel_memory_region.h b/lib/i915/intel_memory_region.h
index 024c76d3644..8b427b7e729 100644
--- a/lib/i915/intel_memory_region.h
+++ b/lib/i915/intel_memory_region.h
@@ -58,7 +58,7 @@ uint32_t gem_get_batch_size(int fd, uint8_t mem_region_type);
 
 struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd);
 
-uint8_t gem_get_lmem_region_count(int fd);
+unsigned int gem_get_lmem_region_count(int fd);
 
 bool gem_has_lmem(int fd);
 
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index bf57ccf50df..30b175d70d8 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -40,6 +40,8 @@
 
 #include <i915/gem_submission.h>
 
+#include "igt_core.h"
+
 /* signal interrupt helpers */
 #ifdef __linux__
 # ifndef HAVE_GETTID
@@ -212,26 +214,42 @@ void intel_require_files(uint64_t count);
 #define CHECK_RAM 0x1
 #define CHECK_SWAP 0x2
 
-#define min(a, b) ({			\
-	typeof(a) _a = (a);		\
-	typeof(b) _b = (b);		\
-	_a < _b ? _a : _b;		\
-})
-#define max(a, b) ({			\
-	typeof(a) _a = (a);		\
-	typeof(b) _b = (b);		\
-	_a > _b ? _a : _b;		\
-})
+#define __typecheck(x, y) \
+        (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
 
-#define clamp(x, min, max) ({		\
-	typeof(min) _min = (min);	\
-	typeof(max) _max = (max);	\
-	typeof(x) _x = (x);		\
-	_x < _min ? _min : _x > _max ? _max : _x;	\
+#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
+
+#define __cmp_once(x, y, unique_x, unique_y, op) ({     \
+	typeof(x) unique_x = (x);               \
+	typeof(y) unique_y = (y);               \
+	__cmp(unique_x, unique_y, op);		\
 })
 
+#define __is_constexpr(x) \
+	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
+
+#define __no_side_effects(x, y) \
+	(__is_constexpr(x) && __is_constexpr(y))
+
+#define __safe_cmp(x, y) \
+	(__typecheck(x, y) && __no_side_effects(x, y))
+
+#define __careful_cmp(x, y, op, prefix) \
+	__builtin_choose_expr(__safe_cmp(x, y), \
+			      __cmp(x, y, op), \
+			      __cmp_once(x, y, igt_unique(igt_tokencat(prefix, __x)), igt_unique(igt_tokencat(prefix, __y)), op))
+
+#define min(x, y)	__careful_cmp(x, y, <, min)
+#define max(x, y)	__careful_cmp(x, y, >, max)
+
+#define clamp(val, lo, hi) min(max(val, lo), hi)
+
+#define min_t(t, x, y)	__careful_cmp((typeof(t))x, (typeof(t))y, <, min_t)
+#define max_t(t, x, y)	__careful_cmp((typeof(t))x, (typeof(t))y, >, max_t)
+
 #define igt_swap(a, b) do {	\
 	typeof(a) _tmp = (a);	\
+	_Static_assert(__typecheck(a, b), "type mismatch for swap"); \
 	(a) = (b);		\
 	(b) = _tmp;		\
 } while (0)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ea4d83ab736..fba835a0b8f 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -733,7 +733,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
 		 * tiled. But then that failure is expected.
 		 */
 
-		stride = max(min_stride, 512);
+		stride = max(min_stride, 512u);
 		stride = roundup_power_of_two(stride);
 
 		return stride;
@@ -747,7 +747,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
 		/*
 		 * For amdgpu device with tiling mode
 		 */
-		unsigned int tile_width, tile_height;
+		uint32_t tile_width, tile_height;
 
 		igt_amd_fb_calculate_tile_dimension(fb->plane_bpp[plane],
 				     &tile_width, &tile_height);
@@ -812,9 +812,9 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
 	if (fb->modifier != DRM_FORMAT_MOD_NONE &&
 	    is_i915_device(fb->fd) &&
 	    intel_display_ver(intel_get_drm_devid(fb->fd)) <= 3) {
-		uint64_t min_size = (uint64_t) fb->strides[plane] *
+		uint64_t size = (uint64_t) fb->strides[plane] *
 			fb->plane_height[plane];
-		uint64_t size;
+		uint64_t min_size = 1024 * 1024;
 
 		/* Round the tiling up to the next power-of-two and the region
 		 * up to the next pot fence size so that this works on all
@@ -824,10 +824,7 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
 		 * tiled. But then that failure is expected.
 		 */
 
-		size = max(min_size, 1024*1024);
-		size = roundup_power_of_two(size);
-
-		return size;
+		return roundup_power_of_two(max(size, min_size));
 	} else if (fb->modifier != DRM_FORMAT_MOD_NONE && is_amdgpu_device(fb->fd)) {
 		/*
 		 * For amdgpu device with tiling mode
diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
index 133176ed42e..eabff1f9a13 100644
--- a/lib/intel_allocator.c
+++ b/lib/intel_allocator.c
@@ -1088,7 +1088,7 @@ uint64_t __intel_allocator_alloc(uint64_t allocator_handle, uint32_t handle,
 	struct alloc_resp resp;
 
 	igt_assert((alignment & (alignment-1)) == 0);
-	req.alloc.alignment = max(alignment, 1 << 12);
+	req.alloc.alignment = max_t(uint64_t, alignment, 1 << 12);
 
 	igt_assert(handle_request(&req, &resp) == 0);
 	igt_assert(resp.response_type == RESP_ALLOC);
diff --git a/lib/intel_allocator_random.c b/lib/intel_allocator_random.c
index 9e31426179b..d22f8176705 100644
--- a/lib/intel_allocator_random.c
+++ b/lib/intel_allocator_random.c
@@ -180,7 +180,7 @@ intel_allocator_random_create(int fd, uint64_t start, uint64_t end)
 	igt_assert(ial->priv);
 	ialr->prng = (uint32_t) to_user_pointer(ial);
 
-	start = max(start, BIAS);
+	start = max_t(uint64_t, start, BIAS);
 	igt_assert(start < end);
 	ialr->start = start;
 	ialr->end = end;
diff --git a/lib/intel_allocator_reloc.c b/lib/intel_allocator_reloc.c
index 1790e6c7975..ee3ad43f4a5 100644
--- a/lib/intel_allocator_reloc.c
+++ b/lib/intel_allocator_reloc.c
@@ -176,7 +176,7 @@ intel_allocator_reloc_create(int fd, uint64_t start, uint64_t end)
 	igt_assert(ial->priv);
 	ialr->prng = (uint32_t) to_user_pointer(ial);
 
-	start = max(start, BIAS);
+	start = max_t(uint64_t, start, BIAS);
 	igt_assert(start < end);
 	ialr->offset = ialr->start = start;
 	ialr->end = end;
diff --git a/runner/resultgen.c b/runner/resultgen.c
index b74970a6e65..bccfca12a48 100644
--- a/runner/resultgen.c
+++ b/runner/resultgen.c
@@ -481,12 +481,15 @@ static int find_subtest_idx_limited(struct matches matches,
 	if (line_len < 0)
 		return -1;
 
-	for (k = first; k < last; k++)
+	for (k = first; k < last; k++) {
+		ptrdiff_t rem = bufend - matches.items[k].where;
+
 		if (matches.items[k].what == linekey &&
 		    !memcmp(matches.items[k].where,
 			    full_line,
-			    min(line_len, bufend - matches.items[k].where)))
+			    min_t(ptrdiff_t, line_len, rem)))
 			break;
+	}
 
 	free(full_line);
 
diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
index 293720b4b3c..82943a34191 100644
--- a/tests/i915/api_intel_bb.c
+++ b/tests/i915/api_intel_bb.c
@@ -904,7 +904,7 @@ static int compare_bufs(struct intel_buf *buf1, struct intel_buf *buf2,
 	return ret;
 }
 
-#define LINELEN 76
+#define LINELEN 76ul
 static int dump_base64(const char *name, struct intel_buf *buf)
 {
 	void *ptr;
diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
index d9ff1981a71..3d094433b7b 100644
--- a/tests/i915/gem_eio.c
+++ b/tests/i915/gem_eio.c
@@ -489,7 +489,7 @@ static void test_inflight(int fd, unsigned int wait)
 
 	max = gem_measure_ring_inflight(fd, -1, 0);
 	igt_require(max > 1);
-	max = min(max - 1, ARRAY_SIZE(fence));
+	max = min_t(max, max - 1, ARRAY_SIZE(fence));
 	igt_debug("Using %d inflight batches\n", max);
 
 	for_each_ring(e, parent_fd) {
@@ -558,7 +558,7 @@ static void test_inflight_suspend(int fd)
 
 	max = gem_measure_ring_inflight(fd, -1, 0);
 	igt_require(max > 1);
-	max = min(max - 1, ARRAY_SIZE(fence));
+	max = min_t(max, max - 1, ARRAY_SIZE(fence));
 	igt_debug("Using %d inflight batches\n", max);
 
 	fd = reopen_device(fd);
diff --git a/tests/i915/gem_exec_alignment.c b/tests/i915/gem_exec_alignment.c
index c4611bd1ee2..68b95c869c9 100644
--- a/tests/i915/gem_exec_alignment.c
+++ b/tests/i915/gem_exec_alignment.c
@@ -166,7 +166,7 @@ naughty_child(int i915, int link, uint32_t shared, unsigned int flags)
 	if (!gem_uses_full_ppgtt(i915))
 		gtt_size /= 2; /* We have to *share* our GTT! */
 
-	ram_size = min(intel_get_total_ram_mb(), 4096);
+	ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
 	ram_size *= 1024 * 1024;
 
 	count = min(gtt_size, ram_size) / 16384;
@@ -376,7 +376,7 @@ setup_many(int i915, unsigned long *out)
 	if (!gem_uses_full_ppgtt(i915))
 		gtt_size /= 2; /* We have to *share* our GTT! */
 
-	ram_size = min(intel_get_total_ram_mb(), 4096);
+	ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
 	ram_size *= 1024 * 1024;
 
 	count = min(gtt_size, ram_size) / 16384;
diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index 19f3836e385..7e0a8b8addb 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -566,7 +566,7 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
 		  gtt, ram);
 
 	count = min(gtt, ram) / 4;
-	count = min(count, 256); /* Keep the duration within reason */
+	count = min(count, 256ul); /* Keep the duration within reason */
 	igt_require(count > 1);
 
 	intel_require_memory(count, size, CHECK_RAM);
diff --git a/tests/i915/gem_exec_fair.c b/tests/i915/gem_exec_fair.c
index ef5a450f6ca..89945d40e3c 100644
--- a/tests/i915/gem_exec_fair.c
+++ b/tests/i915/gem_exec_fair.c
@@ -605,7 +605,7 @@ static void fair_child(int i915, const intel_ctx_t *ctx,
 		map = gem_mmap__device_coherent(i915, obj[0].handle,
 						0, 4096, PROT_WRITE);
 		igt_assert(map[0]);
-		for (n = 1; n < min(count, 512); n++) {
+		for (n = 1; n < min(count, 512ul); n++) {
 			igt_assert(map[n]);
 			map[n - 1] = map[n] - map[n - 1];
 		}
diff --git a/tests/i915/gem_stress.c b/tests/i915/gem_stress.c
index 3e4d4907605..3765ab14bdb 100644
--- a/tests/i915/gem_stress.c
+++ b/tests/i915/gem_stress.c
@@ -769,7 +769,7 @@ static void init(void)
 
 	if (options.num_buffers == 0) {
 		tmp = gem_aperture_size(drm_fd);
-		tmp = min(256 * (1024 * 1024), tmp);
+		tmp = min(256 * 1024 * 1024u, tmp);
 		num_buffers = 2 * tmp / options.scratch_buf_size / 3;
 		num_buffers /= 2;
 		igt_info("using %u buffers\n", num_buffers);
diff --git a/tests/i915/gem_tiled_swapping.c b/tests/i915/gem_tiled_swapping.c
index d33b76dbd5b..d66b6ca7f9b 100644
--- a/tests/i915/gem_tiled_swapping.c
+++ b/tests/i915/gem_tiled_swapping.c
@@ -67,7 +67,7 @@ IGT_TEST_DESCRIPTION("Exercise swizzle code for swapping.");
 static uint32_t current_tiling_mode;
 
 #define PAGE_SIZE 4096
-#define AVAIL_RAM 512
+#define AVAIL_RAM 512ul
 
 static uint32_t
 create_bo(int fd)
@@ -183,7 +183,8 @@ igt_main
 		/* lock RAM, leaving only 512MB available */
 		count = intel_get_total_ram_mb() - intel_get_avail_ram_mb();
 		count = max(count + 64, AVAIL_RAM);
-		lock_size = max(0, intel_get_total_ram_mb() - count);
+		count = intel_get_total_ram_mb() - count;
+		lock_size = max_t(long, 0, count);
 		igt_info("Mlocking %zdMiB of %ld/%ldMiB\n",
 			 lock_size,
 			 (long)intel_get_avail_ram_mb(),
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 756bd6e4786..078c75c3947 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -1693,7 +1693,7 @@ static void test_forking_evictions(int fd, int size, int count,
 	 * processes meaning swapping will be triggered system
 	 * wide even if one process on it's own can't do it.
 	 */
-	num_threads = min(sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
+	num_threads = min_t(int, sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
 	trash_count /= num_threads;
 	if (count > trash_count)
 		count = trash_count;
diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
index 96a951406f5..cf9eae90278 100644
--- a/tests/i915/i915_pm_rc6_residency.c
+++ b/tests/i915/i915_pm_rc6_residency.c
@@ -345,7 +345,7 @@ static void bg_load(int i915, unsigned int flags, unsigned long *ctl)
 		ctl[1]++;
 
 		/* aim for ~1% busy */
-		usleep(min(elapsed / 10, 50 * 1000));
+		usleep(min_t(elapsed, elapsed / 10, 50 * 1000));
 	} while (!READ_ONCE(*ctl));
 }
 
diff --git a/tests/i915/kms_big_fb.c b/tests/i915/kms_big_fb.c
index 308227c9113..8665903827d 100644
--- a/tests/i915/kms_big_fb.c
+++ b/tests/i915/kms_big_fb.c
@@ -400,9 +400,9 @@ static bool test_plane(data_t *data)
 
 static bool test_pipe(data_t *data)
 {
+	uint16_t width, height;
 	drmModeModeInfo *mode;
 	igt_plane_t *primary;
-	int width, height;
 	bool ret = false;
 
 	if (data->format == DRM_FORMAT_C8 &&
diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
index 1214cda8c32..e9df0290dd7 100644
--- a/tests/i915/perf_pmu.c
+++ b/tests/i915/perf_pmu.c
@@ -1413,7 +1413,7 @@ static int target_num_interrupts(int i915)
 {
 	const intel_ctx_cfg_t cfg = intel_ctx_cfg_all_physical(i915);
 
-	return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30);
+	return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30u);
 }
 
 static void
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index bc0a1c81b46..9c0a91bf201 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -789,7 +789,7 @@ static void run_modeset_tests(data_t *data, int howmany, bool nonblocking, bool
 	unsigned iter_max;
 	igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
 	igt_output_t *output;
-	unsigned width = 0, height = 0;
+	uint16_t width = 0, height = 0;
 
 	for (i = 0; i < data->display.n_outputs; i++)
 		igt_output_set_pipe(&data->display.outputs[i], PIPE_NONE);
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 1ab411cecfb..11926bbcfa8 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -2399,7 +2399,7 @@ static void test_display_planes_random(data_t *data,
 		igt_output_count_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
 
 	/* Limit the number of planes to a reasonable scene. */
-	overlay_planes_max = min(overlay_planes_max, 4);
+	overlay_planes_max = min(overlay_planes_max, 4u);
 
 	overlay_planes_count = (rand() % overlay_planes_max) + 1;
 	igt_debug("Using %d overlay planes\n", overlay_planes_count);
diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index e8002df2711..f2047173a34 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -703,9 +703,9 @@ static void test_content_protection_cleanup(void)
 
 static void create_fbs(void)
 {
-	igt_output_t *output;
-	int width = 0, height = 0;
+	uint16_t width = 0, height = 0;
 	drmModeModeInfo *mode;
+	igt_output_t *output;
 
 	for_each_connected_output(&data.display, output) {
 		mode = igt_output_get_mode(output);
diff --git a/tests/kms_invalid_mode.c b/tests/kms_invalid_mode.c
index d4feba327fd..11960dfd799 100644
--- a/tests/kms_invalid_mode.c
+++ b/tests/kms_invalid_mode.c
@@ -195,8 +195,8 @@ test_output(data_t *data)
 		return 0;
 
 	igt_create_fb(data->drm_fd,
-		      max(mode.hdisplay, 64),
-		      max(mode.vdisplay, 64),
+		      max_t(uint16_t, mode.hdisplay, 64),
+		      max_t(uint16_t, mode.vdisplay, 64),
 		      DRM_FORMAT_XRGB8888,
 		      DRM_FORMAT_MOD_NONE,
 		      &fb);
diff --git a/tests/kms_multipipe_modeset.c b/tests/kms_multipipe_modeset.c
index b1dbc73a39b..97499508f1b 100644
--- a/tests/kms_multipipe_modeset.c
+++ b/tests/kms_multipipe_modeset.c
@@ -40,10 +40,11 @@ static void run_test(data_t *data, int valid_outputs)
 	igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
 	igt_crc_t ref_crcs[IGT_MAX_PIPES], new_crcs[IGT_MAX_PIPES];
 	igt_display_t *display = &data->display;
-	int width = 0, height = 0, i = 0;
+	uint16_t width = 0, height = 0;
 	igt_pipe_t *pipe;
 	igt_plane_t *plane;
 	drmModeModeInfo *mode;
+	int i = 0;
 
 	for_each_connected_output(display, output) {
 		mode = igt_output_get_mode(output);
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 11401a6d00a..a7f4d22f91f 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -214,6 +214,11 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 		igt_pipe_crc_start(data->pipe_crc);
 }
 
+#define TEST_WIDTH(km) \
+	 min_t((km)->hdisplay, (km)->hdisplay, TEST_MAX_WIDTH)
+#define TEST_HEIGHT(km) \
+	 min_t((km)->vdisplay, (km)->vdisplay, TEST_MAX_HEIGHT)
+
 static void prepare_fbs(data_t *data, igt_output_t *output,
 			igt_plane_t *plane, enum rectangle_type rect, uint32_t format)
 {
@@ -234,8 +239,8 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
 			w = mode->hdisplay;
 			h = mode->vdisplay;
 		} else {
-			w = min(TEST_MAX_WIDTH, mode->hdisplay);
-			h = min(TEST_MAX_HEIGHT, mode->vdisplay);
+			w = TEST_WIDTH(mode);
+			h = TEST_HEIGHT(mode);
 		}
 
 		min_w = 256;
@@ -614,7 +619,7 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
 			  int c)
 {
 	if (data->planepos[c].origo & p_right) {
-		p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay)
+		p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode)
 				+ mode->hdisplay);
 		p[c].x1 &= ~3;
 		/*
@@ -625,17 +630,17 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
 		 */
 		p[c].x1 -= mode->hdisplay & 2;
 	} else {
-		p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay));
+		p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode));
 		p[c].x1 &= ~3;
 	}
 
 	if (data->planepos[c].origo & p_bottom) {
-		p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay)
+		p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode)
 				+ mode->vdisplay);
 		p[c].y1 &= ~3;
 		p[c].y1 -= mode->vdisplay & 2;
 	} else {
-		p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay));
+		p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode));
 		p[c].y1 &= ~3;
 	}
 }
@@ -698,8 +703,8 @@ static void test_multi_plane_rotation(data_t *data, enum pipe pipe)
 		igt_display_require_output(display);
 		igt_display_commit2(display, COMMIT_ATOMIC);
 
-		used_w = min(TEST_MAX_WIDTH, mode->hdisplay);
-		used_h = min(TEST_MAX_HEIGHT, mode->vdisplay);
+		used_w = TEST_WIDTH(mode);
+		used_h = TEST_HEIGHT(mode);
 
 		p[0].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
 		p[1].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 80665204c68..d62251742a4 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -421,15 +421,8 @@ static int test_stealing(int fd, struct crtc_config *crtc, uint32_t *ids)
 	return ret;
 }
 
-static double frame_time(const drmModeModeInfo *kmode)
-{
-	return 1000.0 * kmode->htotal * kmode->vtotal / kmode->clock;
-}
-
-static double line_time(const drmModeModeInfo *kmode)
-{
-	return 1000.0 * kmode->htotal / kmode->clock;
-}
+#define frame_time(km) (1000.0 * (km)->htotal * (km)->vtotal / (km)->clock)
+#define line_time(km) (1000.0 * (km)->htotal / (km)->clock)
 
 static void check_timings(int crtc_idx, const drmModeModeInfo *kmode)
 {
diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index d3d2bec15bb..cbd773fcb97 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -837,8 +837,9 @@ igt_main
 	igt_fixture {
 		igt_require_sw_sync();
 		multi_consumer_threads =
-			min(multi_consumer_threads,
-			    sysconf(_SC_NPROCESSORS_ONLN));
+			min_t(multi_consumer_threads,
+			      multi_consumer_threads,
+			      sysconf(_SC_NPROCESSORS_ONLN));
 	}
 
 	igt_subtest("alloc_timeline")
diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
index 625dc078752..b063af8469d 100644
--- a/tools/intel_vbt_decode.c
+++ b/tools/intel_vbt_decode.c
@@ -534,10 +534,11 @@ static void dump_child_devices(struct context *context, const uint8_t *devices,
 	 * initialized to zero.
 	 */
 	child = calloc(1, sizeof(*child));
+	igt_assert(child);
 
 	for (i = 0; i < child_dev_num; i++) {
 		memcpy(child, devices + i * child_dev_size,
-		       min(sizeof(*child), child_dev_size));
+		       min_t(child_dev_size, sizeof(*child), child_dev_size));
 
 		dump_child_device(context, child);
 	}
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib: Refactor construction of unique tokens
  2021-10-05 22:29 [igt-dev] [PATCH i-g-t 1/2] lib: Refactor construction of unique tokens Ashutosh Dixit
  2021-10-05 22:29 ` [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax Ashutosh Dixit
@ 2021-10-05 23:16 ` Patchwork
  2021-10-06  3:46 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  2021-10-06  8:01 ` [igt-dev] [PATCH i-g-t 1/2] " Zbigniew Kempczyński
  3 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2021-10-05 23:16 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: igt-dev

[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]

== Series Details ==

Series: series starting with [i-g-t,1/2] lib: Refactor construction of unique tokens
URL   : https://patchwork.freedesktop.org/series/95485/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_10685 -> IGTPW_6291
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/index.html

Known issues
------------

  Here are the changes found in IGTPW_6291 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_suspend@basic-s0:
    - fi-cfl-8109u:       [PASS][1] -> [INCOMPLETE][2] ([i915#155])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/fi-cfl-8109u/igt@gem_exec_suspend@basic-s0.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/fi-cfl-8109u/igt@gem_exec_suspend@basic-s0.html

  
#### Possible fixes ####

  * igt@core_hotunplug@unbind-rebind:
    - fi-tgl-u2:          [INCOMPLETE][3] -> [PASS][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/fi-tgl-u2/igt@core_hotunplug@unbind-rebind.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/fi-tgl-u2/igt@core_hotunplug@unbind-rebind.html

  * igt@gem_exec_suspend@basic-s3:
    - fi-tgl-u2:          [FAIL][5] ([i915#1888]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/fi-tgl-u2/igt@gem_exec_suspend@basic-s3.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/fi-tgl-u2/igt@gem_exec_suspend@basic-s3.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-cml-u2:          [DMESG-WARN][7] ([i915#95]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/fi-cml-u2/igt@kms_frontbuffer_tracking@basic.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/fi-cml-u2/igt@kms_frontbuffer_tracking@basic.html

  
  [i915#155]: https://gitlab.freedesktop.org/drm/intel/issues/155
  [i915#1888]: https://gitlab.freedesktop.org/drm/intel/issues/1888
  [i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95


Participating hosts (41 -> 21)
------------------------------

  Missing    (20): fi-kbl-soraka fi-ilk-m540 bat-dg1-6 fi-bsw-n3050 fi-hsw-4200u fi-glk-dsi fi-icl-u2 fi-bwr-2160 fi-apl-guc fi-snb-2520m fi-ctg-p8600 fi-tgl-1115g4 fi-bsw-cyan bat-adlp-4 fi-ivb-3770 fi-icl-y fi-bsw-kefka fi-bsw-nick bat-jsl-1 fi-kbl-r 


Build changes
-------------

  * CI: CI-20190529 -> None
  * IGT: IGT_6232 -> IGTPW_6291

  CI-20190529: 20190529
  CI_DRM_10685: 36c3656c997b07f326d6b967efb1b75e01713773 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_6291: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/index.html
  IGT_6232: effad6af5678be711a2c3e58e182319de784de54 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/index.html

[-- Attachment #2: Type: text/html, Size: 3590 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/2] lib: Refactor construction of unique tokens
  2021-10-05 22:29 [igt-dev] [PATCH i-g-t 1/2] lib: Refactor construction of unique tokens Ashutosh Dixit
  2021-10-05 22:29 ` [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax Ashutosh Dixit
  2021-10-05 23:16 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib: Refactor construction of unique tokens Patchwork
@ 2021-10-06  3:46 ` Patchwork
  2021-10-06  8:01 ` [igt-dev] [PATCH i-g-t 1/2] " Zbigniew Kempczyński
  3 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2021-10-06  3:46 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: igt-dev

[-- Attachment #1: Type: text/plain, Size: 30294 bytes --]

== Series Details ==

Series: series starting with [i-g-t,1/2] lib: Refactor construction of unique tokens
URL   : https://patchwork.freedesktop.org/series/95485/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_10685_full -> IGTPW_6291_full
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with IGTPW_6291_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_6291_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/index.html

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_6291_full:

### IGT changes ###

#### Possible regressions ####

  * igt@kms_writeback@writeback-invalid-parameters:
    - shard-tglb:         NOTRUN -> [SKIP][1]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@kms_writeback@writeback-invalid-parameters.html
    - shard-iclb:         NOTRUN -> [SKIP][2]
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb3/igt@kms_writeback@writeback-invalid-parameters.html

  
#### Warnings ####

  * igt@kms_writeback@writeback-check-output:
    - shard-iclb:         [SKIP][3] ([i915#2437]) -> [SKIP][4] +2 similar issues
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-iclb1/igt@kms_writeback@writeback-check-output.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb3/igt@kms_writeback@writeback-check-output.html

  * igt@kms_writeback@writeback-fb-id:
    - shard-tglb:         [SKIP][5] ([i915#2437]) -> [SKIP][6] +2 similar issues
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-tglb5/igt@kms_writeback@writeback-fb-id.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@kms_writeback@writeback-fb-id.html

  
Known issues
------------

  Here are the changes found in IGTPW_6291_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@feature_discovery@display-2x:
    - shard-tglb:         NOTRUN -> [SKIP][7] ([i915#1839])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@feature_discovery@display-2x.html

  * igt@gem_ctx_persistence@legacy-engines-mixed:
    - shard-snb:          NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#1099]) +4 similar issues
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-snb2/igt@gem_ctx_persistence@legacy-engines-mixed.html

  * igt@gem_exec_fair@basic-none-share@rcs0:
    - shard-iclb:         [PASS][9] -> [FAIL][10] ([i915#2842])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-iclb6/igt@gem_exec_fair@basic-none-share@rcs0.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb3/igt@gem_exec_fair@basic-none-share@rcs0.html
    - shard-glk:          [PASS][11] -> [FAIL][12] ([i915#2842])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-glk2/igt@gem_exec_fair@basic-none-share@rcs0.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk3/igt@gem_exec_fair@basic-none-share@rcs0.html

  * igt@gem_exec_fair@basic-none@rcs0:
    - shard-kbl:          [PASS][13] -> [FAIL][14] ([i915#2842])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-kbl3/igt@gem_exec_fair@basic-none@rcs0.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl3/igt@gem_exec_fair@basic-none@rcs0.html

  * igt@gem_exec_fair@basic-throttle@rcs0:
    - shard-glk:          NOTRUN -> [FAIL][15] ([i915#2842])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk3/igt@gem_exec_fair@basic-throttle@rcs0.html

  * igt@gem_exec_whisper@basic-queues-forked-all:
    - shard-glk:          [PASS][16] -> [DMESG-WARN][17] ([i915#118] / [i915#95]) +1 similar issue
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-glk8/igt@gem_exec_whisper@basic-queues-forked-all.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk2/igt@gem_exec_whisper@basic-queues-forked-all.html

  * igt@gem_huc_copy@huc-copy:
    - shard-apl:          NOTRUN -> [SKIP][18] ([fdo#109271] / [i915#2190])
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl6/igt@gem_huc_copy@huc-copy.html

  * igt@gem_media_vme:
    - shard-tglb:         NOTRUN -> [SKIP][19] ([i915#284])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb1/igt@gem_media_vme.html

  * igt@gem_render_copy@linear-to-vebox-y-tiled:
    - shard-iclb:         NOTRUN -> [SKIP][20] ([i915#768]) +1 similar issue
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb7/igt@gem_render_copy@linear-to-vebox-y-tiled.html

  * igt@gem_softpin@evict-snoop:
    - shard-iclb:         NOTRUN -> [SKIP][21] ([fdo#109312])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb3/igt@gem_softpin@evict-snoop.html
    - shard-tglb:         NOTRUN -> [SKIP][22] ([fdo#109312])
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@gem_softpin@evict-snoop.html

  * igt@gem_userptr_blits@dmabuf-sync:
    - shard-kbl:          NOTRUN -> [SKIP][23] ([fdo#109271] / [i915#3323])
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl7/igt@gem_userptr_blits@dmabuf-sync.html
    - shard-iclb:         NOTRUN -> [SKIP][24] ([i915#3323])
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb2/igt@gem_userptr_blits@dmabuf-sync.html
    - shard-apl:          NOTRUN -> [SKIP][25] ([fdo#109271] / [i915#3323])
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl1/igt@gem_userptr_blits@dmabuf-sync.html
    - shard-glk:          NOTRUN -> [SKIP][26] ([fdo#109271] / [i915#3323])
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk7/igt@gem_userptr_blits@dmabuf-sync.html
    - shard-tglb:         NOTRUN -> [SKIP][27] ([i915#3323])
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb1/igt@gem_userptr_blits@dmabuf-sync.html

  * igt@gem_userptr_blits@readonly-pwrite-unsync:
    - shard-tglb:         NOTRUN -> [SKIP][28] ([i915#3297])
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb1/igt@gem_userptr_blits@readonly-pwrite-unsync.html
    - shard-iclb:         NOTRUN -> [SKIP][29] ([i915#3297])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb1/igt@gem_userptr_blits@readonly-pwrite-unsync.html

  * igt@gem_userptr_blits@vma-merge:
    - shard-snb:          NOTRUN -> [FAIL][30] ([i915#2724])
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-snb2/igt@gem_userptr_blits@vma-merge.html

  * igt@gem_workarounds@suspend-resume-fd:
    - shard-kbl:          NOTRUN -> [DMESG-WARN][31] ([i915#180])
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl6/igt@gem_workarounds@suspend-resume-fd.html

  * igt@gen3_render_tiledy_blits:
    - shard-tglb:         NOTRUN -> [SKIP][32] ([fdo#109289]) +3 similar issues
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb7/igt@gen3_render_tiledy_blits.html

  * igt@gen7_exec_parse@basic-allowed:
    - shard-iclb:         NOTRUN -> [SKIP][33] ([fdo#109289])
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb5/igt@gen7_exec_parse@basic-allowed.html

  * igt@gen9_exec_parse@bb-secure:
    - shard-tglb:         NOTRUN -> [SKIP][34] ([i915#2856]) +1 similar issue
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb8/igt@gen9_exec_parse@bb-secure.html

  * igt@i915_pm_lpsp@screens-disabled:
    - shard-tglb:         NOTRUN -> [SKIP][35] ([i915#1902])
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@i915_pm_lpsp@screens-disabled.html

  * igt@i915_pm_rc6_residency@media-rc6-accuracy:
    - shard-tglb:         NOTRUN -> [SKIP][36] ([fdo#109289] / [fdo#111719])
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb6/igt@i915_pm_rc6_residency@media-rc6-accuracy.html

  * igt@i915_pm_rc6_residency@rc6-idle:
    - shard-tglb:         NOTRUN -> [WARN][37] ([i915#2681] / [i915#2684])
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb1/igt@i915_pm_rc6_residency@rc6-idle.html
    - shard-iclb:         NOTRUN -> [WARN][38] ([i915#2684])
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb2/igt@i915_pm_rc6_residency@rc6-idle.html

  * igt@i915_pm_rpm@pc8-residency:
    - shard-tglb:         NOTRUN -> [SKIP][39] ([fdo#109506] / [i915#2411])
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb6/igt@i915_pm_rpm@pc8-residency.html

  * igt@i915_selftest@live@gt_lrc:
    - shard-tglb:         NOTRUN -> [DMESG-FAIL][40] ([i915#2373])
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb5/igt@i915_selftest@live@gt_lrc.html

  * igt@i915_selftest@live@gt_pm:
    - shard-tglb:         NOTRUN -> [DMESG-FAIL][41] ([i915#1759] / [i915#2291])
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb5/igt@i915_selftest@live@gt_pm.html

  * igt@i915_selftest@live@hangcheck:
    - shard-snb:          NOTRUN -> [INCOMPLETE][42] ([i915#3921])
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-snb6/igt@i915_selftest@live@hangcheck.html

  * igt@kms_addfb_basic@invalid-smem-bo-on-discrete:
    - shard-tglb:         NOTRUN -> [SKIP][43] ([i915#3826])
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb6/igt@kms_addfb_basic@invalid-smem-bo-on-discrete.html
    - shard-iclb:         NOTRUN -> [SKIP][44] ([i915#3826])
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb6/igt@kms_addfb_basic@invalid-smem-bo-on-discrete.html

  * igt@kms_big_fb@linear-64bpp-rotate-270:
    - shard-tglb:         NOTRUN -> [SKIP][45] ([fdo#111614])
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb8/igt@kms_big_fb@linear-64bpp-rotate-270.html

  * igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip:
    - shard-apl:          NOTRUN -> [SKIP][46] ([fdo#109271] / [i915#3777]) +3 similar issues
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl2/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip.html

  * igt@kms_big_fb@yf-tiled-32bpp-rotate-270:
    - shard-iclb:         [PASS][47] -> [DMESG-FAIL][48] ([i915#1226])
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-iclb1/igt@kms_big_fb@yf-tiled-32bpp-rotate-270.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb4/igt@kms_big_fb@yf-tiled-32bpp-rotate-270.html

  * igt@kms_big_fb@yf-tiled-8bpp-rotate-270:
    - shard-iclb:         NOTRUN -> [SKIP][49] ([fdo#110723])
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb5/igt@kms_big_fb@yf-tiled-8bpp-rotate-270.html

  * igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-0-hflip:
    - shard-kbl:          NOTRUN -> [SKIP][50] ([fdo#109271] / [i915#3777])
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl3/igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-0-hflip.html

  * igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0:
    - shard-apl:          NOTRUN -> [SKIP][51] ([fdo#109271]) +295 similar issues
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl7/igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0.html

  * igt@kms_big_joiner@2x-modeset:
    - shard-iclb:         NOTRUN -> [SKIP][52] ([i915#2705])
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb2/igt@kms_big_joiner@2x-modeset.html
    - shard-tglb:         NOTRUN -> [SKIP][53] ([i915#2705])
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb1/igt@kms_big_joiner@2x-modeset.html

  * igt@kms_ccs@pipe-a-random-ccs-data-y_tiled_gen12_rc_ccs_cc:
    - shard-iclb:         NOTRUN -> [SKIP][54] ([fdo#109278] / [i915#3886]) +2 similar issues
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb3/igt@kms_ccs@pipe-a-random-ccs-data-y_tiled_gen12_rc_ccs_cc.html

  * igt@kms_ccs@pipe-b-ccs-on-another-bo-y_tiled_gen12_mc_ccs:
    - shard-tglb:         NOTRUN -> [SKIP][55] ([i915#3689] / [i915#3886]) +4 similar issues
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb5/igt@kms_ccs@pipe-b-ccs-on-another-bo-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-c-ccs-on-another-bo-y_tiled_gen12_mc_ccs:
    - shard-kbl:          NOTRUN -> [SKIP][56] ([fdo#109271] / [i915#3886]) +7 similar issues
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl7/igt@kms_ccs@pipe-c-ccs-on-another-bo-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-c-ccs-on-another-bo-y_tiled_gen12_rc_ccs_cc:
    - shard-apl:          NOTRUN -> [SKIP][57] ([fdo#109271] / [i915#3886]) +15 similar issues
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl2/igt@kms_ccs@pipe-c-ccs-on-another-bo-y_tiled_gen12_rc_ccs_cc.html

  * igt@kms_ccs@pipe-c-missing-ccs-buffer-y_tiled_gen12_rc_ccs_cc:
    - shard-glk:          NOTRUN -> [SKIP][58] ([fdo#109271] / [i915#3886]) +1 similar issue
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk5/igt@kms_ccs@pipe-c-missing-ccs-buffer-y_tiled_gen12_rc_ccs_cc.html

  * igt@kms_ccs@pipe-d-crc-sprite-planes-basic-y_tiled_ccs:
    - shard-tglb:         NOTRUN -> [SKIP][59] ([i915#3689]) +9 similar issues
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb2/igt@kms_ccs@pipe-d-crc-sprite-planes-basic-y_tiled_ccs.html

  * igt@kms_cdclk@plane-scaling:
    - shard-tglb:         NOTRUN -> [SKIP][60] ([i915#3742])
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb2/igt@kms_cdclk@plane-scaling.html

  * igt@kms_chamelium@hdmi-hpd-storm:
    - shard-kbl:          NOTRUN -> [SKIP][61] ([fdo#109271] / [fdo#111827]) +13 similar issues
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl7/igt@kms_chamelium@hdmi-hpd-storm.html

  * igt@kms_chamelium@vga-hpd:
    - shard-apl:          NOTRUN -> [SKIP][62] ([fdo#109271] / [fdo#111827]) +19 similar issues
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl1/igt@kms_chamelium@vga-hpd.html

  * igt@kms_chamelium@vga-hpd-without-ddc:
    - shard-snb:          NOTRUN -> [SKIP][63] ([fdo#109271] / [fdo#111827]) +15 similar issues
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-snb6/igt@kms_chamelium@vga-hpd-without-ddc.html

  * igt@kms_color@pipe-a-gamma:
    - shard-tglb:         [PASS][64] -> [FAIL][65] ([i915#1149])
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-tglb8/igt@kms_color@pipe-a-gamma.html
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb2/igt@kms_color@pipe-a-gamma.html

  * igt@kms_color_chamelium@pipe-a-ctm-0-75:
    - shard-iclb:         NOTRUN -> [SKIP][66] ([fdo#109284] / [fdo#111827]) +1 similar issue
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb5/igt@kms_color_chamelium@pipe-a-ctm-0-75.html

  * igt@kms_color_chamelium@pipe-c-ctm-0-5:
    - shard-glk:          NOTRUN -> [SKIP][67] ([fdo#109271] / [fdo#111827]) +6 similar issues
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk6/igt@kms_color_chamelium@pipe-c-ctm-0-5.html

  * igt@kms_color_chamelium@pipe-d-ctm-blue-to-red:
    - shard-iclb:         NOTRUN -> [SKIP][68] ([fdo#109278] / [fdo#109284] / [fdo#111827])
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb2/igt@kms_color_chamelium@pipe-d-ctm-blue-to-red.html

  * igt@kms_color_chamelium@pipe-d-ctm-red-to-blue:
    - shard-tglb:         NOTRUN -> [SKIP][69] ([fdo#109284] / [fdo#111827]) +10 similar issues
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb5/igt@kms_color_chamelium@pipe-d-ctm-red-to-blue.html

  * igt@kms_concurrent@pipe-a:
    - shard-tglb:         NOTRUN -> [FAIL][70] ([i915#1385])
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@kms_concurrent@pipe-a.html

  * igt@kms_content_protection@srm:
    - shard-kbl:          NOTRUN -> [TIMEOUT][71] ([i915#1319])
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl6/igt@kms_content_protection@srm.html

  * igt@kms_content_protection@uevent:
    - shard-kbl:          NOTRUN -> [FAIL][72] ([i915#2105])
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl7/igt@kms_content_protection@uevent.html

  * igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque:
    - shard-iclb:         [PASS][73] -> [FAIL][74] ([i915#3444])
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-iclb8/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb6/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
    - shard-apl:          [PASS][75] -> [FAIL][76] ([i915#3444])
   [75]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-apl8/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
   [76]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl6/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
    - shard-glk:          [PASS][77] -> [FAIL][78] ([i915#3444])
   [77]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-glk7/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
   [78]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk6/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
    - shard-tglb:         [PASS][79] -> [FAIL][80] ([i915#2124] / [i915#4024])
   [79]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-tglb6/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
   [80]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb2/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
    - shard-snb:          [PASS][81] -> [FAIL][82] ([i915#4024])
   [81]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-snb5/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html
   [82]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-snb6/igt@kms_cursor_crc@pipe-a-cursor-alpha-opaque.html

  * igt@kms_cursor_crc@pipe-b-cursor-32x10-random:
    - shard-tglb:         NOTRUN -> [SKIP][83] ([i915#3359]) +3 similar issues
   [83]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb6/igt@kms_cursor_crc@pipe-b-cursor-32x10-random.html

  * igt@kms_cursor_crc@pipe-b-cursor-512x512-rapid-movement:
    - shard-iclb:         NOTRUN -> [SKIP][84] ([fdo#109278] / [fdo#109279]) +1 similar issue
   [84]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb4/igt@kms_cursor_crc@pipe-b-cursor-512x512-rapid-movement.html

  * igt@kms_cursor_crc@pipe-b-cursor-suspend:
    - shard-apl:          [PASS][85] -> [DMESG-WARN][86] ([i915#180])
   [85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-apl8/igt@kms_cursor_crc@pipe-b-cursor-suspend.html
   [86]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl3/igt@kms_cursor_crc@pipe-b-cursor-suspend.html

  * igt@kms_cursor_crc@pipe-c-cursor-32x32-onscreen:
    - shard-tglb:         NOTRUN -> [SKIP][87] ([i915#3319]) +1 similar issue
   [87]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb7/igt@kms_cursor_crc@pipe-c-cursor-32x32-onscreen.html

  * igt@kms_cursor_crc@pipe-d-cursor-512x170-offscreen:
    - shard-tglb:         NOTRUN -> [SKIP][88] ([fdo#109279] / [i915#3359]) +4 similar issues
   [88]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb5/igt@kms_cursor_crc@pipe-d-cursor-512x170-offscreen.html

  * igt@kms_cursor_crc@pipe-d-cursor-suspend:
    - shard-tglb:         [PASS][89] -> [INCOMPLETE][90] ([i915#4211])
   [89]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-tglb2/igt@kms_cursor_crc@pipe-d-cursor-suspend.html
   [90]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb7/igt@kms_cursor_crc@pipe-d-cursor-suspend.html

  * igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
    - shard-tglb:         NOTRUN -> [SKIP][91] ([i915#4103])
   [91]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb8/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic.html

  * igt@kms_cursor_legacy@cursorb-vs-flipa-atomic:
    - shard-iclb:         NOTRUN -> [SKIP][92] ([fdo#109274] / [fdo#109278])
   [92]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb4/igt@kms_cursor_legacy@cursorb-vs-flipa-atomic.html

  * igt@kms_cursor_legacy@pipe-d-torture-bo:
    - shard-apl:          NOTRUN -> [SKIP][93] ([fdo#109271] / [i915#533]) +1 similar issue
   [93]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl1/igt@kms_cursor_legacy@pipe-d-torture-bo.html
    - shard-glk:          NOTRUN -> [SKIP][94] ([fdo#109271] / [i915#533]) +1 similar issue
   [94]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk4/igt@kms_cursor_legacy@pipe-d-torture-bo.html

  * igt@kms_flip@2x-plain-flip-interruptible:
    - shard-iclb:         NOTRUN -> [SKIP][95] ([fdo#109274]) +1 similar issue
   [95]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb3/igt@kms_flip@2x-plain-flip-interruptible.html

  * igt@kms_flip@flip-vs-expired-vblank@c-dp1:
    - shard-apl:          NOTRUN -> [FAIL][96] ([i915#79])
   [96]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl3/igt@kms_flip@flip-vs-expired-vblank@c-dp1.html

  * igt@kms_flip@flip-vs-suspend@c-dp1:
    - shard-kbl:          [PASS][97] -> [DMESG-WARN][98] ([i915#180]) +11 similar issues
   [97]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-kbl7/igt@kms_flip@flip-vs-suspend@c-dp1.html
   [98]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl1/igt@kms_flip@flip-vs-suspend@c-dp1.html
    - shard-apl:          NOTRUN -> [DMESG-WARN][99] ([i915#180]) +1 similar issue
   [99]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl8/igt@kms_flip@flip-vs-suspend@c-dp1.html

  * igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs:
    - shard-apl:          NOTRUN -> [SKIP][100] ([fdo#109271] / [i915#2672])
   [100]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl8/igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs.html

  * igt@kms_flip_scaled_crc@flip-64bpp-ytile-to-32bpp-ytilercccs:
    - shard-kbl:          NOTRUN -> [SKIP][101] ([fdo#109271] / [i915#2672])
   [101]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl3/igt@kms_flip_scaled_crc@flip-64bpp-ytile-to-32bpp-ytilercccs.html

  * igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-blt:
    - shard-iclb:         NOTRUN -> [SKIP][102] ([fdo#109280]) +14 similar issues
   [102]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb5/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-blt.html

  * igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-pri-indfb-draw-blt:
    - shard-tglb:         NOTRUN -> [SKIP][103] ([fdo#111825]) +41 similar issues
   [103]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb1/igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-pri-indfb-draw-blt.html

  * igt@kms_frontbuffer_tracking@psr-1p-primscrn-cur-indfb-onoff:
    - shard-snb:          NOTRUN -> [SKIP][104] ([fdo#109271]) +370 similar issues
   [104]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-snb5/igt@kms_frontbuffer_tracking@psr-1p-primscrn-cur-indfb-onoff.html

  * igt@kms_frontbuffer_tracking@psr-2p-scndscrn-spr-indfb-draw-render:
    - shard-glk:          NOTRUN -> [SKIP][105] ([fdo#109271]) +71 similar issues
   [105]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk2/igt@kms_frontbuffer_tracking@psr-2p-scndscrn-spr-indfb-draw-render.html

  * igt@kms_frontbuffer_tracking@psr-rgb101010-draw-mmap-wc:
    - shard-kbl:          NOTRUN -> [SKIP][106] ([fdo#109271]) +146 similar issues
   [106]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl7/igt@kms_frontbuffer_tracking@psr-rgb101010-draw-mmap-wc.html

  * igt@kms_hdr@static-toggle:
    - shard-tglb:         NOTRUN -> [SKIP][107] ([i915#1187])
   [107]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb5/igt@kms_hdr@static-toggle.html

  * igt@kms_plane@plane-panning-bottom-right-suspend@pipe-b-planes:
    - shard-tglb:         [PASS][108] -> [INCOMPLETE][109] ([i915#456])
   [108]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-tglb5/igt@kms_plane@plane-panning-bottom-right-suspend@pipe-b-planes.html
   [109]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb7/igt@kms_plane@plane-panning-bottom-right-suspend@pipe-b-planes.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-basic:
    - shard-apl:          NOTRUN -> [FAIL][110] ([fdo#108145] / [i915#265]) +3 similar issues
   [110]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl1/igt@kms_plane_alpha_blend@pipe-c-alpha-basic.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb:
    - shard-glk:          NOTRUN -> [FAIL][111] ([fdo#108145] / [i915#265])
   [111]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk1/igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-transparent-fb:
    - shard-apl:          NOTRUN -> [FAIL][112] ([i915#265])
   [112]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl1/igt@kms_plane_alpha_blend@pipe-c-alpha-transparent-fb.html

  * igt@kms_plane_alpha_blend@pipe-d-constant-alpha-max:
    - shard-iclb:         NOTRUN -> [SKIP][113] ([fdo#109278]) +13 similar issues
   [113]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb2/igt@kms_plane_alpha_blend@pipe-d-constant-alpha-max.html

  * igt@kms_plane_lowres@pipe-a-tiling-none:
    - shard-tglb:         NOTRUN -> [SKIP][114] ([i915#3536]) +2 similar issues
   [114]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb6/igt@kms_plane_lowres@pipe-a-tiling-none.html

  * igt@kms_plane_scaling@scaler-with-clipping-clamping@pipe-c-scaler-with-clipping-clamping:
    - shard-apl:          NOTRUN -> [SKIP][115] ([fdo#109271] / [i915#2733])
   [115]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl3/igt@kms_plane_scaling@scaler-with-clipping-clamping@pipe-c-scaler-with-clipping-clamping.html

  * igt@kms_psr2_sf@cursor-plane-update-sf:
    - shard-tglb:         NOTRUN -> [SKIP][116] ([i915#2920]) +2 similar issues
   [116]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb2/igt@kms_psr2_sf@cursor-plane-update-sf.html

  * igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-3:
    - shard-iclb:         NOTRUN -> [SKIP][117] ([i915#658])
   [117]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb7/igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-3.html
    - shard-kbl:          NOTRUN -> [SKIP][118] ([fdo#109271] / [i915#658]) +3 similar issues
   [118]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl3/igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-3.html

  * igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-4:
    - shard-apl:          NOTRUN -> [SKIP][119] ([fdo#109271] / [i915#658]) +7 similar issues
   [119]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl1/igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-4.html

  * igt@kms_psr2_su@frontbuffer:
    - shard-iclb:         [PASS][120] -> [SKIP][121] ([fdo#109642] / [fdo#111068] / [i915#658])
   [120]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-iclb2/igt@kms_psr2_su@frontbuffer.html
   [121]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb3/igt@kms_psr2_su@frontbuffer.html

  * igt@kms_psr2_su@page_flip:
    - shard-glk:          NOTRUN -> [SKIP][122] ([fdo#109271] / [i915#658]) +1 similar issue
   [122]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-glk8/igt@kms_psr2_su@page_flip.html

  * igt@kms_psr@psr2_cursor_mmap_gtt:
    - shard-tglb:         NOTRUN -> [FAIL][123] ([i915#132] / [i915#3467])
   [123]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@kms_psr@psr2_cursor_mmap_gtt.html

  * igt@kms_psr@psr2_sprite_blt:
    - shard-iclb:         [PASS][124] -> [SKIP][125] ([fdo#109441]) +1 similar issue
   [124]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-iclb2/igt@kms_psr@psr2_sprite_blt.html
   [125]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb8/igt@kms_psr@psr2_sprite_blt.html

  * igt@kms_rotation_crc@primary-yf-tiled-reflect-x-0:
    - shard-tglb:         NOTRUN -> [SKIP][126] ([fdo#111615]) +7 similar issues
   [126]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb3/igt@kms_rotation_crc@primary-yf-tiled-reflect-x-0.html

  * igt@kms_sysfs_edid_timing:
    - shard-apl:          [PASS][127] -> [FAIL][128] ([IGT#2])
   [127]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-apl3/igt@kms_sysfs_edid_timing.html
   [128]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-apl2/igt@kms_sysfs_edid_timing.html
    - shard-kbl:          [PASS][129] -> [FAIL][130] ([IGT#2])
   [129]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10685/shard-kbl7/igt@kms_sysfs_edid_timing.html
   [130]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-kbl2/igt@kms_sysfs_edid_timing.html

  * igt@nouveau_crc@pipe-a-source-outp-inactive:
    - shard-iclb:         NOTRUN -> [SKIP][131] ([i915#2530])
   [131]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb1/igt@nouveau_crc@pipe-a-source-outp-inactive.html

  * igt@nouveau_crc@pipe-c-ctx-flip-skip-current-frame:
    - shard-tglb:         NOTRUN -> [SKIP][132] ([i915#2530]) +3 similar issues
   [132]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb1/igt@nouveau_crc@pipe-c-ctx-flip-skip-current-frame.html

  * igt@prime_nv_test@i915_blt_fill_nv_read:
    - shard-tglb:         NOTRUN -> [SKIP][133] ([fdo#109291])
   [133]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-tglb8/igt@prime_nv_test@i915_blt_fill_nv_read.html
    - shard-iclb:         NOTRUN -> [SKIP][134] ([fdo#109291])
   [134]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/shard-iclb5/igt@prime

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6291/index.html

[-- Attachment #2: Type: text/html, Size: 33892 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 1/2] lib: Refactor construction of unique tokens
  2021-10-05 22:29 [igt-dev] [PATCH i-g-t 1/2] lib: Refactor construction of unique tokens Ashutosh Dixit
                   ` (2 preceding siblings ...)
  2021-10-06  3:46 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
@ 2021-10-06  8:01 ` Zbigniew Kempczyński
  3 siblings, 0 replies; 7+ messages in thread
From: Zbigniew Kempczyński @ 2021-10-06  8:01 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: igt-dev, Petri Latvala, Chris Wilson

On Tue, Oct 05, 2021 at 03:29:34PM -0700, Ashutosh Dixit wrote:
> From: Chris Wilson <chris.p.wilson@intel.com>
> 
> Wrap all the igt_tokencat(prefix, __LINE) into its own igt_unique() to
> reduce the clutter and make it easier to generate unique tokens for other
> common macros.
> 
> Signed-off-by: Chris Wilson <chris.p.wilson@intel.com>

Ok, looks safe.

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>

--
Zbigniew

> ---
>  lib/igt_core.h | 54 ++++++++++++++++++++++++++++++--------------------
>  1 file changed, 32 insertions(+), 22 deletions(-)
> 
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 8d433fc1655..6b8dbf348d8 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -147,12 +147,12 @@ __noreturn void __igt_fixture_end(void);
>   * enumeration (e.g. when enumerating on systems without an intel gpu) such
>   * blocks should be annotated with igt_fixture.
>   */
> -#define igt_fixture for (volatile int igt_tokencat(__tmpint,__LINE__) = 0; \
> -			 igt_tokencat(__tmpint,__LINE__) < 1 && \
> +#define igt_fixture for (volatile int igt_unique(__tmpint) = 0; \
> +			 igt_unique(__tmpint) < 1 && \
>  			 (STATIC_ANALYSIS_BUILD || \
>  			 (__igt_fixture() && \
>  			 (sigsetjmp(igt_subtest_jmpbuf, 1) == 0))); \
> -			 igt_tokencat(__tmpint,__LINE__) ++, \
> +			 igt_unique(__tmpint) ++, \
>  			 __igt_fixture_complete())
>  
>  /* subtest infrastructure */
> @@ -203,6 +203,16 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
>   */
>  #define igt_tokencat(x, y) __igt_tokencat2(x, y)
>  
> +/**
> + * igt_unique:
> + * @prefix: local identifier
> + *
> + * C preprocessor helper to generate a custom 'unique' token by appending
> + * the line number onto the token.
> + */
> +#define igt_unique(prefix) \
> +	igt_tokencat(igt_tokencat(__igt_unique__, prefix), __LINE__)
> +
>  /**
>   * igt_subtest:
>   * @name: name of the subtest
> @@ -238,7 +248,7 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
>   * static string.
>   */
>  #define igt_subtest_f(f...) \
> -	__igt_subtest_f(igt_tokencat(__tmpchar, __LINE__), f)
> +	__igt_subtest_f(igt_unique(__tmpchar), f)
>  
>  /**
>   * igt_subtest_with_dynamic:
> @@ -315,7 +325,7 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
>   * format string instead of a static string.
>   */
>  #define igt_subtest_with_dynamic_f(f...) \
> -	__igt_subtest_with_dynamic_f(igt_tokencat(__tmpchar, __LINE__), f)
> +	__igt_subtest_with_dynamic_f(igt_unique(__tmpchar), f)
>  
>  /**
>   * igt_dynamic:
> @@ -358,7 +368,7 @@ bool __igt_run_dynamic_subtest(const char *dynamic_subtest_name);
>   * instead of a static string.
>   */
>  #define igt_dynamic_f(f...) \
> -	__igt_dynamic_f(igt_tokencat(__tmpchar, __LINE__), f)
> +	__igt_dynamic_f(igt_unique(__tmpchar), f)
>  
>  const char *igt_subtest_name(void);
>  bool igt_only_list_subtests(void);
> @@ -380,15 +390,15 @@ void __igt_subtest_group_restore(int, int);
>   * clauses. If any common setup in a fixture fails, only the subtests in this
>   * group will fail or skip. Subtest groups can be arbitrarily nested.
>   */
> -#define igt_subtest_group for (int igt_tokencat(__tmpint,__LINE__) = 0, \
> -			       igt_tokencat(__save,__LINE__) = 0, \
> -			       igt_tokencat(__desc,__LINE__) = 0; \
> -			       igt_tokencat(__tmpint,__LINE__) < 1 && \
> -			       (__igt_subtest_group_save(& igt_tokencat(__save,__LINE__), \
> -							 & igt_tokencat(__desc,__LINE__) ), true); \
> -			       igt_tokencat(__tmpint,__LINE__) ++, \
> -			       __igt_subtest_group_restore(igt_tokencat(__save,__LINE__), \
> -							   igt_tokencat(__desc,__LINE__)))
> +#define igt_subtest_group for (int igt_unique(__tmpint) = 0, \
> +			       igt_unique(__save) = 0, \
> +			       igt_unique(__desc) = 0; \
> +			       igt_unique(__tmpint) < 1 && \
> +			       (__igt_subtest_group_save(& igt_unique(__save), \
> +							 & igt_unique(__desc) ), true); \
> +			       igt_unique(__tmpint) ++, \
> +			       __igt_subtest_group_restore(igt_unique(__save), \
> +							   igt_unique(__desc)))
>  
>  /**
>   * igt_main_args:
> @@ -404,15 +414,15 @@ void __igt_subtest_group_restore(int, int);
>   * #igt_subtest_init_parse_opts.
>   */
>  #define igt_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \
> -	static void igt_tokencat(__real_main, __LINE__)(void); \
> +	static void igt_unique(__real_main)(void); \
>  	int main(int argc, char **argv) { \
>  		igt_subtest_init_parse_opts(&argc, argv, \
>  					    short_opts, long_opts, help_str, \
>  					    opt_handler, handler_data); \
> -		igt_tokencat(__real_main, __LINE__)(); \
> +		igt_unique(__real_main)(); \
>  		igt_exit(); \
>  	} \
> -	static void igt_tokencat(__real_main, __LINE__)(void) \
> +	static void igt_unique(__real_main)(void) \
>  
>  
>  /**
> @@ -460,15 +470,15 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
>   * #igt_simple_init_parse_opts.
>   */
>  #define igt_simple_main_args(short_opts, long_opts, help_str, opt_handler, handler_data) \
> -	static void igt_tokencat(__real_main, __LINE__)(void); \
> +	static void igt_unique(__real_main)(void); \
>  	int main(int argc, char **argv) { \
>  		igt_simple_init_parse_opts(&argc, argv, \
>  					   short_opts, long_opts, help_str, \
>  					   opt_handler, handler_data);	\
> -		igt_tokencat(__real_main, __LINE__)(); \
> +		igt_unique(__real_main)(); \
>  		igt_exit(); \
>  	} \
> -	static void igt_tokencat(__real_main, __LINE__)(void) \
> +	static void igt_unique(__real_main)(void) \
>  
>  
>  /**
> @@ -490,7 +500,7 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
>   */
>  #define igt_constructor \
>  	__attribute__((constructor)) \
> -	static void igt_tokencat(__igt_constructor_l, __LINE__)(void)
> +	static void igt_unique(__igt_constructor_l)(void)
>  
>  __noreturn __attribute__((format(printf, 1, 2)))
>  void igt_skip(const char *f, ...);
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax
  2021-10-05 22:29 ` [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax Ashutosh Dixit
@ 2021-10-06 18:11   ` Zbigniew Kempczyński
  2021-10-06 20:26   ` Zbigniew Kempczyński
  1 sibling, 0 replies; 7+ messages in thread
From: Zbigniew Kempczyński @ 2021-10-06 18:11 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: igt-dev, Petri Latvala, Chris Wilson

On Tue, Oct 05, 2021 at 03:29:35PM -0700, Ashutosh Dixit wrote:
> From: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Add typechecking to the min/max macros and make their locals truly
> unique-ish to reduce the risk of shadowing.
> 
> v2: small bug fix, write also height coordinate on rotation
>     test. (jheikkil)
> v3: Fix up a couple of other max/max_t instances (Ashutosh)
> 
> Signed-off-by: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Signed-off-by: Chris Wilson <chris.p.wilson@intel.com>
> ---
>  lib/i915/intel_memory_region.c     |  9 ++----
>  lib/i915/intel_memory_region.h     |  2 +-
>  lib/igt_aux.h                      | 48 ++++++++++++++++++++----------
>  lib/igt_fb.c                       | 13 ++++----
>  lib/intel_allocator.c              |  2 +-
>  lib/intel_allocator_random.c       |  2 +-
>  lib/intel_allocator_reloc.c        |  2 +-
>  runner/resultgen.c                 |  7 +++--
>  tests/i915/api_intel_bb.c          |  2 +-
>  tests/i915/gem_eio.c               |  4 +--
>  tests/i915/gem_exec_alignment.c    |  4 +--
>  tests/i915/gem_exec_capture.c      |  2 +-
>  tests/i915/gem_exec_fair.c         |  2 +-
>  tests/i915/gem_stress.c            |  2 +-
>  tests/i915/gem_tiled_swapping.c    |  5 ++--
>  tests/i915/gem_userptr_blits.c     |  2 +-
>  tests/i915/i915_pm_rc6_residency.c |  2 +-
>  tests/i915/kms_big_fb.c            |  2 +-
>  tests/i915/perf_pmu.c              |  2 +-
>  tests/kms_atomic_transition.c      |  2 +-
>  tests/kms_chamelium.c              |  2 +-
>  tests/kms_content_protection.c     |  4 +--
>  tests/kms_invalid_mode.c           |  4 +--
>  tests/kms_multipipe_modeset.c      |  3 +-
>  tests/kms_rotation_crc.c           | 21 ++++++++-----
>  tests/kms_setmode.c                | 11 ++-----
>  tests/sw_sync.c                    |  5 ++--
>  tools/intel_vbt_decode.c           |  3 +-
>  28 files changed, 93 insertions(+), 76 deletions(-)
> 
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index bc2f66dbff5..058b273dcf8 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -146,19 +146,16 @@ out:
>   *
>   * Returns: Number of found lmem regions.
>   */
> -uint8_t gem_get_lmem_region_count(int fd)
> +unsigned int gem_get_lmem_region_count(int fd)
>  {
>  	struct drm_i915_query_memory_regions *query_info;
> -	uint8_t num_regions;
> -	uint8_t lmem_regions = 0;
> +	unsigned int lmem_regions = 0;
>  
>  	query_info = gem_get_query_memory_regions(fd);
>  	if (!query_info)
>  		goto out;
>  
> -	num_regions = query_info->num_regions;
> -
> -	for (int i = 0; i < num_regions; i++) {
> +	for (unsigned int i = 0; i < query_info->num_regions; i++) {
>  		if (query_info->regions[i].region.memory_class == I915_MEMORY_CLASS_DEVICE)
>  			lmem_regions += 1;
>  	}
> diff --git a/lib/i915/intel_memory_region.h b/lib/i915/intel_memory_region.h
> index 024c76d3644..8b427b7e729 100644
> --- a/lib/i915/intel_memory_region.h
> +++ b/lib/i915/intel_memory_region.h
> @@ -58,7 +58,7 @@ uint32_t gem_get_batch_size(int fd, uint8_t mem_region_type);
>  
>  struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd);
>  
> -uint8_t gem_get_lmem_region_count(int fd);
> +unsigned int gem_get_lmem_region_count(int fd);
>  
>  bool gem_has_lmem(int fd);

Above changes in memory regions should be part of another patch as it
not related to typechecking. 

>  
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index bf57ccf50df..30b175d70d8 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -40,6 +40,8 @@
>  
>  #include <i915/gem_submission.h>
>  
> +#include "igt_core.h"
> +
>  /* signal interrupt helpers */
>  #ifdef __linux__
>  # ifndef HAVE_GETTID
> @@ -212,26 +214,42 @@ void intel_require_files(uint64_t count);
>  #define CHECK_RAM 0x1
>  #define CHECK_SWAP 0x2
>  
> -#define min(a, b) ({			\
> -	typeof(a) _a = (a);		\
> -	typeof(b) _b = (b);		\
> -	_a < _b ? _a : _b;		\
> -})
> -#define max(a, b) ({			\
> -	typeof(a) _a = (a);		\
> -	typeof(b) _b = (b);		\
> -	_a > _b ? _a : _b;		\
> -})
> +#define __typecheck(x, y) \
> +        (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>  
> -#define clamp(x, min, max) ({		\
> -	typeof(min) _min = (min);	\
> -	typeof(max) _max = (max);	\
> -	typeof(x) _x = (x);		\
> -	_x < _min ? _min : _x > _max ? _max : _x;	\
> +#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
> +
> +#define __cmp_once(x, y, unique_x, unique_y, op) ({     \
> +	typeof(x) unique_x = (x);               \
> +	typeof(y) unique_y = (y);               \
> +	__cmp(unique_x, unique_y, op);		\
>  })
>  
> +#define __is_constexpr(x) \
> +	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
> +
> +#define __no_side_effects(x, y) \
> +	(__is_constexpr(x) && __is_constexpr(y))
> +
> +#define __safe_cmp(x, y) \
> +	(__typecheck(x, y) && __no_side_effects(x, y))
> +
> +#define __careful_cmp(x, y, op, prefix) \
> +	__builtin_choose_expr(__safe_cmp(x, y), \
> +			      __cmp(x, y, op), \
> +			      __cmp_once(x, y, igt_unique(igt_tokencat(prefix, __x)), igt_unique(igt_tokencat(prefix, __y)), op))
> +
> +#define min(x, y)	__careful_cmp(x, y, <, min)
> +#define max(x, y)	__careful_cmp(x, y, >, max)
> +
> +#define clamp(val, lo, hi) min(max(val, lo), hi)
> +
> +#define min_t(t, x, y)	__careful_cmp((typeof(t))x, (typeof(t))y, <, min_t)
> +#define max_t(t, x, y)	__careful_cmp((typeof(t))x, (typeof(t))y, >, max_t)
> +
>  #define igt_swap(a, b) do {	\
>  	typeof(a) _tmp = (a);	\
> +	_Static_assert(__typecheck(a, b), "type mismatch for swap"); \
>  	(a) = (b);		\
>  	(b) = _tmp;		\
>  } while (0)

Transplanted from kernel, ok. __is_constexpr() is really mindblowing.


> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index ea4d83ab736..fba835a0b8f 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -733,7 +733,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
>  		 * tiled. But then that failure is expected.
>  		 */
>  
> -		stride = max(min_stride, 512);
> +		stride = max(min_stride, 512u);
>  		stride = roundup_power_of_two(stride);
>  
>  		return stride;
> @@ -747,7 +747,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
>  		/*
>  		 * For amdgpu device with tiling mode
>  		 */
> -		unsigned int tile_width, tile_height;
> +		uint32_t tile_width, tile_height;
>  
>  		igt_amd_fb_calculate_tile_dimension(fb->plane_bpp[plane],
>  				     &tile_width, &tile_height);
> @@ -812,9 +812,9 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
>  	if (fb->modifier != DRM_FORMAT_MOD_NONE &&
>  	    is_i915_device(fb->fd) &&
>  	    intel_display_ver(intel_get_drm_devid(fb->fd)) <= 3) {
> -		uint64_t min_size = (uint64_t) fb->strides[plane] *
> +		uint64_t size = (uint64_t) fb->strides[plane] *
>  			fb->plane_height[plane];
> -		uint64_t size;
> +		uint64_t min_size = 1024 * 1024;
>  
>  		/* Round the tiling up to the next power-of-two and the region
>  		 * up to the next pot fence size so that this works on all
> @@ -824,10 +824,7 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
>  		 * tiled. But then that failure is expected.
>  		 */
>  
> -		size = max(min_size, 1024*1024);
> -		size = roundup_power_of_two(size);
> -
> -		return size;
> +		return roundup_power_of_two(max(size, min_size));
>  	} else if (fb->modifier != DRM_FORMAT_MOD_NONE && is_amdgpu_device(fb->fd)) {
>  		/*
>  		 * For amdgpu device with tiling mode
> diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
> index 133176ed42e..eabff1f9a13 100644
> --- a/lib/intel_allocator.c
> +++ b/lib/intel_allocator.c
> @@ -1088,7 +1088,7 @@ uint64_t __intel_allocator_alloc(uint64_t allocator_handle, uint32_t handle,
>  	struct alloc_resp resp;
>  
>  	igt_assert((alignment & (alignment-1)) == 0);
> -	req.alloc.alignment = max(alignment, 1 << 12);
> +	req.alloc.alignment = max_t(uint64_t, alignment, 1 << 12);
>  
>  	igt_assert(handle_request(&req, &resp) == 0);
>  	igt_assert(resp.response_type == RESP_ALLOC);
> diff --git a/lib/intel_allocator_random.c b/lib/intel_allocator_random.c
> index 9e31426179b..d22f8176705 100644
> --- a/lib/intel_allocator_random.c
> +++ b/lib/intel_allocator_random.c
> @@ -180,7 +180,7 @@ intel_allocator_random_create(int fd, uint64_t start, uint64_t end)
>  	igt_assert(ial->priv);
>  	ialr->prng = (uint32_t) to_user_pointer(ial);
>  
> -	start = max(start, BIAS);
> +	start = max_t(uint64_t, start, BIAS);
>  	igt_assert(start < end);
>  	ialr->start = start;
>  	ialr->end = end;
> diff --git a/lib/intel_allocator_reloc.c b/lib/intel_allocator_reloc.c
> index 1790e6c7975..ee3ad43f4a5 100644
> --- a/lib/intel_allocator_reloc.c
> +++ b/lib/intel_allocator_reloc.c
> @@ -176,7 +176,7 @@ intel_allocator_reloc_create(int fd, uint64_t start, uint64_t end)
>  	igt_assert(ial->priv);
>  	ialr->prng = (uint32_t) to_user_pointer(ial);
>  
> -	start = max(start, BIAS);
> +	start = max_t(uint64_t, start, BIAS);
>  	igt_assert(start < end);
>  	ialr->offset = ialr->start = start;
>  	ialr->end = end;
> diff --git a/runner/resultgen.c b/runner/resultgen.c
> index b74970a6e65..bccfca12a48 100644
> --- a/runner/resultgen.c
> +++ b/runner/resultgen.c
> @@ -481,12 +481,15 @@ static int find_subtest_idx_limited(struct matches matches,
>  	if (line_len < 0)
>  		return -1;
>  
> -	for (k = first; k < last; k++)
> +	for (k = first; k < last; k++) {
> +		ptrdiff_t rem = bufend - matches.items[k].where;
> +
>  		if (matches.items[k].what == linekey &&
>  		    !memcmp(matches.items[k].where,
>  			    full_line,
> -			    min(line_len, bufend - matches.items[k].where)))
> +			    min_t(ptrdiff_t, line_len, rem)))
>  			break;
> +	}
>  
>  	free(full_line);
>  
> diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
> index 293720b4b3c..82943a34191 100644
> --- a/tests/i915/api_intel_bb.c
> +++ b/tests/i915/api_intel_bb.c
> @@ -904,7 +904,7 @@ static int compare_bufs(struct intel_buf *buf1, struct intel_buf *buf2,
>  	return ret;
>  }
>  
> -#define LINELEN 76
> +#define LINELEN 76ul
>  static int dump_base64(const char *name, struct intel_buf *buf)
>  {
>  	void *ptr;
> diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
> index d9ff1981a71..3d094433b7b 100644
> --- a/tests/i915/gem_eio.c
> +++ b/tests/i915/gem_eio.c
> @@ -489,7 +489,7 @@ static void test_inflight(int fd, unsigned int wait)
>  
>  	max = gem_measure_ring_inflight(fd, -1, 0);
>  	igt_require(max > 1);
> -	max = min(max - 1, ARRAY_SIZE(fence));
> +	max = min_t(max, max - 1, ARRAY_SIZE(fence));
>  	igt_debug("Using %d inflight batches\n", max);
>  
>  	for_each_ring(e, parent_fd) {
> @@ -558,7 +558,7 @@ static void test_inflight_suspend(int fd)
>  
>  	max = gem_measure_ring_inflight(fd, -1, 0);
>  	igt_require(max > 1);
> -	max = min(max - 1, ARRAY_SIZE(fence));
> +	max = min_t(max, max - 1, ARRAY_SIZE(fence));
>  	igt_debug("Using %d inflight batches\n", max);
>  
>  	fd = reopen_device(fd);
> diff --git a/tests/i915/gem_exec_alignment.c b/tests/i915/gem_exec_alignment.c
> index c4611bd1ee2..68b95c869c9 100644
> --- a/tests/i915/gem_exec_alignment.c
> +++ b/tests/i915/gem_exec_alignment.c
> @@ -166,7 +166,7 @@ naughty_child(int i915, int link, uint32_t shared, unsigned int flags)
>  	if (!gem_uses_full_ppgtt(i915))
>  		gtt_size /= 2; /* We have to *share* our GTT! */
>  
> -	ram_size = min(intel_get_total_ram_mb(), 4096);
> +	ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
>  	ram_size *= 1024 * 1024;
>  
>  	count = min(gtt_size, ram_size) / 16384;
> @@ -376,7 +376,7 @@ setup_many(int i915, unsigned long *out)
>  	if (!gem_uses_full_ppgtt(i915))
>  		gtt_size /= 2; /* We have to *share* our GTT! */
>  
> -	ram_size = min(intel_get_total_ram_mb(), 4096);
> +	ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
>  	ram_size *= 1024 * 1024;
>  
>  	count = min(gtt_size, ram_size) / 16384;
> diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
> index 19f3836e385..7e0a8b8addb 100644
> --- a/tests/i915/gem_exec_capture.c
> +++ b/tests/i915/gem_exec_capture.c
> @@ -566,7 +566,7 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
>  		  gtt, ram);
>  
>  	count = min(gtt, ram) / 4;
> -	count = min(count, 256); /* Keep the duration within reason */
> +	count = min(count, 256ul); /* Keep the duration within reason */
>  	igt_require(count > 1);
>  
>  	intel_require_memory(count, size, CHECK_RAM);
> diff --git a/tests/i915/gem_exec_fair.c b/tests/i915/gem_exec_fair.c
> index ef5a450f6ca..89945d40e3c 100644
> --- a/tests/i915/gem_exec_fair.c
> +++ b/tests/i915/gem_exec_fair.c
> @@ -605,7 +605,7 @@ static void fair_child(int i915, const intel_ctx_t *ctx,
>  		map = gem_mmap__device_coherent(i915, obj[0].handle,
>  						0, 4096, PROT_WRITE);
>  		igt_assert(map[0]);
> -		for (n = 1; n < min(count, 512); n++) {
> +		for (n = 1; n < min(count, 512ul); n++) {
>  			igt_assert(map[n]);
>  			map[n - 1] = map[n] - map[n - 1];
>  		}
> diff --git a/tests/i915/gem_stress.c b/tests/i915/gem_stress.c
> index 3e4d4907605..3765ab14bdb 100644
> --- a/tests/i915/gem_stress.c
> +++ b/tests/i915/gem_stress.c
> @@ -769,7 +769,7 @@ static void init(void)
>  
>  	if (options.num_buffers == 0) {
>  		tmp = gem_aperture_size(drm_fd);
> -		tmp = min(256 * (1024 * 1024), tmp);
> +		tmp = min(256 * 1024 * 1024u, tmp);
>  		num_buffers = 2 * tmp / options.scratch_buf_size / 3;
>  		num_buffers /= 2;
>  		igt_info("using %u buffers\n", num_buffers);
> diff --git a/tests/i915/gem_tiled_swapping.c b/tests/i915/gem_tiled_swapping.c
> index d33b76dbd5b..d66b6ca7f9b 100644
> --- a/tests/i915/gem_tiled_swapping.c
> +++ b/tests/i915/gem_tiled_swapping.c
> @@ -67,7 +67,7 @@ IGT_TEST_DESCRIPTION("Exercise swizzle code for swapping.");
>  static uint32_t current_tiling_mode;
>  
>  #define PAGE_SIZE 4096
> -#define AVAIL_RAM 512
> +#define AVAIL_RAM 512ul
>  
>  static uint32_t
>  create_bo(int fd)
> @@ -183,7 +183,8 @@ igt_main
>  		/* lock RAM, leaving only 512MB available */
>  		count = intel_get_total_ram_mb() - intel_get_avail_ram_mb();
>  		count = max(count + 64, AVAIL_RAM);
> -		lock_size = max(0, intel_get_total_ram_mb() - count);
> +		count = intel_get_total_ram_mb() - count;
> +		lock_size = max_t(long, 0, count);
>  		igt_info("Mlocking %zdMiB of %ld/%ldMiB\n",
>  			 lock_size,
>  			 (long)intel_get_avail_ram_mb(),
> diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
> index 756bd6e4786..078c75c3947 100644
> --- a/tests/i915/gem_userptr_blits.c
> +++ b/tests/i915/gem_userptr_blits.c
> @@ -1693,7 +1693,7 @@ static void test_forking_evictions(int fd, int size, int count,
>  	 * processes meaning swapping will be triggered system
>  	 * wide even if one process on it's own can't do it.
>  	 */
> -	num_threads = min(sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
> +	num_threads = min_t(int, sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
>  	trash_count /= num_threads;
>  	if (count > trash_count)
>  		count = trash_count;
> diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
> index 96a951406f5..cf9eae90278 100644
> --- a/tests/i915/i915_pm_rc6_residency.c
> +++ b/tests/i915/i915_pm_rc6_residency.c
> @@ -345,7 +345,7 @@ static void bg_load(int i915, unsigned int flags, unsigned long *ctl)
>  		ctl[1]++;
>  
>  		/* aim for ~1% busy */
> -		usleep(min(elapsed / 10, 50 * 1000));
> +		usleep(min_t(elapsed, elapsed / 10, 50 * 1000));
>  	} while (!READ_ONCE(*ctl));
>  }
>  
> diff --git a/tests/i915/kms_big_fb.c b/tests/i915/kms_big_fb.c
> index 308227c9113..8665903827d 100644
> --- a/tests/i915/kms_big_fb.c
> +++ b/tests/i915/kms_big_fb.c
> @@ -400,9 +400,9 @@ static bool test_plane(data_t *data)
>  
>  static bool test_pipe(data_t *data)
>  {
> +	uint16_t width, height;
>  	drmModeModeInfo *mode;
>  	igt_plane_t *primary;
> -	int width, height;
>  	bool ret = false;
>  
>  	if (data->format == DRM_FORMAT_C8 &&
> diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
> index 1214cda8c32..e9df0290dd7 100644
> --- a/tests/i915/perf_pmu.c
> +++ b/tests/i915/perf_pmu.c
> @@ -1413,7 +1413,7 @@ static int target_num_interrupts(int i915)
>  {
>  	const intel_ctx_cfg_t cfg = intel_ctx_cfg_all_physical(i915);
>  
> -	return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30);
> +	return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30u);
>  }
>  
>  static void
> diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
> index bc0a1c81b46..9c0a91bf201 100644
> --- a/tests/kms_atomic_transition.c
> +++ b/tests/kms_atomic_transition.c
> @@ -789,7 +789,7 @@ static void run_modeset_tests(data_t *data, int howmany, bool nonblocking, bool
>  	unsigned iter_max;
>  	igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
>  	igt_output_t *output;
> -	unsigned width = 0, height = 0;
> +	uint16_t width = 0, height = 0;
>  
>  	for (i = 0; i < data->display.n_outputs; i++)
>  		igt_output_set_pipe(&data->display.outputs[i], PIPE_NONE);
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index 1ab411cecfb..11926bbcfa8 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -2399,7 +2399,7 @@ static void test_display_planes_random(data_t *data,
>  		igt_output_count_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
>  
>  	/* Limit the number of planes to a reasonable scene. */
> -	overlay_planes_max = min(overlay_planes_max, 4);
> +	overlay_planes_max = min(overlay_planes_max, 4u);
>  
>  	overlay_planes_count = (rand() % overlay_planes_max) + 1;
>  	igt_debug("Using %d overlay planes\n", overlay_planes_count);
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index e8002df2711..f2047173a34 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -703,9 +703,9 @@ static void test_content_protection_cleanup(void)
>  
>  static void create_fbs(void)
>  {
> -	igt_output_t *output;
> -	int width = 0, height = 0;
> +	uint16_t width = 0, height = 0;
>  	drmModeModeInfo *mode;
> +	igt_output_t *output;
>  
>  	for_each_connected_output(&data.display, output) {
>  		mode = igt_output_get_mode(output);
> diff --git a/tests/kms_invalid_mode.c b/tests/kms_invalid_mode.c
> index d4feba327fd..11960dfd799 100644
> --- a/tests/kms_invalid_mode.c
> +++ b/tests/kms_invalid_mode.c
> @@ -195,8 +195,8 @@ test_output(data_t *data)
>  		return 0;
>  
>  	igt_create_fb(data->drm_fd,
> -		      max(mode.hdisplay, 64),
> -		      max(mode.vdisplay, 64),
> +		      max_t(uint16_t, mode.hdisplay, 64),
> +		      max_t(uint16_t, mode.vdisplay, 64),
>  		      DRM_FORMAT_XRGB8888,
>  		      DRM_FORMAT_MOD_NONE,
>  		      &fb);
> diff --git a/tests/kms_multipipe_modeset.c b/tests/kms_multipipe_modeset.c
> index b1dbc73a39b..97499508f1b 100644
> --- a/tests/kms_multipipe_modeset.c
> +++ b/tests/kms_multipipe_modeset.c
> @@ -40,10 +40,11 @@ static void run_test(data_t *data, int valid_outputs)
>  	igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
>  	igt_crc_t ref_crcs[IGT_MAX_PIPES], new_crcs[IGT_MAX_PIPES];
>  	igt_display_t *display = &data->display;
> -	int width = 0, height = 0, i = 0;
> +	uint16_t width = 0, height = 0;
>  	igt_pipe_t *pipe;
>  	igt_plane_t *plane;
>  	drmModeModeInfo *mode;
> +	int i = 0;
>  
>  	for_each_connected_output(display, output) {
>  		mode = igt_output_get_mode(output);
> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> index 11401a6d00a..a7f4d22f91f 100644
> --- a/tests/kms_rotation_crc.c
> +++ b/tests/kms_rotation_crc.c
> @@ -214,6 +214,11 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
>  		igt_pipe_crc_start(data->pipe_crc);
>  }
>  
> +#define TEST_WIDTH(km) \
> +	 min_t((km)->hdisplay, (km)->hdisplay, TEST_MAX_WIDTH)
> +#define TEST_HEIGHT(km) \
> +	 min_t((km)->vdisplay, (km)->vdisplay, TEST_MAX_HEIGHT)
> +
>  static void prepare_fbs(data_t *data, igt_output_t *output,
>  			igt_plane_t *plane, enum rectangle_type rect, uint32_t format)
>  {
> @@ -234,8 +239,8 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
>  			w = mode->hdisplay;
>  			h = mode->vdisplay;
>  		} else {
> -			w = min(TEST_MAX_WIDTH, mode->hdisplay);
> -			h = min(TEST_MAX_HEIGHT, mode->vdisplay);
> +			w = TEST_WIDTH(mode);
> +			h = TEST_HEIGHT(mode);
>  		}
>  
>  		min_w = 256;
> @@ -614,7 +619,7 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
>  			  int c)
>  {
>  	if (data->planepos[c].origo & p_right) {
> -		p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay)
> +		p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode)
>  				+ mode->hdisplay);
>  		p[c].x1 &= ~3;
>  		/*
> @@ -625,17 +630,17 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
>  		 */
>  		p[c].x1 -= mode->hdisplay & 2;
>  	} else {
> -		p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay));
> +		p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode));
>  		p[c].x1 &= ~3;
>  	}
>  
>  	if (data->planepos[c].origo & p_bottom) {
> -		p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay)
> +		p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode)
>  				+ mode->vdisplay);
>  		p[c].y1 &= ~3;
>  		p[c].y1 -= mode->vdisplay & 2;
>  	} else {
> -		p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay));
> +		p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode));
>  		p[c].y1 &= ~3;
>  	}
>  }
> @@ -698,8 +703,8 @@ static void test_multi_plane_rotation(data_t *data, enum pipe pipe)
>  		igt_display_require_output(display);
>  		igt_display_commit2(display, COMMIT_ATOMIC);
>  
> -		used_w = min(TEST_MAX_WIDTH, mode->hdisplay);
> -		used_h = min(TEST_MAX_HEIGHT, mode->vdisplay);
> +		used_w = TEST_WIDTH(mode);
> +		used_h = TEST_HEIGHT(mode);
>  
>  		p[0].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
>  		p[1].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
> diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
> index 80665204c68..d62251742a4 100644
> --- a/tests/kms_setmode.c
> +++ b/tests/kms_setmode.c
> @@ -421,15 +421,8 @@ static int test_stealing(int fd, struct crtc_config *crtc, uint32_t *ids)
>  	return ret;
>  }
>  
> -static double frame_time(const drmModeModeInfo *kmode)
> -{
> -	return 1000.0 * kmode->htotal * kmode->vtotal / kmode->clock;
> -}
> -
> -static double line_time(const drmModeModeInfo *kmode)
> -{
> -	return 1000.0 * kmode->htotal / kmode->clock;
> -}
> +#define frame_time(km) (1000.0 * (km)->htotal * (km)->vtotal / (km)->clock)
> +#define line_time(km) (1000.0 * (km)->htotal / (km)->clock)

These changes in kms_setmode also don't match typechecking patch subject
and should be part of another patch IMO.

Other changes with typechecking looks ok. I would split this patch to
three - memory regions changes, change function to definitions in kms_setmode
and typechecking.

--
Zbigniew

>  
>  static void check_timings(int crtc_idx, const drmModeModeInfo *kmode)
>  {
> diff --git a/tests/sw_sync.c b/tests/sw_sync.c
> index d3d2bec15bb..cbd773fcb97 100644
> --- a/tests/sw_sync.c
> +++ b/tests/sw_sync.c
> @@ -837,8 +837,9 @@ igt_main
>  	igt_fixture {
>  		igt_require_sw_sync();
>  		multi_consumer_threads =
> -			min(multi_consumer_threads,
> -			    sysconf(_SC_NPROCESSORS_ONLN));
> +			min_t(multi_consumer_threads,
> +			      multi_consumer_threads,
> +			      sysconf(_SC_NPROCESSORS_ONLN));
>  	}
>  
>  	igt_subtest("alloc_timeline")
> diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
> index 625dc078752..b063af8469d 100644
> --- a/tools/intel_vbt_decode.c
> +++ b/tools/intel_vbt_decode.c
> @@ -534,10 +534,11 @@ static void dump_child_devices(struct context *context, const uint8_t *devices,
>  	 * initialized to zero.
>  	 */
>  	child = calloc(1, sizeof(*child));
> +	igt_assert(child);
>  
>  	for (i = 0; i < child_dev_num; i++) {
>  		memcpy(child, devices + i * child_dev_size,
> -		       min(sizeof(*child), child_dev_size));
> +		       min_t(child_dev_size, sizeof(*child), child_dev_size));
>  
>  		dump_child_device(context, child);
>  	}
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax
  2021-10-05 22:29 ` [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax Ashutosh Dixit
  2021-10-06 18:11   ` Zbigniew Kempczyński
@ 2021-10-06 20:26   ` Zbigniew Kempczyński
  1 sibling, 0 replies; 7+ messages in thread
From: Zbigniew Kempczyński @ 2021-10-06 20:26 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: igt-dev, Petri Latvala, Chris Wilson

On Tue, Oct 05, 2021 at 03:29:35PM -0700, Ashutosh Dixit wrote:
> From: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Add typechecking to the min/max macros and make their locals truly
> unique-ish to reduce the risk of shadowing.
> 
> v2: small bug fix, write also height coordinate on rotation
>     test. (jheikkil)
> v3: Fix up a couple of other max/max_t instances (Ashutosh)

Ok, I've discussed with Chris - we can take this patch as a whole
without splitting. So:

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>

--
Zbigniew

> 
> Signed-off-by: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Signed-off-by: Chris Wilson <chris.p.wilson@intel.com>
> ---
>  lib/i915/intel_memory_region.c     |  9 ++----
>  lib/i915/intel_memory_region.h     |  2 +-
>  lib/igt_aux.h                      | 48 ++++++++++++++++++++----------
>  lib/igt_fb.c                       | 13 ++++----
>  lib/intel_allocator.c              |  2 +-
>  lib/intel_allocator_random.c       |  2 +-
>  lib/intel_allocator_reloc.c        |  2 +-
>  runner/resultgen.c                 |  7 +++--
>  tests/i915/api_intel_bb.c          |  2 +-
>  tests/i915/gem_eio.c               |  4 +--
>  tests/i915/gem_exec_alignment.c    |  4 +--
>  tests/i915/gem_exec_capture.c      |  2 +-
>  tests/i915/gem_exec_fair.c         |  2 +-
>  tests/i915/gem_stress.c            |  2 +-
>  tests/i915/gem_tiled_swapping.c    |  5 ++--
>  tests/i915/gem_userptr_blits.c     |  2 +-
>  tests/i915/i915_pm_rc6_residency.c |  2 +-
>  tests/i915/kms_big_fb.c            |  2 +-
>  tests/i915/perf_pmu.c              |  2 +-
>  tests/kms_atomic_transition.c      |  2 +-
>  tests/kms_chamelium.c              |  2 +-
>  tests/kms_content_protection.c     |  4 +--
>  tests/kms_invalid_mode.c           |  4 +--
>  tests/kms_multipipe_modeset.c      |  3 +-
>  tests/kms_rotation_crc.c           | 21 ++++++++-----
>  tests/kms_setmode.c                | 11 ++-----
>  tests/sw_sync.c                    |  5 ++--
>  tools/intel_vbt_decode.c           |  3 +-
>  28 files changed, 93 insertions(+), 76 deletions(-)
> 
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index bc2f66dbff5..058b273dcf8 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -146,19 +146,16 @@ out:
>   *
>   * Returns: Number of found lmem regions.
>   */
> -uint8_t gem_get_lmem_region_count(int fd)
> +unsigned int gem_get_lmem_region_count(int fd)
>  {
>  	struct drm_i915_query_memory_regions *query_info;
> -	uint8_t num_regions;
> -	uint8_t lmem_regions = 0;
> +	unsigned int lmem_regions = 0;
>  
>  	query_info = gem_get_query_memory_regions(fd);
>  	if (!query_info)
>  		goto out;
>  
> -	num_regions = query_info->num_regions;
> -
> -	for (int i = 0; i < num_regions; i++) {
> +	for (unsigned int i = 0; i < query_info->num_regions; i++) {
>  		if (query_info->regions[i].region.memory_class == I915_MEMORY_CLASS_DEVICE)
>  			lmem_regions += 1;
>  	}
> diff --git a/lib/i915/intel_memory_region.h b/lib/i915/intel_memory_region.h
> index 024c76d3644..8b427b7e729 100644
> --- a/lib/i915/intel_memory_region.h
> +++ b/lib/i915/intel_memory_region.h
> @@ -58,7 +58,7 @@ uint32_t gem_get_batch_size(int fd, uint8_t mem_region_type);
>  
>  struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd);
>  
> -uint8_t gem_get_lmem_region_count(int fd);
> +unsigned int gem_get_lmem_region_count(int fd);
>  
>  bool gem_has_lmem(int fd);
>  
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index bf57ccf50df..30b175d70d8 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -40,6 +40,8 @@
>  
>  #include <i915/gem_submission.h>
>  
> +#include "igt_core.h"
> +
>  /* signal interrupt helpers */
>  #ifdef __linux__
>  # ifndef HAVE_GETTID
> @@ -212,26 +214,42 @@ void intel_require_files(uint64_t count);
>  #define CHECK_RAM 0x1
>  #define CHECK_SWAP 0x2
>  
> -#define min(a, b) ({			\
> -	typeof(a) _a = (a);		\
> -	typeof(b) _b = (b);		\
> -	_a < _b ? _a : _b;		\
> -})
> -#define max(a, b) ({			\
> -	typeof(a) _a = (a);		\
> -	typeof(b) _b = (b);		\
> -	_a > _b ? _a : _b;		\
> -})
> +#define __typecheck(x, y) \
> +        (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>  
> -#define clamp(x, min, max) ({		\
> -	typeof(min) _min = (min);	\
> -	typeof(max) _max = (max);	\
> -	typeof(x) _x = (x);		\
> -	_x < _min ? _min : _x > _max ? _max : _x;	\
> +#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
> +
> +#define __cmp_once(x, y, unique_x, unique_y, op) ({     \
> +	typeof(x) unique_x = (x);               \
> +	typeof(y) unique_y = (y);               \
> +	__cmp(unique_x, unique_y, op);		\
>  })
>  
> +#define __is_constexpr(x) \
> +	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
> +
> +#define __no_side_effects(x, y) \
> +	(__is_constexpr(x) && __is_constexpr(y))
> +
> +#define __safe_cmp(x, y) \
> +	(__typecheck(x, y) && __no_side_effects(x, y))
> +
> +#define __careful_cmp(x, y, op, prefix) \
> +	__builtin_choose_expr(__safe_cmp(x, y), \
> +			      __cmp(x, y, op), \
> +			      __cmp_once(x, y, igt_unique(igt_tokencat(prefix, __x)), igt_unique(igt_tokencat(prefix, __y)), op))
> +
> +#define min(x, y)	__careful_cmp(x, y, <, min)
> +#define max(x, y)	__careful_cmp(x, y, >, max)
> +
> +#define clamp(val, lo, hi) min(max(val, lo), hi)
> +
> +#define min_t(t, x, y)	__careful_cmp((typeof(t))x, (typeof(t))y, <, min_t)
> +#define max_t(t, x, y)	__careful_cmp((typeof(t))x, (typeof(t))y, >, max_t)
> +
>  #define igt_swap(a, b) do {	\
>  	typeof(a) _tmp = (a);	\
> +	_Static_assert(__typecheck(a, b), "type mismatch for swap"); \
>  	(a) = (b);		\
>  	(b) = _tmp;		\
>  } while (0)
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index ea4d83ab736..fba835a0b8f 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -733,7 +733,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
>  		 * tiled. But then that failure is expected.
>  		 */
>  
> -		stride = max(min_stride, 512);
> +		stride = max(min_stride, 512u);
>  		stride = roundup_power_of_two(stride);
>  
>  		return stride;
> @@ -747,7 +747,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
>  		/*
>  		 * For amdgpu device with tiling mode
>  		 */
> -		unsigned int tile_width, tile_height;
> +		uint32_t tile_width, tile_height;
>  
>  		igt_amd_fb_calculate_tile_dimension(fb->plane_bpp[plane],
>  				     &tile_width, &tile_height);
> @@ -812,9 +812,9 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
>  	if (fb->modifier != DRM_FORMAT_MOD_NONE &&
>  	    is_i915_device(fb->fd) &&
>  	    intel_display_ver(intel_get_drm_devid(fb->fd)) <= 3) {
> -		uint64_t min_size = (uint64_t) fb->strides[plane] *
> +		uint64_t size = (uint64_t) fb->strides[plane] *
>  			fb->plane_height[plane];
> -		uint64_t size;
> +		uint64_t min_size = 1024 * 1024;
>  
>  		/* Round the tiling up to the next power-of-two and the region
>  		 * up to the next pot fence size so that this works on all
> @@ -824,10 +824,7 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
>  		 * tiled. But then that failure is expected.
>  		 */
>  
> -		size = max(min_size, 1024*1024);
> -		size = roundup_power_of_two(size);
> -
> -		return size;
> +		return roundup_power_of_two(max(size, min_size));
>  	} else if (fb->modifier != DRM_FORMAT_MOD_NONE && is_amdgpu_device(fb->fd)) {
>  		/*
>  		 * For amdgpu device with tiling mode
> diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
> index 133176ed42e..eabff1f9a13 100644
> --- a/lib/intel_allocator.c
> +++ b/lib/intel_allocator.c
> @@ -1088,7 +1088,7 @@ uint64_t __intel_allocator_alloc(uint64_t allocator_handle, uint32_t handle,
>  	struct alloc_resp resp;
>  
>  	igt_assert((alignment & (alignment-1)) == 0);
> -	req.alloc.alignment = max(alignment, 1 << 12);
> +	req.alloc.alignment = max_t(uint64_t, alignment, 1 << 12);
>  
>  	igt_assert(handle_request(&req, &resp) == 0);
>  	igt_assert(resp.response_type == RESP_ALLOC);
> diff --git a/lib/intel_allocator_random.c b/lib/intel_allocator_random.c
> index 9e31426179b..d22f8176705 100644
> --- a/lib/intel_allocator_random.c
> +++ b/lib/intel_allocator_random.c
> @@ -180,7 +180,7 @@ intel_allocator_random_create(int fd, uint64_t start, uint64_t end)
>  	igt_assert(ial->priv);
>  	ialr->prng = (uint32_t) to_user_pointer(ial);
>  
> -	start = max(start, BIAS);
> +	start = max_t(uint64_t, start, BIAS);
>  	igt_assert(start < end);
>  	ialr->start = start;
>  	ialr->end = end;
> diff --git a/lib/intel_allocator_reloc.c b/lib/intel_allocator_reloc.c
> index 1790e6c7975..ee3ad43f4a5 100644
> --- a/lib/intel_allocator_reloc.c
> +++ b/lib/intel_allocator_reloc.c
> @@ -176,7 +176,7 @@ intel_allocator_reloc_create(int fd, uint64_t start, uint64_t end)
>  	igt_assert(ial->priv);
>  	ialr->prng = (uint32_t) to_user_pointer(ial);
>  
> -	start = max(start, BIAS);
> +	start = max_t(uint64_t, start, BIAS);
>  	igt_assert(start < end);
>  	ialr->offset = ialr->start = start;
>  	ialr->end = end;
> diff --git a/runner/resultgen.c b/runner/resultgen.c
> index b74970a6e65..bccfca12a48 100644
> --- a/runner/resultgen.c
> +++ b/runner/resultgen.c
> @@ -481,12 +481,15 @@ static int find_subtest_idx_limited(struct matches matches,
>  	if (line_len < 0)
>  		return -1;
>  
> -	for (k = first; k < last; k++)
> +	for (k = first; k < last; k++) {
> +		ptrdiff_t rem = bufend - matches.items[k].where;
> +
>  		if (matches.items[k].what == linekey &&
>  		    !memcmp(matches.items[k].where,
>  			    full_line,
> -			    min(line_len, bufend - matches.items[k].where)))
> +			    min_t(ptrdiff_t, line_len, rem)))
>  			break;
> +	}
>  
>  	free(full_line);
>  
> diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
> index 293720b4b3c..82943a34191 100644
> --- a/tests/i915/api_intel_bb.c
> +++ b/tests/i915/api_intel_bb.c
> @@ -904,7 +904,7 @@ static int compare_bufs(struct intel_buf *buf1, struct intel_buf *buf2,
>  	return ret;
>  }
>  
> -#define LINELEN 76
> +#define LINELEN 76ul
>  static int dump_base64(const char *name, struct intel_buf *buf)
>  {
>  	void *ptr;
> diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
> index d9ff1981a71..3d094433b7b 100644
> --- a/tests/i915/gem_eio.c
> +++ b/tests/i915/gem_eio.c
> @@ -489,7 +489,7 @@ static void test_inflight(int fd, unsigned int wait)
>  
>  	max = gem_measure_ring_inflight(fd, -1, 0);
>  	igt_require(max > 1);
> -	max = min(max - 1, ARRAY_SIZE(fence));
> +	max = min_t(max, max - 1, ARRAY_SIZE(fence));
>  	igt_debug("Using %d inflight batches\n", max);
>  
>  	for_each_ring(e, parent_fd) {
> @@ -558,7 +558,7 @@ static void test_inflight_suspend(int fd)
>  
>  	max = gem_measure_ring_inflight(fd, -1, 0);
>  	igt_require(max > 1);
> -	max = min(max - 1, ARRAY_SIZE(fence));
> +	max = min_t(max, max - 1, ARRAY_SIZE(fence));
>  	igt_debug("Using %d inflight batches\n", max);
>  
>  	fd = reopen_device(fd);
> diff --git a/tests/i915/gem_exec_alignment.c b/tests/i915/gem_exec_alignment.c
> index c4611bd1ee2..68b95c869c9 100644
> --- a/tests/i915/gem_exec_alignment.c
> +++ b/tests/i915/gem_exec_alignment.c
> @@ -166,7 +166,7 @@ naughty_child(int i915, int link, uint32_t shared, unsigned int flags)
>  	if (!gem_uses_full_ppgtt(i915))
>  		gtt_size /= 2; /* We have to *share* our GTT! */
>  
> -	ram_size = min(intel_get_total_ram_mb(), 4096);
> +	ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
>  	ram_size *= 1024 * 1024;
>  
>  	count = min(gtt_size, ram_size) / 16384;
> @@ -376,7 +376,7 @@ setup_many(int i915, unsigned long *out)
>  	if (!gem_uses_full_ppgtt(i915))
>  		gtt_size /= 2; /* We have to *share* our GTT! */
>  
> -	ram_size = min(intel_get_total_ram_mb(), 4096);
> +	ram_size = min_t(uint64_t, intel_get_total_ram_mb(), 4096);
>  	ram_size *= 1024 * 1024;
>  
>  	count = min(gtt_size, ram_size) / 16384;
> diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
> index 19f3836e385..7e0a8b8addb 100644
> --- a/tests/i915/gem_exec_capture.c
> +++ b/tests/i915/gem_exec_capture.c
> @@ -566,7 +566,7 @@ static void prioinv(int fd, int dir, const intel_ctx_t *ctx,
>  		  gtt, ram);
>  
>  	count = min(gtt, ram) / 4;
> -	count = min(count, 256); /* Keep the duration within reason */
> +	count = min(count, 256ul); /* Keep the duration within reason */
>  	igt_require(count > 1);
>  
>  	intel_require_memory(count, size, CHECK_RAM);
> diff --git a/tests/i915/gem_exec_fair.c b/tests/i915/gem_exec_fair.c
> index ef5a450f6ca..89945d40e3c 100644
> --- a/tests/i915/gem_exec_fair.c
> +++ b/tests/i915/gem_exec_fair.c
> @@ -605,7 +605,7 @@ static void fair_child(int i915, const intel_ctx_t *ctx,
>  		map = gem_mmap__device_coherent(i915, obj[0].handle,
>  						0, 4096, PROT_WRITE);
>  		igt_assert(map[0]);
> -		for (n = 1; n < min(count, 512); n++) {
> +		for (n = 1; n < min(count, 512ul); n++) {
>  			igt_assert(map[n]);
>  			map[n - 1] = map[n] - map[n - 1];
>  		}
> diff --git a/tests/i915/gem_stress.c b/tests/i915/gem_stress.c
> index 3e4d4907605..3765ab14bdb 100644
> --- a/tests/i915/gem_stress.c
> +++ b/tests/i915/gem_stress.c
> @@ -769,7 +769,7 @@ static void init(void)
>  
>  	if (options.num_buffers == 0) {
>  		tmp = gem_aperture_size(drm_fd);
> -		tmp = min(256 * (1024 * 1024), tmp);
> +		tmp = min(256 * 1024 * 1024u, tmp);
>  		num_buffers = 2 * tmp / options.scratch_buf_size / 3;
>  		num_buffers /= 2;
>  		igt_info("using %u buffers\n", num_buffers);
> diff --git a/tests/i915/gem_tiled_swapping.c b/tests/i915/gem_tiled_swapping.c
> index d33b76dbd5b..d66b6ca7f9b 100644
> --- a/tests/i915/gem_tiled_swapping.c
> +++ b/tests/i915/gem_tiled_swapping.c
> @@ -67,7 +67,7 @@ IGT_TEST_DESCRIPTION("Exercise swizzle code for swapping.");
>  static uint32_t current_tiling_mode;
>  
>  #define PAGE_SIZE 4096
> -#define AVAIL_RAM 512
> +#define AVAIL_RAM 512ul
>  
>  static uint32_t
>  create_bo(int fd)
> @@ -183,7 +183,8 @@ igt_main
>  		/* lock RAM, leaving only 512MB available */
>  		count = intel_get_total_ram_mb() - intel_get_avail_ram_mb();
>  		count = max(count + 64, AVAIL_RAM);
> -		lock_size = max(0, intel_get_total_ram_mb() - count);
> +		count = intel_get_total_ram_mb() - count;
> +		lock_size = max_t(long, 0, count);
>  		igt_info("Mlocking %zdMiB of %ld/%ldMiB\n",
>  			 lock_size,
>  			 (long)intel_get_avail_ram_mb(),
> diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
> index 756bd6e4786..078c75c3947 100644
> --- a/tests/i915/gem_userptr_blits.c
> +++ b/tests/i915/gem_userptr_blits.c
> @@ -1693,7 +1693,7 @@ static void test_forking_evictions(int fd, int size, int count,
>  	 * processes meaning swapping will be triggered system
>  	 * wide even if one process on it's own can't do it.
>  	 */
> -	num_threads = min(sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
> +	num_threads = min_t(int, sysconf(_SC_NPROCESSORS_ONLN) * 4, 12);
>  	trash_count /= num_threads;
>  	if (count > trash_count)
>  		count = trash_count;
> diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
> index 96a951406f5..cf9eae90278 100644
> --- a/tests/i915/i915_pm_rc6_residency.c
> +++ b/tests/i915/i915_pm_rc6_residency.c
> @@ -345,7 +345,7 @@ static void bg_load(int i915, unsigned int flags, unsigned long *ctl)
>  		ctl[1]++;
>  
>  		/* aim for ~1% busy */
> -		usleep(min(elapsed / 10, 50 * 1000));
> +		usleep(min_t(elapsed, elapsed / 10, 50 * 1000));
>  	} while (!READ_ONCE(*ctl));
>  }
>  
> diff --git a/tests/i915/kms_big_fb.c b/tests/i915/kms_big_fb.c
> index 308227c9113..8665903827d 100644
> --- a/tests/i915/kms_big_fb.c
> +++ b/tests/i915/kms_big_fb.c
> @@ -400,9 +400,9 @@ static bool test_plane(data_t *data)
>  
>  static bool test_pipe(data_t *data)
>  {
> +	uint16_t width, height;
>  	drmModeModeInfo *mode;
>  	igt_plane_t *primary;
> -	int width, height;
>  	bool ret = false;
>  
>  	if (data->format == DRM_FORMAT_C8 &&
> diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
> index 1214cda8c32..e9df0290dd7 100644
> --- a/tests/i915/perf_pmu.c
> +++ b/tests/i915/perf_pmu.c
> @@ -1413,7 +1413,7 @@ static int target_num_interrupts(int i915)
>  {
>  	const intel_ctx_cfg_t cfg = intel_ctx_cfg_all_physical(i915);
>  
> -	return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30);
> +	return min(gem_submission_measure(i915, &cfg, I915_EXEC_DEFAULT), 30u);
>  }
>  
>  static void
> diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
> index bc0a1c81b46..9c0a91bf201 100644
> --- a/tests/kms_atomic_transition.c
> +++ b/tests/kms_atomic_transition.c
> @@ -789,7 +789,7 @@ static void run_modeset_tests(data_t *data, int howmany, bool nonblocking, bool
>  	unsigned iter_max;
>  	igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
>  	igt_output_t *output;
> -	unsigned width = 0, height = 0;
> +	uint16_t width = 0, height = 0;
>  
>  	for (i = 0; i < data->display.n_outputs; i++)
>  		igt_output_set_pipe(&data->display.outputs[i], PIPE_NONE);
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index 1ab411cecfb..11926bbcfa8 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -2399,7 +2399,7 @@ static void test_display_planes_random(data_t *data,
>  		igt_output_count_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
>  
>  	/* Limit the number of planes to a reasonable scene. */
> -	overlay_planes_max = min(overlay_planes_max, 4);
> +	overlay_planes_max = min(overlay_planes_max, 4u);
>  
>  	overlay_planes_count = (rand() % overlay_planes_max) + 1;
>  	igt_debug("Using %d overlay planes\n", overlay_planes_count);
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index e8002df2711..f2047173a34 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -703,9 +703,9 @@ static void test_content_protection_cleanup(void)
>  
>  static void create_fbs(void)
>  {
> -	igt_output_t *output;
> -	int width = 0, height = 0;
> +	uint16_t width = 0, height = 0;
>  	drmModeModeInfo *mode;
> +	igt_output_t *output;
>  
>  	for_each_connected_output(&data.display, output) {
>  		mode = igt_output_get_mode(output);
> diff --git a/tests/kms_invalid_mode.c b/tests/kms_invalid_mode.c
> index d4feba327fd..11960dfd799 100644
> --- a/tests/kms_invalid_mode.c
> +++ b/tests/kms_invalid_mode.c
> @@ -195,8 +195,8 @@ test_output(data_t *data)
>  		return 0;
>  
>  	igt_create_fb(data->drm_fd,
> -		      max(mode.hdisplay, 64),
> -		      max(mode.vdisplay, 64),
> +		      max_t(uint16_t, mode.hdisplay, 64),
> +		      max_t(uint16_t, mode.vdisplay, 64),
>  		      DRM_FORMAT_XRGB8888,
>  		      DRM_FORMAT_MOD_NONE,
>  		      &fb);
> diff --git a/tests/kms_multipipe_modeset.c b/tests/kms_multipipe_modeset.c
> index b1dbc73a39b..97499508f1b 100644
> --- a/tests/kms_multipipe_modeset.c
> +++ b/tests/kms_multipipe_modeset.c
> @@ -40,10 +40,11 @@ static void run_test(data_t *data, int valid_outputs)
>  	igt_pipe_crc_t *pipe_crcs[IGT_MAX_PIPES] = { 0 };
>  	igt_crc_t ref_crcs[IGT_MAX_PIPES], new_crcs[IGT_MAX_PIPES];
>  	igt_display_t *display = &data->display;
> -	int width = 0, height = 0, i = 0;
> +	uint16_t width = 0, height = 0;
>  	igt_pipe_t *pipe;
>  	igt_plane_t *plane;
>  	drmModeModeInfo *mode;
> +	int i = 0;
>  
>  	for_each_connected_output(display, output) {
>  		mode = igt_output_get_mode(output);
> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> index 11401a6d00a..a7f4d22f91f 100644
> --- a/tests/kms_rotation_crc.c
> +++ b/tests/kms_rotation_crc.c
> @@ -214,6 +214,11 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
>  		igt_pipe_crc_start(data->pipe_crc);
>  }
>  
> +#define TEST_WIDTH(km) \
> +	 min_t((km)->hdisplay, (km)->hdisplay, TEST_MAX_WIDTH)
> +#define TEST_HEIGHT(km) \
> +	 min_t((km)->vdisplay, (km)->vdisplay, TEST_MAX_HEIGHT)
> +
>  static void prepare_fbs(data_t *data, igt_output_t *output,
>  			igt_plane_t *plane, enum rectangle_type rect, uint32_t format)
>  {
> @@ -234,8 +239,8 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
>  			w = mode->hdisplay;
>  			h = mode->vdisplay;
>  		} else {
> -			w = min(TEST_MAX_WIDTH, mode->hdisplay);
> -			h = min(TEST_MAX_HEIGHT, mode->vdisplay);
> +			w = TEST_WIDTH(mode);
> +			h = TEST_HEIGHT(mode);
>  		}
>  
>  		min_w = 256;
> @@ -614,7 +619,7 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
>  			  int c)
>  {
>  	if (data->planepos[c].origo & p_right) {
> -		p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay)
> +		p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode)
>  				+ mode->hdisplay);
>  		p[c].x1 &= ~3;
>  		/*
> @@ -625,17 +630,17 @@ static void pointlocation(data_t *data, planeinfos *p, drmModeModeInfo *mode,
>  		 */
>  		p[c].x1 -= mode->hdisplay & 2;
>  	} else {
> -		p[c].x1 = (int32_t)(data->planepos[c].x * min(TEST_MAX_WIDTH, mode->hdisplay));
> +		p[c].x1 = (int32_t)(data->planepos[c].x * TEST_WIDTH(mode));
>  		p[c].x1 &= ~3;
>  	}
>  
>  	if (data->planepos[c].origo & p_bottom) {
> -		p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay)
> +		p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode)
>  				+ mode->vdisplay);
>  		p[c].y1 &= ~3;
>  		p[c].y1 -= mode->vdisplay & 2;
>  	} else {
> -		p[c].y1 = (int32_t)(data->planepos[c].y * min(TEST_MAX_HEIGHT, mode->vdisplay));
> +		p[c].y1 = (int32_t)(data->planepos[c].y * TEST_HEIGHT(mode));
>  		p[c].y1 &= ~3;
>  	}
>  }
> @@ -698,8 +703,8 @@ static void test_multi_plane_rotation(data_t *data, enum pipe pipe)
>  		igt_display_require_output(display);
>  		igt_display_commit2(display, COMMIT_ATOMIC);
>  
> -		used_w = min(TEST_MAX_WIDTH, mode->hdisplay);
> -		used_h = min(TEST_MAX_HEIGHT, mode->vdisplay);
> +		used_w = TEST_WIDTH(mode);
> +		used_h = TEST_HEIGHT(mode);
>  
>  		p[0].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
>  		p[1].plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
> diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
> index 80665204c68..d62251742a4 100644
> --- a/tests/kms_setmode.c
> +++ b/tests/kms_setmode.c
> @@ -421,15 +421,8 @@ static int test_stealing(int fd, struct crtc_config *crtc, uint32_t *ids)
>  	return ret;
>  }
>  
> -static double frame_time(const drmModeModeInfo *kmode)
> -{
> -	return 1000.0 * kmode->htotal * kmode->vtotal / kmode->clock;
> -}
> -
> -static double line_time(const drmModeModeInfo *kmode)
> -{
> -	return 1000.0 * kmode->htotal / kmode->clock;
> -}
> +#define frame_time(km) (1000.0 * (km)->htotal * (km)->vtotal / (km)->clock)
> +#define line_time(km) (1000.0 * (km)->htotal / (km)->clock)
>  
>  static void check_timings(int crtc_idx, const drmModeModeInfo *kmode)
>  {
> diff --git a/tests/sw_sync.c b/tests/sw_sync.c
> index d3d2bec15bb..cbd773fcb97 100644
> --- a/tests/sw_sync.c
> +++ b/tests/sw_sync.c
> @@ -837,8 +837,9 @@ igt_main
>  	igt_fixture {
>  		igt_require_sw_sync();
>  		multi_consumer_threads =
> -			min(multi_consumer_threads,
> -			    sysconf(_SC_NPROCESSORS_ONLN));
> +			min_t(multi_consumer_threads,
> +			      multi_consumer_threads,
> +			      sysconf(_SC_NPROCESSORS_ONLN));
>  	}
>  
>  	igt_subtest("alloc_timeline")
> diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
> index 625dc078752..b063af8469d 100644
> --- a/tools/intel_vbt_decode.c
> +++ b/tools/intel_vbt_decode.c
> @@ -534,10 +534,11 @@ static void dump_child_devices(struct context *context, const uint8_t *devices,
>  	 * initialized to zero.
>  	 */
>  	child = calloc(1, sizeof(*child));
> +	igt_assert(child);
>  
>  	for (i = 0; i < child_dev_num; i++) {
>  		memcpy(child, devices + i * child_dev_size,
> -		       min(sizeof(*child), child_dev_size));
> +		       min_t(child_dev_size, sizeof(*child), child_dev_size));
>  
>  		dump_child_device(context, child);
>  	}
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-06 20:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 22:29 [igt-dev] [PATCH i-g-t 1/2] lib: Refactor construction of unique tokens Ashutosh Dixit
2021-10-05 22:29 ` [igt-dev] [PATCH i-g-t 2/2] lib: Typechecking minmax Ashutosh Dixit
2021-10-06 18:11   ` Zbigniew Kempczyński
2021-10-06 20:26   ` Zbigniew Kempczyński
2021-10-05 23:16 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib: Refactor construction of unique tokens Patchwork
2021-10-06  3:46 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-10-06  8:01 ` [igt-dev] [PATCH i-g-t 1/2] " Zbigniew Kempczyński

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.