mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 01:46:14 +00:00
lib: Add a drm_open_any_render() that will try to use render nodes
I was fedup with having to run my tests as root and not being able to use my usual setup for tests that only exercise the GT part of the GPU. Render nodes to the rescue! Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit is contained in:
parent
8329acb752
commit
69c200b0bb
@ -222,6 +222,35 @@ static int __drm_open_any(void)
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int __drm_open_any_render(void)
|
||||
{
|
||||
char *name;
|
||||
int i, fd;
|
||||
|
||||
for (i = 128; i < (128 + 16); i++) {
|
||||
int ret;
|
||||
|
||||
ret = asprintf(&name, "/dev/dri/renderD%u", i);
|
||||
igt_assert(ret != -1);
|
||||
|
||||
fd = open(name, O_RDWR);
|
||||
free(name);
|
||||
|
||||
if (fd == -1)
|
||||
continue;
|
||||
|
||||
if (!is_intel(fd)) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void quiescent_gpu_at_exit(int sig)
|
||||
{
|
||||
int fd;
|
||||
@ -233,6 +262,17 @@ static void quiescent_gpu_at_exit(int sig)
|
||||
}
|
||||
}
|
||||
|
||||
static void quiescent_gpu_at_exit_render(int sig)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = __drm_open_any_render();
|
||||
if (fd >= 0) {
|
||||
gem_quiescent_gpu(fd);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
int drm_open_any(void)
|
||||
{
|
||||
static int open_count;
|
||||
@ -249,6 +289,24 @@ int drm_open_any(void)
|
||||
return fd;
|
||||
}
|
||||
|
||||
int drm_open_any_render(void)
|
||||
{
|
||||
static int open_count;
|
||||
int fd = __drm_open_any_render();
|
||||
|
||||
/* no render nodes, fallback to drm_open_any() */
|
||||
if (fd == -1)
|
||||
return drm_open_any();
|
||||
|
||||
if (__sync_fetch_and_add(&open_count, 1))
|
||||
return fd;
|
||||
|
||||
gem_quiescent_gpu(fd);
|
||||
igt_install_exit_handler(quiescent_gpu_at_exit_render);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int __gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
|
||||
{
|
||||
struct drm_i915_gem_set_tiling st;
|
||||
|
@ -50,6 +50,7 @@ drm_intel_bo * gem_handle_to_libdrm_bo(drm_intel_bufmgr *bufmgr, int fd,
|
||||
|
||||
int drm_get_card(void);
|
||||
int drm_open_any(void);
|
||||
int drm_open_any_render(void);
|
||||
|
||||
void gem_quiescent_gpu(int fd);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user