[PATCH i-g-t 2/4] tests/core_hotunplug: Also unload audio on device unplug
Janusz Krzysztofik
janusz.krzysztofik at linux.intel.com
Fri Sep 9 17:25:55 UTC 2022
Starting from commit e9c69e02b2f7 ("tests/core_hotunplug: Unload snd
driver before i915 unbind") that replaced a former conservative workaround
with a more liberal one but also moved it out of initial igt_fixture
section to driver_unbind(), *plug* subtests (still blockisted in CI) can
suffer from issues related to an audio driver using i915 hardware. Fix it
by adding a copy of the workaround in its current shape also to
device_unplug() / bus_rescan() pair of functions.
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
---
tests/core_hotunplug.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 9961cdad57..669b8ce1bc 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -198,6 +198,21 @@ static void device_unplug(struct hotunplug *priv, const char *prefix,
{
igt_require(priv->fd.sysfs_dev == -1);
+ /*
+ * FIXME: on some devices, the audio driver (snd_hda_intel)
+ * binds into the i915 driver. On such hardware, kernel warnings
+ * and errors may happen if i915 is unbind/removed before removing
+ * first the audio driver.
+ * So, add a logic that unloads the audio driver before trying to
+ * unbind i915 driver, reloading it when binding again.
+ */
+ if (igt_audio_driver_unload(&priv->snd_driver)) {
+ 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);
+ }
+
priv->fd.sysfs_dev = openat(priv->fd.sysfs_bus, priv->dev_bus_addr,
O_DIRECTORY);
igt_assert_fd(priv->fd.sysfs_dev);
@@ -231,6 +246,13 @@ static void bus_rescan(struct hotunplug *priv, int timeout)
igt_fail_on_f(faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr,
F_OK, 0),
"Fakely unplugged device not rediscovered (%s)!\n", priv->dev_bus_addr);
+
+ if (priv->snd_driver) {
+ igt_info("Realoading %s\n", priv->snd_driver);
+ igt_kmod_load(priv->snd_driver, NULL);
+ kfree(priv->snd_driver);
+ priv->snd_driver = NULL;
+ }
}
static void cleanup(struct hotunplug *priv)
--
2.25.1
More information about the Intel-gfx-trybot
mailing list