diff options
author | Victor Lu <victorchengchi.lu@amd.com> | 2021-06-16 09:55:47 -0400 |
---|---|---|
committer | Rodrigo Siqueira <Rodrigo.Siqueira@amd.com> | 2021-06-16 18:58:06 -0400 |
commit | fa0624e5d8febe4b8bd5531bcfcdd250f7a3d212 (patch) | |
tree | f453e8310cd6c41c0df81cd3b3b9de7dd820f674 /lib/igt_kmod.c | |
parent | 009f5a68be0c46cfc85284197caa08085711fa41 (diff) |
tests/amdgpu: Add amdgpu module reload test
Test to ensure unloading and loading of amdgpu driver works
Tested on:
ASIC: NAVI14
Changes since v1:
* Added documentaion
* Updated commit message
Signed-off-by: Victor Lu <victorchengchi.lu@amd.com>
Co-developed-by: Anson Jacob <Anson.Jacob@amd.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Mark Yacoub <markyacoub@google.com>
Acked-by: Petri Latvala <petri.latvala@intel.com>
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Diffstat (limited to 'lib/igt_kmod.c')
-rw-r--r-- | lib/igt_kmod.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index 55295fa5..10e98384 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -433,6 +433,65 @@ igt_i915_driver_unload(void) return IGT_EXIT_SUCCESS; } +/** + * igt_amdgpu_driver_load: + * @opts: options to pass to amdgpu driver + * + * Returns: IGT_EXIT_SUCCESS or IGT_EXIT_FAILURE. + * + * Loads the amdgpu driver and its dependencies. + * + */ +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; +} + +/** + * igt_amdgpu_driver_unload: + * + * Returns: IGT_EXIT_SUCCESS on success, IGT_EXIT_FAILURE on failure + * and IGT_EXIT_SKIP if amdgpu could not be unloaded. + * + * Unloads the amdgpu driver and its dependencies. + * + */ +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; +} + static void kmsg_dump(int fd) { char record[4096 + 1]; |