From patchwork Tue Sep 13 12:04:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 12974707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D33CDC6FA82 for ; Tue, 13 Sep 2022 12:05:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8163E10E6C3; Tue, 13 Sep 2022 12:05:13 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7E43010E6B3; Tue, 13 Sep 2022 12:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663070707; x=1694606707; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0NGhHAvgbuEMTp9BhqihFAEj/QoX5SkT2NMb9MJ5nnc=; b=OFNVP7jFoNIWBE6NorHd7zylBGOxLo+2Qu1SmTDYoX/kPR71iyN9UsfY CXTnkrzWkslGpbOMzSrV0HEunBvMVMuVoIXCXyI51EqwHg8BU4lE1mHav O4HSPMOYzRhNQqLSmmh7bE5RmCSCtddaMVdQpA0pedjPjo23CXqzVGgat GMGHwjrCXHMf1w/BPY+urpHrc354QwMPlcg5c5NQ0K/OgOkRdgoHByzfj JKoEd2u07jtZVBMUS82JIU5bNB8KrjZQny3yAfxx25xvvsDTDC0zfB1FN PQOnjgUdw9DA+vTyEHJhZim4ZhFAvX/fVd8cAGPIkWDx/yv/HPgztGhs0 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="281136815" X-IronPort-AV: E=Sophos;i="5.93,312,1654585200"; d="scan'208";a="281136815" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2022 05:05:07 -0700 X-IronPort-AV: E=Sophos;i="5.93,312,1654585200"; d="scan'208";a="678538739" Received: from jkrzyszt-mobl1.ger.corp.intel.com (HELO jkrzyszt-mobl1.lan) ([10.213.10.213]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2022 05:05:05 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Tue, 13 Sep 2022 14:04:39 +0200 Message-Id: <20220913120441.146757-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913120441.146757-1-janusz.krzysztofik@linux.intel.com> References: <20220913120441.146757-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/4] tests/core_hotunplug: Also unload audio before device unplug X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, Mauro Carvalho Chehab Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Reviewed-by: Mauro Carvalho Chehab --- tests/core_hotunplug.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 733ea8efb0..c3756889c2 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); + free(priv->snd_driver); + priv->snd_driver = NULL; + } } static void cleanup(struct hotunplug *priv)