From f6dfe556659f5473e4bf13cc8d4770ac39c7d678 Mon Sep 17 00:00:00 2001 From: Michał Winiarski Date: Mon, 16 Oct 2017 11:05:14 +0200 Subject: lib: Extract helpers for determining submission method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Couple of tests are using either determining submission method, or pretty printing. Let's move those to helpers in lib. v2: s/igt_show/gem_show Signed-off-by: Michał Winiarski Cc: Arkadiusz Hiler Cc: Chris Wilson Cc: Katarzyna Dec Cc: Petri Latvala Reviewed-by: Chris Wilson Reviewed-by: Katarzyna Dec Acked-by: Arkadiusz Hiler --- lib/igt_aux.c | 18 +++++++++++++++++ lib/igt_aux.h | 2 ++ lib/igt_gt.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_gt.h | 7 +++++++ 4 files changed, 90 insertions(+) (limited to 'lib') diff --git a/lib/igt_aux.c b/lib/igt_aux.c index ee53559c..c1082143 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1493,6 +1493,24 @@ igt_show_stat(proc_t *info, int *state, const char *fn) ++*state; } +void gem_show_submission_method(int fd) +{ + const unsigned flags = gem_submission_method(fd); + + if (flags & GEM_SUBMISSION_GUC) { + igt_info("Using GuC submission\n"); + return; + } + + if (flags & GEM_SUBMISSION_EXECLISTS) { + igt_info("Using Execlists submission\n"); + return; + } + + igt_info("Using Legacy submission%s\n", + flags & GEM_SUBMISSION_SEMAPHORES ? ", with semaphores" : ""); +} + static void __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) { diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 688ad1b8..e4a48eba 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -280,6 +280,8 @@ void igt_unlock_mem(void); ret_; \ }) +void gem_show_submission_method(int fd); + struct igt_mean; void igt_start_siglatency(int sig); /* 0 => SIGRTMIN (default) */ double igt_stop_siglatency(struct igt_mean *result); diff --git a/lib/igt_gt.c b/lib/igt_gt.c index f6cc20b0..601b03f6 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -607,3 +607,66 @@ bool gem_can_store_dword(int fd, unsigned int engine) return true; } + +/** + * gem_submission_method: + * @fd: open i915 drm file descriptor + * + * Returns: Submission method bitmap. + */ +unsigned gem_submission_method(int fd) +{ + unsigned flags = 0; + bool active; + int dir; + + dir = igt_sysfs_open_parameters(fd); + if (dir < 0) + return 0; + + active = igt_sysfs_get_boolean(dir, "enable_guc_submission"); + if (active) { + flags |= GEM_SUBMISSION_GUC | GEM_SUBMISSION_EXECLISTS; + goto out; + } + + active = igt_sysfs_get_boolean(dir, "enable_execlists"); + if (active) { + flags |= GEM_SUBMISSION_EXECLISTS; + goto out; + } + + active = igt_sysfs_get_boolean(dir, "semaphores"); + if (active) { + flags |= GEM_SUBMISSION_SEMAPHORES; + } + +out: + close(dir); + return flags; +} + + +/** + * gem_has_semaphores: + * @fd: open i915 drm file descriptor + * + * Feature test macro to query whether the driver is using semaphores for + * synchronization between engines. + */ +bool gem_has_semaphores(int fd) +{ + return gem_submission_method(fd) & GEM_SUBMISSION_SEMAPHORES; +} + +/** + * gem_has_execlists: + * @fd: open i915 drm file descriptor + * + * Feature test macro to query whether the driver is using execlists as a + * hardware submission method. + */ +bool gem_has_execlists(int fd) +{ + return gem_submission_method(fd) & GEM_SUBMISSION_EXECLISTS; +} diff --git a/lib/igt_gt.h b/lib/igt_gt.h index 2579cbd3..6b8f78eb 100644 --- a/lib/igt_gt.h +++ b/lib/igt_gt.h @@ -80,4 +80,11 @@ extern const struct intel_execution_engine { bool gem_can_store_dword(int fd, unsigned int engine); +#define GEM_SUBMISSION_SEMAPHORES (1 << 0) +#define GEM_SUBMISSION_EXECLISTS (1 << 1) +#define GEM_SUBMISSION_GUC (1 << 2) +unsigned gem_submission_method(int fd); +bool gem_has_semaphores(int fd); +bool gem_has_execlists(int fd); + #endif /* IGT_GT_H */ -- cgit v1.2.3