From patchwork Fri Nov 13 14:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 11903733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B4EFC388F7 for ; Fri, 13 Nov 2020 14:54:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B1E921D79 for ; Fri, 13 Nov 2020 14:54:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B1E921D79 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40F0C6E4F4; Fri, 13 Nov 2020 14:54:12 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 323FE6E4F4; Fri, 13 Nov 2020 14:54:11 +0000 (UTC) IronPort-SDR: r9gRsKW8I4/3l3GvTU/Rp6qe5SQ2bEUryy/EAecXzFPwuQQjFLZtbu2FHZIBB1AeDxFgavC5ky RA4g5VL7byeQ== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="170651225" X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="170651225" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 06:54:09 -0800 IronPort-SDR: Mfr3gjTH9FDObBf0TTVZSxDJCl939Qf4DM4rWdIt/csewQYMImWnDrAUNLFTlgCp4laB08IniI Q7rDkSl8HoFg== X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="542679853" Received: from shalomzo-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.251.180.188]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 06:54:06 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 13 Nov 2020 14:53:54 +0000 Message-Id: <20201113145357.2400122-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/4] intel_gpu_top: User friendly device listing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin Adding a new device selection print type suitable for user-facing use cases like intel_gpu_top -L and later lsgpu. Instead of: sys:/sys/devices/pci0000:00/0000:00:02.0/drm/card0 subsystem : drm drm card : /dev/dri/card0 parent : sys:/sys/devices/pci0000:00/0000:00:02.0 sys:/sys/devices/pci0000:00/0000:00:02.0/drm/renderD128 subsystem : drm drm render : /dev/dri/renderD128 parent : sys:/sys/devices/pci0000:00/0000:00:02.0 sys:/sys/devices/pci0000:00/0000:00:02.0 subsystem : pci drm card : /dev/dri/card0 drm render : /dev/dri/renderD128 vendor : 8086 device : 193B New format looks like: card0 8086:193B drm:/dev/dri/card0 └─renderD128 drm:/dev/dri/renderD128 Advantages are more compact, more readable, one entry per GPU, shorter string to copy and paste to intel_gpu_top -d, or respective usage. v2: * Increase stack filter size. (Zbigniew) Signed-off-by: Tvrtko Ursulin Cc: Petri Latvala Cc: Zbigniew Kempczyński Reviewed-by: Zbigniew Kempczyński --- lib/igt_device_scan.c | 109 +++++++++++++++++++++++++++++++++++++----- lib/igt_device_scan.h | 1 + tools/intel_gpu_top.c | 3 +- 3 files changed, 100 insertions(+), 13 deletions(-) diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c index c581a31ae55e..c0cd6757fc27 100644 --- a/lib/igt_device_scan.c +++ b/lib/igt_device_scan.c @@ -735,18 +735,26 @@ static inline void _pr_simple2(const char *k, const char *v1, const char *v2) printf(" %-16s: %s:%s\n", k, v1, v2); } -static void igt_devs_print_simple(struct igt_list_head *view) +static bool __check_empty(struct igt_list_head *view) { - struct igt_device *dev; - if (!view) - return; + return true; if (igt_list_empty(view)) { printf("No GPU devices found\n"); - return; + return true; } + return false; +} + +static void igt_devs_print_simple(struct igt_list_head *view) +{ + struct igt_device *dev; + + if (__check_empty(view)) + return; + igt_list_for_each_entry(dev, view, link) { printf("sys:%s\n", dev->syspath); if (dev->subsystem) @@ -768,6 +776,89 @@ static void igt_devs_print_simple(struct igt_list_head *view) } } +static struct igt_device * +__find_pci(struct igt_list_head *view, const char *drm) +{ + struct igt_device *dev; + + igt_list_for_each_entry(dev, view, link) { + if (!is_pci_subsystem(dev) || !dev->drm_card) + continue; + + if (!strcmp(dev->drm_card, drm)) + return dev; + } + + return NULL; +} + +static void igt_devs_print_user(struct igt_list_head *view) +{ + struct igt_device *dev; + + if (__check_empty(view)) + return; + + igt_list_for_each_entry(dev, view, link) { + unsigned int i, num_children; + struct igt_device *pci_dev; + struct igt_device *dev2; + char filter[256]; + char *drm_name; + int ret; + + if (!is_drm_subsystem(dev)) + continue; + if (!dev->drm_card || dev->drm_render) + continue; + + drm_name = rindex(dev->drm_card, '/'); + if (!drm_name || !*++drm_name) + continue; + + ret = snprintf(filter, sizeof(filter), "drm:%s", dev->drm_card); + igt_assert(ret < sizeof(filter)); + + pci_dev = __find_pci(view, dev->drm_card); + if (pci_dev) + printf("%-24s%4s:%4s %s\n", + drm_name, pci_dev->vendor, pci_dev->device, + filter); + else + printf("%-24s %s\n", drm_name, filter); + + num_children = 0; + igt_list_for_each_entry(dev2, view, link) { + if (!is_drm_subsystem(dev2) || !dev2->drm_render) + continue; + if (strcmp(dev2->parent->syspath, dev->parent->syspath)) + continue; + + num_children++; + } + + i = 0; + igt_list_for_each_entry(dev2, view, link) { + if (!is_drm_subsystem(dev2) || !dev2->drm_render) + continue; + if (strcmp(dev2->parent->syspath, dev->parent->syspath)) + continue; + + drm_name = rindex(dev2->drm_render, '/'); + if (!drm_name || !*++drm_name) + continue; + + ret = snprintf(filter, sizeof(filter), "drm:%s", + dev2->drm_render); + igt_assert(ret < sizeof(filter)); + + printf("%s%-22s %s\n", + (++i == num_children) ? "└─" : "├─", + drm_name, filter); + } + } +} + static inline void _print_key_value(const char* k, const char *v) { printf("%-32s: %s\n", k, v); @@ -792,14 +883,9 @@ static void igt_devs_print_detail(struct igt_list_head *view) { struct igt_device *dev; - if (!view) + if (__check_empty(view)) return; - if (igt_list_empty(view)) { - printf("No GPU devices found\n"); - return; - } - igt_list_for_each_entry(dev, view, link) { printf("========== %s:%s ==========\n", dev->subsystem, dev->syspath); @@ -821,6 +907,7 @@ static struct print_func { } print_functions[] = { [IGT_PRINT_SIMPLE] = { .prn = igt_devs_print_simple }, [IGT_PRINT_DETAIL] = { .prn = igt_devs_print_detail }, + [IGT_PRINT_USER] = { .prn = igt_devs_print_user }, }; /** diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h index 99daee0c52d6..9822c22cb69c 100644 --- a/lib/igt_device_scan.h +++ b/lib/igt_device_scan.h @@ -37,6 +37,7 @@ enum igt_devices_print_type { IGT_PRINT_SIMPLE, IGT_PRINT_DETAIL, + IGT_PRINT_USER, /* End user friendly. */ }; #define INTEGRATED_I915_GPU_PCI_ID "0000:00:02.0" diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 298defa4e6ed..5230472d2af4 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -1313,7 +1313,6 @@ int main(int argc, char **argv) unsigned int i; int ret = 0, ch; bool list_device = false; - enum igt_devices_print_type printtype = IGT_PRINT_SIMPLE; char *pmu_device, *opt_device = NULL; struct igt_device_card card; @@ -1388,7 +1387,7 @@ int main(int argc, char **argv) igt_devices_scan(false); if (list_device) { - igt_devices_print(printtype); + igt_devices_print(IGT_PRINT_USER); goto exit; } From patchwork Fri Nov 13 14:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 11903735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38241C4742C for ; Fri, 13 Nov 2020 14:54:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E528C21D79 for ; Fri, 13 Nov 2020 14:54:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E528C21D79 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB9E66E511; Fri, 13 Nov 2020 14:54:14 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id DDBDE6E4F4; Fri, 13 Nov 2020 14:54:11 +0000 (UTC) IronPort-SDR: ImMSCBqcTL3fDtBYNlOwteGJxnjX595mM5fl2+UunLd0ygtx0qL+toHDuE+1coirHo1v/cAz/7 fSw3Dc3glINg== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="170651229" X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="170651229" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 06:54:11 -0800 IronPort-SDR: UB2AwWny4MUOqKuh65tekdEHVOPxk1y9XJZPuzKjkd+SLyyNB74Ko7RLs10FNdQv1+13j1wwKX mLMChbTkkwTg== X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="542679868" Received: from shalomzo-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.251.180.188]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 06:54:09 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 13 Nov 2020 14:53:55 +0000 Message-Id: <20201113145357.2400122-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113145357.2400122-1-tvrtko.ursulin@linux.intel.com> References: <20201113145357.2400122-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/4] lsgpu: User friendly device listing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin New default user frindly device listing mode which replaces: sys:/sys/devices/pci0000:00/0000:00:02.0/drm/card0 subsystem : drm drm card : /dev/dri/card0 parent : sys:/sys/devices/pci0000:00/0000:00:02.0 sys:/sys/devices/pci0000:00/0000:00:02.0/drm/renderD128 subsystem : drm drm render : /dev/dri/renderD128 parent : sys:/sys/devices/pci0000:00/0000:00:02.0 sys:/sys/devices/pci0000:00/0000:00:02.0 subsystem : pci drm card : /dev/dri/card0 drm render : /dev/dri/renderD128 vendor : 8086 device : 193B With: card0 8086:193B drm:/dev/dri/card0 └─renderD128 drm:/dev/dri/renderD128 Advantages are more compact, more readable, one entry per GPU. Legacy format can be chose using the -s / --print-simple command line switches. Signed-off-by: Tvrtko Ursulin Cc: Petri Latvala Cc: Zbigniew Kempczyński Reviewed-by: Zbigniew Kempczyński --- tools/lsgpu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/lsgpu.c b/tools/lsgpu.c index 2541d1c24e66..3b234b73361a 100644 --- a/tools/lsgpu.c +++ b/tools/lsgpu.c @@ -70,6 +70,7 @@ */ enum { + OPT_PRINT_SIMPLE = 's', OPT_PRINT_DETAIL = 'p', OPT_LIST_VENDORS = 'v', OPT_LIST_FILTERS = 'l', @@ -85,6 +86,7 @@ static char *igt_device; static const char *usage_str = "usage: lsgpu [options]\n\n" "Options:\n" + " -s, --print-simple Print simple (legacy) device details\n" " -p, --print-details Print devices with details\n" " -v, --list-vendors List recognized vendors\n" " -l, --list-filter-types List registered device filters types\n" @@ -151,6 +153,7 @@ static char *get_device_from_rc(void) int main(int argc, char *argv[]) { static struct option long_options[] = { + {"print-simple", no_argument, NULL, OPT_PRINT_SIMPLE}, {"print-detail", no_argument, NULL, OPT_PRINT_DETAIL}, {"list-vendors", no_argument, NULL, OPT_LIST_VENDORS}, {"list-filter-types", no_argument, NULL, OPT_LIST_FILTERS}, @@ -160,12 +163,15 @@ int main(int argc, char *argv[]) }; int c, index = 0; char *env_device = NULL, *opt_device = NULL, *rc_device = NULL; - enum igt_devices_print_type printtype = IGT_PRINT_SIMPLE; + enum igt_devices_print_type printtype = IGT_PRINT_USER; - while ((c = getopt_long(argc, argv, "pvld:h", + while ((c = getopt_long(argc, argv, "spvld:h", long_options, &index)) != -1) { switch(c) { + case OPT_PRINT_SIMPLE: + printtype = IGT_PRINT_SIMPLE; + break; case OPT_PRINT_DETAIL: printtype = IGT_PRINT_DETAIL; break; From patchwork Fri Nov 13 14:53:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 11903739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0429C388F7 for ; Fri, 13 Nov 2020 14:54:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B4CF621D79 for ; Fri, 13 Nov 2020 14:54:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4CF621D79 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF1496E558; Fri, 13 Nov 2020 14:54:17 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 869CD6E58B; Fri, 13 Nov 2020 14:54:16 +0000 (UTC) IronPort-SDR: 8tc/i3JsCG2/yzx6ZD2JS/PXiHJuRxrnto5nL1byDQQow40XasGtolWpski4l6+lij3rV66Ykx URNTI8tYA5VA== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="170651235" X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="170651235" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 06:54:16 -0800 IronPort-SDR: BrvZff9wuAL5qP83ThwQFxSQr314wSOOtp8bPm04sKH7N2C3uvudibnskZXIScmeVOuNxAQQW7 efCH0KGTKmBg== X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="542679902" Received: from shalomzo-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.251.180.188]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 06:54:14 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 13 Nov 2020 14:53:57 +0000 Message-Id: <20201113145357.2400122-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113145357.2400122-1-tvrtko.ursulin@linux.intel.com> References: <20201113145357.2400122-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 4/4] intel_gpu_top: Default GPU list to PCI mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin It is more obvious for the user to only shows filters for DRM master nodes since those are the ones that intel_gpu_top monitors. Signed-off-by: Tvrtko Ursulin --- tools/intel_gpu_top.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 07f88d555dc8..37b2141e784d 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -1388,7 +1388,8 @@ int main(int argc, char **argv) if (list_device) { struct igt_devices_print_format fmt = { - .type = IGT_PRINT_USER + .type = IGT_PRINT_USER, + .option = IGT_PRINT_PCI, }; igt_devices_print(&fmt);