Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 576C4113228 for ; Tue, 17 May 2022 15:40:51 +0000 (UTC) From: Mauro Carvalho Chehab To: igt-dev@lists.freedesktop.org, Petri Latvala Date: Tue, 17 May 2022 17:40:41 +0200 Message-Id: <20220517154044.226733-7-mauro.chehab@linux.intel.com> In-Reply-To: <20220517154044.226733-1-mauro.chehab@linux.intel.com> References: <20220517154044.226733-1-mauro.chehab@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t v6 6/9] lib/igt_kmod: make it less pedantic with audio driver removal List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: From: Mauro Carvalho Chehab Current Linux Kernel don't report if the audio driver binds into the DRM driver. As this is CPU specific, allow audio driver unload fail without skipping the IGT tests on legacy Kernels, as this may not be mandatory. On new kernels where lsmod will properly display the dependency between the audio and DRM drivers, skip the core hotunplug test if it fails to unload the audio driver, as this is unrelated to the DRM driver - and it could simply because there are some userspace code using the audio device while the IGT test is running. Reviewed-by Jonathan Cavitt Reviewed-by: Andi Shyti Signed-off-by: Mauro Carvalho Chehab --- lib/igt_kmod.c | 31 +++++++++++++++++++++++++++---- tests/core_hotunplug.c | 7 ++----- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index 9bb2fc705eb8..5d358c899cfb 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -408,18 +408,34 @@ static int igt_always_unload_audio_driver(char **who) NULL, }; + /* + * With old Kernels, the dependencies between audio and DRM drivers + * are not shown. So, it may not be mandatory to remove the audio + * driver before unload/unbind the DRM one. So, let's print warnings, + * but return 0 on errors, as, if the dependency is mandatory, this + * will be detected later when trying to unbind/unload the DRM driver. + */ for (const char **m = sound; *m; m++) { if (igt_kmod_is_loaded(*m)) { if (who) *who = strdup_realloc(*who, *m); - if (igt_lsof_kill_audio_processes()) - return EACCES; + ret = igt_lsof_kill_audio_processes(); + if (ret) { + igt_warn("Could not stop %d audio process(es)\n", ret); + igt_kmod_list_loaded(); + igt_lsof("/dev/snd"); + return 0; + } kick_snd_hda_intel(); ret = igt_kmod_unload(*m, 0); - if (ret) - return ret; + if (ret) { + igt_warn("Could not unload audio driver %s\n", *m); + igt_kmod_list_loaded(); + igt_lsof("/dev/snd"); + return 0; + } } } return 0; @@ -610,6 +626,13 @@ int igt_audio_driver_unload(char **who) } ret: + if (ret) { + igt_warn("Couldn't unload %s, which is using the %s driver\n", + mod[pos].name, drm_driver); + igt_kmod_list_loaded(); + igt_lsof("/dev/snd"); + } + free_module_ref(mod, num_mod); return ret; diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 456ad6b4ce40..a0d29b799a48 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -149,11 +149,8 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix, * unbind i915 driver, reloading it when binding again. */ if (igt_audio_driver_unload(&priv->snd_driver)) { - if (priv->snd_driver) - igt_warn("Could not unload audio driver %s\n", priv->snd_driver); - igt_kmod_list_loaded(); - igt_lsof("/dev/snd"); - igt_skip("Audio is in use, skipping\n"); + igt_skip("Audio driver %s in use, skipping test\n", + priv->snd_driver); } else if (priv->snd_driver) { igt_info("Unloaded audio driver %s\n", priv->snd_driver); } -- 2.36.1