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 4/4] Add device selection in IGT
Date: Mon, 18 Nov 2019 14:14:04 +0200 [thread overview]
Message-ID: <20191118121404.GZ25209@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20191024110515.11741-5-arkadiusz.hiler@intel.com>
On Thu, Oct 24, 2019 at 02:05:15PM +0300, Arkadiusz Hiler wrote:
> From: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
>
> New IGT command line argument --device, IGT_DEVICE enviroment
> and .igtrc Common::Device were added to allow selecting device
> using device selection API.
>
> v2 (Arek):
> * remove functions acting on igt_device_card
> * 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>
> ---
> .../igt-gpu-tools/igt_test_programs.xml | 7 ++
> lib/drmtest.c | 94 +++++++++++++++++--
> lib/drmtest.h | 2 +
> lib/igt_core.c | 47 ++++++++++
> 4 files changed, 142 insertions(+), 8 deletions(-)
>
> diff --git a/docs/reference/igt-gpu-tools/igt_test_programs.xml b/docs/reference/igt-gpu-tools/igt_test_programs.xml
> index b64ba474..fcce1458 100644
> --- a/docs/reference/igt-gpu-tools/igt_test_programs.xml
> +++ b/docs/reference/igt-gpu-tools/igt_test_programs.xml
> @@ -43,6 +43,13 @@
> </para></listitem>
> </varlistentry>
>
> + <varlistentry>
> + <term><option>--device filter</option></term>
> + <listitem><para>
> + select device using filter (see "Device selection" for details)
> + </para></listitem>
> + </varlistentry>
> +
> <varlistentry>
> <term><option>--help-description</option></term>
> <listitem><para>
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index c379a7b7..43471625 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -55,6 +55,7 @@
> #include "igt_gt.h"
> #include "igt_kmod.h"
> #include "igt_sysfs.h"
> +#include "igt_device_scan.h"
> #include "version.h"
> #include "config.h"
> #include "intel_reg.h"
> @@ -266,14 +267,9 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset)
> return -1;
> }
>
> -static int __open_driver(const char *base, int offset, unsigned int chipset)
> +static void __try_modprobe(unsigned int chipset)
> {
> static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
> - int fd;
> -
> - fd = __search_and_open(base, offset, chipset);
> - if (fd != -1)
> - return fd;
>
> pthread_mutex_lock(&mutex);
> for (const struct module *m = modules; m->module; m++) {
> @@ -285,26 +281,108 @@ static int __open_driver(const char *base, int offset, unsigned int chipset)
> }
> }
> pthread_mutex_unlock(&mutex);
> +}
> +
> +static int __open_driver(const char *base, int offset, unsigned int chipset)
> +{
> + int fd;
> +
> + fd = __search_and_open(base, offset, chipset);
> + if (fd != -1)
> + return fd;
> +
> + __try_modprobe(chipset);
>
> return __search_and_open(base, offset, chipset);
> }
>
> +static int __open_driver_exact(const char *name, unsigned int chipset)
> +{
> + int fd;
> +
> + fd = open_device(name, chipset);
> + if (fd != -1)
> + return fd;
> +
> + __try_modprobe(chipset);
> +
> + return open_device(name, chipset);
> +}
> +
> +/*
> + * A helper to get the first marching card in case a filter is set.
Cards can do what?
'matching' might be more appropriate.
> + * It does all the extra logging around the filters for us.
> + *
> + * @card: pointer to the igt_device_card structure to be filled
> + * when a card is found.
> + *
> + * Returns:
> + * True if card according to the added filter was found,
> + * false othwerwise.
> + */
> +static bool __get_the_first_card(struct igt_device_card *card)
> +{
> + const char *filter;
> +
> + if (igt_device_is_filter_set()) {
> + filter = igt_device_filter_get();
> + igt_info("Looking for devices to open using filter: %s\n", filter);
> +
> + if (igt_device_card_match(filter, card)) {
> + igt_info("Filter matched %s | %s\n", card->card, card->render);
> + return true;
> + }
> +
> + igt_warn("No card matches the filter!\n");
> + }
> +
> + return false;
> +}
> +
> /**
> * __drm_open_driver:
> * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
> *
> - * Open the first DRM device we can find, searching up to 16 device nodes
> + * Function opens device in the following order:
> + * 1. when --device arguments are present device scanning will be executed,
> + * then filter argument is used to find matching one.
> + * 2. compatibility mode - open the first DRM device we can find,
> + * searching up to 16 device nodes.
> *
> * Returns:
> * An open DRM fd or -1 on error
> */
> int __drm_open_driver(int chipset)
> {
> + if (igt_device_is_filter_set()) {
> + bool found;
> + struct igt_device_card card;
> +
> + found = __get_the_first_card(&card);
> +
> + if (!found || !strlen(card.card))
> + return -1;
> +
> + return __open_driver_exact(card.card, chipset);
> + }
> +
> return __open_driver("/dev/dri/card", 0, chipset);
> }
I'm a little confused how this all works with IGT_FORCE_DRIVER? And
how does this work for tests that open two different drivers?
--
Petri Latvala
_______________________________________________
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 12:14 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
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 [this message]
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=20191118121404.GZ25209@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