summaryrefslogtreecommitdiff
path: root/tests/i915
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2021-10-05 15:29:35 -0700
committerAshutosh Dixit <ashutosh.dixit@intel.com>2021-10-08 19:16:05 -0700
commit426723f979380f18f9c07d36ebac3a52f760ba7e (patch)
treeeefda917ee9bb1bf8b7aefd8c607f4a0d8f4eabb /tests/i915
parentd5d99d16817eca9ce8d191b6e84c1a1fe2ad4428 (diff)
lib: Typechecking minmax
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> Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Diffstat (limited to 'tests/i915')
-rw-r--r--tests/i915/api_intel_bb.c2
-rw-r--r--tests/i915/gem_eio.c4
-rw-r--r--tests/i915/gem_exec_alignment.c4
-rw-r--r--tests/i915/gem_exec_capture.c2
-rw-r--r--tests/i915/gem_exec_fair.c2
-rw-r--r--tests/i915/gem_pxp.c4
-rw-r--r--tests/i915/gem_stress.c2
-rw-r--r--tests/i915/gem_tiled_swapping.c5
-rw-r--r--tests/i915/gem_userptr_blits.c2
-rw-r--r--tests/i915/i915_pm_rc6_residency.c2
-rw-r--r--tests/i915/kms_big_fb.c2
-rw-r--r--tests/i915/perf_pmu.c2
12 files changed, 17 insertions, 16 deletions
diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
index 293720b4..82943a34 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 d9ff1981..3d094433 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 c4611bd1..68b95c86 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 19f3836e..7e0a8b8a 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 ef5a450f..89945d40 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_pxp.c b/tests/i915/gem_pxp.c
index 0430f4b8..5f269bab 100644
--- a/tests/i915/gem_pxp.c
+++ b/tests/i915/gem_pxp.c
@@ -1082,8 +1082,8 @@ static void test_display_protected_crc(int i915, igt_display_t *display)
for_each_connected_output(display, output) {
mode = igt_output_get_mode(output);
- width = max(width, mode->hdisplay);
- height = max(height, mode->vdisplay);
+ width = max_t(int, width, mode->hdisplay);
+ height = max_t(int, height, mode->vdisplay);
}
igt_create_color_fb(i915, width, height, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
diff --git a/tests/i915/gem_stress.c b/tests/i915/gem_stress.c
index 3e4d4907..3765ab14 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 d33b76db..d66b6ca7 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 0d084674..93e4b25b 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 96a95140..cf9eae90 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 308227c9..86659038 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 1214cda8..e9df0290 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