From: Petri Latvala <petri.latvala@intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 3/4] Introduce device selection lsgpu tool
Date: Mon, 18 Nov 2019 13:58:56 +0200 [thread overview]
Message-ID: <20191118115856.GY25209@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20191024110515.11741-4-arkadiusz.hiler@intel.com>
On Thu, Oct 24, 2019 at 02:05:14PM +0300, Arkadiusz Hiler wrote:
> From: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
>
> Tool uses device selection API to scan and display GPU devices.
> It can be used to check filter correctness as well as order
> of applying the filters (.igtrc, IGT_DEVICE and --device argument).
>
> v2 (Arek):
> * don't print chip as it's no longer there
> * make it a second patch, before any alterations to igt_core or drmtest
> * use only a single filter
>
> Cc: Petri Latvala <petri.latvala@intel.com>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> ---
> tools/Makefile.sources | 1 +
> tools/lsgpu.c | 295 +++++++++++++++++++++++++++++++++++++++++
> tools/meson.build | 1 +
> 3 files changed, 297 insertions(+)
> create mode 100644 tools/lsgpu.c
>
> diff --git a/tools/Makefile.sources b/tools/Makefile.sources
> index d764895d..b7a43d47 100644
> --- a/tools/Makefile.sources
> +++ b/tools/Makefile.sources
> @@ -33,6 +33,7 @@ tools_prog_lists = \
> intel_watermark \
> intel_gem_info \
> intel_gvtg_test \
> + lsgpu \
> $(NULL)
>
> dist_bin_SCRIPTS = intel_gpu_abrt
> diff --git a/tools/lsgpu.c b/tools/lsgpu.c
> new file mode 100644
> index 00000000..e385aaa6
> --- /dev/null
> +++ b/tools/lsgpu.c
> @@ -0,0 +1,295 @@
> +/*
> + * Copyright © 2019 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 "igt_device_scan.h"
> +#include "igt.h"
> +#include <sys/ioctl.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +#include <string.h>
> +#include <signal.h>
> +#include <glib.h>
> +
> +/**
> + * SECTION:lsgpu
> + * @short_description: lsgpu
> + * @title: lsgpu
> + * @include: lsgpu.c
> + *
> + * # lsgpu
> + *
> + * The devices can be scanned and displayed using 'lsgpu' tool. Tool also
> + * displays properties and sysattrs (-p switch, means print detail) which
> + * can be used during filter implementation.
> + *
> + * Tool can also be used to try out filters.
> + * To select device use '-d' or '--device' argument like:
> + *
> + * |[<!-- language="plain" -->
> + * ./lsgpu -d 'pci:vendor=Intel'
> + * === Device filter list ===
> + * [ 0]: pci:vendor=Intel
> +
> + * === Testing device open ===
> + * subsystem : pci
> + * drm card : /dev/dri/card0
> + * drm render : /dev/dri/renderD128
> + * Device /dev/dri/card0 successfully opened
> + * Device /dev/dri/renderD128 successfully opened
> + * ]|
> + *
> + * Additionally lsgpu tries to open the card and render nodes to verify
> + * permissions. It also uses IGT variable search order:
> + * - use --device first (it overrides IGT_DEVICE and .igtrc Common::Device
> + * settings)
> + * - use IGT_DEVICE enviroment variable if no --device are passed
> + * - use .igtrc Common::Device if no --device nor IGT_DEVICE are passed
> + */
> +
> +enum {
> + OPT_PRINT_DETAIL = 'p',
> + OPT_LIST_VENDORS = 'v',
> + OPT_LIST_FILTERS = 'l',
> + OPT_DEVICE = 'd',
> + OPT_HELP = 'h'
> +};
> +
> +static bool g_show_vendors;
> +static bool g_list_filters;
> +static bool g_device;
> +static bool g_help;
> +static char *igt_rc_device;
> +
> +static const char *usage_str =
> + "usage: lsgpu [options]\n\n"
> + "Options:\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"
> + " -d, --device filter Device filter, can be given multiple times\n"
> + " -h, --help Show this help message and exit\n";
> +
> +static void test_device_open(struct igt_device_card *card)
> +{
> + int fd;
> +
> + if (!card)
> + return;
> +
> + fd = igt_open_card(card);
> + if (fd >= 0) {
> + printf("Device %s successfully opened\n", card->card);
> + close(fd);
> + } else {
> + if (strlen(card->card))
> + printf("Cannot open card %s device\n", card->card);
> + else
> + printf("Cannot open card device, empty name\n");
> + }
> +
> + fd = igt_open_render(card);
> + if (fd >= 0) {
> + printf("Device %s successfully opened\n", card->render);
> + close(fd);
> + } else {
> + if (strlen(card->render))
> + printf("Cannot open render %s device\n", card->render);
> + else
> + printf("Cannot open render device, empty name\n");
> + }
> +}
> +
> +static void print_card(struct igt_device_card *card)
> +{
> + if (!card)
> + return;
> +
> + printf("subsystem : %s\n", card->subsystem);
> + printf("drm card : %s\n", card->card);
> + printf("drm render : %s\n", card->render);
> +}
> +
> +/* Partially copied from igt_core to simulate device selection order:
> + * 1. --device (IGT_DEVICE and .igtrc Common::Device are ignored)
> + * 2. IGT_DEVICE env (.igtrc Common::Device is ignored)
> + * 3. .igtrc (overrides
> + */
Is that the reason to not use igt_load_igtrc?
> +static void common_init_config(void)
> +{
> + char *key_file_env = NULL;
> + char *key_file_loc = NULL;
> + GError *error = NULL;
> + GKeyFile *igt_key_file;
> + int ret;
> +
> + /* Filter count > 0, just skip .igtrc */
> + if (igt_device_is_filter_set())
> + return;
> +
> + /* Determine igt config path */
> + key_file_env = getenv("IGT_CONFIG_PATH");
> + if (key_file_env) {
> + key_file_loc = key_file_env;
> + } else {
> + key_file_loc = malloc(100);
This malloc is not free()d.
Otherwise LGTM.
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-11-18 11:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 11:05 [igt-dev] [PATCH i-g-t 0/4] device selection && lsgpu Arkadiusz Hiler
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 1/4] lib/igt_list: Update, clean-up and document igt_list Arkadiusz Hiler
2019-10-24 11:16 ` Chris Wilson
2019-10-24 11:20 ` Arkadiusz Hiler
2019-10-24 11:23 ` Chris Wilson
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 2/4] Introduce device selection API Arkadiusz Hiler
[not found] ` <20191024164030.GA7823@zkempczy-mobl2>
2019-10-28 13:06 ` Arkadiusz Hiler
2019-11-15 13:31 ` Petri Latvala
2019-11-18 11:55 ` Petri Latvala
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 3/4] Introduce device selection lsgpu tool Arkadiusz Hiler
2019-10-24 13:06 ` Chris Wilson
2019-10-28 11:21 ` Arkadiusz Hiler
2019-11-18 11:58 ` Petri Latvala [this message]
2019-10-24 11:05 ` [igt-dev] [PATCH i-g-t 4/4] Add device selection in IGT Arkadiusz Hiler
2019-11-18 12:14 ` Petri Latvala
2019-11-19 14:18 ` Arkadiusz Hiler
2019-11-20 9:31 ` Petri Latvala
2019-10-24 13:00 ` [igt-dev] ✓ Fi.CI.BAT: success for device selection && lsgpu Patchwork
2019-10-25 17:07 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-11-12 10:14 ` [igt-dev] [PATCH i-g-t 0/4] " Tvrtko Ursulin
2019-12-02 12:37 ` Arkadiusz Hiler
2019-12-03 13:59 ` Tvrtko Ursulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191118115856.GY25209@platvala-desk.ger.corp.intel.com \
--to=petri.latvala@intel.com \
--cc=arkadiusz.hiler@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox