From 83884e97e18739e3588c6467a210838099d42073 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 21 Mar 2017 17:16:03 +0000 Subject: Restore "lib: Open debugfs files for the given DRM device" This reverts commit 25fbae15262cf570e207e62f50e7c5233e06bc67, restoring commit 301ad44cdf1b868b1ab89096721da91fa8541fdc Author: Tomeu Vizoso Date: Thu Mar 2 10:37:11 2017 +0100 lib: Open debugfs files for the given DRM device with fixes. Signed-off-by: Chris Wilson --- tests/chamelium.c | 20 +++++++++--------- tests/drv_hangman.c | 4 ++-- tests/drv_missed_irq.c | 35 ++++++++++++++++--------------- tests/drv_suspend.c | 8 +++---- tests/gem_concurrent_all.c | 2 +- tests/gem_eio.c | 2 +- tests/gem_exec_latency.c | 2 +- tests/gem_exec_parse.c | 2 +- tests/gem_exec_whisper.c | 6 +++--- tests/gem_mocs_settings.c | 14 ++++++++----- tests/gem_persistent_relocs.c | 2 +- tests/gem_ppgtt.c | 10 ++++----- tests/gem_reloc_vs_gpu.c | 2 +- tests/gem_render_linear_blits.c | 2 +- tests/gem_render_tiled_blits.c | 2 +- tests/gem_seqno_wrap.c | 24 ++++++++++----------- tests/gem_tiled_swapping.c | 9 ++++---- tests/gem_workarounds.c | 4 ++-- tests/kms_atomic_transition.c | 2 +- tests/kms_ccs.c | 4 ++-- tests/kms_chv_cursor_fail.c | 4 ++-- tests/kms_crtc_background_color.c | 4 ++-- tests/kms_cursor_crc.c | 4 ++-- tests/kms_cursor_legacy.c | 4 ++-- tests/kms_draw_crc.c | 2 +- tests/kms_fbc_crc.c | 8 +++---- tests/kms_fbcon_fbt.c | 44 +++++++++++++++++++-------------------- tests/kms_flip_tiling.c | 8 +++---- tests/kms_frontbuffer_tracking.c | 26 +++++++++++------------ tests/kms_invalid_dotclock.c | 6 +++--- tests/kms_mmap_write_crc.c | 4 ++-- tests/kms_mmio_vs_cs_flip.c | 6 +++--- tests/kms_pipe_color.c | 5 +++-- tests/kms_pipe_crc_basic.c | 12 +++++------ tests/kms_plane.c | 4 ++-- tests/kms_plane_lowres.c | 14 ++++++------- tests/kms_plane_multiple.c | 4 ++-- tests/kms_plane_scaling.c | 4 ++-- tests/kms_psr_sink_crc.c | 6 +++--- tests/kms_pwrite_crc.c | 4 ++-- tests/kms_rotation_crc.c | 4 ++-- tests/kms_sink_crc_basic.c | 8 +++---- tests/kms_universal_plane.c | 12 +++++------ tests/perf.c | 16 +++++++------- tests/pm_lpsp.c | 2 +- tests/pm_rpm.c | 6 +++--- tests/pm_sseu.c | 28 ++++++++++++------------- tests/prime_mmap_kms.c | 2 +- 48 files changed, 205 insertions(+), 202 deletions(-) (limited to 'tests') diff --git a/tests/chamelium.c b/tests/chamelium.c index 810c955e..dc631161 100644 --- a/tests/chamelium.c +++ b/tests/chamelium.c @@ -154,7 +154,7 @@ test_basic_hotplug(data_t *data, struct chamelium_port *port) int i; reset_state(data, port); - igt_hpd_storm_set_threshold(0); + igt_hpd_storm_set_threshold(data->drm_fd, 0); for (i = 0; i < 15; i++) { igt_flush_hotplugs(mon); @@ -175,7 +175,7 @@ test_basic_hotplug(data_t *data, struct chamelium_port *port) } igt_cleanup_hotplug(mon); - igt_hpd_storm_reset(); + igt_hpd_storm_reset(data->drm_fd); } static void @@ -536,12 +536,12 @@ test_hpd_storm_detect(data_t *data, struct chamelium_port *port, int width) struct udev_monitor *mon; int count = 0; - igt_require_hpd_storm_ctl(); + igt_require_hpd_storm_ctl(data->drm_fd); reset_state(data, port); - igt_hpd_storm_set_threshold(1); + igt_hpd_storm_set_threshold(data->drm_fd, 1); chamelium_fire_hpd_pulses(data->chamelium, port, width, 10); - igt_assert(igt_hpd_storm_detected()); + igt_assert(igt_hpd_storm_detected(data->drm_fd)); mon = igt_watch_hotplug(); chamelium_fire_hpd_pulses(data->chamelium, port, width, 10); @@ -555,21 +555,21 @@ test_hpd_storm_detect(data_t *data, struct chamelium_port *port, int width) igt_assert_lt(count, 2); igt_cleanup_hotplug(mon); - igt_hpd_storm_reset(); + igt_hpd_storm_reset(data->drm_fd); } static void test_hpd_storm_disable(data_t *data, struct chamelium_port *port, int width) { - igt_require_hpd_storm_ctl(); + igt_require_hpd_storm_ctl(data->drm_fd); reset_state(data, port); - igt_hpd_storm_set_threshold(0); + igt_hpd_storm_set_threshold(data->drm_fd, 0); chamelium_fire_hpd_pulses(data->chamelium, port, width, 10); - igt_assert(!igt_hpd_storm_detected()); + igt_assert(!igt_hpd_storm_detected(data->drm_fd)); - igt_hpd_storm_reset(); + igt_hpd_storm_reset(data->drm_fd); } #define for_each_port(p, port) \ diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c index b8c6b87f..0551ec16 100644 --- a/tests/drv_hangman.c +++ b/tests/drv_hangman.c @@ -88,7 +88,7 @@ static void test_error_state_basic(void) assert_error_state_clear(); /* Manually trigger a hang by request a reset */ - fd = igt_debugfs_open("i915_wedged", O_WRONLY); + fd = igt_debugfs_open(device, "i915_wedged", O_WRONLY); igt_ignore_warn(write(fd, "1\n", 2)); close(fd); @@ -224,7 +224,7 @@ static void hangcheck_unterminated(void) gem_execbuf(device, &execbuf); if (gem_wait(device, handle, &timeout_ns) != 0) { /* need to manually trigger an hang to clean before failing */ - igt_force_gpu_reset(); + igt_force_gpu_reset(device); igt_assert_f(0, "unterminated batch did not trigger an hang!"); } } diff --git a/tests/drv_missed_irq.c b/tests/drv_missed_irq.c index 7283a17b..652cbc20 100644 --- a/tests/drv_missed_irq.c +++ b/tests/drv_missed_irq.c @@ -29,6 +29,8 @@ IGT_TEST_DESCRIPTION("Inject missed interrupts and make sure they are caught"); +static int drm_fd; + static void trigger_missed_interrupt(int fd, unsigned ring) { const int gen = intel_gen(intel_get_drm_devid(fd)); @@ -116,16 +118,16 @@ static uint32_t engine_mask(void) uint32_t mask; FILE *file; - file = igt_debugfs_fopen("i915_ring_test_irq", "w"); + file = igt_debugfs_fopen(drm_fd, "i915_ring_test_irq", "w"); fprintf(file, "0x%x", -1); fclose(file); mask = -1; - file = igt_debugfs_fopen("i915_ring_test_irq", "r"); + file = igt_debugfs_fopen(drm_fd, "i915_ring_test_irq", "r"); igt_ignore_warn(fscanf(file, "%x", &mask)); fclose(file); - file = igt_debugfs_fopen("i915_ring_test_irq", "w"); + file = igt_debugfs_fopen(drm_fd, "i915_ring_test_irq", "w"); fprintf(file, "0"); fclose(file); @@ -136,7 +138,7 @@ static void enable_missed_irq(void) { FILE *file; - file = igt_debugfs_fopen("i915_ring_test_irq", "w"); + file = igt_debugfs_fopen(drm_fd, "i915_ring_test_irq", "w"); fprintf(file, "0x%x", -1); fclose(file); } @@ -146,11 +148,11 @@ static uint32_t disable_missed_irq(void) FILE *file; uint32_t mask = 0; - file = igt_debugfs_fopen("i915_ring_test_irq", "r"); + file = igt_debugfs_fopen(drm_fd, "i915_ring_test_irq", "r"); igt_ignore_warn(fscanf(file, "%x", &mask)); fclose(file); - file = igt_debugfs_fopen("i915_ring_test_irq", "w"); + file = igt_debugfs_fopen(drm_fd, "i915_ring_test_irq", "w"); fprintf(file, "0"); fclose(file); @@ -163,20 +165,19 @@ igt_simple_main unsigned expect_rings; unsigned missed_rings; unsigned check_rings; - int fd; igt_skip_on_simulation(); bind_to_cpu(0); - fd = drm_open_driver(DRIVER_INTEL); - igt_require_gem(fd); - gem_require_mmap_wc(fd); - igt_fork_hang_detector(fd); + drm_fd = drm_open_driver(DRIVER_INTEL); + igt_require_gem(drm_fd); + gem_require_mmap_wc(drm_fd); + igt_fork_hang_detector(drm_fd); expect_rings = engine_mask(); igt_debug("Clearing rings %x\n", expect_rings); - intel_detect_and_clear_missed_interrupts(fd); + intel_detect_and_clear_missed_interrupts(drm_fd); for (e = intel_execution_engines; e->name; e++) { if (expect_rings == -1 && e->exec_id) continue; @@ -186,9 +187,9 @@ igt_simple_main igt_debug("Clearing ring %s [%x]\n", e->name, e->exec_id | e->flags); - trigger_missed_interrupt(fd, e->exec_id | e->flags); + trigger_missed_interrupt(drm_fd, e->exec_id | e->flags); } - igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); + igt_assert_eq(intel_detect_and_clear_missed_interrupts(drm_fd), 0); igt_debug("Testing rings %x\n", expect_rings); enable_missed_irq(); @@ -201,9 +202,9 @@ igt_simple_main igt_debug("Executing on ring %s [%x]\n", e->name, e->exec_id | e->flags); - trigger_missed_interrupt(fd, e->exec_id | e->flags); + trigger_missed_interrupt(drm_fd, e->exec_id | e->flags); } - missed_rings = intel_detect_and_clear_missed_interrupts(fd); + missed_rings = intel_detect_and_clear_missed_interrupts(drm_fd); check_rings = disable_missed_irq(); igt_assert_eq_u32(check_rings, expect_rings); @@ -214,5 +215,5 @@ igt_simple_main igt_assert_eq_u32(missed_rings, expect_rings); igt_stop_hang_detector(); - close(fd); + close(drm_fd); } diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c index 1d7cc1f8..2e39f20a 100644 --- a/tests/drv_suspend.c +++ b/tests/drv_suspend.c @@ -161,11 +161,11 @@ test_sysfs_reader(bool hibernate) } static void -test_forcewake(bool hibernate) +test_forcewake(int fd, bool hibernate) { int fw_fd; - fw_fd = igt_open_forcewake_handle(); + fw_fd = igt_open_forcewake_handle(fd); igt_assert_lte(0, fw_fd); if (hibernate) @@ -200,7 +200,7 @@ igt_main test_sysfs_reader(false); igt_subtest("forcewake") - test_forcewake(false); + test_forcewake(fd, false); igt_subtest("fence-restore-tiled2untiled-hibernate") test_fence_restore(fd, true, true); @@ -215,7 +215,7 @@ igt_main test_sysfs_reader(true); igt_subtest("forcewake-hibernate") - test_forcewake(true); + test_forcewake(fd, true); igt_fixture close(fd); diff --git a/tests/gem_concurrent_all.c b/tests/gem_concurrent_all.c index aecd5e28..b2e11ea0 100644 --- a/tests/gem_concurrent_all.c +++ b/tests/gem_concurrent_all.c @@ -1905,7 +1905,7 @@ igt_main count = num_buffers(gem_mappable_aperture_size(), s, c, CHECK_RAM); - igt_fork_shrink_helper(); + igt_fork_shrink_helper(fd); } run_modes(name, c, modes, s, count); diff --git a/tests/gem_eio.c b/tests/gem_eio.c index d9e68657..3c826626 100644 --- a/tests/gem_eio.c +++ b/tests/gem_eio.c @@ -61,7 +61,7 @@ static bool i915_reset_control(bool enable) static void trigger_reset(int fd) { - igt_force_gpu_reset(); + igt_force_gpu_reset(fd); /* And just check the gpu is indeed running again */ igt_debug("Checking that the GPU recovered\n"); diff --git a/tests/gem_exec_latency.c b/tests/gem_exec_latency.c index c3ebc20a..dd6703f4 100644 --- a/tests/gem_exec_latency.c +++ b/tests/gem_exec_latency.c @@ -442,9 +442,9 @@ igt_main int device = -1; igt_fixture { - intel_register_access_init(intel_get_pci_device(), false); device = drm_open_driver(DRIVER_INTEL); igt_require_gem(device); + intel_register_access_init(intel_get_pci_device(), false, device); print_welcome(device); ring_size = measure_ring_size(device); diff --git a/tests/gem_exec_parse.c b/tests/gem_exec_parse.c index 4631746b..b653b1bd 100644 --- a/tests/gem_exec_parse.c +++ b/tests/gem_exec_parse.c @@ -526,7 +526,7 @@ igt_main #undef REG igt_fixture { - intel_register_access_init(intel_get_pci_device(), 0); + intel_register_access_init(intel_get_pci_device(), 0, fd); } for (int i = 0; i < ARRAY_SIZE(lris); i++) { diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c index cac3fedd..04ccc7f0 100644 --- a/tests/gem_exec_whisper.c +++ b/tests/gem_exec_whisper.c @@ -41,12 +41,12 @@ #define VERIFY 0 -static void write_seqno(unsigned offset) +static void write_seqno(int fd, unsigned offset) { uint32_t seqno = UINT32_MAX - offset; FILE *file; - file = igt_debugfs_fopen("i915_next_seqno", "w"); + file = igt_debugfs_fopen(fd, "i915_next_seqno", "w"); igt_assert(file); igt_assert(fprintf(file, "0x%x", seqno) > 0); @@ -337,7 +337,7 @@ static void whisper(int fd, unsigned engine, unsigned flags) uint64_t offset; if (!(flags & FORKED)) - write_seqno(pass); + write_seqno(fd, pass); if (flags & HANG) submit_hang(&hang, engines, nengine); diff --git a/tests/gem_mocs_settings.c b/tests/gem_mocs_settings.c index 9faf6c54..a96aa66d 100644 --- a/tests/gem_mocs_settings.c +++ b/tests/gem_mocs_settings.c @@ -383,7 +383,7 @@ static void default_context_tests(unsigned mode) switch (mode) { case NONE: break; - case RESET: igt_force_gpu_reset(); break; + case RESET: igt_force_gpu_reset(fd); break; case SUSPEND: igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); break; case HIBERNATE: igt_system_suspend_autoresume(SUSPEND_STATE_DISK, @@ -424,7 +424,7 @@ static void default_dirty_tests(unsigned mode) switch (mode) { case NONE: break; - case RESET: igt_force_gpu_reset(); break; + case RESET: igt_force_gpu_reset(fd); break; case SUSPEND: igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); break; case HIBERNATE: igt_system_suspend_autoresume(SUSPEND_STATE_DISK, @@ -449,7 +449,7 @@ static void context_save_restore_test(unsigned mode) switch (mode) { case NONE: break; - case RESET: igt_force_gpu_reset(); break; + case RESET: igt_force_gpu_reset(fd); break; case SUSPEND: igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); break; case HIBERNATE: igt_system_suspend_autoresume(SUSPEND_STATE_DISK, @@ -494,7 +494,7 @@ static void context_dirty_test(unsigned mode) switch (mode) { case NONE: break; - case RESET: igt_force_gpu_reset(); break; + case RESET: igt_force_gpu_reset(fd); break; case SUSPEND: igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); break; case HIBERNATE: igt_system_suspend_autoresume(SUSPEND_STATE_DISK, @@ -514,10 +514,14 @@ static void context_dirty_test(unsigned mode) static void run_tests(unsigned mode) { struct pci_device *pci_dev; + int fd; pci_dev = intel_get_pci_device(); igt_require(pci_dev); - intel_register_access_init(pci_dev, 0); + + fd = drm_open_driver_master(DRIVER_INTEL); + intel_register_access_init(pci_dev, 0, fd); + close(fd); default_context_tests(mode); default_dirty_tests(mode); diff --git a/tests/gem_persistent_relocs.c b/tests/gem_persistent_relocs.c index 9c885307..e51420e1 100644 --- a/tests/gem_persistent_relocs.c +++ b/tests/gem_persistent_relocs.c @@ -288,7 +288,7 @@ static void do_forked_test(int fd, unsigned flags) igt_fork_helper(&thrasher) { while (1) { usleep(1000); - igt_drop_caches_set(val); + igt_drop_caches_set(fd, val); } } } diff --git a/tests/gem_ppgtt.c b/tests/gem_ppgtt.c index a64d6d4f..37d601ce 100644 --- a/tests/gem_ppgtt.c +++ b/tests/gem_ppgtt.c @@ -236,7 +236,7 @@ static void flink_and_close(void) gem_sync(fd2, flinked_bo); gem_close(fd2, flinked_bo); - igt_drop_caches_set(DROP_RETIRE); + igt_drop_caches_set(fd, DROP_RETIRE); /* the flinked bo VMA should have been cleared now, so a new bo of the * same size should get the same offset @@ -269,12 +269,12 @@ static void flink_and_exit(void) flinked_bo = gem_open(fd2, name); /* Verify VMA is not there yet. */ - igt_assert(!igt_debugfs_search("i915_gem_gtt", match)); + igt_assert(!igt_debugfs_search(fd, "i915_gem_gtt", match)); exec_and_get_offset(fd2, flinked_bo); /* Verify VMA has been created. */ - igt_assert(igt_debugfs_search("i915_gem_gtt", match)); + igt_assert(igt_debugfs_search(fd, "i915_gem_gtt", match)); /* Close the context. */ close(fd2); @@ -286,8 +286,8 @@ static void flink_and_exit(void) exec_and_get_offset(fd3, gem_create(fd3, 4096)); close(fd3); - igt_drop_caches_set(DROP_ACTIVE | DROP_RETIRE); - igt_assert(!igt_debugfs_search("i915_gem_gtt", match)); + igt_drop_caches_set(fd, DROP_ACTIVE | DROP_RETIRE); + igt_assert(!igt_debugfs_search(fd, "i915_gem_gtt", match)); close(fd); } diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c index fa4d9aa3..afc31328 100644 --- a/tests/gem_reloc_vs_gpu.c +++ b/tests/gem_reloc_vs_gpu.c @@ -265,7 +265,7 @@ static void do_forked_test(int fd, unsigned flags) igt_fork_helper(&thrasher) { while (1) { usleep(1000); - igt_drop_caches_set(val); + igt_drop_caches_set(fd, val); } } } diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c index acc3bd5a..1548ee91 100644 --- a/tests/gem_render_linear_blits.c +++ b/tests/gem_render_linear_blits.c @@ -204,7 +204,7 @@ igt_main } igt_subtest("aperture-shrink") { - igt_fork_shrink_helper(); + igt_fork_shrink_helper(fd); count = 3 * gem_aperture_size(fd) / SIZE / 2; intel_require_memory(count, SIZE, CHECK_RAM); diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c index aebbcb96..22acc459 100644 --- a/tests/gem_render_tiled_blits.c +++ b/tests/gem_render_tiled_blits.c @@ -217,7 +217,7 @@ igt_main } igt_subtest("aperture-shrink") { - igt_fork_shrink_helper(); + igt_fork_shrink_helper(fd); count = 3 * gem_aperture_size(fd) / SIZE / 2; intel_require_memory(count, SIZE, CHECK_RAM); diff --git a/tests/gem_seqno_wrap.c b/tests/gem_seqno_wrap.c index 3b0cc3a8..2270dfa2 100644 --- a/tests/gem_seqno_wrap.c +++ b/tests/gem_seqno_wrap.c @@ -47,6 +47,7 @@ IGT_TEST_DESCRIPTION("Runs blitcopy -> rendercopy with multiple buffers over" " wrap boundary."); +static int drm_fd; static int devid; static int card_index = 0; static uint32_t last_seqno = 0; @@ -174,26 +175,25 @@ static void run_sync_test(int num_buffers, bool verify) int max; drm_intel_bo **src, **dst1, **dst2; int width = 128, height = 128; - int fd; int i; unsigned int *p_dst1, *p_dst2; struct igt_buf *s_src, *s_dst; - fd = drm_open_driver(DRIVER_INTEL); + drm_fd = drm_open_driver(DRIVER_INTEL); - gem_quiescent_gpu(fd); + gem_quiescent_gpu(drm_fd); - devid = intel_get_drm_devid(fd); + devid = intel_get_drm_devid(drm_fd); - max = gem_aperture_size (fd) / (1024 * 1024) / 2; + max = gem_aperture_size (drm_fd) / (1024 * 1024) / 2; if (num_buffers > max) num_buffers = max; - bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); + bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); drm_intel_bufmgr_gem_enable_reuse(bufmgr); - batch_blt = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); + batch_blt = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(drm_fd)); igt_assert(batch_blt); - batch_3d = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); + batch_3d = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(drm_fd)); igt_assert(batch_3d); src = malloc(num_buffers * sizeof(*src)); @@ -265,9 +265,9 @@ static void run_sync_test(int num_buffers, bool verify) free(dst1); free(src); - gem_quiescent_gpu(fd); + gem_quiescent_gpu(drm_fd); - close(fd); + close(drm_fd); } static int __read_seqno(uint32_t *seqno) @@ -278,7 +278,7 @@ static int __read_seqno(uint32_t *seqno) char *p; unsigned long int tmp; - fh = igt_debugfs_open("i915_next_seqno", O_RDONLY); + fh = igt_debugfs_open(drm_fd, "i915_next_seqno", O_RDONLY); r = read(fh, buf, sizeof(buf) - 1); close(fh); @@ -332,7 +332,7 @@ static void write_seqno(uint32_t seqno) if (options.dontwrap) return; - fd = igt_debugfs_open("i915_next_seqno", O_RDWR); + fd = igt_debugfs_open(drm_fd, "i915_next_seqno", O_RDWR); len = snprintf(buf, sizeof(buf), "0x%x", seqno); igt_assert(write(fd, buf, len) == len); close(fd); diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c index b5849bc1..dce66806 100644 --- a/tests/gem_tiled_swapping.c +++ b/tests/gem_tiled_swapping.c @@ -155,9 +155,9 @@ static void thread_fini(struct thread *t) free(t->idx_arr); } -static void check_memory_layout(void) +static void check_memory_layout(int fd) { - igt_skip_on_f(igt_debugfs_search("i915_swizzle_info", "L-shaped"), + igt_skip_on_f(igt_debugfs_search(fd, "i915_swizzle_info", "L-shaped"), "L-shaped memory configuration detected\n"); igt_debug("normal memory configuration detected, continuing\n"); @@ -173,11 +173,10 @@ igt_main current_tiling_mode = I915_TILING_X; - intel_purge_vm_caches(); - fd = drm_open_driver(DRIVER_INTEL); - check_memory_layout(); + intel_purge_vm_caches(fd); + check_memory_layout(fd); /* lock RAM, leaving only 512MB available */ lock_size = max(0, intel_get_total_ram_mb() - AVAIL_RAM); diff --git a/tests/gem_workarounds.c b/tests/gem_workarounds.c index e512dd3d..08a1d09a 100644 --- a/tests/gem_workarounds.c +++ b/tests/gem_workarounds.c @@ -133,9 +133,9 @@ igt_main pci_dev = intel_get_pci_device(); igt_require(pci_dev); - intel_register_access_init(pci_dev, 0); + intel_register_access_init(pci_dev, 0, fd); - file = igt_debugfs_fopen("i915_wa_registers", "r"); + file = igt_debugfs_fopen(fd, "i915_wa_registers", "r"); igt_assert(getline(&line, &line_size, file) > 0); igt_debug("i915_wa_registers: %s", line); sscanf(line, "Workarounds applied: %d", &num_wa_regs); diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index a8ab1b7b..70bff203 100644 --- a/tests/kms_atomic_transition.c +++ b/tests/kms_atomic_transition.c @@ -675,7 +675,7 @@ static void run_modeset_tests(igt_display_t *display, int howmany, bool nonblock drmModeModeInfo *mode = NULL; if (is_i915_device(display->drm_fd)) - pipe_crcs[i] = igt_pipe_crc_new(i, INTEL_PIPE_CRC_SOURCE_AUTO); + pipe_crcs[i] = igt_pipe_crc_new(display->drm_fd, i, INTEL_PIPE_CRC_SOURCE_AUTO); for_each_valid_output_on_pipe(display, i, output) { if (output->pending_crtc_idx_mask) diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c index 11acda89..d8291520 100644 --- a/tests/kms_ccs.c +++ b/tests/kms_ccs.c @@ -212,7 +212,7 @@ static void test_output(data_t *data) igt_output_set_pipe(data->output, data->pipe); if (data->flags & TEST_CRC) { - pipe_crc = igt_pipe_crc_new(data->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + pipe_crc = igt_pipe_crc_new(data->drm_fd, data->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); display_fb(data, TEST_COMPRESSED); igt_pipe_crc_collect_crc(pipe_crc, &ref_crc); @@ -276,7 +276,7 @@ igt_main igt_require(intel_gen(intel_get_drm_devid(data.drm_fd)) >= 9); kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_chv_cursor_fail.c b/tests/kms_chv_cursor_fail.c index ce6e8df6..3e74df11 100644 --- a/tests/kms_chv_cursor_fail.c +++ b/tests/kms_chv_cursor_fail.c @@ -254,7 +254,7 @@ static void prepare_crtc(data_t *data) if (data->pipe_crc) igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new_nonblock(data->pipe, + data->pipe_crc = igt_pipe_crc_new_nonblock(data->drm_fd, data->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); /* make sure cursor is disabled */ @@ -374,7 +374,7 @@ int main(int argc, char **argv) kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_crtc_background_color.c b/tests/kms_crtc_background_color.c index d6dd8d90..e12e1634 100644 --- a/tests/kms_crtc_background_color.c +++ b/tests/kms_crtc_background_color.c @@ -85,7 +85,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, /* create the pipe_crc object for this pipe */ igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); mode = igt_output_get_mode(output); @@ -179,7 +179,7 @@ igt_simple_main igt_skip_on_simulation(); data.gfx_fd = drm_open_driver(DRIVER_INTEL); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.gfx_fd); igt_display_init(&data.display, data.gfx_fd); test_crtc_background(&data); diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c index 4851e18f..206f8526 100644 --- a/tests/kms_cursor_crc.c +++ b/tests/kms_cursor_crc.c @@ -310,7 +310,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, if (data->pipe_crc) igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(data->pipe, + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, data->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); /* x/y position where the cursor is still fully visible */ @@ -602,7 +602,7 @@ igt_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c index b048f4ac..8a8c71b5 100644 --- a/tests/kms_cursor_legacy.c +++ b/tests/kms_cursor_legacy.c @@ -1264,7 +1264,7 @@ static void flip_vs_cursor_crc(igt_display_t *display, bool atomic) igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); - pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + pipe_crc = igt_pipe_crc_new(display->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); set_cursor_on_pipe(display, pipe, &cursor_fb); igt_display_commit2(display, COMMIT_UNIVERSAL); @@ -1326,7 +1326,7 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic) igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); - pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + pipe_crc = igt_pipe_crc_new(display->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); set_cursor_on_pipe(display, pipe, &cursor_fb); igt_display_commit2(display, COMMIT_UNIVERSAL); diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c index e1639810..c57d3a35 100644 --- a/tests/kms_draw_crc.c +++ b/tests/kms_draw_crc.c @@ -232,7 +232,7 @@ static void setup_environment(void) drm_intel_bufmgr_gem_enable_reuse(bufmgr); find_modeset_params(); - pipe_crc = igt_pipe_crc_new(kmstest_get_crtc_idx(drm_res, ms.crtc_id), + pipe_crc = igt_pipe_crc_new(drm_fd, kmstest_get_crtc_idx(drm_res, ms.crtc_id), INTEL_PIPE_CRC_SOURCE_AUTO); } diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c index 96af06a0..7964e052 100644 --- a/tests/kms_fbc_crc.c +++ b/tests/kms_fbc_crc.c @@ -211,7 +211,7 @@ static bool fbc_enabled(data_t *data) { char str[128] = {}; - igt_debugfs_read("i915_fbc_status", str); + igt_debugfs_read(data->drm_fd, "i915_fbc_status", str); return strstr(str, "FBC enabled") != NULL; } @@ -378,7 +378,7 @@ static bool prepare_test(data_t *data, enum test_mode test_mode) igt_pipe_crc_free(data->pipe_crc); data->pipe_crc = NULL; - pipe_crc = igt_pipe_crc_new(data->pipe, + pipe_crc = igt_pipe_crc_new(data->drm_fd, data->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); data->pipe_crc = pipe_crc; @@ -530,9 +530,9 @@ igt_main data.devid = intel_get_drm_devid(data.drm_fd); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(data.drm_fd, "i915_fbc_status", buf); igt_require_f(!strstr(buf, "unsupported on this chipset"), "FBC not supported\n"); diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c index 6342289f..d0090912 100644 --- a/tests/kms_fbcon_fbt.c +++ b/tests/kms_fbcon_fbt.c @@ -82,11 +82,11 @@ static void teardown_drm(struct drm_info *drm) igt_assert(close(drm->fd) == 0); } -static bool fbc_supported_on_chipset(void) +static bool fbc_supported_on_chipset(int fd) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(fd, "i915_fbc_status", buf); return !strstr(buf, "FBC unsupported on this chipset\n"); } @@ -95,17 +95,17 @@ static bool connector_can_fbc(drmModeConnectorPtr connector) return true; } -static bool fbc_is_enabled(void) +static bool fbc_is_enabled(int fd) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(fd, "i915_fbc_status", buf); return strstr(buf, "FBC enabled\n"); } -static bool fbc_wait_until_enabled(void) +static bool fbc_wait_until_enabled(int fd) { - return igt_wait(fbc_is_enabled(), 5000, 1); + return igt_wait(fbc_is_enabled(fd), 5000, 1); } typedef bool (*connector_possible_fn)(drmModeConnectorPtr connector); @@ -147,11 +147,11 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb, igt_assert_eq(rc, 0); } -static bool psr_supported_on_chipset(void) +static bool psr_supported_on_chipset(int fd) { char buf[256]; - igt_debugfs_read("i915_edp_psr_status", buf); + igt_debugfs_read(fd, "i915_edp_psr_status", buf); return strstr(buf, "Sink_Support: yes\n"); } @@ -160,22 +160,22 @@ static bool connector_can_psr(drmModeConnectorPtr connector) return (connector->connector_type == DRM_MODE_CONNECTOR_eDP); } -static bool psr_is_enabled(void) +static bool psr_is_enabled(int fd) { char buf[256]; - igt_debugfs_read("i915_edp_psr_status", buf); + igt_debugfs_read(fd, "i915_edp_psr_status", buf); return strstr(buf, "\nActive: yes\n"); } -static bool psr_wait_until_enabled(void) +static bool psr_wait_until_enabled(int fd) { - return igt_wait(psr_is_enabled(), 5000, 1); + return igt_wait(psr_is_enabled(fd), 5000, 1); } struct feature { - bool (*supported_on_chipset)(void); - bool (*wait_until_enabled)(void); + bool (*supported_on_chipset)(int fd); + bool (*wait_until_enabled)(int fd); bool (*connector_possible_fn)(drmModeConnectorPtr connector); const char *param_name; } fbc = { @@ -201,26 +201,26 @@ static void subtest(struct feature *feature, bool suspend) struct drm_info drm; struct igt_fb fb; - igt_require(feature->supported_on_chipset()); + setup_drm(&drm); + + igt_require(feature->supported_on_chipset(drm.fd)); disable_features(); igt_set_module_param_int(feature->param_name, 1); - setup_drm(&drm); - kmstest_unset_all_crtcs(drm.fd, drm.res); wait_user("Modes unset."); - igt_assert(!feature->wait_until_enabled()); + igt_assert(!feature->wait_until_enabled(drm.fd)); set_mode_for_one_screen(&drm, &fb, feature->connector_possible_fn); wait_user("Screen set."); - igt_assert(feature->wait_until_enabled()); + igt_assert(feature->wait_until_enabled(drm.fd)); if (suspend) { igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); sleep(5); - igt_assert(feature->wait_until_enabled()); + igt_assert(feature->wait_until_enabled(drm.fd)); } igt_remove_fb(drm.fd, &fb); @@ -230,13 +230,13 @@ static void subtest(struct feature *feature, bool suspend) sleep(3); wait_user("Back to fbcon."); - igt_assert(!feature->wait_until_enabled()); + igt_assert(!feature->wait_until_enabled(drm.fd)); if (suspend) { igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); sleep(5); - igt_assert(!feature->wait_until_enabled()); + igt_assert(!feature->wait_until_enabled(drm.fd)); } } diff --git a/tests/kms_flip_tiling.c b/tests/kms_flip_tiling.c index cd2f510f..143be198 100644 --- a/tests/kms_flip_tiling.c +++ b/tests/kms_flip_tiling.c @@ -41,14 +41,14 @@ typedef struct { static igt_pipe_crc_t *_pipe_crc; -static igt_pipe_crc_t *pipe_crc_new(int pipe) +static igt_pipe_crc_t *pipe_crc_new(data_t *data, int pipe) { if (_pipe_crc) { igt_pipe_crc_free(_pipe_crc); _pipe_crc = NULL; } - _pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + _pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); igt_assert(_pipe_crc); return _pipe_crc; @@ -89,7 +89,7 @@ test_flip_tiling(data_t *data, enum pipe pipe, igt_output_t *output, uint64_t ti igt_crc_t reference_crc, crc; int fb_id, ret, width; - pipe_crc = pipe_crc_new(pipe); + pipe_crc = pipe_crc_new(data, pipe); igt_output_set_pipe(output, pipe); mode = igt_output_get_mode(output); @@ -168,7 +168,7 @@ igt_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index 03c77107..28e4b5b1 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -781,7 +781,7 @@ static bool fbc_is_enabled(void) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); return strstr(buf, "FBC enabled\n"); } @@ -789,7 +789,7 @@ static void fbc_print_status(void) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); igt_info("FBC status:\n%s\n", buf); } @@ -797,7 +797,7 @@ static bool psr_is_enabled(void) { char buf[256]; - igt_debugfs_read("i915_edp_psr_status", buf); + igt_debugfs_read(drm.fd, "i915_edp_psr_status", buf); return strstr(buf, "\nActive: yes\n") && strstr(buf, "\nHW Enabled & Active bit: yes\n"); } @@ -806,7 +806,7 @@ static void psr_print_status(void) { char buf[256]; - igt_debugfs_read("i915_edp_psr_status", buf); + igt_debugfs_read(drm.fd, "i915_edp_psr_status", buf); igt_info("PSR status:\n%s\n", buf); } @@ -817,7 +817,7 @@ static struct timespec fbc_get_last_action(void) char *action; ssize_t n_read; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); action = strstr(buf, "\nLast action:"); igt_assert(action); @@ -866,7 +866,7 @@ static void fbc_setup_last_action(void) char buf[128]; char *action; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); action = strstr(buf, "\nLast action:"); if (!action) { @@ -885,7 +885,7 @@ static bool fbc_is_compressing(void) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); return strstr(buf, "\nCompressing: yes\n") != NULL; } @@ -898,7 +898,7 @@ static bool fbc_not_enough_stolen(void) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); return strstr(buf, "FBC disabled: not enough stolen memory\n"); } @@ -906,7 +906,7 @@ static bool fbc_stride_not_supported(void) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); return strstr(buf, "FBC disabled: framebuffer stride not supported\n"); } @@ -1420,7 +1420,7 @@ static void setup_sink_crc(void) fill_fb_region(&prim_mode_params.fb, COLOR_PRIM_BG); set_mode_for_params(&prim_mode_params); - sink_crc.fd = igt_debugfs_open("i915_sink_crc_eDP1", O_RDONLY); + sink_crc.fd = igt_debugfs_open(drm.fd, "i915_sink_crc_eDP1", O_RDONLY); igt_assert_lte(0, sink_crc.fd); /* Do a first read to try to detect if it's supported. */ @@ -1432,7 +1432,7 @@ static void setup_crcs(void) enum pixel_format f; int crtc_idx = kmstest_get_crtc_idx(drm.res, prim_mode_params.crtc_id); - pipe_crc = igt_pipe_crc_new(crtc_idx, INTEL_PIPE_CRC_SOURCE_AUTO); + pipe_crc = igt_pipe_crc_new(drm.fd, crtc_idx, INTEL_PIPE_CRC_SOURCE_AUTO); setup_sink_crc(); @@ -1497,7 +1497,7 @@ static bool fbc_supported_on_chipset(void) { char buf[128]; - igt_debugfs_read("i915_fbc_status", buf); + igt_debugfs_read(drm.fd, "i915_fbc_status", buf); return !strstr(buf, "FBC unsupported on this chipset\n"); } @@ -1533,7 +1533,7 @@ static bool psr_sink_has_support(void) { char buf[256]; - igt_debugfs_read("i915_edp_psr_status", buf); + igt_debugfs_read(drm.fd, "i915_edp_psr_status", buf); return strstr(buf, "Sink_Support: yes\n"); } diff --git a/tests/kms_invalid_dotclock.c b/tests/kms_invalid_dotclock.c index 43f768fd..e6e72f52 100644 --- a/tests/kms_invalid_dotclock.c +++ b/tests/kms_invalid_dotclock.c @@ -104,13 +104,13 @@ static void test(data_t *data) igt_require_f(valid_connectors, "No suitable connectors found\n"); } -static int i915_max_dotclock(void) +static int i915_max_dotclock(data_t *data) { char buf[4096]; char *s; int max_dotclock = 0; - igt_debugfs_read("i915_frequency_info", buf); + igt_debugfs_read(data->drm_fd, "i915_frequency_info", buf); s = strstr(buf, "Max pixel clock frequency:"); igt_assert(s); igt_assert_eq(sscanf(s, "Max pixel clock frequency: %d kHz", &max_dotclock), 1); @@ -137,7 +137,7 @@ igt_simple_main data.res = drmModeGetResources(data.drm_fd); kmstest_unset_all_crtcs(data.drm_fd, data.res); - data.max_dotclock = i915_max_dotclock(); + data.max_dotclock = i915_max_dotclock(&data); igt_info("Max dotclock: %d kHz\n", data.max_dotclock); test(&data); diff --git a/tests/kms_mmap_write_crc.c b/tests/kms_mmap_write_crc.c index 8a1331cc..e5f089f6 100644 --- a/tests/kms_mmap_write_crc.c +++ b/tests/kms_mmap_write_crc.c @@ -185,7 +185,7 @@ static void prepare_crtc(data_t *data) if (data->pipe_crc) igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(data->pipe, + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, data->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); /* get reference crc for the white fb */ @@ -277,7 +277,7 @@ int main(int argc, char **argv) kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); diff --git a/tests/kms_mmio_vs_cs_flip.c b/tests/kms_mmio_vs_cs_flip.c index 09217b31..96a9dec3 100644 --- a/tests/kms_mmio_vs_cs_flip.c +++ b/tests/kms_mmio_vs_cs_flip.c @@ -235,7 +235,7 @@ test_plane(data_t *data, igt_output_t *output, enum pipe pipe, int plane) if (data->pipe_crc) igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); /* set red fb and grab reference crc */ igt_plane_set_fb(primary, &red_fb); @@ -374,7 +374,7 @@ test_crtc(data_t *data, igt_output_t *output, enum pipe pipe) if (data->pipe_crc) igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); /* set red fb and grab reference crc */ igt_plane_set_fb(primary, &red_fb); @@ -497,7 +497,7 @@ igt_main data.devid = intel_get_drm_devid(data.drm_fd); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096); diff --git a/tests/kms_pipe_color.c b/tests/kms_pipe_color.c index c7a5d2f1..fd58ac81 100644 --- a/tests/kms_pipe_color.c +++ b/tests/kms_pipe_color.c @@ -852,7 +852,7 @@ run_tests_for_pipe(data_t *data, enum pipe p) igt_fixture { int valid_tests = 0; - igt_require_pipe_crc(); + igt_require_pipe_crc(data->drm_fd); igt_require(p < data->display.n_pipes); @@ -861,7 +861,8 @@ run_tests_for_pipe(data_t *data, enum pipe p) primary = igt_pipe_get_plane_type(pipe, DRM_PLANE_TYPE_PRIMARY); - data->pipe_crc = igt_pipe_crc_new(primary->pipe->pipe, + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, + primary->pipe->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); igt_require(igt_pipe_get_property(&data->display.pipes[p], diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c index 2d857b0f..f3c58390 100644 --- a/tests/kms_pipe_crc_basic.c +++ b/tests/kms_pipe_crc_basic.c @@ -48,7 +48,7 @@ static void test_bad_command(data_t *data, const char *cmd) FILE *ctl; size_t written; - ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+"); + ctl = igt_debugfs_fopen(data->drm_fd, "i915_display_crc_ctl", "r+"); igt_require(ctl); written = fwrite(cmd, 1, strlen(cmd), ctl); @@ -66,7 +66,7 @@ static void test_bad_source(data_t *data) size_t written; const char *source = "foo"; - f = igt_debugfs_fopen("crtc-0/crc/control", "w"); + f = igt_debugfs_fopen(data->drm_fd, "crtc-0/crc/control", "w"); if (!f) { test_bad_command(data, "pipe A foo"); return; @@ -78,7 +78,7 @@ static void test_bad_source(data_t *data) igt_assert(!ferror(f)); fclose(f); - f = igt_debugfs_fopen("crtc-0/crc/data", "w"); + f = igt_debugfs_fopen(data->drm_fd, "crtc-0/crc/data", "w"); igt_assert(!f); igt_assert_eq(errno, EINVAL); } @@ -126,7 +126,7 @@ test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output, if (flags & TEST_NONBLOCK) { igt_pipe_crc_t *pipe_crc; - pipe_crc = igt_pipe_crc_new_nonblock(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + pipe_crc = igt_pipe_crc_new_nonblock(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); igt_wait_for_vblank(data->drm_fd, pipe); igt_pipe_crc_start(pipe_crc); @@ -140,7 +140,7 @@ test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output, } else { igt_pipe_crc_t *pipe_crc; - pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); igt_pipe_crc_start(pipe_crc); n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS, &crcs); @@ -212,7 +212,7 @@ igt_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_plane.c b/tests/kms_plane.c index d0de0f52..e1bd467b 100644 --- a/tests/kms_plane.c +++ b/tests/kms_plane.c @@ -52,7 +52,7 @@ static color_t blue = { 0.0f, 0.0f, 1.0f }; */ static void test_init(data_t *data, enum pipe pipe) { - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); } static void test_fini(data_t *data) @@ -430,7 +430,7 @@ igt_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_plane_lowres.c b/tests/kms_plane_lowres.c index 689c248e..6f159601 100644 --- a/tests/kms_plane_lowres.c +++ b/tests/kms_plane_lowres.c @@ -112,7 +112,7 @@ get_lowres_mode(int drmfd, drmModeModeInfo *mode_default) static void test_init(data_t *data, enum pipe pipe) { - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); data->plane = calloc(data->display.pipes[pipe].n_planes, sizeof(data->plane));\ igt_assert_f(data->plane, "Failed to allocate memory for %d planes\n", data->display.pipes[pipe].n_planes); @@ -189,11 +189,9 @@ test_setup(data_t *data, enum pipe pipe, uint64_t modifier, int flags, int size; int i, x, y; - crtc.planes = calloc(sizeof(struct kmstest_plane), data->display.pipes[pipe].n_planes); - igt_assert_f(crtc.planes, "Failed to allocate memory for %d planes\n", data->display.pipes[pipe].n_planes); igt_output_set_pipe(output, pipe); - kmstest_get_crtc(pipe, &crtc); + kmstest_get_crtc(data->drm_fd, pipe, &crtc); igt_skip_on(crtc.n_planes > data->display.pipes[pipe].n_planes); igt_skip_on(crtc.n_planes == 0); @@ -263,7 +261,7 @@ test_plane_position_with_output(data_t *data, enum pipe pipe, n = igt_pipe_crc_get_crcs(data->pipe_crc, 1, &crc_hires1); igt_assert_eq(1, n); - igt_assert_plane_visible(pipe, true); + igt_assert_plane_visible(data->drm_fd, pipe, true); /* switch to lower resolution */ igt_output_override_mode(output, &mode_lowres); @@ -275,7 +273,7 @@ test_plane_position_with_output(data_t *data, enum pipe pipe, display_commit_mode(data, pipe, flags, crc_lowres); - igt_assert_plane_visible(pipe, false); + igt_assert_plane_visible(data->drm_fd, pipe, false); /* switch back to higher resolution */ igt_output_override_mode(output, NULL); @@ -287,7 +285,7 @@ test_plane_position_with_output(data_t *data, enum pipe pipe, display_commit_mode(data, pipe, flags, crc_hires2); - igt_assert_plane_visible(pipe, true); + igt_assert_plane_visible(data->drm_fd, pipe, true); igt_pipe_crc_stop(data->pipe_crc); @@ -348,7 +346,7 @@ igt_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_plane_multiple.c b/tests/kms_plane_multiple.c index 4930286c..93dce6b0 100644 --- a/tests/kms_plane_multiple.c +++ b/tests/kms_plane_multiple.c @@ -72,7 +72,7 @@ struct { */ static void test_init(data_t *data, enum pipe pipe, int n_planes) { - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); data->plane = calloc(n_planes, sizeof(data->plane)); igt_assert_f(data->plane != NULL, "Failed to allocate memory for planes\n"); @@ -508,7 +508,7 @@ int main(int argc, char *argv[]) igt_fixture { data.drm_fd = drm_open_driver_master(DRIVER_INTEL); kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); igt_require(data.display.n_pipes > 0); } diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c index 18ba86c9..1457894a 100644 --- a/tests/kms_plane_scaling.c +++ b/tests/kms_plane_scaling.c @@ -64,7 +64,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, /* create the pipe_crc object for this pipe */ igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); /* before allocating, free if any older fb */ if (data->fb_id1) { @@ -318,7 +318,7 @@ igt_simple_main data.drm_fd = drm_open_driver(DRIVER_INTEL); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); data.devid = intel_get_drm_devid(data.drm_fd); diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index 8f6bdc0d..f66a7543 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -195,7 +195,7 @@ static bool psr_possible(data_t *data) { char buf[512]; - igt_debugfs_read("i915_edp_psr_status", buf); + igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf); return running_with_psr_disabled || strstr(buf, "Sink_Support: yes\n"); @@ -205,7 +205,7 @@ static bool psr_active(data_t *data) { char buf[512]; - igt_debugfs_read("i915_edp_psr_status", buf); + igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf); return running_with_psr_disabled || strstr(buf, "HW Enabled & Active bit: yes\n"); @@ -229,7 +229,7 @@ static void get_sink_crc(data_t *data, char *crc) { if (igt_interactive_debug) return; - file = igt_debugfs_fopen("i915_sink_crc_eDP1", "r"); + file = igt_debugfs_fopen(data->drm_fd, "i915_sink_crc_eDP1", "r"); igt_require(file); ret = fscanf(file, "%s\n", crc); diff --git a/tests/kms_pwrite_crc.c b/tests/kms_pwrite_crc.c index 1e626375..ee895db6 100644 --- a/tests/kms_pwrite_crc.c +++ b/tests/kms_pwrite_crc.c @@ -124,7 +124,7 @@ static void prepare_crtc(data_t *data) if (data->pipe_crc) igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(data->pipe, + data->pipe_crc = igt_pipe_crc_new(data->drm_fd, data->pipe, INTEL_PIPE_CRC_SOURCE_AUTO); /* get reference crc for the white fb */ @@ -183,7 +183,7 @@ igt_simple_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index 9bfcde33..43478849 100644 --- a/tests/kms_rotation_crc.c +++ b/tests/kms_rotation_crc.c @@ -139,7 +139,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, /* create the pipe_crc object for this pipe */ igt_pipe_crc_free(data->pipe_crc); - data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); mode = igt_output_get_mode(output); @@ -517,7 +517,7 @@ igt_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.gfx_fd); igt_display_init(&data.display, data.gfx_fd); } diff --git a/tests/kms_sink_crc_basic.c b/tests/kms_sink_crc_basic.c index 953ead10..f8f814f2 100644 --- a/tests/kms_sink_crc_basic.c +++ b/tests/kms_sink_crc_basic.c @@ -46,11 +46,11 @@ typedef struct { igt_plane_t *primary; } data_t; -static void get_crc(char *crc) { +static void get_crc(data_t *data, char *crc) { int ret; FILE *file; - file = igt_debugfs_fopen("i915_sink_crc_eDP1", "r"); + file = igt_debugfs_fopen(data->drm_fd, "i915_sink_crc_eDP1", "r"); igt_require(file); ret = fscanf(file, "%s\n", crc); @@ -95,7 +95,7 @@ static void basic_sink_crc_check(data_t *data) igt_display_commit(&data->display); /* It should be Green */ - get_crc(crc); + get_crc(data, crc); assert_color(crc, GREEN); /* Go Red */ @@ -103,7 +103,7 @@ static void basic_sink_crc_check(data_t *data) igt_display_commit(&data->display); /* It should be Red */ - get_crc(crc); + get_crc(data, crc); assert_color(crc, RED); } diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c index a2fe1cc1..991204ce 100644 --- a/tests/kms_universal_plane.c +++ b/tests/kms_universal_plane.c @@ -67,7 +67,7 @@ functional_test_init(functional_test_t *test, igt_output_t *output, enum pipe pi data_t *data = test->data; drmModeModeInfo *mode; - test->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + test->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); igt_output_set_pipe(output, pipe); @@ -545,13 +545,13 @@ cursor_leak_test_fini(data_t *data, } static int -i915_gem_fb_count(void) +i915_gem_fb_count(data_t *data) { char buf[1024]; FILE *fp; int count = 0; - fp = igt_debugfs_fopen("i915_gem_framebuffer", "r"); + fp = igt_debugfs_fopen(data->drm_fd, "i915_gem_framebuffer", "r"); igt_require(fp); while (fgets(buf, sizeof(buf), fp) != NULL) count++; @@ -579,7 +579,7 @@ cursor_leak_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) mode = igt_output_get_mode(output); /* Count GEM framebuffers before creating our cursor FB's */ - count1 = i915_gem_fb_count(); + count1 = i915_gem_fb_count(data); /* Black background FB */ igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, @@ -637,7 +637,7 @@ cursor_leak_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) cursor_leak_test_fini(data, output, &background_fb, cursor_fb); /* We should be back to the same framebuffer count as when we started */ - count2 = i915_gem_fb_count(); + count2 = i915_gem_fb_count(data); igt_assert_eq(count1, count2); } @@ -791,7 +791,7 @@ igt_main kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(data.drm_fd); igt_display_init(&data.display, data.drm_fd); } diff --git a/tests/perf.c b/tests/perf.c index c9c5c57e..17925eea 100644 --- a/tests/perf.c +++ b/tests/perf.c @@ -297,7 +297,7 @@ sysfs_write(const char *file, uint64_t val) } static char * -read_debugfs_record(const char *file, const char *key) +read_debugfs_record(int fd, const char *file, const char *key) { FILE *fp; char *line = NULL; @@ -306,7 +306,7 @@ read_debugfs_record(const char *file, const char *key) int key_len = strlen(key); char *value = NULL; - fp = igt_debugfs_fopen(file, "r"); + fp = igt_debugfs_fopen(fd, file, "r"); igt_require(fp); while ((len = getline(&line, &line_buf_size, fp)) > 0) { @@ -332,9 +332,9 @@ done: } static uint64_t -read_debugfs_u64_record(const char *file, const char *key) +read_debugfs_u64_record(int fd, const char *file, const char *key) { - char *str_val = read_debugfs_record(file, key); + char *str_val = read_debugfs_record(fd, file, key); uint64_t val; igt_require(str_val); @@ -2137,25 +2137,25 @@ test_rc6_disable(void) .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); - uint64_t n_events_start = read_debugfs_u64_record("i915_drpc_info", + uint64_t n_events_start = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); uint64_t n_events_end; nanosleep(&(struct timespec){ .tv_sec = 0, .tv_nsec = 500000000 }, NULL); - n_events_end = read_debugfs_u64_record("i915_drpc_info", + n_events_end = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); igt_assert_eq(n_events_end - n_events_start, 0); close(stream_fd); - n_events_start = read_debugfs_u64_record("i915_drpc_info", + n_events_start = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); nanosleep(&(struct timespec){ .tv_sec = 0, .tv_nsec = 500000000 }, NULL); - n_events_end = read_debugfs_u64_record("i915_drpc_info", + n_events_end = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); igt_assert_neq(n_events_end - n_events_start, 0); diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c index bfe58288..a741cb78 100644 --- a/tests/pm_lpsp.c +++ b/tests/pm_lpsp.c @@ -209,7 +209,7 @@ igt_main igt_require(supports_lpsp(devid)); - intel_register_access_init(intel_get_pci_device(), 0); + intel_register_access_init(intel_get_pci_device(), 0, drm_fd); kmstest_set_vt_graphics_mode(); } diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index d0600d59..e5475c91 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -657,9 +657,9 @@ static void setup_pc8(void) if (!supports_pc8_plus_residencies()) return; - pc8_status_fd = igt_debugfs_open("i915_pc8_status", O_RDONLY); + pc8_status_fd = igt_debugfs_open(drm_fd, "i915_pc8_status", O_RDONLY); if (pc8_status_fd == -1) - pc8_status_fd = igt_debugfs_open("i915_runtime_pm_status", + pc8_status_fd = igt_debugfs_open(drm_fd, "i915_runtime_pm_status", O_RDONLY); igt_assert_f(pc8_status_fd >= 0, "Can't open /sys/kernel/debug/dri/0/i915_runtime_pm_status"); @@ -919,7 +919,7 @@ static void debugfs_forcewake_user_subtest(void) disable_all_screens_and_wait(&ms_data); - fd = igt_open_forcewake_handle(); + fd = igt_open_forcewake_handle(drm_fd); igt_require(fd >= 0); if (has_runtime_pm) { diff --git a/tests/pm_sseu.c b/tests/pm_sseu.c index 3e60a5f8..317bb261 100644 --- a/tests/pm_sseu.c +++ b/tests/pm_sseu.c @@ -35,6 +35,19 @@ IGT_TEST_DESCRIPTION("Tests slice/subslice/EU power gating functionality.\n"); +struct { + int init; + int drm_fd; + int devid; + int gen; + int has_ppgtt; + drm_intel_bufmgr *bufmgr; + struct intel_batchbuffer *batch; + igt_media_spinfunc_t spinfunc; + struct igt_buf buf; + uint32_t spins_per_msec; +} gem; + static double to_dt(const struct timespec *start, const struct timespec *end) { @@ -174,7 +187,7 @@ dbg_get_status(struct status *stat) static void dbg_init(void) { - dbg.status_fd = igt_debugfs_open("i915_sseu_status", O_RDONLY); + dbg.status_fd = igt_debugfs_open(gem.drm_fd, "i915_sseu_status", O_RDONLY); igt_skip_on_f(dbg.status_fd == -1, "debugfs entry 'i915_sseu_status' not found\n"); dbg.init = 1; @@ -190,19 +203,6 @@ dbg_deinit(void) } } -struct { - int init; - int drm_fd; - int devid; - int gen; - int has_ppgtt; - drm_intel_bufmgr *bufmgr; - struct intel_batchbuffer *batch; - igt_media_spinfunc_t spinfunc; - struct igt_buf buf; - uint32_t spins_per_msec; -} gem; - static void gem_check_spin(uint32_t spins) { diff --git a/tests/prime_mmap_kms.c b/tests/prime_mmap_kms.c index e7cca54c..faace4af 100644 --- a/tests/prime_mmap_kms.c +++ b/tests/prime_mmap_kms.c @@ -246,7 +246,7 @@ igt_main igt_skip_on((check_for_dma_buf_mmap(gpu.drm_fd) != 0)); kmstest_set_vt_graphics_mode(); - igt_require_pipe_crc(); + igt_require_pipe_crc(gpu.drm_fd); igt_display_init(&gpu.display, gpu.drm_fd); } -- cgit v1.2.3