Re: [igt-dev] [PATCH i-g-t v2] Add support for forcing specific module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>

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@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

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




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux