[igt-dev] [PATCH i-g-t] gem_lmem_swapping: Check requirements before module unload

Matthew Auld matthew.auld at intel.com
Wed Apr 20 08:43:48 UTC 2022


On 19/04/2022 14:00, Petri Latvala wrote:
> To prevent a needless unload-load cycle, check for lmem before the
> unload if i915 is already loaded.
> 
> Also check that the device is there at all so we get a better error
> message than EBADFD from require_gem.
> 
> Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> Cc: Matthew Auld <matthew.auld at intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at linux.intel.com>
Acked-by: Matthew Auld <matthew.auld at intel.com>

> ---
>   tests/i915/gem_lmem_swapping.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
> 
> diff --git a/tests/i915/gem_lmem_swapping.c b/tests/i915/gem_lmem_swapping.c
> index 2f9f3268..ec41dfc3 100644
> --- a/tests/i915/gem_lmem_swapping.c
> +++ b/tests/i915/gem_lmem_swapping.c
> @@ -534,10 +534,25 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
>   		struct intel_execution_engine2 *e;
>   		char *tmp;
>   
> +		/*
> +		 * If the driver is already loaded, check that it has
> +		 * lmem before unloading to prevent a needless
> +		 * unload-load cycle on integrated platforms.
> +		 */
> +		if (igt_kmod_is_loaded("i915")) {
> +			i915 = __drm_open_driver(DRIVER_INTEL);
> +			igt_require_fd(i915);
> +			igt_require_gem(i915);
> +			igt_require(gem_has_lmem(i915));
> +			close(i915);
> +		}
> +
>   		igt_i915_driver_unload();
>   		igt_assert_eq(igt_i915_driver_load("lmem_size=4096"), 0);
>   
>   		i915 = __drm_open_driver(DRIVER_INTEL);
> +		igt_require_fd(i915);
> +		/* Do the lmem check again in case the reload messed something up (as unlikely it is) */
>   		igt_require_gem(i915);
>   		igt_require(gem_has_lmem(i915));
>   


More information about the igt-dev mailing list