mirror of
				https://github.com/tiagovignatti/intel-gpu-tools.git
				synced 2025-11-04 12:07:12 +00:00 
			
		
		
		
	tests: use lib igt_[get|set]_stop_rings()
on gem_reset_stats, kms_flip and pm_rps. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75876 Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
This commit is contained in:
		
							parent
							
								
									bfa6fa9a4b
								
							
						
					
					
						commit
						d983a47f14
					
				@ -242,38 +242,10 @@ static int exec_valid(int fd, int ctx)
 | 
			
		||||
	return exec_valid_ring(fd, ctx, current_ring->exec);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void stop_rings(const int mask)
 | 
			
		||||
{
 | 
			
		||||
	int fd;
 | 
			
		||||
	char buf[80];
 | 
			
		||||
 | 
			
		||||
	igt_assert((mask & ~((1 << NUM_RINGS) - 1)) == 0);
 | 
			
		||||
	igt_assert(snprintf(buf, sizeof(buf), "0x%02x", mask) == 4);
 | 
			
		||||
	fd = igt_debugfs_open("i915_ring_stop", O_WRONLY);
 | 
			
		||||
	igt_assert(fd >= 0);
 | 
			
		||||
 | 
			
		||||
	igt_assert(write(fd, buf, 4) == 4);
 | 
			
		||||
	close(fd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define BUFSIZE (4 * 1024)
 | 
			
		||||
#define ITEMS   (BUFSIZE >> 2)
 | 
			
		||||
 | 
			
		||||
static int ring_to_mask(int ring)
 | 
			
		||||
{
 | 
			
		||||
	for (unsigned i = 0; i < NUM_RINGS; i++) {
 | 
			
		||||
		const struct target_ring *r = &rings[i];
 | 
			
		||||
 | 
			
		||||
		if (r->exec == ring)
 | 
			
		||||
			return (1 << i);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	igt_assert(0);
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int inject_hang_ring(int fd, int ctx, int ring)
 | 
			
		||||
static int inject_hang_ring(int fd, int ctx, int ring, bool ignore_ban_error)
 | 
			
		||||
{
 | 
			
		||||
	struct drm_i915_gem_execbuffer2 execbuf;
 | 
			
		||||
	struct drm_i915_gem_exec_object2 exec;
 | 
			
		||||
@ -281,6 +253,7 @@ static int inject_hang_ring(int fd, int ctx, int ring)
 | 
			
		||||
	uint32_t *buf;
 | 
			
		||||
	int roff, i;
 | 
			
		||||
	unsigned cmd_len = 2;
 | 
			
		||||
	enum stop_ring_flags flags;
 | 
			
		||||
 | 
			
		||||
	srandom(time(NULL));
 | 
			
		||||
 | 
			
		||||
@ -364,14 +337,26 @@ static int inject_hang_ring(int fd, int ctx, int ring)
 | 
			
		||||
 | 
			
		||||
	free(buf);
 | 
			
		||||
 | 
			
		||||
	stop_rings(ring_to_mask(ring));
 | 
			
		||||
	flags = igt_to_stop_ring_flag(ring);
 | 
			
		||||
 | 
			
		||||
	flags |= STOP_RING_ALLOW_BAN;
 | 
			
		||||
 | 
			
		||||
	if (!ignore_ban_error)
 | 
			
		||||
		flags |= STOP_RING_ALLOW_ERRORS;
 | 
			
		||||
 | 
			
		||||
	igt_set_stop_rings(flags);
 | 
			
		||||
 | 
			
		||||
	return exec.handle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int inject_hang(int fd, int ctx)
 | 
			
		||||
{
 | 
			
		||||
	return inject_hang_ring(fd, ctx, current_ring->exec);
 | 
			
		||||
	return inject_hang_ring(fd, ctx, current_ring->exec, false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int inject_hang_no_ban_error(int fd, int ctx)
 | 
			
		||||
{
 | 
			
		||||
	return inject_hang_ring(fd, ctx, current_ring->exec, true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _assert_reset_status(int fd, int ctx, int status)
 | 
			
		||||
@ -553,7 +538,7 @@ static void test_ban(void)
 | 
			
		||||
	assert_reset_status(fd_bad, 0, RS_NO_ERROR);
 | 
			
		||||
	assert_reset_status(fd_good, 0, RS_NO_ERROR);
 | 
			
		||||
 | 
			
		||||
	h2 = inject_hang(fd_bad, 0);
 | 
			
		||||
	h2 = inject_hang_no_ban_error(fd_bad, 0);
 | 
			
		||||
	igt_assert(h2 >= 0);
 | 
			
		||||
	active_count++;
 | 
			
		||||
	/* Second hang will be pending for this */
 | 
			
		||||
@ -563,7 +548,7 @@ static void test_ban(void)
 | 
			
		||||
	h7 = exec_valid(fd_good, 0);
 | 
			
		||||
 | 
			
		||||
        while (retry--) {
 | 
			
		||||
                h3 = inject_hang(fd_bad, 0);
 | 
			
		||||
                h3 = inject_hang_no_ban_error(fd_bad, 0);
 | 
			
		||||
                igt_assert(h3 >= 0);
 | 
			
		||||
                gem_sync(fd_bad, h3);
 | 
			
		||||
		active_count++;
 | 
			
		||||
@ -645,7 +630,7 @@ static void test_ban_ctx(void)
 | 
			
		||||
	assert_reset_status(fd, ctx_good, RS_NO_ERROR);
 | 
			
		||||
	assert_reset_status(fd, ctx_bad, RS_NO_ERROR);
 | 
			
		||||
 | 
			
		||||
	h2 = inject_hang(fd, ctx_bad);
 | 
			
		||||
	h2 = inject_hang_no_ban_error(fd, ctx_bad);
 | 
			
		||||
	igt_assert(h2 >= 0);
 | 
			
		||||
	active_count++;
 | 
			
		||||
	/* Second hang will be pending for this */
 | 
			
		||||
@ -655,7 +640,7 @@ static void test_ban_ctx(void)
 | 
			
		||||
	h7 = exec_valid(fd, ctx_good);
 | 
			
		||||
 | 
			
		||||
        while (retry--) {
 | 
			
		||||
                h3 = inject_hang(fd, ctx_bad);
 | 
			
		||||
                h3 = inject_hang_no_ban_error(fd, ctx_bad);
 | 
			
		||||
                igt_assert(h3 >= 0);
 | 
			
		||||
                gem_sync(fd, h3);
 | 
			
		||||
		active_count++;
 | 
			
		||||
 | 
			
		||||
@ -44,6 +44,7 @@
 | 
			
		||||
#include "intel_batchbuffer.h"
 | 
			
		||||
#include "igt_kms.h"
 | 
			
		||||
#include "igt_aux.h"
 | 
			
		||||
#include "igt_debugfs.h"
 | 
			
		||||
 | 
			
		||||
#define TEST_DPMS		(1 << 0)
 | 
			
		||||
#define TEST_WITH_DUMMY_BCS	(1 << 1)
 | 
			
		||||
@ -692,35 +693,17 @@ static void set_y_tiling(struct test_output *o, int fb_idx)
 | 
			
		||||
 | 
			
		||||
static void stop_rings(bool stop)
 | 
			
		||||
{
 | 
			
		||||
	static const char dfs_base[] = "/sys/kernel/debug/dri";
 | 
			
		||||
	static const char dfs_entry[] = "i915_ring_stop";
 | 
			
		||||
	static const char stop_data[] = "0xf";
 | 
			
		||||
	static const char run_data[] = "0x0";
 | 
			
		||||
	char fname[FILENAME_MAX];
 | 
			
		||||
	int card_index = drm_get_card();
 | 
			
		||||
	int fd;
 | 
			
		||||
 | 
			
		||||
	snprintf(fname, FILENAME_MAX, "%s/%i/%s",
 | 
			
		||||
		 dfs_base, card_index, dfs_entry);
 | 
			
		||||
 | 
			
		||||
	fd = open(fname, O_WRONLY);
 | 
			
		||||
	igt_assert(fd >= 0);
 | 
			
		||||
 | 
			
		||||
	if (stop)
 | 
			
		||||
		igt_assert(write(fd, stop_data, sizeof(stop_data)) == sizeof(stop_data));
 | 
			
		||||
		igt_set_stop_rings(STOP_RING_DEFAULTS);
 | 
			
		||||
	else
 | 
			
		||||
		igt_assert(write(fd, run_data, sizeof(run_data)) == sizeof(run_data));
 | 
			
		||||
 | 
			
		||||
	close(fd);
 | 
			
		||||
		igt_set_stop_rings(STOP_RING_NONE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void eat_error_state(void)
 | 
			
		||||
{
 | 
			
		||||
	static const char dfs_base[] = "/sys/kernel/debug/dri";
 | 
			
		||||
	static const char dfs_entry_error[] = "i915_error_state";
 | 
			
		||||
	static const char dfs_entry_stop[] = "i915_ring_stop";
 | 
			
		||||
	static const char data[] = "";
 | 
			
		||||
	static char tmp[128];
 | 
			
		||||
	char fname[FILENAME_MAX];
 | 
			
		||||
	int card_index = drm_get_card();
 | 
			
		||||
	int fd;
 | 
			
		||||
@ -739,16 +722,9 @@ static void eat_error_state(void)
 | 
			
		||||
 | 
			
		||||
	/* and check whether stop_rings is not reset, i.e. the hang has indeed
 | 
			
		||||
	 * happened */
 | 
			
		||||
	snprintf(fname, FILENAME_MAX, "%s/%i/%s",
 | 
			
		||||
		 dfs_base, card_index, dfs_entry_stop);
 | 
			
		||||
 | 
			
		||||
	fd = open(fname, O_RDONLY);
 | 
			
		||||
	igt_assert(fd >= 0);
 | 
			
		||||
 | 
			
		||||
	igt_assert(read(fd, tmp, sizeof tmp) > 0);
 | 
			
		||||
 | 
			
		||||
	igt_assert_f(atoi(tmp) == 0,
 | 
			
		||||
		     "no gpu hang detected, stop_rings is still %s\n", tmp);
 | 
			
		||||
	igt_assert_f(igt_get_stop_rings() == STOP_RING_NONE,
 | 
			
		||||
		     "no gpu hang detected, stop_rings is still 0x%x\n",
 | 
			
		||||
		     igt_get_stop_rings());
 | 
			
		||||
 | 
			
		||||
	close(fd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -306,37 +306,6 @@ static void load_helper_deinit(void)
 | 
			
		||||
		drm_intel_bufmgr_destroy(lh.bufmgr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void stop_rings(void)
 | 
			
		||||
{
 | 
			
		||||
	int fd;
 | 
			
		||||
	static const char data[] = "0xf";
 | 
			
		||||
 | 
			
		||||
	fd = igt_debugfs_open("i915_ring_stop", O_WRONLY);
 | 
			
		||||
	igt_assert(fd >= 0);
 | 
			
		||||
 | 
			
		||||
	igt_debug("injecting ring stop\n");
 | 
			
		||||
	igt_assert(write(fd, data, sizeof(data)) == sizeof(data));
 | 
			
		||||
 | 
			
		||||
	close(fd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool rings_stopped(void)
 | 
			
		||||
{
 | 
			
		||||
	int fd;
 | 
			
		||||
	static char buf[128];
 | 
			
		||||
	unsigned long long val;
 | 
			
		||||
 | 
			
		||||
	fd = igt_debugfs_open("i915_ring_stop", O_RDONLY);
 | 
			
		||||
	igt_assert(fd >= 0);
 | 
			
		||||
 | 
			
		||||
	igt_assert(read(fd, buf, sizeof(buf)) > 0);
 | 
			
		||||
	close(fd);
 | 
			
		||||
 | 
			
		||||
	sscanf(buf, "%llx", &val);
 | 
			
		||||
 | 
			
		||||
	return (bool)val;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void min_max_config(void (*check)(void))
 | 
			
		||||
{
 | 
			
		||||
	int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
 | 
			
		||||
@ -499,8 +468,8 @@ static void reset(void)
 | 
			
		||||
	stabilize_check(pre_freqs);
 | 
			
		||||
 | 
			
		||||
	igt_debug("Stop rings...\n");
 | 
			
		||||
	stop_rings();
 | 
			
		||||
	while (rings_stopped())
 | 
			
		||||
	igt_set_stop_rings(STOP_RING_DEFAULTS);
 | 
			
		||||
	while (igt_get_stop_rings())
 | 
			
		||||
		usleep(1000 * 100);
 | 
			
		||||
	igt_debug("Ring stop cleared\n");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user