Commit 83884e97 authored by Chris Wilson's avatar Chris Wilson

Restore "lib: Open debugfs files for the given DRM device"

This reverts commit 25fbae15, restoring
commit 301ad44c
Author: Tomeu Vizoso <tomeu.vizoso@collabora.com>
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's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 25fbae15
......@@ -470,7 +470,7 @@ static int run(int seconds,
if (gen < 6)
return IGT_EXIT_SKIP; /* Needs BCS timestamp */
intel_register_access_init(intel_get_pci_device(), false);
intel_register_access_init(intel_get_pci_device(), false, fd);
if (gen == 6)
timestamp_reg = REG(RCS_TIMESTAMP);
......
......@@ -183,7 +183,7 @@ void gem_quiescent_gpu(int fd)
gem_sync(fd, obj.handle);
gem_close(fd, obj.handle);
igt_drop_caches_set(DROP_RETIRE | DROP_FREED);
igt_drop_caches_set(fd, DROP_RETIRE | DROP_FREED);
}
/**
......
......@@ -350,10 +350,10 @@ void igt_stop_signal_helper(void)
}
static struct igt_helper_process shrink_helper;
static void __attribute__((noreturn)) shrink_helper_process(pid_t pid)
static void __attribute__((noreturn)) shrink_helper_process(int fd, pid_t pid)
{
while (1) {
igt_drop_caches_set(DROP_SHRINK_ALL);
igt_drop_caches_set(fd, DROP_SHRINK_ALL);
usleep(1000 * 1000 / 50);
if (kill(pid, 0)) /* Parent has died, so must we. */
exit(0);
......@@ -370,12 +370,12 @@ static void __attribute__((noreturn)) shrink_helper_process(pid_t pid)
*
* This should only be used from an igt_fixture.
*/
void igt_fork_shrink_helper(void)
void igt_fork_shrink_helper(int drm_fd)
{
assert(!igt_only_list_subtests());
igt_require(igt_drop_caches_has(DROP_SHRINK_ALL));
igt_require(igt_drop_caches_has(drm_fd, DROP_SHRINK_ALL));
igt_fork_helper(&shrink_helper)
shrink_helper_process(getppid());
shrink_helper_process(drm_fd, getppid());
}
/**
......
......@@ -51,7 +51,7 @@ extern int num_trash_bos;
void igt_fork_signal_helper(void);
void igt_stop_signal_helper(void);
void igt_fork_shrink_helper(void);
void igt_fork_shrink_helper(int fd);
void igt_stop_shrink_helper(void);
void igt_fork_hang_detector(int fd);
......@@ -198,7 +198,7 @@ void igt_debug_manual_check(const char *var, const char *expected);
/* These are separate to allow easier testing when porting, see the comment at
* the bottom of intel_os.c. */
void intel_purge_vm_caches(void);
void intel_purge_vm_caches(int fd);
uint64_t intel_get_avail_ram_mb(void);
uint64_t intel_get_total_ram_mb(void);
uint64_t intel_get_total_swap_mb(void);
......
This diff is collapsed.
......@@ -33,11 +33,11 @@ enum pipe;
const char *igt_debugfs_mount(void);
int igt_debugfs_open(const char *filename, int mode);
FILE *igt_debugfs_fopen(const char *filename,
int igt_debugfs_open(int fd, const char *filename, int mode);
FILE *igt_debugfs_fopen(int fd, const char *filename,
const char *mode);
void __igt_debugfs_read(const char *filename, char *buf, int buf_size);
bool igt_debugfs_search(const char *filename, const char *substring);
void __igt_debugfs_read(int fd, const char *filename, char *buf, int buf_size);
bool igt_debugfs_search(int fd, const char *filename, const char *substring);
/**
* igt_debugfs_read:
......@@ -47,8 +47,8 @@ bool igt_debugfs_search(const char *filename, const char *substring);
* This is just a convenience wrapper for __igt_debugfs_read. See its
* documentation.
*/
#define igt_debugfs_read(filename, buf) \
__igt_debugfs_read((filename), (buf), sizeof(buf))
#define igt_debugfs_read(fd, filename, buf) \
__igt_debugfs_read(fd, (filename), (buf), sizeof(buf))
/*
* Pipe CRC
......@@ -116,11 +116,11 @@ enum intel_pipe_crc_source {
void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b);
char *igt_crc_to_string(igt_crc_t *crc);
void igt_require_pipe_crc(void);
void igt_require_pipe_crc(int fd);
igt_pipe_crc_t *
igt_pipe_crc_new(enum pipe pipe, enum intel_pipe_crc_source source);
igt_pipe_crc_new(int fd, enum pipe pipe, enum intel_pipe_crc_source source);
igt_pipe_crc_t *
igt_pipe_crc_new_nonblock(enum pipe pipe, enum intel_pipe_crc_source source);
igt_pipe_crc_new_nonblock(int fd, enum pipe pipe, enum intel_pipe_crc_source source);
void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
......@@ -129,10 +129,10 @@ int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
igt_crc_t **out_crcs);
void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
void igt_hpd_storm_set_threshold(unsigned int threshold);
void igt_hpd_storm_reset(void);
bool igt_hpd_storm_detected(void);
void igt_require_hpd_storm_ctl(void);
void igt_hpd_storm_set_threshold(int fd, unsigned int threshold);
void igt_hpd_storm_reset(int fd);
bool igt_hpd_storm_detected(int fd);
void igt_require_hpd_storm_ctl(int fd);
/*
* Drop caches
......@@ -188,8 +188,8 @@ void igt_require_hpd_storm_ctl(void);
DROP_ACTIVE | \
DROP_FREED)
bool igt_drop_caches_has(uint64_t val);
void igt_drop_caches_set(uint64_t val);
bool igt_drop_caches_has(int fd, uint64_t val);
void igt_drop_caches_set(int fd, uint64_t val);
/*
* Prefault control
......
......@@ -360,14 +360,14 @@ void igt_post_hang_ring(int fd, igt_hang_t arg)
* stuck, either because the test manually disabled gpu resets or because the
* test hit an hangcheck bug
*/
void igt_force_gpu_reset(void)
void igt_force_gpu_reset(int drm_fd)
{
FILE *file;
int fd, ret, wedged;
igt_debug("Triggering GPU reset\n");
fd = igt_debugfs_open("i915_wedged", O_RDWR);
fd = igt_debugfs_open(drm_fd, "i915_wedged", O_RDWR);
igt_require(fd >= 0);
ret = write(fd, "-1\n", 3);
......@@ -375,7 +375,7 @@ void igt_force_gpu_reset(void)
igt_assert_eq(ret, 3);
file = igt_debugfs_fopen("i915_wedged", "r");
file = igt_debugfs_fopen(drm_fd, "i915_wedged", "r");
igt_assert(file);
wedged = 1;
......@@ -451,11 +451,11 @@ void igt_stop_hang_helper(void)
* Returns:
* The file descriptor of the forcewake handle or -1 if that didn't work out.
*/
int igt_open_forcewake_handle(void)
int igt_open_forcewake_handle(int fd)
{
if (getenv("IGT_NO_FORCEWAKE"))
return -1;
return igt_debugfs_open("i915_forcewake_user", O_WRONLY);
return igt_debugfs_open(fd, "i915_forcewake_user", O_WRONLY);
}
#if defined(__x86_64__) || defined(__i386__)
......@@ -543,13 +543,13 @@ unsigned intel_detect_and_clear_missed_interrupts(int fd)
gem_quiescent_gpu(fd);
file = igt_debugfs_fopen("i915_ring_missed_irq", "r");
file = igt_debugfs_fopen(fd, "i915_ring_missed_irq", "r");
if (file) {
igt_assert(fscanf(file, "%x", &missed) == 1);
fclose(file);
}
if (missed) {
file = igt_debugfs_fopen("i915_ring_missed_irq", "w");
file = igt_debugfs_fopen(fd, "i915_ring_missed_irq", "w");
if (file) {
fwrite("0\n", 1, 2, file);
fclose(file);
......
......@@ -51,12 +51,12 @@ igt_hang_t igt_hang_ctx(int fd,
igt_hang_t igt_hang_ring(int fd, int ring);
void igt_post_hang_ring(int fd, igt_hang_t arg);
void igt_force_gpu_reset(void);
void igt_force_gpu_reset(int fd);
void igt_fork_hang_helper(void);
void igt_stop_hang_helper(void);
int igt_open_forcewake_handle(void);
int igt_open_forcewake_handle(int fd);
int igt_setup_clflush(void);
void igt_clflush_range(void *addr, int size);
......
......@@ -747,7 +747,7 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
igt_assert_neq(asprintf(&path, "%s-%d/edid_override", kmstest_connector_type_str(connector->connector_type), connector->connector_type_id),
-1);
debugfs_fd = igt_debugfs_open(path, O_WRONLY | O_TRUNC);
debugfs_fd = igt_debugfs_open(drm_fd, path, O_WRONLY | O_TRUNC);
free(path);
igt_assert(debugfs_fd != -1);
......@@ -1324,7 +1324,7 @@ static void parse_crtc(char *info, struct kmstest_crtc *crtc)
igt_assert_eq(ret, 2);
}
void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc)
void kmstest_get_crtc(int fd, enum pipe pipe, struct kmstest_crtc *crtc)
{
char tmp[256];
FILE *fid;
......@@ -1333,7 +1333,7 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc)
int line;
long int n;
fid = igt_debugfs_fopen("i915_display_info", mode);
fid = igt_debugfs_fopen(fd, "i915_display_info", mode);
igt_skip_on(fid == NULL);
......@@ -1370,13 +1370,13 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc)
igt_skip_on(ncrtc == 0);
}
void igt_assert_plane_visible(enum pipe pipe, bool visibility)
void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility)
{
struct kmstest_crtc crtc;
int i;
bool visible;
kmstest_get_crtc(pipe, &crtc);
kmstest_get_crtc(fd, pipe, &crtc);
visible = true;
for (i = 0; i < crtc.n_planes; i++) {
......
......@@ -215,8 +215,8 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
unsigned prot);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc);
void igt_assert_plane_visible(enum pipe pipe, bool visibility);
void kmstest_get_crtc(int fd, enum pipe pipe, struct kmstest_crtc *crtc);
void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility);
/*
* A small modeset API
......
......@@ -36,7 +36,7 @@ extern void *igt_global_mmio;
void intel_mmio_use_pci_bar(struct pci_device *pci_dev);
void intel_mmio_use_dump_file(char *file);
int intel_register_access_init(struct pci_device *pci_dev, int safe);
int intel_register_access_init(struct pci_device *pci_dev, int safe, int fd);
void intel_register_access_fini(void);
uint32_t intel_register_read(uint32_t reg);
void intel_register_write(uint32_t reg, uint32_t val);
......
......@@ -165,7 +165,7 @@ release_forcewake_lock(int fd)
* @pci_dev can be obtained from intel_get_pci_device().
*/
int
intel_register_access_init(struct pci_device *pci_dev, int safe)
intel_register_access_init(struct pci_device *pci_dev, int safe, int fd)
{
int ret;
......@@ -187,7 +187,7 @@ intel_register_access_init(struct pci_device *pci_dev, int safe)
/* Find where the forcewake lock is. Forcewake doesn't exist
* gen < 6, but the debugfs should do the right things for us.
*/
ret = igt_open_forcewake_handle();
ret = igt_open_forcewake_handle(fd);
if (ret == -1)
mmio_data.key = FAKEKEY;
else
......
......@@ -97,8 +97,11 @@ intel_get_avail_ram_mb(void)
#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */
struct sysinfo sysinf;
int fd;
intel_purge_vm_caches();
fd = drm_open_driver(DRIVER_INTEL);
intel_purge_vm_caches(fd);
close(fd);
igt_assert(sysinfo(&sysinf) == 0);
retval = sysinf.freeram;
......@@ -292,11 +295,11 @@ void intel_require_memory(uint64_t count, uint64_t size, unsigned mode)
igt_skip_on_simulation();
}
void intel_purge_vm_caches(void)
void intel_purge_vm_caches(int drm_fd)
{
int fd;
igt_drop_caches_set(DROP_SHRINK_ALL);
igt_drop_caches_set(drm_fd, DROP_SHRINK_ALL);
fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
if (fd >= 0) {
......
......@@ -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) \
......
......@@ -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!");
}
}
......
......@@ -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);
}
......@@ -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);
......
......@@ -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);
......
......@@ -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");
......
......@@ -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);
......
......@@ -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++) {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
}
}
......
......@@ -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);
}
......
......@@ -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);
}
}
}
......
......@@ -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);
......
......@@ -217,7 +217,7 @@ igt_main
}
igt_subtest("aperture-shrink") {
igt_fork_shrink_helper();
igt_fork_shrink_helper(fd);