From patchwork Thu Aug 20 14:51:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726381 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 72CD9739 for ; Thu, 20 Aug 2020 14:52:48 +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 5BD4D2075E for ; Thu, 20 Aug 2020 14:52:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BD4D2075E 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 6F3EA6E58A; Thu, 20 Aug 2020 14:52:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id BA8CE6E378; Thu, 20 Aug 2020 14:52:43 +0000 (UTC) IronPort-SDR: r1TebQdLg/1QAg5zIiiyng9eAWDrAx1B6i4s5CROCK0EGp3eFRqgY9QVYQSepTR3/t61T5CR4F BqmfjVAdaZxQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136050" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136050" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:42 -0700 IronPort-SDR: fkOoJB/Eytgo3HJCuC95nvY2hc2tmZDsAvE9QPrSn6B+Esoj7eY2ubr+90OOwSzrGnAXmZH3lE 7pT7SyuX49+g== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679581" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:39 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:51:57 +0200 Message-Id: <20200820145215.13238-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 01/19] 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 Thu Aug 20 14:51:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726387 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 E5C79739 for ; Thu, 20 Aug 2020 14:52:53 +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 CF07F2075E for ; Thu, 20 Aug 2020 14:52:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF07F2075E 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 159D96E59F; Thu, 20 Aug 2020 14:52:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3340E6E34C; Thu, 20 Aug 2020 14:52:45 +0000 (UTC) IronPort-SDR: z2u6CMwC3zKuFvRo2NO72voKUA20fka86c4R4tTV+gtvvYT0e3XWWbo3S85mMXSL7tW2HeEExl eazfGW8d1vmA== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136067" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136067" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:44 -0700 IronPort-SDR: /EJPgnTKF7Nxw0eJDnBWo4aHtCfShQ8+gomoGNGpYroU/vHXXHtRf/TlpKKJqMPEoH0LlCtt4T J2sZuKkGnTjA== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679614" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:42 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:51:58 +0200 Message-Id: <20200820145215.13238-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 02/19] 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 Thu Aug 20 14:51:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726383 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 AB72B138C for ; Thu, 20 Aug 2020 14:52:50 +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 945CC2075E for ; Thu, 20 Aug 2020 14:52:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 945CC2075E 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 208A76E94B; Thu, 20 Aug 2020 14:52:49 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id C4CDD6E94B; Thu, 20 Aug 2020 14:52:47 +0000 (UTC) IronPort-SDR: HNp6Oi80f8KEKk48H2LVPJqsY8UmdQCLeX1yX11PSI0gj5uS5xk8rUw3V/hkln9RrML9yLAEBi C5aCWQx47+Zg== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136081" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136081" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:47 -0700 IronPort-SDR: gR/piRffpqkKylkxpZPcs/b2K/I/OhumrMhhmnnBhubsNFwz7BMEYVqHZiCwsmkPvmE3/kS7LI 0wj7w7WI5rQw== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679626" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:45 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:51:59 +0200 Message-Id: <20200820145215.13238-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 03/19] 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 Thu Aug 20 14:52:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726385 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 ABEEF739 for ; Thu, 20 Aug 2020 14:52:52 +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 94AB02075E for ; Thu, 20 Aug 2020 14:52:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94AB02075E 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 8B6C46E102; Thu, 20 Aug 2020 14:52:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6740E6E378; Thu, 20 Aug 2020 14:52:50 +0000 (UTC) IronPort-SDR: TlfdBvk8NXzQbcIZd1EGxiVoGJa9OgjQm8DhnZgEAMjNs/hbUVVxoVycC5wK4OsWJzA9+yKHRJ tY1BT9Q8dGyg== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136098" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136098" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:50 -0700 IronPort-SDR: 5xcqlX8AgbHunK9Mi3VkXrFtYQCAxKa1E6N/YTK+HHcWGhLpBNkgzsFWSDKn67drwul5DJavk8 A0xwH0qU1Lcg== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679637" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:47 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:00 +0200 Message-Id: <20200820145215.13238-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 04/19] 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. v3: Refresh and extend over new case (local_drm_open_driver), - allow callers to specify a message suffix as well where applicable. 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..5093233d7 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 *prefix, const char *suffix) { int fd_drm; + igt_debug("%sopening device%s\n", prefix, suffix); + 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 healthcheck"); 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 Thu Aug 20 14:52:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726389 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 10846739 for ; Thu, 20 Aug 2020 14:52:56 +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 EDA9C2078B for ; Thu, 20 Aug 2020 14:52:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDA9C2078B 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 5892B6E378; Thu, 20 Aug 2020 14:52:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BDB96E378; Thu, 20 Aug 2020 14:52:53 +0000 (UTC) IronPort-SDR: 9dCwIdoS9IPSbHmrO9H0A4H4znEsaUa8UgBRueRRz9xr9uHRjqjaaUw0oTb0XdjgR2PgEiwo5V hBv3xBnLmj+w== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136115" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136115" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:52 -0700 IronPort-SDR: /bwdiQaJVdDxEcxzWZ+ulV22G6wONdLWFbwoFjGzTa5COJ1HywWlA1De+BjXyJszJ20KZAcQmg Yp2142BJF+tg== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679660" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:50 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:01 +0200 Message-Id: <20200820145215.13238-6-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 05/19] 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 5093233d7..46f9ad118 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 Thu Aug 20 14:52:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726391 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 31078138C for ; Thu, 20 Aug 2020 14:52:58 +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 19D382075E for ; Thu, 20 Aug 2020 14:52:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19D382075E 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 608946E946; Thu, 20 Aug 2020 14:52:57 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9891D6E946; Thu, 20 Aug 2020 14:52:55 +0000 (UTC) IronPort-SDR: Py2mIFFFLzpzuuAFT43A4y0Tq6TBe84b3YhLAAaP7E347uRGz/e6lcdnnr8mf9KowKP1y1H6ue 6XM2zodInxxQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136133" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136133" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:55 -0700 IronPort-SDR: jQF+eAI4iJXY/Ga2AyhV/0OLY2AVtvBdXR9s36cc39qzd7sfMGq3Pf8aeo1r4JH/up1HISULpI ofGynNLPX3ig== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679673" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:52 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:02 +0200 Message-Id: <20200820145215.13238-7-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 06/19] 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, - skip subtest after device close errors, - prepare invariant data only once per test run, - move device health checks to igt_fixture sections, - try to recover from subtest failures 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. 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 46f9ad118..95d326ee9 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 Thu Aug 20 14:52:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726393 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 5C709138C for ; Thu, 20 Aug 2020 14:53:00 +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 45C412078B for ; Thu, 20 Aug 2020 14:53:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45C412078B 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 C3DFA6E949; Thu, 20 Aug 2020 14:52:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7231E6E949; Thu, 20 Aug 2020 14:52:58 +0000 (UTC) IronPort-SDR: 1h7CfC1V97viJoJOAy8KnExK5+4kZuPTQb7yG/VqS3+lqY5s+gpYQe0B6tO1QimTKWlSUxaFGy s5wfIrCeUOIQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136152" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136152" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:58 -0700 IronPort-SDR: 64ny0EnvTyVUFBtZqBJXjvn2J+9aUEy89J7XTnX4ElGkjr1toJxk1btdfDlpoN2i45CALT3OoW R58WIYMBUS1w== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679690" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:55 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:03 +0200 Message-Id: <20200820145215.13238-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 07/19] 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. 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 95d326ee9..4f7e89c95 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 healthcheck"); - 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 Thu Aug 20 14:52:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726395 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 8DF23138C for ; Thu, 20 Aug 2020 14:53: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 76DF22078B for ; Thu, 20 Aug 2020 14:53:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76DF22078B 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 ECB786E94C; Thu, 20 Aug 2020 14:53:02 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FC4F6E94A; Thu, 20 Aug 2020 14:53:01 +0000 (UTC) IronPort-SDR: 0QMKdgbh+W+13b7kRrHuKO3alc9dFn+y9/B8XxE2krlt8Emm0ziepkw5lHCJyVKM3r27aFM12M 2Ry7/F2AThgQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136176" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136176" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:01 -0700 IronPort-SDR: PMKF4VjC35mhAikXv2E2j0lWUAuk986rW7NnfI8pF0KCtB4JwfsUPG6bTXCUYPDVToaLnuqB41 Ijl8ysecjvLg== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679707" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:52:58 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:04 +0200 Message-Id: <20200820145215.13238-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 08/19] 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 messages to helpers. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v1 --- tests/core_hotunplug.c | 64 +++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 4f7e89c95..f7a54010b 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,25 @@ static int local_drm_open_driver(const char *prefix, const char *suffix) return fd_drm; } +static int local_close(int fd, const char *message) +{ + errno = 0; + if (igt_warn_on_f(close(fd), "%s\n", message)) + return -errno; /* (never -1) */ + + return -1; /* success - return 'closed' */ +} + +static int close_device(int fd_drm) +{ + 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,7 +102,8 @@ 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) @@ -142,7 +162,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 +181,7 @@ static void bus_rescan(struct hotunplug *priv) static void healthcheck(struct hotunplug *priv) { + /* preserve error code potentially stored before in priv->fd.drm */ int fd_drm; /* device name may have changed, rebuild IGT device list */ @@ -176,7 +197,17 @@ static void healthcheck(struct hotunplug *priv) priv->failure = NULL; } - close(fd_drm); + fd_drm = close_device(fd_drm); + if (priv->fd.drm == -1) /* store result if no error code to preserve */ + 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) @@ -203,7 +234,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); + igt_assert_eq(priv->fd.drm, -1); driver_unbind(priv, ""); @@ -217,7 +249,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); + igt_assert_eq(priv->fd.drm, -1); device_unplug(priv, ""); @@ -237,7 +270,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); healthcheck(priv); } @@ -251,7 +284,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); healthcheck(priv); } @@ -260,7 +293,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 +312,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), -1); } igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); @@ -284,26 +320,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 Thu Aug 20 14:52:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726397 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 33469739 for ; Thu, 20 Aug 2020 14:53: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 1C6222078B for ; Thu, 20 Aug 2020 14:53:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C6222078B 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 94D066E54C; Thu, 20 Aug 2020 14:53:05 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3E4AF6E94D; Thu, 20 Aug 2020 14:53:04 +0000 (UTC) IronPort-SDR: wTJ9WWiZpwJmjsugoPX/Kv0LIN92UrZhC2yItBwyUzuUGHDuQMkJ04y8dbp6jl4LEVoS1EIqZ3 ScM2wS0rnXRQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136191" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136191" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:03 -0700 IronPort-SDR: fubk1n1G0ZOjYDDwXXRaDkRRdCm8fMzFSO+YyWVm2gNCL/zo1skbtDub87rX0totATf1nLAY2o eF3QfHutRGiw== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679724" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:01 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:05 +0200 Message-Id: <20200820145215.13238-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 09/19] 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 lifecycle 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' subnode 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. v3: Refresh. Suggested-by: Michał Winiarski Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 85 +++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 54 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index f7a54010b..849a774ff 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -86,41 +86,30 @@ 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); -} - -static void prepare(struct hotunplug *priv, char *buf, int buflen) -{ - priv->fd.drm = local_drm_open_driver("", " for subtest"); + sysfs_path = strchr(filter, ':'); + igt_assert(sysfs_path++); - priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); + priv->fd.sysfs_dev = open(sysfs_path, O_DIRECTORY); igt_assert_fd(priv->fd.sysfs_dev); - 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_drv = openat(priv->fd.sysfs_dev, "driver", O_DIRECTORY); + igt_assert_fd(priv->fd.sysfs_drv); + + priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev, "subsystem/devices", + 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 */ @@ -133,8 +122,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 */ @@ -147,18 +134,20 @@ 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) { + 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; @@ -172,11 +161,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) @@ -229,14 +216,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)); - - igt_debug("closing the device\n"); - priv->fd.drm = close_device(priv->fd.drm); - igt_assert_eq(priv->fd.drm, -1); - driver_unbind(priv, ""); driver_bind(priv); @@ -246,12 +225,6 @@ static void unbind_rebind(struct hotunplug *priv) static void unplug_rescan(struct hotunplug *priv) { - prepare(priv, NULL, 0); - - igt_debug("closing the device\n"); - priv->fd.drm = close_device(priv->fd.drm); - igt_assert_eq(priv->fd.drm, -1); - device_unplug(priv, ""); bus_rescan(priv); @@ -261,9 +234,7 @@ static void unplug_rescan(struct hotunplug *priv) static void hotunbind_lateclose(struct hotunplug *priv) { - char buf[PATH_MAX]; - - prepare(priv, buf, sizeof(buf)); + priv->fd.drm = local_drm_open_driver("", " for hotunbind"); driver_unbind(priv, "hot "); @@ -277,7 +248,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) static void hotunplug_lateclose(struct hotunplug *priv) { - prepare(priv, NULL, 0); + priv->fd.drm = local_drm_open_driver("", " for hotunplug"); device_unplug(priv, "hot "); @@ -313,6 +284,8 @@ igt_main set_filter_from_device(fd_drm); igt_assert_eq(close_device(fd_drm), -1); + + prepare(&priv); } igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); @@ -340,6 +313,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 Thu Aug 20 14:52:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726399 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 68778138C for ; Thu, 20 Aug 2020 14:53: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 51A2A2078B for ; Thu, 20 Aug 2020 14:53:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51A2A2078B 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 C58376E952; Thu, 20 Aug 2020 14:53:07 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0D0056E944; Thu, 20 Aug 2020 14:53:07 +0000 (UTC) IronPort-SDR: hD9kDr+Z6VH3IpHu5Q2xmygLEq8MgxmPZFuJehOhY4qRT7LjFIajq15bDBNkMjZlw1UdNBmFeP 084z5brX3LqQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136212" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136212" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:06 -0700 IronPort-SDR: M0VcYyoZ19v+Ti3LHvWXieJz9+iq5ldZY2LRVSmfy/cBXU7gL3d13bCQafRMshCs/y9cHyuVZC JDI3rrmfc0+g== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679740" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:04 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:06 +0200 Message-Id: <20200820145215.13238-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 10/19] 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. v3: Refresh. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 849a774ff..602a91cf8 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -109,7 +109,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 */ @@ -139,6 +138,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_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); @@ -194,7 +195,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 Thu Aug 20 14:52:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726401 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 A18E6739 for ; Thu, 20 Aug 2020 14:53: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 8A98E2078B for ; Thu, 20 Aug 2020 14:53:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A98E2078B 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 EB78E6E94D; Thu, 20 Aug 2020 14:53:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id D571D6E94D; Thu, 20 Aug 2020 14:53:09 +0000 (UTC) IronPort-SDR: 99lSFLOkJNKJNl5qoMyxV4HQwrbpR2v+Dj4xNFdVOEOl+ut+NjOKGrl/osqTsGV5A326VW8036 jbjon1j/N52g== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136235" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136235" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:09 -0700 IronPort-SDR: MiS3rBKByX/fmfvDYbDy1CwnixfB1rre8pV+bRO/V0J+Sv5eHB1TjmVG4n1SZmIfIkFwnpW/e/ cGHR+Nh5umXg== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679751" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:06 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:07 +0200 Message-Id: <20200820145215.13238-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 11/19] 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 which must be followed by a successful health check in order to avoid aborting the test is executed. Then, move health checks not essential for subtests out of those subtest bodies, or just copy them if essentiall, to subtest associated individual follow-up igt_fixture sections, 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 if the preceding igt_subtest section 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. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v1 --- tests/core_hotunplug.c | 104 +++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 30 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 602a91cf8..145593683 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -69,6 +69,9 @@ static int local_drm_open_driver(const char *prefix, const char *suffix) static int local_close(int fd, const char *message) { + if (fd < 0) /* not open - return current status */ + return fd; + errno = 0; if (igt_warn_on_f(close(fd), "%s\n", message)) return -errno; /* (never -1) */ @@ -115,24 +118,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 */ @@ -145,12 +146,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); } @@ -159,17 +159,23 @@ 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); + priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } static void healthcheck(struct hotunplug *priv) { /* preserve error code potentially stored before in priv->fd.drm */ + bool closed = priv->fd.drm == -1; int fd_drm; /* device name may have changed, rebuild IGT device list */ @@ -177,23 +183,45 @@ static void healthcheck(struct hotunplug *priv) priv->failure = "Device reopen failure!"; fd_drm = local_drm_open_driver("re", " for healthcheck"); - priv->failure = NULL; + if (closed) /* store for cleanup if no error code to preserve */ + priv->fd.drm = fd_drm; 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; } + /* not only request igt_abort on failure, also fail the health check */ + igt_fail_on_f(priv->failure, "%s\n", priv->failure); + fd_drm = close_device(fd_drm); - if (priv->fd.drm == -1) /* store result if no error code to preserve */ + if (closed) /* store result if no error code to preserve */ priv->fd.drm = fd_drm; } +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); } @@ -242,8 +270,6 @@ static void hotunbind_lateclose(struct hotunplug *priv) igt_debug("late closing the unbound device instance\n"); priv->fd.drm = close_device(priv->fd.drm); - - healthcheck(priv); } static void hotunplug_lateclose(struct hotunplug *priv) @@ -256,8 +282,6 @@ static void hotunplug_lateclose(struct hotunplug *priv) igt_debug("late closing the removed device instance\n"); priv->fd.drm = close_device(priv->fd.drm); - - healthcheck(priv); } /* Main */ @@ -288,30 +312,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 Thu Aug 20 14:52:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726403 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 BB6DB739 for ; Thu, 20 Aug 2020 14:53: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 A458D2075E for ; Thu, 20 Aug 2020 14:53:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A458D2075E 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 396CD6E953; Thu, 20 Aug 2020 14:53:15 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 24BC76E944; Thu, 20 Aug 2020 14:53:12 +0000 (UTC) IronPort-SDR: cIphLg+s463SZnK7rdVX4eT+Ym+dZ7YnEAO2nHWkrZ+7BKtcytco/deDTvmAhEIR9B3vLrW1Vl ifAh0Mv8gDlQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136255" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136255" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:11 -0700 IronPort-SDR: GLwMoLhm8NQ/l6P9HQ5u/HA2mw7ksomdvyf8ERgjbCmLKIFHVuW09sCAI5Ltm3ke4C7M3nHGz9 OmkMn4/1Blbw== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679759" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:09 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:08 +0200 Message-Id: <20200820145215.13238-13-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 12/19] 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. v3: 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 145593683..e048f3a15 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -153,6 +153,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 */ @@ -270,6 +271,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) igt_debug("late closing the unbound device instance\n"); priv->fd.drm = close_device(priv->fd.drm); + igt_assert_eq(priv->fd.drm, -1); } static void hotunplug_lateclose(struct hotunplug *priv) @@ -282,6 +284,7 @@ static void hotunplug_lateclose(struct hotunplug *priv) igt_debug("late closing the removed device instance\n"); priv->fd.drm = close_device(priv->fd.drm); + igt_assert_eq(priv->fd.drm, -1); } /* Main */ From patchwork Thu Aug 20 14:52:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726405 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 E79A2739 for ; Thu, 20 Aug 2020 14:53: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 D0DB92078B for ; Thu, 20 Aug 2020 14:53:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0DB92078B 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 5829C6E944; Thu, 20 Aug 2020 14:53:17 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 735496E955; Thu, 20 Aug 2020 14:53:14 +0000 (UTC) IronPort-SDR: NB1T1HynN6P6sjnOZxxxi2M8G8q+r98ps1ix7wwY3pu2SV+MoQGrSAGcTlLhDbUhoUScb1N/8o PKGnsGpwRKDQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136272" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136272" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:13 -0700 IronPort-SDR: Rrn2IRTnBIl943Gl8J0D6XCKp1UWLf275r+IiYE0yAmojKdNhN4eNSDAbkVrE2Yqh23mH8fl2g m4Cg69M5vi2w== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679775" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:12 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:09 +0200 Message-Id: <20200820145215.13238-14-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 13/19] 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. 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 e048f3a15..572c66474 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -115,29 +115,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); @@ -148,7 +150,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(); @@ -157,12 +159,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(); } @@ -209,10 +211,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); @@ -245,18 +247,18 @@ static void set_filter_from_device(int fd) static void unbind_rebind(struct hotunplug *priv) { - driver_unbind(priv, ""); + driver_unbind(priv, "", 0); - driver_bind(priv); + driver_bind(priv, 0); healthcheck(priv); } static void unplug_rescan(struct hotunplug *priv) { - device_unplug(priv, ""); + device_unplug(priv, "", 0); - bus_rescan(priv); + bus_rescan(priv, 0); healthcheck(priv); } @@ -265,9 +267,9 @@ static void hotunbind_lateclose(struct hotunplug *priv) { priv->fd.drm = local_drm_open_driver("", " for hotunbind"); - driver_unbind(priv, "hot "); + driver_unbind(priv, "hot ", 0); - driver_bind(priv); + driver_bind(priv, 60); igt_debug("late closing the unbound device instance\n"); priv->fd.drm = close_device(priv->fd.drm); @@ -278,9 +280,9 @@ static void hotunplug_lateclose(struct hotunplug *priv) { priv->fd.drm = local_drm_open_driver("", " for hotunplug"); - device_unplug(priv, "hot "); + device_unplug(priv, "hot ", 0); - bus_rescan(priv); + bus_rescan(priv, 60); igt_debug("late closing the removed device instance\n"); priv->fd.drm = close_device(priv->fd.drm); From patchwork Thu Aug 20 14:52:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726409 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 DD8FB138C for ; Thu, 20 Aug 2020 14:53: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 C6EA82078B for ; Thu, 20 Aug 2020 14:53:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6EA82078B 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 A7E5B6E957; Thu, 20 Aug 2020 14:53:19 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id BA2F26E955; Thu, 20 Aug 2020 14:53:16 +0000 (UTC) IronPort-SDR: 9Q+2isuD/Re3cmr42Pam4FrrDS71BjJdQfJecLXH1ReJIH3CRoZTGr7rvSkElOZlV9+vksmwCy P6IfwLDukFsA== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136285" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136285" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:16 -0700 IronPort-SDR: swmJavx7LYroP4wXgHTXrHH+02Cpwoffl7iLB1IYWQIbV8mYa3FG2Ji4G/qEtDPkKoaWVXoWv2 RBfwZ177lwxg== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679794" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:14 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:10 +0200 Message-Id: <20200820145215.13238-15-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 14/19] 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 572c66474..f280771ab 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -122,7 +122,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(); } @@ -133,7 +135,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(); } @@ -151,7 +155,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); @@ -165,7 +170,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 Thu Aug 20 14:52:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726407 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 CEC2816B1 for ; Thu, 20 Aug 2020 14:53:19 +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 B8082207DE for ; Thu, 20 Aug 2020 14:53:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8082207DE 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 3CBE36E955; Thu, 20 Aug 2020 14:53:19 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 974A86E955; Thu, 20 Aug 2020 14:53:18 +0000 (UTC) IronPort-SDR: FpWQbNjzuxuVTzIcJlm7/31mOdf6issrnWYGHbyN3MCyzfeQ8mlhK0Oql0Ezkr1RNSNHyHL9F0 i2TRF5kZWBEg== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136295" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136295" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:17 -0700 IronPort-SDR: mSwWJDlvGXDohxqbCwPWf/6yOg37LtJN4FX9kOslV2gBKO2xXVrUKOPZ5hmZJzZyF/rMXYvfFt 0XKB1hUw215g== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679804" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:16 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:11 +0200 Message-Id: <20200820145215.13238-16-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 15/19] 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 f280771ab..d30ad8525 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -126,6 +126,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 */ @@ -139,6 +142,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 */ @@ -161,6 +168,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 */ @@ -173,6 +183,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 Thu Aug 20 14:52:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726411 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 91F62138C for ; Thu, 20 Aug 2020 14:53:22 +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 7B4F12078B for ; Thu, 20 Aug 2020 14:53:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B4F12078B 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 DAEA06E34C; Thu, 20 Aug 2020 14:53:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 429FD6E95B; Thu, 20 Aug 2020 14:53:20 +0000 (UTC) IronPort-SDR: 7hS7qxUpjWSodLFBBqaUpFahHWBcTX9N0QCXVKdFqKaVhOKmW6k5rl9z5LREaWY8JtFtgc5ii5 csUbXr21lTAg== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136308" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136308" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:20 -0700 IronPort-SDR: 25n8vCSaB3OMqhAO3atzwVGOvSwziHrKlH7hTFCy1KVEY2qNR7W6uVKGHwQLsxjRFRcQggEABu IqXbqqduRnRg== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679817" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:18 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:12 +0200 Message-Id: <20200820145215.13238-17-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 16/19] 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 d30ad8525..24beed81a 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -256,7 +256,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(); @@ -385,7 +385,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 Thu Aug 20 14:52:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726413 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 8EC6D739 for ; Thu, 20 Aug 2020 14:53:25 +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 77F762078B for ; Thu, 20 Aug 2020 14:53:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77F762078B 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 05BDE6E59D; Thu, 20 Aug 2020 14:53:25 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E2CF6E59D; Thu, 20 Aug 2020 14:53:22 +0000 (UTC) IronPort-SDR: 0FeBtpiTJ9ysTwr+uscO/p0qc3cQIw4rHtHRVOJAcPX4C9JsysTwDQlum43h244iwzGmhElycs QVIqdAVljhzw== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136327" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136327" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:21 -0700 IronPort-SDR: ThsNfHdZ3G6ZMfY100LjtWiCFOPp7b2VFxDB+J6JBRDeePUD8YSn991uVnxeudBJn58vTiAmhX Yw7RgstIFnqw== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679824" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:20 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:13 +0200 Message-Id: <20200820145215.13238-18-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 17/19] 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 healthcheck. 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. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 88 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 24beed81a..277679ea1 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -23,8 +23,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -195,7 +197,71 @@ static void cleanup(struct hotunplug *priv) priv->fd.sysfs_dev = close_sysfs(priv->fd.sysfs_dev); } -static void healthcheck(struct hotunplug *priv) +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; + +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 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; + + igt_debug("running i915 GPU healthcheck\n"); + + if (local_i915_is_wedged(i915)) + return -EIO; + + obj.handle = gem_create(i915, 4096); + gem_write(i915, obj.handle, 0, &bbe, sizeof(bbe)); + + hang_detected = false; + 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) +{ + igt_debug("forcing i915 GPU reset\n"); + igt_force_gpu_reset(i915); + return local_i915_healthcheck(i915); +} + +static void healthcheck(struct hotunplug *priv, bool recover) { /* preserve error code potentially stored before in priv->fd.drm */ bool closed = priv->fd.drm == -1; @@ -210,9 +276,14 @@ static void healthcheck(struct hotunplug *priv) 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) && + (!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; @@ -237,7 +308,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) @@ -271,7 +342,7 @@ static void unbind_rebind(struct hotunplug *priv) driver_bind(priv, 0); - healthcheck(priv); + healthcheck(priv, false); } static void unplug_rescan(struct hotunplug *priv) @@ -280,7 +351,7 @@ static void unplug_rescan(struct hotunplug *priv) bus_rescan(priv, 0); - healthcheck(priv); + healthcheck(priv, false); } static void hotunbind_lateclose(struct hotunplug *priv) @@ -326,7 +397,8 @@ igt_main if (is_i915_device(fd_drm)) { gem_quiescent_gpu(fd_drm); - igt_require_gem(fd_drm); + igt_skip_on_f(local_i915_healthcheck(fd_drm), + "i915 device not healthy on test start\n"); } /* Make sure subtests always reopen the same device */ From patchwork Thu Aug 20 14:52:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726415 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 3E845739 for ; Thu, 20 Aug 2020 14:53:27 +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 27DA22078B for ; Thu, 20 Aug 2020 14:53:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27DA22078B 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 68BC56E94A; Thu, 20 Aug 2020 14:53:26 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id AEBDD6E94A; Thu, 20 Aug 2020 14:53:25 +0000 (UTC) IronPort-SDR: I9oHBlgmlrPAozFR89VQ+ZLOim42astkh2/81L0X7pCN/zVuFmiajNVBD4NFshhrBx9o3/Djfo TkMM18wbvtFQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136340" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136340" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:24 -0700 IronPort-SDR: 7EMFrTdkI10Wl1M++seevX+ooDodKlAjTuDVvr25d8Eetuov8M2FQ41HUEMHF5WjDfMv5qsoTI sCZfRxzjcyeQ== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679842" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:22 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:14 +0200 Message-Id: <20200820145215.13238-19-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 18/19] 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. Rename those variants to more adequate hotrebind/hotreplug-lateclose and add new variants under the old names focused on exercising the lateclose phase regardless of potential rediscover/rebind issues. Moreover, add two more variants which exercise driver rebind / device restore after late close specifically. 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. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v2 --- tests/core_hotunplug.c | 114 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 5 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 277679ea1..42a13f8b5 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -360,8 +360,6 @@ static void hotunbind_lateclose(struct hotunplug *priv) driver_unbind(priv, "hot ", 0); - driver_bind(priv, 60); - igt_debug("late closing the unbound device instance\n"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); @@ -373,11 +371,69 @@ static void hotunplug_lateclose(struct hotunplug *priv) device_unplug(priv, "hot ", 0); - bus_rescan(priv, 60); + igt_debug("late closing the removed device instance\n"); + priv->fd.drm = close_device(priv->fd.drm); + igt_assert_eq(priv->fd.drm, -1); +} + +static void hotunbind_rebind(struct hotunplug *priv) +{ + priv->fd.drm = local_drm_open_driver("", " for hotrebind"); + + driver_unbind(priv, "hot ", 60); + + igt_debug("late closing the unbound device instance\n"); + priv->fd.drm = close_device(priv->fd.drm); + igt_assert_eq(priv->fd.drm, -1); + + driver_bind(priv, 0); + + healthcheck(priv, false); +} + +static void hotunplug_rescan(struct hotunplug *priv) +{ + priv->fd.drm = local_drm_open_driver("", " for hotreplug"); + + device_unplug(priv, "hot ", 60); + + igt_debug("late closing the removed device instance\n"); + priv->fd.drm = close_device(priv->fd.drm); + igt_assert_eq(priv->fd.drm, -1); + + bus_rescan(priv, 0); + + healthcheck(priv, false); +} + +static void hotrebind_lateclose(struct hotunplug *priv) +{ + priv->fd.drm = local_drm_open_driver("", " for hotrebind"); + + driver_unbind(priv, "hot ", 60); + + driver_bind(priv, 0); + + igt_debug("late closing the unbound device instance\n"); + priv->fd.drm = close_device(priv->fd.drm); + igt_assert_eq(priv->fd.drm, -1); + + healthcheck(priv, false); +} + +static void hotreplug_lateclose(struct hotunplug *priv) +{ + priv->fd.drm = local_drm_open_driver("", " for hotreplug"); + + device_unplug(priv, "hot ", 60); + + bus_rescan(priv, 0); igt_debug("late closing the removed device instance\n"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); + + healthcheck(priv, false); } /* Main */ @@ -410,7 +466,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); @@ -422,7 +478,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); @@ -454,6 +510,54 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly rebound to a device after hotunbind-lateclose"); + igt_subtest("hotunbind-rebind") + hotunbind_rebind(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a device can be cleanly restored after hotunplug-lateclose"); + 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); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + 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); + } + igt_fixture { post_healthcheck(&priv); From patchwork Thu Aug 20 14:52:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11726417 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 B230E739 for ; Thu, 20 Aug 2020 14:53:30 +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 9B9192078B for ; Thu, 20 Aug 2020 14:53:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B9192078B 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 EEE7E6E956; Thu, 20 Aug 2020 14:53:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id D9F296E95C; Thu, 20 Aug 2020 14:53:26 +0000 (UTC) IronPort-SDR: uE6ZRvY2jifcy/NrNlM7eNsQqupKJwKoistrHvSVdHd84DKHs25aaqj07uvzIBN3MQPXOwxRWi EU/YLhwugbCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240136354" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="240136354" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:26 -0700 IronPort-SDR: A19Ep4JCkcdCQhmRRUNc3BykZUldwLncGEKD1UHDaFSzCLrHKU5IbntMsTBWtvG/vuA7Ay4OV3 3YymDso3Lw1Q== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="472679861" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 07:53:24 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 20 Aug 2020 16:52:15 +0200 Message-Id: <20200820145215.13238-20-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> References: <20200820145215.13238-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v3 19/19] 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 --- 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