[igt-dev] [i-g-t, 1/2] tests/amdgpu: Introduced new amdgpu module reload test

Petri Latvala petri.latvala at intel.com
Tue Jun 15 08:19:09 UTC 2021


On Mon, Jun 14, 2021 at 11:35:56AM -0400, Anson Jacob wrote:
> From: Victor Lu <victorchengchi.lu at amd.com>
> 
> Based off of i915/i915_module_load, unloads and loads the
> amdgpu module.
> 
> Signed-off-by: Victor Lu <victorchengchi.lu at amd.com>
> Acked-by: Anson Jacob <Anson.Jacob at amd.com>
> ---
>  lib/igt_kmod.c                 | 41 ++++++++++++++++++
>  lib/igt_kmod.h                 |  3 ++
>  tests/amdgpu/amd_module_load.c | 77 ++++++++++++++++++++++++++++++++++
>  tests/amdgpu/meson.build       |  1 +
>  4 files changed, 122 insertions(+)
>  create mode 100644 tests/amdgpu/amd_module_load.c
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index 55295fa5..69bdc810 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -433,6 +433,47 @@ igt_i915_driver_unload(void)
>  	return IGT_EXIT_SUCCESS;
>  }
>  
> +int
> +igt_amdgpu_driver_load(const char *opts)
> +{
> +	if (opts)
> +		igt_info("Reloading amdgpu with %s\n\n", opts);
> +
> +	if (igt_kmod_load("amdgpu", opts)) {
> +		igt_warn("Could not load amdgpu\n");
> +		return IGT_EXIT_FAILURE;
> +	}
> +
> +	bind_fbcon(true);
> +
> +	return IGT_EXIT_SUCCESS;
> +}
> +
> +int
> +igt_amdgpu_driver_unload(void)
> +{
> +	bind_fbcon(false);
> +
> +	if (igt_kmod_is_loaded("amdgpu")) {
> +		if (igt_kmod_unload("amdgpu", 0)) {
> +			igt_warn("Could not unload amdgpu\n");
> +			igt_kmod_list_loaded();
> +			igt_lsof("/dev/dri");
> +			return IGT_EXIT_SKIP;
> +		}
> +	}
> +
> +	igt_kmod_unload("drm_kms_helper", 0);
> +	igt_kmod_unload("drm", 0);
> +
> +	if (igt_kmod_is_loaded("amdgpu")) {
> +		igt_warn("amdgpu.ko still loaded!\n");
> +		return IGT_EXIT_FAILURE;
> +	}
> +
> +	return IGT_EXIT_SUCCESS;
> +}

Add documentation for these functions please.

(Now that I mention it, the i915 equivalent functions have
documentation blocks but don't actually document the return values...)


-- 
Petri Latvala


More information about the igt-dev mailing list