From patchwork Fri Sep 11 10:30:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770213 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D68859D for ; Fri, 11 Sep 2020 10:31:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 28DCB2076C for ; Fri, 11 Sep 2020 10:31:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28DCB2076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 839FE895B2; Fri, 11 Sep 2020 10:30:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D5326E9FC; Fri, 11 Sep 2020 10:30:53 +0000 (UTC) IronPort-SDR: PCSqLcA0qSbLOC9JnjSsumFfdEX98UPxtso1G/gZozJ3Ef1f2fl5fO/JV/QJtk2PZxjV/d8Ihk NEEvaK7kpYHg== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463185" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463185" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:53 -0700 IronPort-SDR: JPeUdtNVRp9d1We6GtTNqHvSFvkSl8ymbWwfpYpc384I681Mc194qxtLc/Vz3k63l15eiZ10aa A7TJpNgCQn5g== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474679" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:51 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:16 +0200 Message-Id: <20200911103039.4574-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 01/24] tests/core_hotunplug: Use igt_assert_fd() 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" There is a new library helper that asserts validity of open file descriptors. Use it instead of open coding. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index e03f3b945..7431346b1 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -57,7 +57,7 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) priv->fd.sysfs_drv = openat(priv->fd.sysfs_dev, "device/driver", O_DIRECTORY); - igt_assert(priv->fd.sysfs_drv >= 0); + igt_assert_fd(priv->fd.sysfs_drv); len = readlinkat(priv->fd.sysfs_dev, "device", buf, buflen - 1); buf[len] = '\0'; @@ -72,10 +72,10 @@ static void prepare(struct hotunplug *priv, char *buf, int buflen) { igt_debug("opening device\n"); priv->fd.drm = __drm_open_driver(DRIVER_ANY); - igt_assert(priv->fd.drm >= 0); + igt_assert_fd(priv->fd.drm); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); - igt_assert(priv->fd.sysfs_dev >= 0); + igt_assert_fd(priv->fd.sysfs_dev); if (buf) { prepare_for_unbind(priv, buf, buflen); @@ -83,7 +83,7 @@ static void prepare(struct hotunplug *priv, char *buf, int buflen) /* prepare for bus rescan */ priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev, "device/subsystem", O_DIRECTORY); - igt_assert(priv->fd.sysfs_bus >= 0); + igt_assert_fd(priv->fd.sysfs_bus); } } @@ -261,7 +261,7 @@ igt_main * a device file descriptor open for exit handler use. */ fd_drm = __drm_open_driver(DRIVER_ANY); - igt_assert(fd_drm >= 0); + igt_assert_fd(fd_drm); if (is_i915_device(fd_drm)) igt_require_gem(fd_drm); From patchwork Fri Sep 11 10:30:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770215 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53D0959D for ; Fri, 11 Sep 2020 10:31:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 263C82076C for ; Fri, 11 Sep 2020 10:31:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 263C82076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A229897B5; Fri, 11 Sep 2020 10:30:57 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9135989A1F; Fri, 11 Sep 2020 10:30:55 +0000 (UTC) IronPort-SDR: owJPNeTE4Loxr/vrkq5h9npuzhTvP52GMGdnehrPXZzrf8k/6IkZNagzCfPmgYnxc+PsJPevUj 4USFbrdt/JGQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463190" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463190" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:55 -0700 IronPort-SDR: VvWHDjuD0eWiJcroy8B//p+L6dwY8+ECPVWTEDbMu3ls/eG/AReD0joLWqQJakIJFLSZpcZKu4 kwP3OzI4Hxog== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474687" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:53 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:17 +0200 Message-Id: <20200911103039.4574-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 02/24] tests/core_hotunplug: Constify dev_bus_addr string 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Device bus address structure field is always initialized with a pointer to a substring of the device sysfs path and never used for its modification. Declare it as a constant string. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 7431346b1..a4071f51e 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -44,7 +44,7 @@ struct hotunplug { int sysfs_bus; int sysfs_drv; } fd; - char *dev_bus_addr; + const char *dev_bus_addr; }; /* Helpers */ From patchwork Fri Sep 11 10:30:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770217 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7610E112E for ; Fri, 11 Sep 2020 10:31:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4AC7E2076C for ; Fri, 11 Sep 2020 10:31:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AC7E2076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FF6C89819; Fri, 11 Sep 2020 10:30:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8CD47896FA; Fri, 11 Sep 2020 10:30:57 +0000 (UTC) IronPort-SDR: TqkBMms8TrOuqTPaYxtE8lWHxtKgiIzrYW5pAkpORdceqrgWH6srz8hV0aOFG7f4N3N3S1HPKk bK8d+o2KKqBw== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463193" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463193" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:57 -0700 IronPort-SDR: AulCekI/Xy56NDq2Dn1yzSrz1nLqztqOlGsUe4uVhyjU4Gct2IDEsqQZU6KtRFDsbMsm420Y22 10Ky47P5qeLg== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474695" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:55 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:18 +0200 Message-Id: <20200911103039.4574-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 03/24] tests/core_hotunplug: Clean up device open error handling 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We don't use drm_driver_open() since in case of an i915 device it keeps an extra file descriptor of the exercised device open for exit handler use, while we would like to be able to close the device completely before running certain test operations. Instead, we call __drm_driver_open() and handle its result ourselves. Unlike drm_driver_open() which skips on device open errors, we always fail or abort the test in such case. Moreover, we don't ensure that the i915 driver is idle before starting subtests like drm_open_driver() does. Skip instead of failing on initial device open error. Also, call gem_quiescent_gpu() if an i915 device is detected. For subsequent device opens, define a local helper that fails on error and use it. If we think we need to abort the test execution on device open error, set our failure marker first to trigger the abort from a follow up igt_fixture section. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index a4071f51e..e576a6c6c 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -49,6 +49,21 @@ struct hotunplug { /* Helpers */ +/** + * Subtests must be able to close examined devices completely. Don't + * use drm_open_driver() since in case of an i915 device it opens it + * twice and keeps a second file descriptor open for exit handler use. + */ +static int local_drm_open_driver(void) +{ + int fd_drm; + + fd_drm = __drm_open_driver(DRIVER_ANY); + igt_assert_fd(fd_drm); + + return fd_drm; +} + static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) { int len; @@ -71,8 +86,7 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) static void prepare(struct hotunplug *priv, char *buf, int buflen) { igt_debug("opening device\n"); - priv->fd.drm = __drm_open_driver(DRIVER_ANY); - igt_assert_fd(priv->fd.drm); + priv->fd.drm = local_drm_open_driver(); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); igt_assert_fd(priv->fd.sysfs_dev); @@ -145,8 +159,9 @@ static void healthcheck(void) igt_devices_scan(true); igt_debug("reopening the device\n"); - fd_drm = __drm_open_driver(DRIVER_ANY); - igt_abort_on_f(fd_drm < 0, "Device reopen failure"); + failure = "Device reopen failure!"; + fd_drm = local_drm_open_driver(); + failure = NULL; if (is_i915_device(fd_drm)) { failure = "GEM failure"; @@ -255,16 +270,13 @@ igt_main igt_fixture { int fd_drm; - /** - * As subtests must be able to close examined devices - * completely, don't use drm_open_driver() as it keeps - * a device file descriptor open for exit handler use. - */ fd_drm = __drm_open_driver(DRIVER_ANY); - igt_assert_fd(fd_drm); + igt_skip_on_f(fd_drm < 0, "No known DRM device found\n"); - if (is_i915_device(fd_drm)) + if (is_i915_device(fd_drm)) { + gem_quiescent_gpu(fd_drm); igt_require_gem(fd_drm); + } /* Make sure subtests always reopen the same device */ set_filter_from_device(fd_drm); From patchwork Fri Sep 11 10:30:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770219 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0896F112E for ; Fri, 11 Sep 2020 10:31:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D6182208FE for ; Fri, 11 Sep 2020 10:31:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6182208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C3ADD896FA; Fri, 11 Sep 2020 10:31:00 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80BD789915; Fri, 11 Sep 2020 10:30:59 +0000 (UTC) IronPort-SDR: tYQFzgTJuon5sF6ePwKXz4g2xGcWVA5T/3lZLBW9JI0pKm8rgw1nJBK+VVY34FJrWcnRoMKJQ+ edGZjYyJUkHw== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463195" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463195" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:59 -0700 IronPort-SDR: oeTZ+nSkVYTesSdCN7xP9A8R/EENwupu1P3exAI9qBz7LBS2oEkH6CfL3cRFZknCPr4SXg59F4 KVB/IosRYdIQ== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474703" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:57 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:19 +0200 Message-Id: <20200911103039.4574-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 04/24] tests/core_hotunplug: Consolidate duplicated debug messages 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Some debug messages which designate specific test operations, or their greater parts at least, sound always the same, no matter which subtest they are called from. Emit them, possibly updated with subtest specified modifiers, from inside respective helpers instead of duplicating them in subtest bodies. v2: Rebase only. v3: Refresh and extend over new case (local_drm_open_driver), - allow callers to specify a message suffix as well where applicable. v4: Rename prefix/suffix string arguments to more meaningful when/why. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v1 --- tests/core_hotunplug.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index e576a6c6c..fc239324a 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -54,10 +54,12 @@ struct hotunplug { * use drm_open_driver() since in case of an i915 device it opens it * twice and keeps a second file descriptor open for exit handler use. */ -static int local_drm_open_driver(void) +static int local_drm_open_driver(const char *when, const char *why) { int fd_drm; + igt_debug("%sopening device%s\n", when, why); + fd_drm = __drm_open_driver(DRIVER_ANY); igt_assert_fd(fd_drm); @@ -85,8 +87,7 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) static void prepare(struct hotunplug *priv, char *buf, int buflen) { - igt_debug("opening device\n"); - priv->fd.drm = local_drm_open_driver(); + priv->fd.drm = local_drm_open_driver("", " for subtest"); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); igt_assert_fd(priv->fd.sysfs_dev); @@ -104,8 +105,11 @@ static void prepare(struct hotunplug *priv, char *buf, int buflen) static const char *failure; /* Unbind the driver from the device */ -static void driver_unbind(int fd_sysfs_drv, const char *dev_bus_addr) +static void driver_unbind(int fd_sysfs_drv, const char *dev_bus_addr, + const char *prefix) { + igt_debug("%sunbinding the driver from the device\n", prefix); + failure = "Driver unbind timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_drv, "unbind", dev_bus_addr); @@ -118,6 +122,8 @@ static void driver_unbind(int fd_sysfs_drv, const char *dev_bus_addr) /* Re-bind the driver to the device */ static void driver_bind(int fd_sysfs_drv, const char *dev_bus_addr) { + igt_debug("rebinding the driver to the device\n"); + failure = "Driver re-bind timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_drv, "bind", dev_bus_addr); @@ -128,8 +134,10 @@ static void driver_bind(int fd_sysfs_drv, const char *dev_bus_addr) } /* Remove (virtually unplug) the device from its bus */ -static void device_unplug(int fd_sysfs_dev) +static void device_unplug(int fd_sysfs_dev, const char *prefix) { + igt_debug("%sunplugging the device\n", prefix); + failure = "Device unplug timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_dev, "device/remove", "1"); @@ -142,6 +150,8 @@ static void device_unplug(int fd_sysfs_dev) /* Re-discover the device by rescanning its bus */ static void bus_rescan(int fd_sysfs_bus) { + igt_debug("rediscovering the device\n"); + failure = "Bus rescan timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_bus, "rescan", "1"); @@ -158,9 +168,8 @@ static void healthcheck(void) /* device name may have changed, rebuild IGT device list */ igt_devices_scan(true); - igt_debug("reopening the device\n"); failure = "Device reopen failure!"; - fd_drm = local_drm_open_driver(); + fd_drm = local_drm_open_driver("re", " for health check"); failure = NULL; if (is_i915_device(fd_drm)) { @@ -199,10 +208,8 @@ static void unbind_rebind(void) igt_debug("closing the device\n"); close(priv.fd.drm); - igt_debug("unbinding the driver from the device\n"); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, ""); - igt_debug("rebinding the driver to the device\n"); driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); healthcheck(); @@ -217,10 +224,8 @@ static void unplug_rescan(void) igt_debug("closing the device\n"); close(priv.fd.drm); - igt_debug("unplugging the device\n"); - device_unplug(priv.fd.sysfs_dev); + device_unplug(priv.fd.sysfs_dev, ""); - igt_debug("recovering the device\n"); bus_rescan(priv.fd.sysfs_bus); healthcheck(); @@ -233,10 +238,8 @@ static void hotunbind_lateclose(void) prepare(&priv, buf, sizeof(buf)); - igt_debug("hot unbinding the driver from the device\n"); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, "hot "); - igt_debug("rebinding the driver to the device\n"); driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); igt_debug("late closing the unbound device instance\n"); @@ -251,10 +254,8 @@ static void hotunplug_lateclose(void) prepare(&priv, NULL, 0); - igt_debug("hot unplugging the device\n"); - device_unplug(priv.fd.sysfs_dev); + device_unplug(priv.fd.sysfs_dev, "hot "); - igt_debug("recovering the device\n"); bus_rescan(priv.fd.sysfs_bus); igt_debug("late closing the removed device instance\n"); From patchwork Fri Sep 11 10:30:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770221 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F127959D for ; Fri, 11 Sep 2020 10:31:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C904D208FE for ; Fri, 11 Sep 2020 10:31:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C904D208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1977899E6; Fri, 11 Sep 2020 10:31:02 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 710EA899E6; Fri, 11 Sep 2020 10:31:01 +0000 (UTC) IronPort-SDR: vlCNv+T6U+/gfrHcGr4LVIDJFwfD4WqvUBVwRxI706BMaEhNlMVk3p2n6qC6rhZvWKeaSJ5ZGf bWsn2nBU/QeA== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463198" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463198" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:01 -0700 IronPort-SDR: w8vU/rvwTWGYswlz4nAKdIdm8DD6dTo8UPaQpz1KX8wAvHlubdsWDh1r003VrYvtzatwWsEG96 YIwgqZFMGGNg== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474719" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:30:59 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:20 +0200 Message-Id: <20200911103039.4574-6-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 05/24] tests/core_hotunplug: Assert successful device filter application 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Return value of igt_device_filter_add() representing a number of successfully installed device filters is now ignored. Fail if not 1. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index fc239324a..2f7031094 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -193,7 +193,7 @@ static void set_filter_from_device(int fd) igt_assert(realpath(path, dst)); igt_device_filter_free_all(); - igt_device_filter_add(filter); + igt_assert_eq(igt_device_filter_add(filter), 1); } /* Subtests */ From patchwork Fri Sep 11 10:30:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770223 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC195112E for ; Fri, 11 Sep 2020 10:31:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C73312076C for ; Fri, 11 Sep 2020 10:31:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C73312076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E12AE89580; Fri, 11 Sep 2020 10:31:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D74B89E03; Fri, 11 Sep 2020 10:31:03 +0000 (UTC) IronPort-SDR: jhmaJs0Bp/s5f/DlPUbcpFDSW8SA2q4q/VlQgMtUBhclNuzN+bkARB6dT/hKV9Uvn/yXTrasEC 1PuOxjdSMN9g== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463201" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463201" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:03 -0700 IronPort-SDR: IEHtS1gCSpc4sAvOZYSzNuTdcIRsVVtplJMvqu2uiVmwSgA4mUS7znm9QAraw1gWcdz4Mr5z/8 LW3YmuOpoa8A== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474730" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:01 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:21 +0200 Message-Id: <20200911103039.4574-7-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 06/24] tests/core_hotunplug: Maintain a single data structure instance 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The following changes to the test are planned: - avoid global variables if possible, - prepare invariant data only once per test run, - skip subsequent subtests after device close errors, - allow subtests to fail on errors and try to recover from those failures in follow up igt dixture sections instead of aborting. For that to be possible, maintain a single instance of hotunplug structure at igt_main level and pass it down to subtests. v2: Commit description refreshed. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 56 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 2f7031094..cb5f10474 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -198,68 +198,62 @@ static void set_filter_from_device(int fd) /* Subtests */ -static void unbind_rebind(void) +static void unbind_rebind(struct hotunplug *priv) { - struct hotunplug priv; char buf[PATH_MAX]; - prepare(&priv, buf, sizeof(buf)); + prepare(priv, buf, sizeof(buf)); igt_debug("closing the device\n"); - close(priv.fd.drm); + close(priv->fd.drm); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, ""); + driver_unbind(priv->fd.sysfs_drv, priv->dev_bus_addr, ""); - driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_bind(priv->fd.sysfs_drv, priv->dev_bus_addr); healthcheck(); } -static void unplug_rescan(void) +static void unplug_rescan(struct hotunplug *priv) { - struct hotunplug priv; - - prepare(&priv, NULL, 0); + prepare(priv, NULL, 0); igt_debug("closing the device\n"); - close(priv.fd.drm); + close(priv->fd.drm); - device_unplug(priv.fd.sysfs_dev, ""); + device_unplug(priv->fd.sysfs_dev, ""); - bus_rescan(priv.fd.sysfs_bus); + bus_rescan(priv->fd.sysfs_bus); healthcheck(); } -static void hotunbind_lateclose(void) +static void hotunbind_lateclose(struct hotunplug *priv) { - struct hotunplug priv; char buf[PATH_MAX]; - prepare(&priv, buf, sizeof(buf)); + prepare(priv, buf, sizeof(buf)); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, "hot "); + driver_unbind(priv->fd.sysfs_drv, priv->dev_bus_addr, "hot "); - driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_bind(priv->fd.sysfs_drv, priv->dev_bus_addr); igt_debug("late closing the unbound device instance\n"); - close(priv.fd.drm); + close(priv->fd.drm); healthcheck(); } -static void hotunplug_lateclose(void) +static void hotunplug_lateclose(struct hotunplug *priv) { - struct hotunplug priv; - - prepare(&priv, NULL, 0); + prepare(priv, NULL, 0); - device_unplug(priv.fd.sysfs_dev, "hot "); + device_unplug(priv->fd.sysfs_dev, "hot "); - bus_rescan(priv.fd.sysfs_bus); + bus_rescan(priv->fd.sysfs_bus); igt_debug("late closing the removed device instance\n"); - close(priv.fd.drm); + close(priv->fd.drm); healthcheck(); } @@ -268,6 +262,8 @@ static void hotunplug_lateclose(void) igt_main { + struct hotunplug priv; + igt_fixture { int fd_drm; @@ -287,28 +283,28 @@ igt_main igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); igt_subtest("unbind-rebind") - unbind_rebind(); + unbind_rebind(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure); igt_describe("Check if a device believed to be closed can be cleanly unplugged"); igt_subtest("unplug-rescan") - unplug_rescan(); + unplug_rescan(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure); igt_describe("Check if the driver can be cleanly unbound from a still open device, then released"); igt_subtest("hotunbind-lateclose") - hotunbind_lateclose(); + hotunbind_lateclose(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure); igt_describe("Check if a still open device can be cleanly unplugged, then released"); igt_subtest("hotunplug-lateclose") - hotunplug_lateclose(); + hotunplug_lateclose(&priv); igt_fixture igt_abort_on_f(failure, "%s\n", failure); From patchwork Fri Sep 11 10:30:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770225 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2717112E for ; Fri, 11 Sep 2020 10:31:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8B3FB208FE for ; Fri, 11 Sep 2020 10:31:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B3FB208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9558589E03; Fri, 11 Sep 2020 10:31:07 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CC9A6E9FC; Fri, 11 Sep 2020 10:31:05 +0000 (UTC) IronPort-SDR: D0iTo8CueSsmFzztVyzk0dRL3cNrsodU82MVgBvfqnAW47BwhlgzbzMZpHnxOnclgmQQiUZN0Z CISZSvcR9K4A== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463207" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463207" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:05 -0700 IronPort-SDR: UUOQua7ZhH4hls60eHVc+lNCDckdrflj9z3c4aFGgcCsGKvdChwX6dya1FL6sUORhVgLt01JqD xrXKj08udrvQ== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474747" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:03 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:22 +0200 Message-Id: <20200911103039.4574-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 07/24] tests/core_hotunplug: Pass errors via a data structure field 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" A pointer to fatal error messages can be passed around via hotunplug structure, no need to declare it as global. v2: Rebase only. v3: Refresh. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 96 +++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index cb5f10474..5c9c4d8bf 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -45,6 +45,7 @@ struct hotunplug { int sysfs_drv; } fd; const char *dev_bus_addr; + const char *failure; }; /* Helpers */ @@ -102,80 +103,77 @@ static void prepare(struct hotunplug *priv, char *buf, int buflen) } } -static const char *failure; - /* Unbind the driver from the device */ -static void driver_unbind(int fd_sysfs_drv, const char *dev_bus_addr, - const char *prefix) +static void driver_unbind(struct hotunplug *priv, const char *prefix) { igt_debug("%sunbinding the driver from the device\n", prefix); - failure = "Driver unbind timeout!"; - igt_set_timeout(60, failure); - igt_sysfs_set(fd_sysfs_drv, "unbind", dev_bus_addr); + priv->failure = "Driver unbind timeout!"; + igt_set_timeout(60, priv->failure); + igt_sysfs_set(priv->fd.sysfs_drv, "unbind", priv->dev_bus_addr); igt_reset_timeout(); - failure = NULL; + priv->failure = NULL; - /* don't close fd_sysfs_drv, it will be used for driver rebinding */ + /* don't close fd.sysfs_drv, it will be used for driver rebinding */ } /* Re-bind the driver to the device */ -static void driver_bind(int fd_sysfs_drv, const char *dev_bus_addr) +static void driver_bind(struct hotunplug *priv) { igt_debug("rebinding the driver to the device\n"); - failure = "Driver re-bind timeout!"; - igt_set_timeout(60, failure); - igt_sysfs_set(fd_sysfs_drv, "bind", dev_bus_addr); + priv->failure = "Driver re-bind timeout!"; + igt_set_timeout(60, priv->failure); + igt_sysfs_set(priv->fd.sysfs_drv, "bind", priv->dev_bus_addr); igt_reset_timeout(); - failure = NULL; + priv->failure = NULL; - close(fd_sysfs_drv); + close(priv->fd.sysfs_drv); } /* Remove (virtually unplug) the device from its bus */ -static void device_unplug(int fd_sysfs_dev, const char *prefix) +static void device_unplug(struct hotunplug *priv, const char *prefix) { igt_debug("%sunplugging the device\n", prefix); - failure = "Device unplug timeout!"; - igt_set_timeout(60, failure); - igt_sysfs_set(fd_sysfs_dev, "device/remove", "1"); + priv->failure = "Device unplug timeout!"; + igt_set_timeout(60, priv->failure); + igt_sysfs_set(priv->fd.sysfs_dev, "device/remove", "1"); igt_reset_timeout(); - failure = NULL; + priv->failure = NULL; - close(fd_sysfs_dev); + close(priv->fd.sysfs_dev); } /* Re-discover the device by rescanning its bus */ -static void bus_rescan(int fd_sysfs_bus) +static void bus_rescan(struct hotunplug *priv) { igt_debug("rediscovering the device\n"); - failure = "Bus rescan timeout!"; - igt_set_timeout(60, failure); - igt_sysfs_set(fd_sysfs_bus, "rescan", "1"); + priv->failure = "Bus rescan timeout!"; + igt_set_timeout(60, priv->failure); + igt_sysfs_set(priv->fd.sysfs_bus, "rescan", "1"); igt_reset_timeout(); - failure = NULL; + priv->failure = NULL; - close(fd_sysfs_bus); + close(priv->fd.sysfs_bus); } -static void healthcheck(void) +static void healthcheck(struct hotunplug *priv) { int fd_drm; /* device name may have changed, rebuild IGT device list */ igt_devices_scan(true); - failure = "Device reopen failure!"; + priv->failure = "Device reopen failure!"; fd_drm = local_drm_open_driver("re", " for health check"); - failure = NULL; + priv->failure = NULL; if (is_i915_device(fd_drm)) { - failure = "GEM failure"; + priv->failure = "GEM failure"; igt_require_gem(fd_drm); - failure = NULL; + priv->failure = NULL; } close(fd_drm); @@ -207,11 +205,11 @@ static void unbind_rebind(struct hotunplug *priv) igt_debug("closing the device\n"); close(priv->fd.drm); - driver_unbind(priv->fd.sysfs_drv, priv->dev_bus_addr, ""); + driver_unbind(priv, ""); - driver_bind(priv->fd.sysfs_drv, priv->dev_bus_addr); + driver_bind(priv); - healthcheck(); + healthcheck(priv); } static void unplug_rescan(struct hotunplug *priv) @@ -221,11 +219,11 @@ static void unplug_rescan(struct hotunplug *priv) igt_debug("closing the device\n"); close(priv->fd.drm); - device_unplug(priv->fd.sysfs_dev, ""); + device_unplug(priv, ""); - bus_rescan(priv->fd.sysfs_bus); + bus_rescan(priv); - healthcheck(); + healthcheck(priv); } static void hotunbind_lateclose(struct hotunplug *priv) @@ -234,35 +232,35 @@ static void hotunbind_lateclose(struct hotunplug *priv) prepare(priv, buf, sizeof(buf)); - driver_unbind(priv->fd.sysfs_drv, priv->dev_bus_addr, "hot "); + driver_unbind(priv, "hot "); - driver_bind(priv->fd.sysfs_drv, priv->dev_bus_addr); + driver_bind(priv); igt_debug("late closing the unbound device instance\n"); close(priv->fd.drm); - healthcheck(); + healthcheck(priv); } static void hotunplug_lateclose(struct hotunplug *priv) { prepare(priv, NULL, 0); - device_unplug(priv->fd.sysfs_dev, "hot "); + device_unplug(priv, "hot "); - bus_rescan(priv->fd.sysfs_bus); + bus_rescan(priv); igt_debug("late closing the removed device instance\n"); close(priv->fd.drm); - healthcheck(); + healthcheck(priv); } /* Main */ igt_main { - struct hotunplug priv; + struct hotunplug priv = { .failure = NULL, }; igt_fixture { int fd_drm; @@ -286,26 +284,26 @@ igt_main unbind_rebind(&priv); igt_fixture - igt_abort_on_f(failure, "%s\n", failure); + igt_abort_on_f(priv.failure, "%s\n", priv.failure); igt_describe("Check if a device believed to be closed can be cleanly unplugged"); igt_subtest("unplug-rescan") unplug_rescan(&priv); igt_fixture - igt_abort_on_f(failure, "%s\n", failure); + igt_abort_on_f(priv.failure, "%s\n", priv.failure); igt_describe("Check if the driver can be cleanly unbound from a still open device, then released"); igt_subtest("hotunbind-lateclose") hotunbind_lateclose(&priv); igt_fixture - igt_abort_on_f(failure, "%s\n", failure); + igt_abort_on_f(priv.failure, "%s\n", priv.failure); igt_describe("Check if a still open device can be cleanly unplugged, then released"); igt_subtest("hotunplug-lateclose") hotunplug_lateclose(&priv); igt_fixture - igt_abort_on_f(failure, "%s\n", failure); + igt_abort_on_f(priv.failure, "%s\n", priv.failure); } From patchwork Fri Sep 11 10:30:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06BAA59D for ; Fri, 11 Sep 2020 10:31:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CFBF1221ED for ; Fri, 11 Sep 2020 10:31:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFBF1221ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27AB489817; Fri, 11 Sep 2020 10:31:09 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 957106E9FC; Fri, 11 Sep 2020 10:31:07 +0000 (UTC) IronPort-SDR: l0NSGrUoYXGR6jc085/17bx1KaeCZjgc6l/aBUbiupfPVHbEcZh+/FJw+LL8itWjAvY6LUwO4P 71kVT41JrOqQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463215" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463215" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:07 -0700 IronPort-SDR: p/14fP1O/Ee1+4cv6f00iOtO5A8aSVENG3tAqKN/fNnKy+FKayqovKLhYjhwW7W4S5HrIM6bo6 tmBRJaJI2j7g== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474754" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:05 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:23 +0200 Message-Id: <20200911103039.4574-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 08/24] tests/core_hotunplug: Handle device close errors 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The test now ignores device close errors. Those errors are believed to have no influence on device health so there is no need to process them the same way as we mostly do on errors, i.e., notify CI about a problem via igt_abort. However, those errors may indicate issues with the test itself. Moreover, impact of those errors on operations performed by subtests, like driver unbind or device remove, should be perceived as undefined. Then, we should fail as soon as a device or device sysfs node close error occurs in a subtest and also skip subsequent subtests. However, once a driver unbind or device unplug operation has been attempted by a subtest, we would still like to check the device health. When in a subtest, store results of device close operations for future reference. Reuse file descriptor fields of the hotunplug structure for that. Unless in between of a driver remove or device unplug operation and a successful device health check completion, fail current test section right after a device close error occurs, warn otherwise. If still running, examine device file descriptor fields in subsequent igt_fixture sections and skip on errors. v2: Fix a typo in post_healthcheck function name. v3: Don't fail on close error after successful health check, warn only, - move duplicated device close error messages to helpers. v4: Assert device file descriptors closed cleanly on start of each subtest. v5: Update device status on open for health check if not yet dirty, - move device close debug messages to helper. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v1 --- tests/core_hotunplug.c | 76 ++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 5c9c4d8bf..51de942ba 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -43,7 +43,7 @@ struct hotunplug { int sysfs_dev; int sysfs_bus; int sysfs_drv; - } fd; + } fd; /* >= 0: valid fd, == -1: closed, < -1: close failed */ const char *dev_bus_addr; const char *failure; }; @@ -67,6 +67,26 @@ static int local_drm_open_driver(const char *when, const char *why) return fd_drm; } +static int local_close(int fd, const char *warning) +{ + errno = 0; + if (igt_warn_on_f(close(fd), "%s\n", warning)) + return -errno; /* (never -1) */ + + return -1; /* success - return 'closed' */ +} + +static int close_device(int fd_drm, const char *when, const char *which) +{ + igt_debug("%sclosing %sdevice instance\n", when, which); + return local_close(fd_drm, "Device close failed"); +} + +static int close_sysfs(int fd_sysfs_dev) +{ + return local_close(fd_sysfs_dev, "Device sysfs node close failed"); +} + static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) { int len; @@ -83,11 +103,16 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) igt_assert(priv->dev_bus_addr++); /* sysfs_dev no longer needed */ - close(priv->fd.sysfs_dev); + priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); + igt_assert_eq(priv->fd.sysfs_dev, -1); } static void prepare(struct hotunplug *priv, char *buf, int buflen) { + /* assert device file descriptors closed cleanly on subtest start */ + igt_assert_eq(priv->fd.drm, -1); + igt_assert_eq(priv->fd.sysfs_dev, -1); + priv->fd.drm = local_drm_open_driver("", " for subtest"); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); @@ -142,7 +167,7 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) igt_reset_timeout(); priv->failure = NULL; - close(priv->fd.sysfs_dev); + priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } /* Re-discover the device by rescanning its bus */ @@ -161,6 +186,8 @@ static void bus_rescan(struct hotunplug *priv) static void healthcheck(struct hotunplug *priv) { + /* preserve potentially dirty device status stored in priv->fd.drm */ + bool closed = priv->fd.drm == -1; int fd_drm; /* device name may have changed, rebuild IGT device list */ @@ -168,6 +195,8 @@ static void healthcheck(struct hotunplug *priv) priv->failure = "Device reopen failure!"; fd_drm = local_drm_open_driver("re", " for health check"); + if (closed) /* store fd for post_healthcheck if not dirty */ + priv->fd.drm = fd_drm; priv->failure = NULL; if (is_i915_device(fd_drm)) { @@ -176,7 +205,17 @@ static void healthcheck(struct hotunplug *priv) priv->failure = NULL; } - close(fd_drm); + fd_drm = close_device(fd_drm, "", "health checked "); + if (closed || fd_drm < -1) /* update status for post_healthcheck */ + priv->fd.drm = fd_drm; +} + +static void post_healthcheck(struct hotunplug *priv) +{ + igt_abort_on_f(priv->failure, "%s\n", priv->failure); + + igt_require(priv->fd.drm == -1); + igt_require(priv->fd.sysfs_dev == -1); } static void set_filter_from_device(int fd) @@ -202,8 +241,8 @@ static void unbind_rebind(struct hotunplug *priv) prepare(priv, buf, sizeof(buf)); - igt_debug("closing the device\n"); - close(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "exercised "); + igt_assert_eq(priv->fd.drm, -1); driver_unbind(priv, ""); @@ -216,8 +255,8 @@ static void unplug_rescan(struct hotunplug *priv) { prepare(priv, NULL, 0); - igt_debug("closing the device\n"); - close(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "exercised "); + igt_assert_eq(priv->fd.drm, -1); device_unplug(priv, ""); @@ -236,8 +275,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) driver_bind(priv); - igt_debug("late closing the unbound device instance\n"); - close(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); healthcheck(priv); } @@ -250,8 +288,7 @@ static void hotunplug_lateclose(struct hotunplug *priv) bus_rescan(priv); - igt_debug("late closing the removed device instance\n"); - close(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); healthcheck(priv); } @@ -260,7 +297,10 @@ static void hotunplug_lateclose(struct hotunplug *priv) igt_main { - struct hotunplug priv = { .failure = NULL, }; + struct hotunplug priv = { + .fd = { .drm = -1, .sysfs_dev = -1, }, + .failure = NULL, + }; igt_fixture { int fd_drm; @@ -276,7 +316,7 @@ igt_main /* Make sure subtests always reopen the same device */ set_filter_from_device(fd_drm); - close(fd_drm); + igt_assert_eq(close_device(fd_drm, "", "selected "), -1); } igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); @@ -284,26 +324,26 @@ igt_main unbind_rebind(&priv); igt_fixture - igt_abort_on_f(priv.failure, "%s\n", priv.failure); + post_healthcheck(&priv); igt_describe("Check if a device believed to be closed can be cleanly unplugged"); igt_subtest("unplug-rescan") unplug_rescan(&priv); igt_fixture - igt_abort_on_f(priv.failure, "%s\n", priv.failure); + post_healthcheck(&priv); igt_describe("Check if the driver can be cleanly unbound from a still open device, then released"); igt_subtest("hotunbind-lateclose") hotunbind_lateclose(&priv); igt_fixture - igt_abort_on_f(priv.failure, "%s\n", priv.failure); + post_healthcheck(&priv); igt_describe("Check if a still open device can be cleanly unplugged, then released"); igt_subtest("hotunplug-lateclose") hotunplug_lateclose(&priv); igt_fixture - igt_abort_on_f(priv.failure, "%s\n", priv.failure); + post_healthcheck(&priv); } From patchwork Fri Sep 11 10:30:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB323112E for ; Fri, 11 Sep 2020 10:31:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9981D221ED for ; Fri, 11 Sep 2020 10:31:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9981D221ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02A058995F; Fri, 11 Sep 2020 10:31:11 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86B2C6E9FD; Fri, 11 Sep 2020 10:31:09 +0000 (UTC) IronPort-SDR: Vg0ZAA53H1YfGmwyNki6nP3WbVE5Qvowc8IpfWJCkBrg+YEEOgcChvb5C2+zKZsURPLSTVQ014 1M27Jv91Ze8w== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463231" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463231" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:09 -0700 IronPort-SDR: HNmq7Zh+/+oQ18IZk1qIwslyaWe/p5owxki8kq9E7H4aa9dIgB09HrWSDbNKd6AKmtK8ejMpQL kGdU86AUfZdg== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474759" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:07 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:24 +0200 Message-Id: <20200911103039.4574-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 09/24] tests/core_hotunplug: Prepare invariant data once per test run 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Each subtest now calls a prepare() helper which opens a couple of files required by that subtest. Those files are then closed after use, either directly from the subtest body, or indirectly from inside one of helper functions called during the subtest execution. That approach not only makes life cycle of individual file descriptors difficult to follow but also prevents us from re-running health checks on subtest failures from follow up igt_fixture sections since we may need to retry bus rescan or driver rebind operations. Two of those files - device bus and driver sysfs nodes - are not affected nor interfere with driver unbind / device unplug operations performed by subtests. Then, there is not much sense in closing and reopening those nodes. Open them once at the beginning of a test run, then close them as late as on test completion. The prepare() helper also populates a device bus address string used by driver unbind / rebind operations. Since the bus address of an exercised device never changes, also prepare that string only once at the beginning of a test run. Note that it is the same as the last component of a device filter string which is already resolved and installed from an initial igt_fixture section of the test. Then, initialize the device bus address field of a hotunplug structure instance with a pointer to the respective substring of that filter rather than resolving it again from the device sysfs node pathname. There is one more sysfs node - a DRM device node - now opened by the prepare() helper for subtests which perform device remove operations. That node can't be opened only once at the beginning of a test run because its open file descriptor is no longer usable as soon as a driver unbind operation is performed. On the other hand, it can't be opened easily from inside a device_remove() helper since some subtests just don't open the device so its file descriptor used by igt_sysfs_open() may just not be available. However, note that only a PCI sysfs node of the device, not necessarily the DRM one, is actually required for a successful device remove operation, and that node can be opened easily from a bus file descriptor using a device bus address string, both already available. Then, change the semantics of a .fd.sysfs_dev field of the hotunplug structure from DRM to PCI device sysfs file descriptor, then let the device_remove() helper open the device PCI node by itself and store its file descriptor in that field. Also, for still more easy access to the device PCI node, use a 'subsystem/devices' sub-node of the PCI device as its bus sysfs location instead of just 'subsystem', then adjust a relative path to the bus 'rescan' function accordingly. A side benefit of using the PCI device sysfs node, not the DRM one, while removing the device is that a future subtest may now easily perform both driver unbind and device remove operations in a row. v2: Rebase only. v3: Refresh. v4: Refresh, still assert a device dile descriptor closed cleanly on subtest start, a device sysfs file descriptor still before open. Suggested-by: Michał Winiarski Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v1 --- tests/core_hotunplug.c | 83 +++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 50 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 51de942ba..7f5e800c6 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -87,45 +87,31 @@ static int close_sysfs(int fd_sysfs_dev) return local_close(fd_sysfs_dev, "Device sysfs node close failed"); } -static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) +static void prepare(struct hotunplug *priv) { - int len; + const char *filter = igt_device_filter_get(0), *sysfs_path; - igt_assert(buflen); + igt_assert(filter); - priv->fd.sysfs_drv = openat(priv->fd.sysfs_dev, "device/driver", - O_DIRECTORY); - igt_assert_fd(priv->fd.sysfs_drv); - - len = readlinkat(priv->fd.sysfs_dev, "device", buf, buflen - 1); - buf[len] = '\0'; - priv->dev_bus_addr = strrchr(buf, '/'); + priv->dev_bus_addr = strrchr(filter, '/'); igt_assert(priv->dev_bus_addr++); - /* sysfs_dev no longer needed */ - priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); - igt_assert_eq(priv->fd.sysfs_dev, -1); -} + sysfs_path = strchr(filter, ':'); + igt_assert(sysfs_path++); -static void prepare(struct hotunplug *priv, char *buf, int buflen) -{ - /* assert device file descriptors closed cleanly on subtest start */ - igt_assert_eq(priv->fd.drm, -1); igt_assert_eq(priv->fd.sysfs_dev, -1); + priv->fd.sysfs_dev = open(sysfs_path, O_DIRECTORY); + igt_assert_fd(priv->fd.sysfs_dev); - priv->fd.drm = local_drm_open_driver("", " for subtest"); + priv->fd.sysfs_drv = openat(priv->fd.sysfs_dev, "driver", O_DIRECTORY); + igt_assert_fd(priv->fd.sysfs_drv); - priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); - igt_assert_fd(priv->fd.sysfs_dev); + priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev, "subsystem/devices", + O_DIRECTORY); + igt_assert_fd(priv->fd.sysfs_bus); - if (buf) { - prepare_for_unbind(priv, buf, buflen); - } else { - /* prepare for bus rescan */ - priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev, - "device/subsystem", O_DIRECTORY); - igt_assert_fd(priv->fd.sysfs_bus); - } + priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); + igt_assert_eq(priv->fd.sysfs_dev, -1); } /* Unbind the driver from the device */ @@ -138,8 +124,6 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix) igt_sysfs_set(priv->fd.sysfs_drv, "unbind", priv->dev_bus_addr); igt_reset_timeout(); priv->failure = NULL; - - /* don't close fd.sysfs_drv, it will be used for driver rebinding */ } /* Re-bind the driver to the device */ @@ -152,18 +136,21 @@ static void driver_bind(struct hotunplug *priv) igt_sysfs_set(priv->fd.sysfs_drv, "bind", priv->dev_bus_addr); igt_reset_timeout(); priv->failure = NULL; - - close(priv->fd.sysfs_drv); } /* Remove (virtually unplug) the device from its bus */ static void device_unplug(struct hotunplug *priv, const char *prefix) { + igt_assert_eq(priv->fd.sysfs_dev, -1); + priv->fd.sysfs_dev = openat(priv->fd.sysfs_bus, priv->dev_bus_addr, + O_DIRECTORY); + igt_assert_fd(priv->fd.sysfs_dev); + igt_debug("%sunplugging the device\n", prefix); priv->failure = "Device unplug timeout!"; igt_set_timeout(60, priv->failure); - igt_sysfs_set(priv->fd.sysfs_dev, "device/remove", "1"); + igt_sysfs_set(priv->fd.sysfs_dev, "remove", "1"); igt_reset_timeout(); priv->failure = NULL; @@ -177,11 +164,9 @@ static void bus_rescan(struct hotunplug *priv) priv->failure = "Bus rescan timeout!"; igt_set_timeout(60, priv->failure); - igt_sysfs_set(priv->fd.sysfs_bus, "rescan", "1"); + igt_sysfs_set(priv->fd.sysfs_bus, "../rescan", "1"); igt_reset_timeout(); priv->failure = NULL; - - close(priv->fd.sysfs_bus); } static void healthcheck(struct hotunplug *priv) @@ -237,11 +222,6 @@ static void set_filter_from_device(int fd) static void unbind_rebind(struct hotunplug *priv) { - char buf[PATH_MAX]; - - prepare(priv, buf, sizeof(buf)); - - priv->fd.drm = close_device(priv->fd.drm, "", "exercised "); igt_assert_eq(priv->fd.drm, -1); driver_unbind(priv, ""); @@ -253,9 +233,6 @@ static void unbind_rebind(struct hotunplug *priv) static void unplug_rescan(struct hotunplug *priv) { - prepare(priv, NULL, 0); - - priv->fd.drm = close_device(priv->fd.drm, "", "exercised "); igt_assert_eq(priv->fd.drm, -1); device_unplug(priv, ""); @@ -267,9 +244,8 @@ static void unplug_rescan(struct hotunplug *priv) static void hotunbind_lateclose(struct hotunplug *priv) { - char buf[PATH_MAX]; - - prepare(priv, buf, sizeof(buf)); + igt_assert_eq(priv->fd.drm, -1); + priv->fd.drm = local_drm_open_driver("", " for hot unbind"); driver_unbind(priv, "hot "); @@ -282,7 +258,8 @@ static void hotunbind_lateclose(struct hotunplug *priv) static void hotunplug_lateclose(struct hotunplug *priv) { - prepare(priv, NULL, 0); + igt_assert_eq(priv->fd.drm, -1); + priv->fd.drm = local_drm_open_driver("", " for hot unplug"); device_unplug(priv, "hot "); @@ -317,6 +294,8 @@ igt_main set_filter_from_device(fd_drm); igt_assert_eq(close_device(fd_drm, "", "selected "), -1); + + prepare(&priv); } igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); @@ -344,6 +323,10 @@ igt_main igt_subtest("hotunplug-lateclose") hotunplug_lateclose(&priv); - igt_fixture + igt_fixture { post_healthcheck(&priv); + + close(priv.fd.sysfs_bus); + close(priv.fd.sysfs_drv); + } } From patchwork Fri Sep 11 10:30:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CB8D112E for ; Fri, 11 Sep 2020 10:31:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1C4C32076C for ; Fri, 11 Sep 2020 10:31:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C4C32076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B7CE89A83; Fri, 11 Sep 2020 10:31:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 96CB36E9FF; Fri, 11 Sep 2020 10:31:11 +0000 (UTC) IronPort-SDR: deHy9dE8fvqaKwjg0jCw8zyVyJInYZR9aRTqxYCCqaJidrW1xmwAwcFDkoKVHYXAh8/Z7Vm+6e 1jKYZC155NzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463247" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463247" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:11 -0700 IronPort-SDR: RNocfXiY+8D89xZDkh17vNJui1CJuGyWjDsZv58Ppg5lLBTC3mhccDr8hUDjZjy2NQvvev//WM vDP2lxAEmNcA== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474766" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:09 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:25 +0200 Message-Id: <20200911103039.4574-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 10/24] tests/core_hotunplug: Skip selectively on sysfs close errors 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since we no longer open a device DRM sysfs node, only a PCI one, driver unbind operations are no longer affected by missed or unsuccessful sysfs file close attempts. Skip only affected subtests if that happens. v2: Rebase only. v3: Refresh. v4: Refresh. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 7f5e800c6..d51526029 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -111,7 +111,6 @@ static void prepare(struct hotunplug *priv) igt_assert_fd(priv->fd.sysfs_bus); priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); - igt_assert_eq(priv->fd.sysfs_dev, -1); } /* Unbind the driver from the device */ @@ -141,7 +140,8 @@ static void driver_bind(struct hotunplug *priv) /* Remove (virtually unplug) the device from its bus */ static void device_unplug(struct hotunplug *priv, const char *prefix) { - igt_assert_eq(priv->fd.sysfs_dev, -1); + igt_require(priv->fd.sysfs_dev == -1); + priv->fd.sysfs_dev = openat(priv->fd.sysfs_bus, priv->dev_bus_addr, O_DIRECTORY); igt_assert_fd(priv->fd.sysfs_dev); @@ -200,7 +200,6 @@ static void post_healthcheck(struct hotunplug *priv) igt_abort_on_f(priv->failure, "%s\n", priv->failure); igt_require(priv->fd.drm == -1); - igt_require(priv->fd.sysfs_dev == -1); } static void set_filter_from_device(int fd) From patchwork Fri Sep 11 10:30:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770233 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98CCF59D for ; Fri, 11 Sep 2020 10:31:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7A3C6221ED for ; Fri, 11 Sep 2020 10:31:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A3C6221ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E9FD6E9FC; Fri, 11 Sep 2020 10:31:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE67F6E9FC; Fri, 11 Sep 2020 10:31:13 +0000 (UTC) IronPort-SDR: VfUnqrnR4Bi/rr/NmWePchV0Bm00Urt3KJYKyl+Q5BKjp2YVXlkPHESd4Fvz4N0VrM9OQYcdfZ jo9NTq19uXTw== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463264" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463264" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:13 -0700 IronPort-SDR: ixYrhW6qjd2Ytg3OlR54NuTg0KI1s2+EVza7kYxTMA6/nH7dcew4KVwMPLamKlNPsJugOdZdu6 vslbADg9/ZHQ== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474773" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:11 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:26 +0200 Message-Id: <20200911103039.4574-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 11/24] tests/core_hotunplug: Recover from subtest failures 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Subtests now forcibly call or request igt_abort on failures in order to avoid silently leaving an exercised device in an unusable state. However, a failure inside a subtest doesn't always mean the device is no longer working correctly and reboot is needed. On the other hand, if a subtest just fails without aborting, that doesn't mean in turn the device is healthy. We should still perform a device health check in that case before deciding on next steps. Reuse the 'failure' structure field as a mark which is set before each critical operation is executed that must be followed by a successful health check in order to avoid aborting the test. Then, follow each subtest with its individual igt_fixture section, from where device file descriptors potentially left open are closed, device rediscover or driver rebing operation is run as needed, and finally the health check is run again if the preceding igt_subtest section has exited with the marker set. v2: Start each recovery phase from unconditionally closing file descriptors potentially left open by a subtest before it entered its critical section, - replace igt_require() with 'if() return;' construct in recover() to reduce noise, - replace "subtest failure" message used as a request for healthcheck with a more appropriate "need healthcheck" for clarity, - rebase on current upstream master. v3: Refresh, - move bus_rescan() and driver_bind() function calls back from heaalthcheck() to recover() so a pure health check can still be called from a subtest if essential, - move failure mark assignments back from subtests to helpers for more adequate abort reason reporting but clean the mark only on health check success, - call cleanup() also from post_healthcheck() in order to close a device file descriptor potentially left open by a failed health check, - reword commit message and update description. v4: Close exercised device fd before failing a health check run, - don't drop health checks from subtest bodies, their results should always matter. v5: Refresh. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v1 --- tests/core_hotunplug.c | 100 ++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 26 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index d51526029..7fc6df688 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -78,12 +78,18 @@ static int local_close(int fd, const char *warning) static int close_device(int fd_drm, const char *when, const char *which) { + if (fd_drm < 0) /* not open - return current status */ + return fd_drm; + igt_debug("%sclosing %sdevice instance\n", when, which); return local_close(fd_drm, "Device close failed"); } static int close_sysfs(int fd_sysfs_dev) { + if (fd_sysfs_dev < 0) /* not open - return current status */ + return fd_sysfs_dev; + return local_close(fd_sysfs_dev, "Device sysfs node close failed"); } @@ -117,24 +123,22 @@ static void prepare(struct hotunplug *priv) static void driver_unbind(struct hotunplug *priv, const char *prefix) { igt_debug("%sunbinding the driver from the device\n", prefix); + priv->failure = "Driver unbind failure!"; - priv->failure = "Driver unbind timeout!"; - igt_set_timeout(60, priv->failure); + igt_set_timeout(60, "Driver unbind timeout!"); igt_sysfs_set(priv->fd.sysfs_drv, "unbind", priv->dev_bus_addr); igt_reset_timeout(); - priv->failure = NULL; } /* Re-bind the driver to the device */ static void driver_bind(struct hotunplug *priv) { igt_debug("rebinding the driver to the device\n"); + priv->failure = "Driver re-bind failure!"; - priv->failure = "Driver re-bind timeout!"; - igt_set_timeout(60, priv->failure); + igt_set_timeout(60, "Driver re-bind timeout!"); igt_sysfs_set(priv->fd.sysfs_drv, "bind", priv->dev_bus_addr); igt_reset_timeout(); - priv->failure = NULL; } /* Remove (virtually unplug) the device from its bus */ @@ -147,12 +151,11 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) igt_assert_fd(priv->fd.sysfs_dev); igt_debug("%sunplugging the device\n", prefix); + priv->failure = "Device unplug failure!"; - priv->failure = "Device unplug timeout!"; - igt_set_timeout(60, priv->failure); + igt_set_timeout(60, "Device unplug timeout!"); igt_sysfs_set(priv->fd.sysfs_dev, "remove", "1"); igt_reset_timeout(); - priv->failure = NULL; priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } @@ -161,12 +164,17 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) static void bus_rescan(struct hotunplug *priv) { igt_debug("rediscovering the device\n"); + priv->failure = "Bus rescan failure!"; - priv->failure = "Bus rescan timeout!"; - igt_set_timeout(60, priv->failure); + igt_set_timeout(60, "Bus rescan timeout!"); igt_sysfs_set(priv->fd.sysfs_bus, "../rescan", "1"); igt_reset_timeout(); - priv->failure = NULL; +} + +static void cleanup(struct hotunplug *priv) +{ + priv->fd.drm = close_device(priv->fd.drm, "post ", "failed "); + priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } static void healthcheck(struct hotunplug *priv) @@ -180,25 +188,45 @@ static void healthcheck(struct hotunplug *priv) priv->failure = "Device reopen failure!"; fd_drm = local_drm_open_driver("re", " for health check"); - if (closed) /* store fd for post_healthcheck if not dirty */ + if (closed) /* store fd for cleanup if not dirty */ priv->fd.drm = fd_drm; - priv->failure = NULL; if (is_i915_device(fd_drm)) { priv->failure = "GEM failure"; igt_require_gem(fd_drm); priv->failure = NULL; + } else { + /* no device specific healthcheck, rely on reopen result */ + priv->failure = NULL; } fd_drm = close_device(fd_drm, "", "health checked "); if (closed || fd_drm < -1) /* update status for post_healthcheck */ priv->fd.drm = fd_drm; + + /* not only request igt_abort on failure, also fail the health check */ + igt_fail_on_f(priv->failure, "%s\n", priv->failure); +} + +static void recover(struct hotunplug *priv) +{ + cleanup(priv); + + if (faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0)) + bus_rescan(priv); + + else if (faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0)) + driver_bind(priv); + + if (priv->failure) + healthcheck(priv); } static void post_healthcheck(struct hotunplug *priv) { igt_abort_on_f(priv->failure, "%s\n", priv->failure); + cleanup(priv); igt_require(priv->fd.drm == -1); } @@ -297,30 +325,50 @@ igt_main prepare(&priv); } - igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); - igt_subtest("unbind-rebind") - unbind_rebind(&priv); + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); + igt_subtest("unbind-rebind") + unbind_rebind(&priv); + + igt_fixture + recover(&priv); + } igt_fixture post_healthcheck(&priv); - igt_describe("Check if a device believed to be closed can be cleanly unplugged"); - igt_subtest("unplug-rescan") - unplug_rescan(&priv); + igt_subtest_group { + igt_describe("Check if a device believed to be closed can be cleanly unplugged"); + igt_subtest("unplug-rescan") + unplug_rescan(&priv); + + igt_fixture + recover(&priv); + } igt_fixture post_healthcheck(&priv); - igt_describe("Check if the driver can be cleanly unbound from a still open device, then released"); - igt_subtest("hotunbind-lateclose") - hotunbind_lateclose(&priv); + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unbound from a still open device, then released"); + igt_subtest("hotunbind-lateclose") + hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } igt_fixture post_healthcheck(&priv); - igt_describe("Check if a still open device can be cleanly unplugged, then released"); - igt_subtest("hotunplug-lateclose") - hotunplug_lateclose(&priv); + igt_subtest_group { + igt_describe("Check if a still open device can be cleanly unplugged, then released"); + igt_subtest("hotunplug-lateclose") + hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } igt_fixture { post_healthcheck(&priv); From patchwork Fri Sep 11 10:30:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770235 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFE1259D for ; Fri, 11 Sep 2020 10:31:17 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C0DEA221ED for ; Fri, 11 Sep 2020 10:31:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0DEA221ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A8A86E9FE; Fri, 11 Sep 2020 10:31:17 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id B3CD86E9FE; Fri, 11 Sep 2020 10:31:15 +0000 (UTC) IronPort-SDR: c1aTm5vxka+pCL+fWYvpXBxDjBSJedoz6kLAT1uVULhni792t77enoqvOWgTZzVOw04axUt7rf rX/N3uCgw3CQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463282" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463282" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:15 -0700 IronPort-SDR: Vy73VIlzL/JeH1BbWO8vtlpf/gABiaIOoJtTfDgYOXbP9i6AtulmBxd/IZZabSQq4Bdn28ro0H ayUFZ4gWaWNg== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474789" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:13 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:27 +0200 Message-Id: <20200911103039.4574-13-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 12/24] tests/core_hotunplug: Fail subtests on device close errors 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since health checks are now run from follow-up fixture sections, it is safe to fail subtests without the need to abort the test execution. Do that on device close errors instead of just emitting warnings. v2: Rebase only. v3: Refresh. v4: Refresh. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 7fc6df688..d31faf215 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -158,6 +158,7 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) igt_reset_timeout(); priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); + igt_assert_eq(priv->fd.sysfs_dev, -1); } /* Re-discover the device by rescanning its bus */ @@ -279,6 +280,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) driver_bind(priv); priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); healthcheck(priv); } @@ -293,6 +295,7 @@ static void hotunplug_lateclose(struct hotunplug *priv) bus_rescan(priv); priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); healthcheck(priv); } From patchwork Fri Sep 11 10:30:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D33359D for ; Fri, 11 Sep 2020 10:31:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4EE2A208FE for ; Fri, 11 Sep 2020 10:31:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EE2A208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5FD26EA07; Fri, 11 Sep 2020 10:31:19 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id B97746EA07; Fri, 11 Sep 2020 10:31:17 +0000 (UTC) IronPort-SDR: Q+Ef4GjE/moCCDc6pyKVeRkXBNCQvlpCSaAT8S9+n0VnjDWVNcbgUlHOn1iePmvuRHpIAq0sOR +t2PMeqJvZ7A== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463294" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463294" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:17 -0700 IronPort-SDR: hmyKSpmpVIWx3+TDyxKk/35ljj+i0HL9EBfmjeaC+Vm7mmixc2+dM+AoSxUoOqwozfLRm71vvl JBDYt0AdXZuQ== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474796" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:15 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:28 +0200 Message-Id: <20200911103039.4574-14-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 13/24] tests/core_hotunplug: Let the driver time out essential sysfs operations 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The test now arms a timer before performing each driver unbind / rebind or device unplug / bus rescan sysfs operation. Then in case of issues we may prevent the driver from showing us if and how it can handle them. Don't arm the timer before sysfs operations which are essential for a subtest. v2: Refresh, - don't time out on hot driver rebind / hot device restore in *-lateclose variants, those operations haven't been covered by other subtests. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index d31faf215..6112704f4 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -120,29 +120,31 @@ static void prepare(struct hotunplug *priv) } /* Unbind the driver from the device */ -static void driver_unbind(struct hotunplug *priv, const char *prefix) +static void driver_unbind(struct hotunplug *priv, const char *prefix, + int timeout) { igt_debug("%sunbinding the driver from the device\n", prefix); priv->failure = "Driver unbind failure!"; - igt_set_timeout(60, "Driver unbind timeout!"); + igt_set_timeout(timeout, "Driver unbind timeout!"); igt_sysfs_set(priv->fd.sysfs_drv, "unbind", priv->dev_bus_addr); igt_reset_timeout(); } /* Re-bind the driver to the device */ -static void driver_bind(struct hotunplug *priv) +static void driver_bind(struct hotunplug *priv, int timeout) { igt_debug("rebinding the driver to the device\n"); priv->failure = "Driver re-bind failure!"; - igt_set_timeout(60, "Driver re-bind timeout!"); + igt_set_timeout(timeout, "Driver re-bind timeout!"); igt_sysfs_set(priv->fd.sysfs_drv, "bind", priv->dev_bus_addr); igt_reset_timeout(); } /* Remove (virtually unplug) the device from its bus */ -static void device_unplug(struct hotunplug *priv, const char *prefix) +static void device_unplug(struct hotunplug *priv, const char *prefix, + int timeout) { igt_require(priv->fd.sysfs_dev == -1); @@ -153,7 +155,7 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) igt_debug("%sunplugging the device\n", prefix); priv->failure = "Device unplug failure!"; - igt_set_timeout(60, "Device unplug timeout!"); + igt_set_timeout(timeout, "Device unplug timeout!"); igt_sysfs_set(priv->fd.sysfs_dev, "remove", "1"); igt_reset_timeout(); @@ -162,12 +164,12 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) } /* Re-discover the device by rescanning its bus */ -static void bus_rescan(struct hotunplug *priv) +static void bus_rescan(struct hotunplug *priv, int timeout) { igt_debug("rediscovering the device\n"); priv->failure = "Bus rescan failure!"; - igt_set_timeout(60, "Bus rescan timeout!"); + igt_set_timeout(timeout, "Bus rescan timeout!"); igt_sysfs_set(priv->fd.sysfs_bus, "../rescan", "1"); igt_reset_timeout(); } @@ -214,10 +216,10 @@ static void recover(struct hotunplug *priv) cleanup(priv); if (faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0)) - bus_rescan(priv); + bus_rescan(priv, 60); else if (faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0)) - driver_bind(priv); + driver_bind(priv, 60); if (priv->failure) healthcheck(priv); @@ -252,9 +254,9 @@ static void unbind_rebind(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); - driver_unbind(priv, ""); + driver_unbind(priv, "", 0); - driver_bind(priv); + driver_bind(priv, 0); healthcheck(priv); } @@ -263,9 +265,9 @@ static void unplug_rescan(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); - device_unplug(priv, ""); + device_unplug(priv, "", 0); - bus_rescan(priv); + bus_rescan(priv, 0); healthcheck(priv); } @@ -275,9 +277,9 @@ static void hotunbind_lateclose(struct hotunplug *priv) igt_assert_eq(priv->fd.drm, -1); priv->fd.drm = local_drm_open_driver("", " for hot unbind"); - driver_unbind(priv, "hot "); + driver_unbind(priv, "hot ", 0); - driver_bind(priv); + driver_bind(priv, 0); priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); igt_assert_eq(priv->fd.drm, -1); @@ -290,9 +292,9 @@ static void hotunplug_lateclose(struct hotunplug *priv) igt_assert_eq(priv->fd.drm, -1); priv->fd.drm = local_drm_open_driver("", " for hot unplug"); - device_unplug(priv, "hot "); + device_unplug(priv, "hot ", 0); - bus_rescan(priv); + bus_rescan(priv, 0); priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); igt_assert_eq(priv->fd.drm, -1); From patchwork Fri Sep 11 10:30:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F372D112E for ; Fri, 11 Sep 2020 10:31:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D49842076C for ; Fri, 11 Sep 2020 10:31:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D49842076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49EB96EA09; Fri, 11 Sep 2020 10:31:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D9A06EA05; Fri, 11 Sep 2020 10:31:19 +0000 (UTC) IronPort-SDR: V/Lwsz21LTTeMzpj39u3tjd3M0HSXedqazU3oBPg2b1mqL1veXZr7UXzhr3l/N9jZ5TP5Oqb3k u7etMTq482rQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463308" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463308" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:19 -0700 IronPort-SDR: +VvzT55ZBtV2tAvDRv0okKZaaz7JcMm/8Z44v4JknBdJTyANrzEWP0VFYMaNtUNo5+ZMbv9nSw jot+h+QRj9cg== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474802" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:17 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:29 +0200 Message-Id: <20200911103039.4574-15-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 14/24] tests/core_hotunplug: Process return values of sysfs operations 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Return values of driver bind/unbind / device remove/recover sysfs operations are now ignored. Assert their correctness. v2: Add trailing newlines missing from igt_assert messages. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 6112704f4..d5b8c5ed3 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -127,7 +127,9 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix, priv->failure = "Driver unbind failure!"; igt_set_timeout(timeout, "Driver unbind timeout!"); - igt_sysfs_set(priv->fd.sysfs_drv, "unbind", priv->dev_bus_addr); + igt_assert_f(igt_sysfs_set(priv->fd.sysfs_drv, "unbind", + priv->dev_bus_addr), + "Driver unbind failure!\n"); igt_reset_timeout(); } @@ -138,7 +140,9 @@ static void driver_bind(struct hotunplug *priv, int timeout) priv->failure = "Driver re-bind failure!"; igt_set_timeout(timeout, "Driver re-bind timeout!"); - igt_sysfs_set(priv->fd.sysfs_drv, "bind", priv->dev_bus_addr); + igt_assert_f(igt_sysfs_set(priv->fd.sysfs_drv, "bind", + priv->dev_bus_addr), + "Driver re-bind failure\n!"); igt_reset_timeout(); } @@ -156,7 +160,8 @@ static void device_unplug(struct hotunplug *priv, const char *prefix, priv->failure = "Device unplug failure!"; igt_set_timeout(timeout, "Device unplug timeout!"); - igt_sysfs_set(priv->fd.sysfs_dev, "remove", "1"); + igt_assert_f(igt_sysfs_set(priv->fd.sysfs_dev, "remove", "1"), + "Device unplug failure\n!"); igt_reset_timeout(); priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); @@ -170,7 +175,8 @@ static void bus_rescan(struct hotunplug *priv, int timeout) priv->failure = "Bus rescan failure!"; igt_set_timeout(timeout, "Bus rescan timeout!"); - igt_sysfs_set(priv->fd.sysfs_bus, "../rescan", "1"); + igt_assert_f(igt_sysfs_set(priv->fd.sysfs_bus, "../rescan", "1"), + "Bus rescan failure!\n"); igt_reset_timeout(); } From patchwork Fri Sep 11 10:30:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F96C59D for ; Fri, 11 Sep 2020 10:31:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E480B208FE for ; Fri, 11 Sep 2020 10:31:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E480B208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 653266EA05; Fri, 11 Sep 2020 10:31:23 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 781E66EA0A; Fri, 11 Sep 2020 10:31:21 +0000 (UTC) IronPort-SDR: O2w6MMQ3Y0b0ZVbXsq9Rto5oKF90kE0lOuqfgUluKx5i97v7/BexfZ6ZJzCCM2BgN9Sw5V4rvX EoyNU25RO9cg== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146463326" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="146463326" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:21 -0700 IronPort-SDR: okomRTYDHb2wkADa/GI6jJlJ1ABf4qC1JSKCWPAxG+ZRJSZCmXUTGiFfcOCL70xZAsSCSeLdn3 LzoGlDjk3epw== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474809" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:19 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:30 +0200 Message-Id: <20200911103039.4574-16-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 15/24] tests/core_hotunplug: Assert expected device presence/absence 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Don't rely on successful write to sysfs control files, assert existence / non-existence of a respective device sysfs node as well. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index d5b8c5ed3..a7dc4cf3b 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -131,6 +131,9 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix, priv->dev_bus_addr), "Driver unbind failure!\n"); igt_reset_timeout(); + + igt_assert_f(faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0), + "Unbound device still present\n"); } /* Re-bind the driver to the device */ @@ -144,6 +147,10 @@ static void driver_bind(struct hotunplug *priv, int timeout) priv->dev_bus_addr), "Driver re-bind failure\n!"); igt_reset_timeout(); + + igt_fail_on_f(faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, + F_OK, 0), + "Rebound device not present!\n"); } /* Remove (virtually unplug) the device from its bus */ @@ -166,6 +173,9 @@ static void device_unplug(struct hotunplug *priv, const char *prefix, priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); igt_assert_eq(priv->fd.sysfs_dev, -1); + + igt_assert_f(faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0), + "Unplugged device still present\n"); } /* Re-discover the device by rescanning its bus */ @@ -178,6 +188,10 @@ static void bus_rescan(struct hotunplug *priv, int timeout) igt_assert_f(igt_sysfs_set(priv->fd.sysfs_bus, "../rescan", "1"), "Bus rescan failure!\n"); igt_reset_timeout(); + + igt_fail_on_f(faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, + F_OK, 0), + "Fakely unplugged device not rediscovered!\n"); } static void cleanup(struct hotunplug *priv) From patchwork Fri Sep 11 10:30:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38B1C59D for ; Fri, 11 Sep 2020 10:31:31 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 17CC9221ED for ; Fri, 11 Sep 2020 10:31:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17CC9221ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7417E6E9FD; Fri, 11 Sep 2020 10:31:30 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C8056E9FF; Fri, 11 Sep 2020 10:31:29 +0000 (UTC) IronPort-SDR: zSjVNXxeBCmaX+oqOsQBS9TUh8S18KxBYwyGvVIOWS5YXd0tyemZNeqUPWYmlFBIrL/oNmZ3hv dvkNemLCA64w== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185700" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185700" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:28 -0700 IronPort-SDR: YIKEBxylETSRjI53EJPTuaCvDrNvY+vohD721wlA/5Fj+DaURLQfmuj6oWIrnQXGHod/5cvZq4 Q+oyfdj5A6gQ== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474839" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:26 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:31 +0200 Message-Id: <20200911103039.4574-17-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 16/24] tests/core_hotunplug: Explicitly ignore unused return values 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Some return values are not useful and can be ignored. Wrap those cases inside igt_ignore_warn(), not only to make sure compilers are happy but also to clearly document our decisions. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index a7dc4cf3b..6cf56d047 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -261,7 +261,7 @@ static void set_filter_from_device(int fd) char path[PATH_MAX + 1]; igt_assert(igt_sysfs_path(fd, path, PATH_MAX)); - strncat(path, "/device", PATH_MAX - strlen(path)); + igt_ignore_warn(strncat(path, "/device", PATH_MAX - strlen(path))); igt_assert(realpath(path, dst)); igt_device_filter_free_all(); @@ -398,7 +398,7 @@ igt_main igt_fixture { post_healthcheck(&priv); - close(priv.fd.sysfs_bus); - close(priv.fd.sysfs_drv); + igt_ignore_warn(close(priv.fd.sysfs_bus)); + igt_ignore_warn(close(priv.fd.sysfs_drv)); } } From patchwork Fri Sep 11 10:30:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770245 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C119459D for ; Fri, 11 Sep 2020 10:31:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A226B208FE for ; Fri, 11 Sep 2020 10:31:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A226B208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 220BA6EA08; Fri, 11 Sep 2020 10:31:32 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80E116E9FF; Fri, 11 Sep 2020 10:31:30 +0000 (UTC) IronPort-SDR: 3wAWom5BfEzSNWpS6xzK+Z6SsGhER7TMeV89skM+bCgL76XhFru+zsPzKOIjXNAhkItPt3XYGn KROnLMcOekvw== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185709" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185709" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:30 -0700 IronPort-SDR: SsbWFIOFTEoZ09Sjjjxg4/QFwPVc16pjf3IBD8CncTy9ZIge93tmOyME4tR5o30rdnSJGYuZO4 K4dJxkgRy7zA== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474845" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:28 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:32 +0200 Message-Id: <20200911103039.4574-18-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 17/24] tests/core_hotunplug: Also check health of render device node 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Failures of subsequent tests accessing the render device node have been observed on CI after late close of a hot rebound device. Extend our health check over the render node to detect that condition and start our recovery phase with unbinding the driver from the device found faulty. Also, check health of both device nodes before running any subtests. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 6cf56d047..5e9eba8e7 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -55,13 +55,15 @@ struct hotunplug { * use drm_open_driver() since in case of an i915 device it opens it * twice and keeps a second file descriptor open for exit handler use. */ -static int local_drm_open_driver(const char *when, const char *why) +static int local_drm_open_driver(bool render, const char *when, const char *why) { int fd_drm; - igt_debug("%sopening device%s\n", when, why); + igt_debug("%sopening %s device%s\n", when, render ? "render" : "DRM", + why); - fd_drm = __drm_open_driver(DRIVER_ANY); + fd_drm = render ? __drm_open_driver_render(DRIVER_ANY) : + __drm_open_driver(DRIVER_ANY); igt_assert_fd(fd_drm); return fd_drm; @@ -200,17 +202,15 @@ static void cleanup(struct hotunplug *priv) priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } -static void healthcheck(struct hotunplug *priv) +static void node_healthcheck(struct hotunplug *priv, bool render) { /* preserve potentially dirty device status stored in priv->fd.drm */ bool closed = priv->fd.drm == -1; int fd_drm; - /* device name may have changed, rebuild IGT device list */ - igt_devices_scan(true); - - priv->failure = "Device reopen failure!"; - fd_drm = local_drm_open_driver("re", " for health check"); + priv->failure = render ? "Render device reopen failure!" : + "DRM device reopen failure!"; + fd_drm = local_drm_open_driver(render, "re", " for health check"); if (closed) /* store fd for cleanup if not dirty */ priv->fd.drm = fd_drm; @@ -226,6 +226,16 @@ static void healthcheck(struct hotunplug *priv) fd_drm = close_device(fd_drm, "", "health checked "); if (closed || fd_drm < -1) /* update status for post_healthcheck */ priv->fd.drm = fd_drm; +} + +static void healthcheck(struct hotunplug *priv) +{ + /* device name may have changed, rebuild IGT device list */ + igt_devices_scan(true); + + node_healthcheck(priv, false); + if (!priv->failure) + node_healthcheck(priv, true); /* not only request igt_abort on failure, also fail the health check */ igt_fail_on_f(priv->failure, "%s\n", priv->failure); @@ -235,6 +245,11 @@ static void recover(struct hotunplug *priv) { cleanup(priv); + /* unbind the driver from a possibly hot rebound unhealthy device */ + if (!faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0) && + priv->fd.drm == -1 && priv->failure) + driver_unbind(priv, "post ", 60); + if (faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0)) bus_rescan(priv, 60); @@ -295,7 +310,7 @@ static void unplug_rescan(struct hotunplug *priv) static void hotunbind_lateclose(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); - priv->fd.drm = local_drm_open_driver("", " for hot unbind"); + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); driver_unbind(priv, "hot ", 0); @@ -310,7 +325,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) static void hotunplug_lateclose(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); - priv->fd.drm = local_drm_open_driver("", " for hot unplug"); + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); device_unplug(priv, "hot ", 0); @@ -348,6 +363,11 @@ igt_main igt_assert_eq(close_device(fd_drm, "", "selected "), -1); prepare(&priv); + + node_healthcheck(&priv, false); + if (!priv.failure) + node_healthcheck(&priv, true); + igt_skip_on_f(priv.failure, "%s\n", priv.failure); } igt_subtest_group { From patchwork Fri Sep 11 10:30:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 148B3112E for ; Fri, 11 Sep 2020 10:31:35 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E9A87208FE for ; Fri, 11 Sep 2020 10:31:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9A87208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 58AF56EA0A; Fri, 11 Sep 2020 10:31:34 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D8166E9FF; Fri, 11 Sep 2020 10:31:32 +0000 (UTC) IronPort-SDR: XoxeGbiIL9qIyA+7QHfmdO28lXzXwOOW6bALw6vIhCgrqtylYoN4XZSnh9CFaiyebVC/tQ8l94 e+EDFca6yh+Q== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185721" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185721" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:32 -0700 IronPort-SDR: 5IFKGXP1I/FH+DPPct/g3lFEmihCyx3efnGWB4wnEwUdBMXTkV6nb8wqFdspsuSu8mBDhqNcNE 3Qgn09YZ1n9w== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474855" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:30 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:33 +0200 Message-Id: <20200911103039.4574-19-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 18/24] tests/core_hotunplug: More thorough i915 healthcheck and recovery 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The test now assumes the i915 driver is able to identify potential hardware or driver issues while rebinding to a device and indicate them by marking the GPU wedged. Should that assumption occur wrong, the health check phase of the test would happily succeed while potentially leaving the device in an unusable state. That would not only give us falsely positive test results but could also potentially affect subsequently run applications. Then, we should examine health of the exercised device more thoroughly and try harder to recover it from potentially detected stalls. We could use a gem_test_engine() library function which submits and asserts successful execution of a NOP batch on each physical engine. Unfortunately, on failure this function jumps out of an IGT test section it is called from, while we would like to continue with recovery steps, possibly not adding another level of test section group nesting. Moreover, the function opens the device again and doesn't close the extra file descriptor before the jump, while we care for being able to close the exercised device completely before running certain subtest operations. Then, reimplement the function locally with those issues fixed and use it as an i915 health check. Call it also on test startup so operations performed by the test are never blamed for driver or hardware issues which may potentially exist and be possible to detect on test start. Should the i915 GPU be found unresponsive by the health check called from a recovery section, try harder to recover it to a usable state with a global GPU reset. For still more effective detection of GPU hangs, use a hang detector provided by IGT library. However, replace the library signal handler with our own implementation that doesn't jump out of the current IGT test section on GPU hang so we are still able to perform the reset and retry. v2: Skip i915 health check if a GPU hang has been already detected by a previous health check run and not yet recovered with a GPU reset, - take care of stopping a hang detector instance possibly left running by a failed health check attempt. v3: Re-run i915 health check as a first setp of i915 recovery (use full GPU reset as a last resort), - prefix i915 health check debug messages with step indicators, - fix spelling error in a comment. v4: Unbind the driver from an unhealthy device before recovery, - drop caches on i915 health check completion. v5: Refresh on top of a new patch added to the series which already unbinds the driver form a device found unhealthy and runs health checks on test startup, - no need to drop caches from the i915 health check, it seems to do its job correctly without that. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 115 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 14 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 5e9eba8e7..bc82ae3fb 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -23,8 +23,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -202,8 +204,87 @@ static void cleanup(struct hotunplug *priv) priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } -static void node_healthcheck(struct hotunplug *priv, bool render) +static bool local_i915_is_wedged(int i915) { + int err = 0; + + if (ioctl(i915, DRM_IOCTL_I915_GEM_THROTTLE)) + err = -errno; + return err == -EIO; +} + +static bool hang_detected = false; + +static void local_sig_abort(int sig) +{ + errno = 0; /* inside a signal, last errno reporting is confusing */ + hang_detected = true; +} + +static int local_i915_healthcheck(int i915, const char *prefix) +{ + const uint32_t bbe = MI_BATCH_BUFFER_END; + struct drm_i915_gem_exec_object2 obj = { }; + struct drm_i915_gem_execbuffer2 execbuf = { + .buffers_ptr = to_user_pointer(&obj), + .buffer_count = 1, + }; + const struct intel_execution_engine2 *engine; + + /* stop our hang detector possibly still running if we failed before */ + igt_stop_hang_detector(); + + /* don't run again before GPU reset if hang has been already detected */ + if (hang_detected) + return -EIO; + + igt_debug("%srunning i915 GPU healthcheck\n", prefix); + + if (local_i915_is_wedged(i915)) + return -EIO; + + obj.handle = gem_create(i915, 4096); + gem_write(i915, obj.handle, 0, &bbe, sizeof(bbe)); + + igt_fork_hang_detector(i915); + signal(SIGIO, local_sig_abort); + + __for_each_physical_engine(i915, engine) { + execbuf.flags = engine->flags; + gem_execbuf(i915, &execbuf); + } + + gem_sync(i915, obj.handle); + gem_close(i915, obj.handle); + + igt_stop_hang_detector(); + if (hang_detected) + return -EIO; + + if (local_i915_is_wedged(i915)) + return -EIO; + + return 0; +} + +static int local_i915_recover(int i915) +{ + hang_detected = false; + if (!local_i915_healthcheck(i915, "re-")) + return 0; + + igt_debug("forcing i915 GPU reset\n"); + igt_force_gpu_reset(i915); + + hang_detected = false; + return local_i915_healthcheck(i915, "post-"); +} + +#define FLAG_RENDER (1 << 0) +#define FLAG_RECOVER (1 << 1) +static void node_healthcheck(struct hotunplug *priv, unsigned flags) +{ + bool render = flags & FLAG_RENDER; /* preserve potentially dirty device status stored in priv->fd.drm */ bool closed = priv->fd.drm == -1; int fd_drm; @@ -215,9 +296,14 @@ static void node_healthcheck(struct hotunplug *priv, bool render) priv->fd.drm = fd_drm; if (is_i915_device(fd_drm)) { - priv->failure = "GEM failure"; - igt_require_gem(fd_drm); - priv->failure = NULL; + /* don't report library failed asserts as healthcheck failure */ + priv->failure = "Unrecoverable test failure"; + if (local_i915_healthcheck(fd_drm, "") && + (!(flags & FLAG_RECOVER) || local_i915_recover(fd_drm))) + priv->failure = "Healthcheck failure!"; + else + priv->failure = NULL; + } else { /* no device specific healthcheck, rely on reopen result */ priv->failure = NULL; @@ -228,14 +314,15 @@ static void node_healthcheck(struct hotunplug *priv, bool render) priv->fd.drm = fd_drm; } -static void healthcheck(struct hotunplug *priv) +static void healthcheck(struct hotunplug *priv, bool recover) { /* device name may have changed, rebuild IGT device list */ igt_devices_scan(true); - node_healthcheck(priv, false); + node_healthcheck(priv, recover ? FLAG_RECOVER : 0); if (!priv->failure) - node_healthcheck(priv, true); + node_healthcheck(priv, + FLAG_RENDER | (recover ? FLAG_RECOVER : 0)); /* not only request igt_abort on failure, also fail the health check */ igt_fail_on_f(priv->failure, "%s\n", priv->failure); @@ -257,7 +344,7 @@ static void recover(struct hotunplug *priv) driver_bind(priv, 60); if (priv->failure) - healthcheck(priv); + healthcheck(priv, true); } static void post_healthcheck(struct hotunplug *priv) @@ -293,7 +380,7 @@ static void unbind_rebind(struct hotunplug *priv) driver_bind(priv, 0); - healthcheck(priv); + healthcheck(priv, false); } static void unplug_rescan(struct hotunplug *priv) @@ -304,7 +391,7 @@ static void unplug_rescan(struct hotunplug *priv) bus_rescan(priv, 0); - healthcheck(priv); + healthcheck(priv, false); } static void hotunbind_lateclose(struct hotunplug *priv) @@ -319,7 +406,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); igt_assert_eq(priv->fd.drm, -1); - healthcheck(priv); + healthcheck(priv, false); } static void hotunplug_lateclose(struct hotunplug *priv) @@ -334,7 +421,7 @@ static void hotunplug_lateclose(struct hotunplug *priv) priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); igt_assert_eq(priv->fd.drm, -1); - healthcheck(priv); + healthcheck(priv, false); } /* Main */ @@ -364,9 +451,9 @@ igt_main prepare(&priv); - node_healthcheck(&priv, false); + node_healthcheck(&priv, 0); if (!priv.failure) - node_healthcheck(&priv, true); + node_healthcheck(&priv, FLAG_RENDER); igt_skip_on_f(priv.failure, "%s\n", priv.failure); } From patchwork Fri Sep 11 10:30:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3CAC112E for ; Fri, 11 Sep 2020 10:31:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D6EAB208FE for ; Fri, 11 Sep 2020 10:31:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6EAB208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C36E6EA0D; Fri, 11 Sep 2020 10:31:36 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FBE76EA0B; Fri, 11 Sep 2020 10:31:34 +0000 (UTC) IronPort-SDR: 8Nj6EOuY5Un2DiFBFJV5wn/mbN7mpWGsg+omPdEsmsJrOHCX/1FqyzS/rV6aNkEQzHK2ZzF+my m0+e2WgZFgTw== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185732" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185732" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:34 -0700 IronPort-SDR: oL0aNEXhIlKwwzqk8AZ2n1NdpieZhvoAzfCQyYYTT5RfHYFINDwtAJPzfv78DXOTI08WC31pAZ xxyVuzaIF8iQ== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474861" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:32 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:34 +0200 Message-Id: <20200911103039.4574-20-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 19/24] tests/core_hotunplug: Add 'lateclose before restore' variants 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" If a GPU gets wedged during driver rebind or device re-plug for some reason, current hotunbind/hotunplug test variants may time out before lateclose phase, resulting in incomplete CI reports. Add new test variants which close the device before restoring it. Also rename old variants to more adequate hotrebind/hotreplug-lateclose and perform health checks both before and after late close. v2: Rebase on upstream. v3: Refresh, - further rename hotunbind/hotunplug-lateclose to hotunbind-rebind and hotunplug-rescan respectively, then add two more variants under the old names which only exercise late close, leaving rebind / rescan to be cared of in the post-subtest recovery phase, - also update descriptions of unmodified subtests for consistency. v4: Refresh, - drop subtests with no health checks, adjust timeouts in successors, - perform health checks of hot restored devices also before late close, - in order to be able to safely run a health check while still keeping an unbound / unplugged device instance open, also preserve the open device fd, not only a close error, - adjust subtest descriptions. v5: Refresh, - split out pre-lateclose health checks and related changes, introduced in v4, to a separate patch. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v2 --- tests/core_hotunplug.c | 78 +++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index bc82ae3fb..436517ce5 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -394,28 +394,58 @@ static void unplug_rescan(struct hotunplug *priv) healthcheck(priv, false); } -static void hotunbind_lateclose(struct hotunplug *priv) +static void hotunbind_rebind(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); driver_unbind(priv, "hot ", 0); - driver_bind(priv, 0); - priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); igt_assert_eq(priv->fd.drm, -1); + driver_bind(priv, 0); + healthcheck(priv, false); } -static void hotunplug_lateclose(struct hotunplug *priv) +static void hotunplug_rescan(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); device_unplug(priv, "hot ", 0); + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); + + bus_rescan(priv, 0); + + healthcheck(priv, false); +} + +static void hotrebind_lateclose(struct hotunplug *priv) +{ + igt_assert_eq(priv->fd.drm, -1); + priv->fd.drm = local_drm_open_driver(false, "", " for hot rebind"); + + driver_unbind(priv, "hot ", 60); + + driver_bind(priv, 0); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); + + healthcheck(priv, false); +} + +static void hotreplug_lateclose(struct hotunplug *priv) +{ + igt_assert_eq(priv->fd.drm, -1); + priv->fd.drm = local_drm_open_driver(false, "", " for hot replug"); + + device_unplug(priv, "hot ", 60); + bus_rescan(priv, 0); priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); @@ -458,7 +488,7 @@ igt_main } igt_subtest_group { - igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); + igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed, then rebound"); igt_subtest("unbind-rebind") unbind_rebind(&priv); @@ -470,7 +500,7 @@ igt_main post_healthcheck(&priv); igt_subtest_group { - igt_describe("Check if a device believed to be closed can be cleanly unplugged"); + igt_describe("Check if a device believed to be closed can be cleanly unplugged, then restored"); igt_subtest("unplug-rescan") unplug_rescan(&priv); @@ -482,9 +512,33 @@ igt_main post_healthcheck(&priv); igt_subtest_group { - igt_describe("Check if the driver can be cleanly unbound from a still open device, then released"); - igt_subtest("hotunbind-lateclose") - hotunbind_lateclose(&priv); + igt_describe("Check if the driver can be cleanly unbound from an open device, then released and rebound"); + igt_subtest("hotunbind-rebind") + hotunbind_rebind(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if an open device can be cleanly unplugged, then released and restored"); + igt_subtest("hotunplug-rescan") + hotunplug_rescan(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver hot unbound from a still open device can be cleanly rebound, then the old instance released"); + igt_subtest("hotrebind-lateclose") + hotrebind_lateclose(&priv); igt_fixture recover(&priv); @@ -494,9 +548,9 @@ igt_main post_healthcheck(&priv); igt_subtest_group { - igt_describe("Check if a still open device can be cleanly unplugged, then released"); - igt_subtest("hotunplug-lateclose") - hotunplug_lateclose(&priv); + igt_describe("Check if a still open while hot unplugged device can be cleanly restored, then the old instance released"); + igt_subtest("hotreplug-lateclose") + hotreplug_lateclose(&priv); igt_fixture recover(&priv); From patchwork Fri Sep 11 10:30:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4EB959D for ; Fri, 11 Sep 2020 10:31:38 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 84CAD2076C for ; Fri, 11 Sep 2020 10:31:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84CAD2076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E36D46EA0E; Fri, 11 Sep 2020 10:31:37 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 677DB6EA0E; Fri, 11 Sep 2020 10:31:36 +0000 (UTC) IronPort-SDR: RIeBgSGbKXAKguylbP3vy3cRA9hfnvyFqBR0zMXDbBtqCYfu/GqTrGdSEgsAs/CsBB6+RbHoj2 +uULyiJDiCeA== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185752" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185752" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:36 -0700 IronPort-SDR: d8LMSMCyFmdbhsZZxUmU4ShHc0kX4x/ECpOJ4K3fVppBGzgHmhXpct8o0AoMbnZ20bOhWpa9ot BsO/b1OsvXVA== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474865" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:34 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:35 +0200 Message-Id: <20200911103039.4574-21-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 20/24] tests/core_hotunplug: Check health both before and after late close 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" In hot rebind / hot replug subtests, device health is now checked only at the end of the subtest, after late close. If something fails, we may be not able to identify the failing phase of the subtest easily. Run health checks also before late closing the device, right after hot rebind / replug. For still being able to perform late close while also handling cleanup of potential device close misses in health checks, we need to maintain two separate device file descriptors in our private data structure. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 436517ce5..ac106d964 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -42,6 +42,7 @@ IGT_TEST_DESCRIPTION("Examine behavior of a driver on device hot unplug"); struct hotunplug { struct { int drm; + int drm_hc; /* for health check */ int sysfs_dev; int sysfs_bus; int sysfs_drv; @@ -200,7 +201,9 @@ static void bus_rescan(struct hotunplug *priv, int timeout) static void cleanup(struct hotunplug *priv) { - priv->fd.drm = close_device(priv->fd.drm, "post ", "failed "); + priv->fd.drm = close_device(priv->fd.drm, "post ", "exercised "); + priv->fd.drm_hc = close_device(priv->fd.drm_hc, "post ", + "health checked "); priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } @@ -286,14 +289,14 @@ static void node_healthcheck(struct hotunplug *priv, unsigned flags) { bool render = flags & FLAG_RENDER; /* preserve potentially dirty device status stored in priv->fd.drm */ - bool closed = priv->fd.drm == -1; + bool closed = priv->fd.drm_hc == -1; int fd_drm; priv->failure = render ? "Render device reopen failure!" : "DRM device reopen failure!"; fd_drm = local_drm_open_driver(render, "re", " for health check"); if (closed) /* store fd for cleanup if not dirty */ - priv->fd.drm = fd_drm; + priv->fd.drm_hc = fd_drm; if (is_i915_device(fd_drm)) { /* don't report library failed asserts as healthcheck failure */ @@ -311,7 +314,7 @@ static void node_healthcheck(struct hotunplug *priv, unsigned flags) fd_drm = close_device(fd_drm, "", "health checked "); if (closed || fd_drm < -1) /* update status for post_healthcheck */ - priv->fd.drm = fd_drm; + priv->fd.drm_hc = fd_drm; } static void healthcheck(struct hotunplug *priv, bool recover) @@ -334,7 +337,7 @@ static void recover(struct hotunplug *priv) /* unbind the driver from a possibly hot rebound unhealthy device */ if (!faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0) && - priv->fd.drm == -1 && priv->failure) + priv->fd.drm == -1 && priv->fd.drm_hc == -1 && priv->failure) driver_unbind(priv, "post ", 60); if (faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0)) @@ -353,6 +356,7 @@ static void post_healthcheck(struct hotunplug *priv) cleanup(priv); igt_require(priv->fd.drm == -1); + igt_require(priv->fd.drm_hc == -1); } static void set_filter_from_device(int fd) @@ -375,6 +379,7 @@ static void set_filter_from_device(int fd) static void unbind_rebind(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); + igt_assert_eq(priv->fd.drm_hc, -1); driver_unbind(priv, "", 0); @@ -386,6 +391,7 @@ static void unbind_rebind(struct hotunplug *priv) static void unplug_rescan(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); + igt_assert_eq(priv->fd.drm_hc, -1); device_unplug(priv, "", 0); @@ -397,6 +403,7 @@ static void unplug_rescan(struct hotunplug *priv) static void hotunbind_rebind(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); + igt_assert_eq(priv->fd.drm_hc, -1); priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); driver_unbind(priv, "hot ", 0); @@ -412,6 +419,7 @@ static void hotunbind_rebind(struct hotunplug *priv) static void hotunplug_rescan(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); + igt_assert_eq(priv->fd.drm_hc, -1); priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); device_unplug(priv, "hot ", 0); @@ -427,12 +435,15 @@ static void hotunplug_rescan(struct hotunplug *priv) static void hotrebind_lateclose(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); + igt_assert_eq(priv->fd.drm_hc, -1); priv->fd.drm = local_drm_open_driver(false, "", " for hot rebind"); driver_unbind(priv, "hot ", 60); driver_bind(priv, 0); + healthcheck(priv, false); + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); igt_assert_eq(priv->fd.drm, -1); @@ -442,12 +453,15 @@ static void hotrebind_lateclose(struct hotunplug *priv) static void hotreplug_lateclose(struct hotunplug *priv) { igt_assert_eq(priv->fd.drm, -1); + igt_assert_eq(priv->fd.drm_hc, -1); priv->fd.drm = local_drm_open_driver(false, "", " for hot replug"); device_unplug(priv, "hot ", 60); bus_rescan(priv, 0); + healthcheck(priv, false); + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); igt_assert_eq(priv->fd.drm, -1); @@ -459,7 +473,7 @@ static void hotreplug_lateclose(struct hotunplug *priv) igt_main { struct hotunplug priv = { - .fd = { .drm = -1, .sysfs_dev = -1, }, + .fd = { .drm = -1, .drm_hc = -1, .sysfs_dev = -1, }, .failure = NULL, }; From patchwork Fri Sep 11 10:30:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3DD059D for ; Fri, 11 Sep 2020 10:31:40 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8EDA7208FE for ; Fri, 11 Sep 2020 10:31:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EDA7208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FEDF6EA10; Fri, 11 Sep 2020 10:31:40 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 756CD6EA10; Fri, 11 Sep 2020 10:31:38 +0000 (UTC) IronPort-SDR: OHr7fPjFYXzx/MaytxMTVTBRHEnyrsmvbK/9GFKs07lXwjQt3olUxyS3XlVarxRbr9RHMS7kQf CDdBu78gpEQw== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185767" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185767" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:38 -0700 IronPort-SDR: lt45MpIArFxOY8ucUqSAVJz2K5hRLCZnixx4qQANSkU1HmtoAvRyZM47HT9rcXBD8ENVs00O+9 08fCjWP6OSUg== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474869" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:36 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:36 +0200 Message-Id: <20200911103039.4574-22-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 21/24] tests/core_hotunplug: HSW/BDW audio issue workaround 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Unbinding the i915 driver on some Haswell and Broadwell platforms with Azalia audio results in a kernel WARNING on "i915 raw-wakerefs=1 wakelocks=1 on cleanup". The issue can be worked around by manually enabling runtime power management for the conflicting audio adapter. Use that method but also display a warning to preserve visibility of the issue. Also tag the workaround with a FIXME comment. v2: Extend the scope of the workaround over Broadwell Signed-off-by: Janusz Krzysztofik Reviewed-by: Petri Latvala --- tests/core_hotunplug.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index ac106d964..3e2a76ddb 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -484,8 +484,23 @@ igt_main igt_skip_on_f(fd_drm < 0, "No known DRM device found\n"); if (is_i915_device(fd_drm)) { + uint32_t devid = intel_get_drm_devid(fd_drm); + gem_quiescent_gpu(fd_drm); igt_require_gem(fd_drm); + + /** + * FIXME: Unbinding the i915 driver on some Haswell + * platforms with Azalia audio results in a kernel WARN + * on "i915 raw-wakerefs=1 wakelocks=1 on cleanup". The + * below CI friendly user level workaround prevents the + * warning from appearing. Drop this hack as soon as + * this is fixed in the kernel. + */ + if (igt_warn_on_f(IS_HASWELL(devid) || + IS_BROADWELL(devid), + "Manually enabling audio PM to work around a kernel WARN\n")) + igt_pm_enable_audio_runtime_pm(); } /* Make sure subtests always reopen the same device */ From patchwork Fri Sep 11 10:30:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3DAC112E for ; Fri, 11 Sep 2020 10:31:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B671A2076C for ; Fri, 11 Sep 2020 10:31:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B671A2076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 585A16EA02; Fri, 11 Sep 2020 10:31:42 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F19F6EA0B; Fri, 11 Sep 2020 10:31:41 +0000 (UTC) IronPort-SDR: YkEgl7SPY59jiz8wmui6csc15woejIyV/HeFNKSR/vdv2Qi5MWhwrxgsXcbZKKoyCRYqIDzVjA cQJQSCVlOGxQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185797" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185797" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:41 -0700 IronPort-SDR: LLR/NtArDeP083NPHzcsVIg8LdFBWcIV0gTZziPRL6lhV0sSqR0kUYDBvxYBRdsmJZXUmHDIub BQXXeyps2/Eg== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474876" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:38 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:37 +0200 Message-Id: <20200911103039.4574-23-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 22/24] tests/core_hotunplug: Duplicate debug messages in dmesg 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The purpose of debug messages displayed by the test is to make identification of a subtest phase that fails more easy. Since issues exhibited by the test are mostly reported to dmesg, print those debug messages to /dev/kmsg as well. v2: Rebase on upstream. v3: Refresh. v4: Refresh. v5: Refresh. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 3e2a76ddb..67e67627f 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -53,6 +53,12 @@ struct hotunplug { /* Helpers */ +#define local_debug(fmt, msg...) \ +({ \ + igt_debug(fmt, msg); \ + igt_kmsg(KMSG_DEBUG "%s: " fmt, igt_test_name(), msg); \ +}) + /** * Subtests must be able to close examined devices completely. Don't * use drm_open_driver() since in case of an i915 device it opens it @@ -62,8 +68,8 @@ static int local_drm_open_driver(bool render, const char *when, const char *why) { int fd_drm; - igt_debug("%sopening %s device%s\n", when, render ? "render" : "DRM", - why); + local_debug("%sopening %s device%s\n", when, render ? "render" : "DRM", + why); fd_drm = render ? __drm_open_driver_render(DRIVER_ANY) : __drm_open_driver(DRIVER_ANY); @@ -86,7 +92,7 @@ static int close_device(int fd_drm, const char *when, const char *which) if (fd_drm < 0) /* not open - return current status */ return fd_drm; - igt_debug("%sclosing %sdevice instance\n", when, which); + local_debug("%sclosing %sdevice instance\n", when, which); return local_close(fd_drm, "Device close failed"); } @@ -128,7 +134,7 @@ static void prepare(struct hotunplug *priv) static void driver_unbind(struct hotunplug *priv, const char *prefix, int timeout) { - igt_debug("%sunbinding the driver from the device\n", prefix); + local_debug("%sunbinding the driver from the device\n", prefix); priv->failure = "Driver unbind failure!"; igt_set_timeout(timeout, "Driver unbind timeout!"); @@ -144,7 +150,7 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix, /* Re-bind the driver to the device */ static void driver_bind(struct hotunplug *priv, int timeout) { - igt_debug("rebinding the driver to the device\n"); + local_debug("%s\n", "rebinding the driver to the device"); priv->failure = "Driver re-bind failure!"; igt_set_timeout(timeout, "Driver re-bind timeout!"); @@ -168,7 +174,7 @@ static void device_unplug(struct hotunplug *priv, const char *prefix, O_DIRECTORY); igt_assert_fd(priv->fd.sysfs_dev); - igt_debug("%sunplugging the device\n", prefix); + local_debug("%sunplugging the device\n", prefix); priv->failure = "Device unplug failure!"; igt_set_timeout(timeout, "Device unplug timeout!"); @@ -186,7 +192,7 @@ static void device_unplug(struct hotunplug *priv, const char *prefix, /* Re-discover the device by rescanning its bus */ static void bus_rescan(struct hotunplug *priv, int timeout) { - igt_debug("rediscovering the device\n"); + local_debug("%s\n", "rediscovering the device"); priv->failure = "Bus rescan failure!"; igt_set_timeout(timeout, "Bus rescan timeout!"); @@ -241,7 +247,7 @@ static int local_i915_healthcheck(int i915, const char *prefix) if (hang_detected) return -EIO; - igt_debug("%srunning i915 GPU healthcheck\n", prefix); + local_debug("%s%s\n", prefix, "running i915 GPU healthcheck"); if (local_i915_is_wedged(i915)) return -EIO; @@ -276,7 +282,7 @@ static int local_i915_recover(int i915) if (!local_i915_healthcheck(i915, "re-")) return 0; - igt_debug("forcing i915 GPU reset\n"); + local_debug("%s\n", "forcing i915 GPU reset"); igt_force_gpu_reset(i915); hang_detected = false; From patchwork Fri Sep 11 10:30:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7929A112E for ; Fri, 11 Sep 2020 10:31:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 59A86208FE for ; Fri, 11 Sep 2020 10:31:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59A86208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F407D6EA0C; Fri, 11 Sep 2020 10:31:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 119046EA12; Fri, 11 Sep 2020 10:31:43 +0000 (UTC) IronPort-SDR: 89mrhyAH63iYqf3kRkvI9dYXfu2RqweSrQ8kNcwz31R4qWCgdvc7qV2iySuDomLXcRokhNj97J jFEzkUEA0SRg== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185814" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185814" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:42 -0700 IronPort-SDR: ZJp/ZIPDJxvAiU343Pj09EqnuNMB53aI6XSPNixyU3Km2+pTn76/cuQk95akawjso39gU6nErs w7LVpFo9tujw== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474886" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:41 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:38 +0200 Message-Id: <20200911103039.4574-24-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 23/24] tests/core_hotunplug: Un-blocklist *bind* subtests 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Subtests which don't remove the device, only unbind the driver from it, seem relatively safe and harmless for CI. Remove them from the CI blocklist. Signed-off-by: Janusz Krzysztofik Acked-by: Petri Latvala --- tests/intel-ci/blacklist.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/intel-ci/blacklist.txt b/tests/intel-ci/blacklist.txt index f9a57cb54..25b567038 100644 --- a/tests/intel-ci/blacklist.txt +++ b/tests/intel-ci/blacklist.txt @@ -120,7 +120,7 @@ igt@perf_pmu@cpu-hotplug # Currently fails and leaves the machine in a very bad state, and # causes coverage loss for other tests. -igt@core_hotunplug@.* +igt@core_hotunplug@.*plug.* # hangs several gens of hosts, and has no immediate fix igt@device_reset@reset-bound \ No newline at end of file From patchwork Fri Sep 11 10:30:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11770259 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F5CF59D for ; Fri, 11 Sep 2020 10:31:47 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3D5A6208FE for ; Fri, 11 Sep 2020 10:31:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D5A6208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA67B6EA0B; Fri, 11 Sep 2020 10:31:46 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 05DFF6EA11; Fri, 11 Sep 2020 10:31:44 +0000 (UTC) IronPort-SDR: 3FmDuaXzcARLO1z7kZjdVaXKac9DnYnXQYBFOM5coOuFx6Y4Yy8/NFYDafJFOSKs3iLcTBZut0 NBdoSYCVt4OA== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="156185831" X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="156185831" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:44 -0700 IronPort-SDR: RTboi6upTNgUcllM0gKSIrlL9RGr4N1CwQkE1OR42JEb2x+1pafs/eWJbyZX1yBEA6aCsSGFEM gIkmNZgyWOzA== X-IronPort-AV: E=Sophos;i="5.76,414,1592895600"; d="scan'208";a="334474891" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 03:31:43 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 11 Sep 2020 12:30:39 +0200 Message-Id: <20200911103039.4574-25-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> References: <20200911103039.4574-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v6 24/24] tests/core_hotunplug: Add unbind-rebind subtest to BAT scope 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: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Unbinding and rebinding the driver to a device scenario is a subset of unloading and reloading the module and should give equally correct results. Signed-off-by: Janusz Krzysztofik --- tests/intel-ci/fast-feedback.testlist | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist index b98cdb245..aa2eb3295 100644 --- a/tests/intel-ci/fast-feedback.testlist +++ b/tests/intel-ci/fast-feedback.testlist @@ -158,6 +158,7 @@ igt@vgem_basic@sysfs # They will sometimes reveal issues of earlier tests leaving the # driver in a broken state that is not otherwise noticed in that test. +igt@core_hotunplug@unbind-rebind igt@vgem_basic@unload igt@i915_module_load@reload igt@i915_pm_rpm@module-reload