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_gt.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'lib/igt_gt.c') 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; +} -- cgit v1.2.3