From patchwork Wed Oct 18 08:02:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 10014013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E5BD602C8 for ; Wed, 18 Oct 2017 08:03:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7011728390 for ; Wed, 18 Oct 2017 08:03:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6490728AF1; Wed, 18 Oct 2017 08:03:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D72B28390 for ; Wed, 18 Oct 2017 08:03:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ADDA46E7EF; Wed, 18 Oct 2017 08:03:00 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id C24BB6E7EF for ; Wed, 18 Oct 2017 08:02:58 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2017 01:02:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.43,395,1503385200"; d="scan'208"; a="1207061489" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga001.fm.intel.com with ESMTP; 18 Oct 2017 01:02:49 -0700 Received: from localhost (172.28.171.152) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 18 Oct 2017 09:02:17 +0100 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: Date: Wed, 18 Oct 2017 10:02:12 +0200 Message-ID: <20171018080212.17680-1-michal.winiarski@intel.com> X-Mailer: git-send-email 2.13.6 MIME-Version: 1.0 X-Originating-IP: [172.28.171.152] Subject: [Intel-gfx] [PATCH i-g-t] lib/i915: Move submission related helpers to lib/i915/gem_submission X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Since I accidentally broke the build for some, by putting the pretty printer for submission inside ifdef HAVE_PROCPS, it's time to move the whole thing into lib/i915 while fixing this mistake. Let's also rename the pretty printer and add a doc to it as well as the section. Fixes: f6dfe556659f ("lib: Extract helpers for determining submission method") Signed-off-by: Michał Winiarski Cc: Arkadiusz Hiler Cc: Chris Wilson Reviewed-by: Chris Wilson --- .../intel-gpu-tools/intel-gpu-tools-docs.xml | 1 + lib/Makefile.sources | 2 + lib/i915/gem_submission.c | 128 +++++++++++++++++++++ lib/i915/gem_submission.h | 35 ++++++ lib/igt_aux.c | 18 --- lib/igt_aux.h | 4 +- lib/igt_gt.c | 63 ---------- lib/igt_gt.h | 7 -- lib/meson.build | 2 + tests/gem_eio.c | 2 +- tests/gem_exec_await.c | 2 +- tests/gem_exec_fence.c | 2 +- tests/gem_exec_latency.c | 2 +- tests/gem_exec_nop.c | 2 +- tests/gem_exec_schedule.c | 2 +- tests/gem_exec_whisper.c | 2 +- tests/gem_read_read_speed.c | 2 +- tests/gem_sync.c | 2 +- 18 files changed, 179 insertions(+), 99 deletions(-) create mode 100644 lib/i915/gem_submission.c create mode 100644 lib/i915/gem_submission.h diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml index c5be60d0..8d77cecd 100644 --- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml @@ -50,6 +50,7 @@ igt/i915 API Reference + diff --git a/lib/Makefile.sources b/lib/Makefile.sources index 09c9ef9f..6e968d9f 100644 --- a/lib/Makefile.sources +++ b/lib/Makefile.sources @@ -7,6 +7,8 @@ lib_source_list = \ i915/gem_context.h \ i915/gem_scheduler.c \ i915/gem_scheduler.h \ + i915/gem_submission.c \ + i915/gem_submission.h \ i915_3d.h \ i915_reg.h \ i915_pciids.h \ diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c new file mode 100644 index 00000000..efc3151f --- /dev/null +++ b/lib/i915/gem_submission.c @@ -0,0 +1,128 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include + +#include "igt_core.h" +#include "igt_sysfs.h" + +#include "i915/gem_submission.h" + +/** + * SECTION:gem_submission + * @short_description: Helpers for determining submission method + * @title: GEM Submission + * + * This helper library contains functions used for getting information on + * currently used hardware submission method. Different generations of hardware + * support different submission backends, currently we're distinguishing 3 + * different methods: legacy ringbuffer submission, execlists, GuC submission. + * For legacy ringbuffer submission, there's also a variation where we're using + * semaphores for synchronization between engines. + */ + +/** + * 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_submission_print_method: + * @fd: open i915 drm file descriptor + * + * Helper for pretty-printing currently used submission method + */ +void gem_submission_print_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" : ""); +} + +/** + * 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/i915/gem_submission.h b/lib/i915/gem_submission.h new file mode 100644 index 00000000..783ed7a0 --- /dev/null +++ b/lib/i915/gem_submission.h @@ -0,0 +1,35 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef GEM_SUBMISSION_H +#define GEM_SUBMISSION_H + +#define GEM_SUBMISSION_SEMAPHORES (1 << 0) +#define GEM_SUBMISSION_EXECLISTS (1 << 1) +#define GEM_SUBMISSION_GUC (1 << 2) +unsigned gem_submission_method(int fd); +void gem_submission_print_method(int fd); +bool gem_has_semaphores(int fd); +bool gem_has_execlists(int fd); + +#endif /* GEM_SUBMISSION_H */ diff --git a/lib/igt_aux.c b/lib/igt_aux.c index c1082143..ee53559c 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1493,24 +1493,6 @@ 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 e4a48eba..0bd226be 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -33,6 +33,8 @@ #include #include +#include + extern drm_intel_bo **trash_bos; extern int num_trash_bos; @@ -280,8 +282,6 @@ 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 601b03f6..f6cc20b0 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -607,66 +607,3 @@ 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 6b8f78eb..2579cbd3 100644 --- a/lib/igt_gt.h +++ b/lib/igt_gt.h @@ -80,11 +80,4 @@ 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 */ diff --git a/lib/meson.build b/lib/meson.build index f0125a6d..b31c68e4 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -4,6 +4,7 @@ lib_headers = [ 'i830_reg.h', 'i915/gem_context.h', 'i915/gem_scheduler.h', + 'i915/gem_submission.h', 'i915_3d.h', 'i915_reg.h', 'i915_pciids.h', @@ -52,6 +53,7 @@ lib_sources = [ 'drmtest.c', 'i915/gem_context.c', 'i915/gem_scheduler.c', + 'i915/gem_submission.c', 'igt_debugfs.c', 'igt_aux.c', 'igt_gt.c', diff --git a/tests/gem_eio.c b/tests/gem_eio.c index c30212f4..2d4c95f4 100644 --- a/tests/gem_eio.c +++ b/tests/gem_eio.c @@ -431,7 +431,7 @@ igt_main igt_force_gpu_reset(fd); igt_install_exit_handler(exit_handler); - gem_show_submission_method(fd); + gem_submission_print_method(fd); igt_require_gem(fd); igt_require_hang_ring(fd, I915_EXEC_DEFAULT); } diff --git a/tests/gem_exec_await.c b/tests/gem_exec_await.c index 326783a1..9c446792 100644 --- a/tests/gem_exec_await.c +++ b/tests/gem_exec_await.c @@ -343,7 +343,7 @@ igt_main device = drm_open_driver(DRIVER_INTEL); igt_require_gem(device); - gem_show_submission_method(device); + gem_submission_print_method(device); ring_size = measure_ring_size(device) - 10; if (!gem_has_execlists(device)) diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c index ae3760c9..2ea23b62 100644 --- a/tests/gem_exec_fence.c +++ b/tests/gem_exec_fence.c @@ -1434,7 +1434,7 @@ igt_main igt_require(gem_has_exec_fence(i915)); gem_require_mmap_wc(i915); - gem_show_submission_method(i915); + gem_submission_print_method(i915); } for (e = intel_execution_engines; e->name; e++) { diff --git a/tests/gem_exec_latency.c b/tests/gem_exec_latency.c index a942c205..e9d93440 100644 --- a/tests/gem_exec_latency.c +++ b/tests/gem_exec_latency.c @@ -417,7 +417,7 @@ igt_main igt_require_gem(device); gem_require_mmap_wc(device); - gem_show_submission_method(device); + gem_submission_print_method(device); ring_size = measure_ring_size(device); igt_info("Ring size: %d batches\n", ring_size); diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c index 37cddd8c..ce3a8ef7 100644 --- a/tests/gem_exec_nop.c +++ b/tests/gem_exec_nop.c @@ -652,7 +652,7 @@ igt_main device = drm_open_driver(DRIVER_INTEL); igt_require_gem(device); - gem_show_submission_method(device); + gem_submission_print_method(device); gem_scheduler_print_capability(device); handle = gem_create(device, 4096); diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c index baf1112d..a2f4419a 100644 --- a/tests/gem_exec_schedule.c +++ b/tests/gem_exec_schedule.c @@ -957,7 +957,7 @@ igt_main igt_fixture { fd = drm_open_driver_master(DRIVER_INTEL); - gem_show_submission_method(fd); + gem_submission_print_method(fd); gem_scheduler_print_capability(fd); igt_require_gem(fd); gem_require_mmap_wc(fd); diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c index dfa8a3b4..51921ba3 100644 --- a/tests/gem_exec_whisper.c +++ b/tests/gem_exec_whisper.c @@ -553,7 +553,7 @@ igt_main fd = drm_open_driver_master(DRIVER_INTEL); igt_require_gem(fd); igt_require(gem_can_store_dword(fd, 0)); - gem_show_submission_method(fd); + gem_submission_print_method(fd); igt_fork_hang_detector(fd); } diff --git a/tests/gem_read_read_speed.c b/tests/gem_read_read_speed.c index bbd8e54e..3dcf440c 100644 --- a/tests/gem_read_read_speed.c +++ b/tests/gem_read_read_speed.c @@ -197,7 +197,7 @@ igt_main batch = intel_batchbuffer_alloc(bufmgr, devid); - gem_show_submission_method(fd); + gem_submission_print_method(fd); } for (i = 0; sizes[i] != 0; i++) { diff --git a/tests/gem_sync.c b/tests/gem_sync.c index 6ead76b8..36180aee 100644 --- a/tests/gem_sync.c +++ b/tests/gem_sync.c @@ -793,7 +793,7 @@ igt_main igt_fixture { fd = drm_open_driver(DRIVER_INTEL); igt_require_gem(fd); - gem_show_submission_method(fd); + gem_submission_print_method(fd); gem_scheduler_print_capability(fd); igt_fork_hang_detector(fd);