mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 10:26:12 +00:00
tests: use igt_debugfs where possible
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
4f689d52e7
commit
c049c39f35
@ -42,6 +42,7 @@
|
|||||||
#include "igt_kms.h"
|
#include "igt_kms.h"
|
||||||
#include "igt_aux.h"
|
#include "igt_aux.h"
|
||||||
#include "intel_chipset.h"
|
#include "intel_chipset.h"
|
||||||
|
#include "igt_debugfs.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There hasn't been a release of libdrm containing these #define's yet, so
|
* There hasn't been a release of libdrm containing these #define's yet, so
|
||||||
@ -308,30 +309,6 @@ void kmstest_set_vt_graphics_mode(void)
|
|||||||
igt_debug("VT: graphics mode set\n");
|
igt_debug("VT: graphics mode set\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_card_number(int fd)
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
/* find the minor number of the device */
|
|
||||||
fstat(fd, &buf);
|
|
||||||
|
|
||||||
return minor(buf.st_rdev) & 0x3f;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector,
|
|
||||||
const char *file)
|
|
||||||
{
|
|
||||||
char *path;
|
|
||||||
|
|
||||||
asprintf(&path, "/sys/kernel/debug/dri/%d/%s-%d/%s",
|
|
||||||
get_card_number(drm_fd),
|
|
||||||
kmstest_connector_type_str(connector->connector_type),
|
|
||||||
connector->connector_type_id,
|
|
||||||
file);
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kmstest_force_connector:
|
* kmstest_force_connector:
|
||||||
* @fd: drm file descriptor
|
* @fd: drm file descriptor
|
||||||
@ -377,8 +354,10 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = get_debugfs_connector_path(drm_fd, connector, "force");
|
asprintf(&path, "%s-%d/force",
|
||||||
debugfs_fd = open(path, O_WRONLY | O_TRUNC);
|
kmstest_connector_type_str(connector->connector_type),
|
||||||
|
connector->connector_type_id);
|
||||||
|
debugfs_fd = igt_debugfs_open(path, O_WRONLY | O_TRUNC);
|
||||||
|
|
||||||
if (debugfs_fd == -1) {
|
if (debugfs_fd == -1) {
|
||||||
return false;
|
return false;
|
||||||
@ -435,10 +414,10 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
|
|||||||
char *path;
|
char *path;
|
||||||
int debugfs_fd, ret;
|
int debugfs_fd, ret;
|
||||||
|
|
||||||
path = get_debugfs_connector_path(drm_fd, connector, "edid_override");
|
asprintf(&path, "%s-%d/edid_override",
|
||||||
|
kmstest_connector_type_str(connector->connector_type),
|
||||||
debugfs_fd = open(path, O_WRONLY | O_TRUNC);
|
connector->connector_type_id);
|
||||||
|
debugfs_fd = igt_debugfs_open(path, O_WRONLY | O_TRUNC);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
igt_assert(debugfs_fd != -1);
|
igt_assert(debugfs_fd != -1);
|
||||||
|
@ -52,16 +52,11 @@ int fd;
|
|||||||
static int get_object_count(void)
|
static int get_object_count(void)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int ret, scanned;
|
int scanned, ret;
|
||||||
int device = drm_get_card();
|
|
||||||
char *path;
|
|
||||||
|
|
||||||
igt_drop_caches_set(DROP_RETIRE);
|
igt_drop_caches_set(DROP_RETIRE);
|
||||||
|
|
||||||
ret = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_gem_objects", device);
|
file = igt_debugfs_fopen("i915_gem_objects", "r");
|
||||||
igt_assert(ret != -1);
|
|
||||||
|
|
||||||
file = fopen(path, "r");
|
|
||||||
|
|
||||||
scanned = fscanf(file, "%i objects", &ret);
|
scanned = fscanf(file, "%i objects", &ret);
|
||||||
igt_assert(scanned == 1);
|
igt_assert(scanned == 1);
|
||||||
|
@ -679,20 +679,11 @@ static void stop_rings(bool stop)
|
|||||||
|
|
||||||
static void eat_error_state(void)
|
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_error[] = "i915_error_state";
|
||||||
static const char data[] = "";
|
static const char data[] = "";
|
||||||
char fname[FILENAME_MAX];
|
|
||||||
int card_index = drm_get_card();
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
igt_assert(card_index != -1);
|
fd = igt_debugfs_open(dfs_entry_error, O_WRONLY);
|
||||||
|
|
||||||
/* clear the error state */
|
|
||||||
snprintf(fname, FILENAME_MAX, "%s/%i/%s",
|
|
||||||
dfs_base, card_index, dfs_entry_error);
|
|
||||||
|
|
||||||
fd = open(fname, O_WRONLY);
|
|
||||||
igt_assert(fd >= 0);
|
igt_assert(fd >= 0);
|
||||||
|
|
||||||
igt_assert(write(fd, data, sizeof(data)) == sizeof(data));
|
igt_assert(write(fd, data, sizeof(data)) == sizeof(data));
|
||||||
|
@ -50,7 +50,9 @@ typedef struct {
|
|||||||
|
|
||||||
static void get_crc(char *crc) {
|
static void get_crc(char *crc) {
|
||||||
int ret;
|
int ret;
|
||||||
FILE *file = fopen("/sys/kernel/debug/dri/0/i915_sink_crc_eDP1", "r");
|
FILE *file;
|
||||||
|
|
||||||
|
file = igt_debugfs_fopen("i915_sink_crc_eDP1", "r");
|
||||||
igt_require(file);
|
igt_require(file);
|
||||||
|
|
||||||
ret = fscanf(file, "%s\n", crc);
|
ret = fscanf(file, "%s\n", crc);
|
||||||
|
@ -663,8 +663,7 @@ static void setup_pc8(void)
|
|||||||
if (!supports_pc8_plus_residencies())
|
if (!supports_pc8_plus_residencies())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pc8_status_fd = open("/sys/kernel/debug/dri/0/i915_pc8_status",
|
pc8_status_fd = igt_debugfs_open("i915_pc8_status", O_RDONLY);
|
||||||
O_RDONLY);
|
|
||||||
igt_assert_f(pc8_status_fd >= 0,
|
igt_assert_f(pc8_status_fd >= 0,
|
||||||
"Can't open /sys/kernel/debug/dri/0/i915_pc8_status");
|
"Can't open /sys/kernel/debug/dri/0/i915_pc8_status");
|
||||||
|
|
||||||
|
@ -216,15 +216,10 @@ static int get_object_count(void)
|
|||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int ret, scanned;
|
int ret, scanned;
|
||||||
int device = drm_get_card();
|
|
||||||
char *path;
|
|
||||||
|
|
||||||
igt_drop_caches_set(DROP_RETIRE);
|
igt_drop_caches_set(DROP_RETIRE);
|
||||||
|
|
||||||
ret = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_gem_objects", device);
|
file = igt_debugfs_fopen("i915_gem_objects", "r");
|
||||||
igt_assert(ret != -1);
|
|
||||||
|
|
||||||
file = fopen(path, "r");
|
|
||||||
|
|
||||||
scanned = fscanf(file, "%i objects", &ret);
|
scanned = fscanf(file, "%i objects", &ret);
|
||||||
igt_assert(scanned == 1);
|
igt_assert(scanned == 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user