public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: igt-dev@lists.freedesktop.org, gustavo@padovan.org,
	intel-gfx@lists.freedesktop.org,
	Petri Latvala <petri.latvala@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t v2] Add support for forcing specific module
Date: Mon, 17 Dec 2018 16:49:30 +0100	[thread overview]
Message-ID: <20181217154930.GH21184@phenom.ffwll.local> (raw)
In-Reply-To: <20180905203827.n7vpugbs6bjvijpg@smtp.gmail.com>

On Wed, Sep 05, 2018 at 05:38:27PM -0300, Rodrigo Siqueira wrote:
> This commit adds a new option for forcing the use of a specific driver
> indicated via an environment variable.
> 
> Changes since V1:
>  Petri:
>  - Use an environment variable instead of command line
>  - Refactor the loop in __search_and_open to accept forced module
>  - Don't try to load kernel modules
> 
> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>

Note: You can't drop the s-o-b line if your patch contains work by other
people, like from Petri here. Proper way to resend a patch by someone else
is to just add a subject prefix of "PATCH RESEND" and otherwise keep
everything unchanged (including author and everything).

https://patchwork.freedesktop.org/patch/245532/

Cheers, Daniel

> ---
>  lib/drmtest.c  | 44 ++++++++++++++++++++++++++++++++++++++++++--
>  lib/drmtest.h  |  2 ++
>  lib/igt_core.c |  5 +++++
>  3 files changed, 49 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index bfa2e0f0..6e35d1be 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -123,6 +123,36 @@ static bool has_known_intel_chipset(int fd)
>  	return true;
>  }
>  
> +static char _forced_driver[5] = "";
> +
> +/**
> + * __set_forced_driver:
> + * @name: name of driver to forcibly use
> + *
> + * Set the name of a driver to use when calling #drm_open_driver with
> + * the #DRIVER_ANY flag.
> + */
> +void __set_forced_driver(const char *name)
> +{
> +	if (!strcmp(name, "")) {
> +		igt_warn("IGT_FORCE_DRIVER flag specified without a value,"
> +			 "ignoring force option\n");
> +		return;
> +	}
> +
> +	igt_info("Attempt to force module %s\n", name);
> +
> +	strncpy(_forced_driver, name, 4);
> +}
> +
> +static const char *forced_driver(void)
> +{
> +	if (_forced_driver[0])
> +		return _forced_driver;
> +
> +	return NULL;
> +}
> +
>  #define LOCAL_I915_EXEC_VEBOX	(4 << 0)
>  /**
>   * gem_quiescent_gpu:
> @@ -250,8 +280,18 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset)
>  
>  		sprintf(name, "%s%u", base, i + offset);
>  		fd = open_device(name, chipset);
> -		if (fd != -1)
> -			return fd;
> +		if (fd == -1)
> +			continue;
> +
> +		// Force module
> +		if (chipset == DRIVER_ANY && forced_driver()) {
> +			if (__is_device(fd, forced_driver()))
> +				return fd;
> +			close(fd);
> +			continue;
> +		}
> +
> +		return fd;
>  	}
>  
>  	return -1;
> diff --git a/lib/drmtest.h b/lib/drmtest.h
> index 949865ee..62f53ec3 100644
> --- a/lib/drmtest.h
> +++ b/lib/drmtest.h
> @@ -51,6 +51,8 @@
>   */
>  #define DRIVER_ANY 	~(DRIVER_VGEM)
>  
> +void __set_forced_driver(const char *name);
> +
>  /**
>   * ARRAY_SIZE:
>   * @arr: static array
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 23bb858f..8e65b5e3 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -647,6 +647,11 @@ static void common_init_env(void)
>  	igt_frame_dump_path = getenv("IGT_FRAME_DUMP_PATH");
>  
>  	stderr_needs_sentinel = getenv("IGT_SENTINEL_ON_STDERR") != NULL;
> +
> +	env = getenv("IGT_FORCE_DRIVER");
> +	if (env) {
> +		__set_forced_driver(env);
> +	}
>  }
>  
>  static int common_init(int *argc, char **argv,
> -- 
> 2.18.0
> 
> 
> -- 
> Rodrigo Siqueira
> http://siqueira.tech
> Graduate Student
> Department of Computer Science
> University of São Paulo
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2018-12-17 15:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 20:38 [igt-dev] [PATCH i-g-t v2] Add support for forcing specific module Rodrigo Siqueira
2018-09-05 22:27 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork
2018-09-05 22:49 ` [igt-dev] [PATCH i-g-t v2] " Chris Wilson
2018-09-05 22:58 ` [igt-dev] ✗ Fi.CI.BAT: failure for Add support for forcing specific module (rev2) Patchwork
2018-12-17 15:49 ` Daniel Vetter [this message]
2018-12-17 16:45   ` [igt-dev] [PATCH i-g-t v2] Add support for forcing specific module Rodrigo Siqueira
2018-12-17 17:22   ` Lucas De Marchi
2018-12-18 12:08     ` Petri Latvala
2018-12-18 13:33       ` Daniel Vetter

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=20181217154930.GH21184@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=gustavo@padovan.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    --cc=rodrigosiqueiramelo@gmail.com \
    /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