diff options
-rw-r--r-- | lib/igt_sysfs.c | 23 | ||||
-rw-r--r-- | lib/igt_sysfs.h | 1 | ||||
-rw-r--r-- | tests/gem_exec_nop.c | 42 | ||||
-rw-r--r-- | tests/gem_exec_whisper.c | 41 | ||||
-rw-r--r-- | tests/gem_sync.c | 41 |
5 files changed, 148 insertions, 0 deletions
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c index 61b94c64..1cf7f710 100644 --- a/lib/igt_sysfs.c +++ b/lib/igt_sysfs.c @@ -119,6 +119,29 @@ int igt_sysfs_open(int fd, int *idx) } /** + * igt_sysfs_open_parameters: + * @device: fd of the device (or -1 to default to Intel) + * + * This opens the module parameters directory (under sysfs) corresponding + * to the device for use with igt_sysfs_set() and igt_sysfs_get(). + * + * Returns: + * The directory fd, or -1 on failure. + */ +int igt_sysfs_open_parameters(int fd) +{ + int dir, params; + + dir = igt_sysfs_open(fd, ¶ms); + if (dir < 0) + return -1; + + params = openat(dir, "device/driver/module/parameters", O_RDONLY); + close(dir); + + return params; +} +/** * igt_sysfs_set: * @dir: directory for the device from igt_sysfs_open() * @attr: name of the sysfs node to open diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h index 5c49f64f..51c7910d 100644 --- a/lib/igt_sysfs.h +++ b/lib/igt_sysfs.h @@ -28,6 +28,7 @@ #include <stdbool.h> int igt_sysfs_open(int device, int *idx); +int igt_sysfs_open_parameters(int fd); bool igt_sysfs_set(int dir, const char *attr, const char *value); char *igt_sysfs_get(int dir, const char *attr); diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c index 9e5aab50..dc7f5143 100644 --- a/tests/gem_exec_nop.c +++ b/tests/gem_exec_nop.c @@ -26,6 +26,7 @@ */ #include "igt.h" +#include "igt_sysfs.h" #include <unistd.h> #include <stdlib.h> #include <stdint.h> @@ -196,6 +197,45 @@ static void all(int fd, uint32_t handle, int timeout) 1e6*time, 1e6*min, 1e6*max, 1e6*(max + 10*min/9)); } +static void print_welcome(int fd) +{ + bool active; + char *str; + int dir; + + dir = igt_sysfs_open_parameters(fd); + if (dir < 0) + return; + + str = igt_sysfs_get(dir, "enable_guc_submission"); + active = str && atoi(str) > 0; + free(str); + + if (active) { + igt_info("Using GuC submission\n"); + goto out; + } + + str = igt_sysfs_get(dir, "enable_execlists"); + active = str && atoi(str) > 0; + free(str); + + if (active) { + igt_info("Using Execlists submission\n"); + goto out; + } + + str = igt_sysfs_get(dir, "semaphores"); + active = str && atoi(str) > 0; + free(str); + + igt_info("Using Legacy submission %s\n", + active ? ", with semaphores" : ""); + +out: + close(dir); +} + igt_main { const struct intel_execution_engine *e; @@ -206,6 +246,8 @@ igt_main const uint32_t bbe = MI_BATCH_BUFFER_END; device = drm_open_driver(DRIVER_INTEL); + print_welcome(device); + handle = gem_create(device, 4096); gem_write(device, handle, 0, &bbe, sizeof(bbe)); diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c index ec179304..eeaa21f1 100644 --- a/tests/gem_exec_whisper.c +++ b/tests/gem_exec_whisper.c @@ -29,6 +29,7 @@ #include "igt.h" #include "igt_gt.h" +#include "igt_sysfs.h" #define LOCAL_I915_EXEC_NO_RELOC (1<<11) #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) @@ -391,6 +392,45 @@ static void whisper(int fd, unsigned engine, unsigned flags) gem_close(fd, batches[n].handle); } +static void print_welcome(int fd) +{ + bool active; + char *str; + int dir; + + dir = igt_sysfs_open_parameters(fd); + if (dir < 0) + return; + + str = igt_sysfs_get(dir, "enable_guc_submission"); + active = str && atoi(str) > 0; + free(str); + + if (active) { + igt_info("Using GuC submission\n"); + goto out; + } + + str = igt_sysfs_get(dir, "enable_execlists"); + active = str && atoi(str) > 0; + free(str); + + if (active) { + igt_info("Using Execlists submission\n"); + goto out; + } + + str = igt_sysfs_get(dir, "semaphores"); + active = str && atoi(str) > 0; + free(str); + + igt_info("Using Legacy submission %s\n", + active ? ", with semaphores" : ""); + +out: + close(dir); +} + igt_main { const struct mode { @@ -412,6 +452,7 @@ igt_main igt_fixture { fd = drm_open_driver_master(DRIVER_INTEL); + print_welcome(fd); igt_fork_hang_detector(fd); } diff --git a/tests/gem_sync.c b/tests/gem_sync.c index abb31679..44b2378c 100644 --- a/tests/gem_sync.c +++ b/tests/gem_sync.c @@ -25,6 +25,7 @@ #include <pthread.h> #include "igt.h" +#include "igt_sysfs.h" #define LOCAL_I915_EXEC_NO_RELOC (1<<11) #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) @@ -689,6 +690,45 @@ store_all(int fd, int num_children) igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); } +static void print_welcome(int fd) +{ + bool active; + char *str; + int dir; + + dir = igt_sysfs_open_parameters(fd); + if (dir < 0) + return; + + str = igt_sysfs_get(dir, "enable_guc_submission"); + active = str && atoi(str) > 0; + free(str); + + if (active) { + igt_info("Using GuC submission\n"); + goto out; + } + + str = igt_sysfs_get(dir, "enable_execlists"); + active = str && atoi(str) > 0; + free(str); + + if (active) { + igt_info("Using Execlists submission\n"); + goto out; + } + + str = igt_sysfs_get(dir, "semaphores"); + active = str && atoi(str) > 0; + free(str); + + igt_info("Using Legacy submission %s\n", + active ? ", with semaphores" : ""); + +out: + close(dir); +} + igt_main { const struct intel_execution_engine *e; @@ -699,6 +739,7 @@ igt_main igt_fixture { fd = drm_open_driver(DRIVER_INTEL); + print_welcome(fd); igt_fork_hang_detector(fd); } |