From patchwork Fri Aug 21 15:37:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729805 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 0FE75739 for ; Fri, 21 Aug 2020 15:38:29 +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 EC2882063A for ; Fri, 21 Aug 2020 15:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC2882063A 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 010016E175; Fri, 21 Aug 2020 15:38: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 062618918F; Fri, 21 Aug 2020 15:38:23 +0000 (UTC) IronPort-SDR: 8+l7V0dY+cHfVfqtcY8QP+kCdpw4QiA8nZD/+VFcvksyE/8y08dKButPZnkJE2LaNTMAdqnjtR RhmPpdEI0sWQ== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381832" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381832" 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; 21 Aug 2020 08:38:23 -0700 IronPort-SDR: 66NH5W7IKalbXZiVs5K+524ZvrVM02+G966+1gdaPYws+AcpKYNTeC5S7cD9koM/MPjfmA9P4M DzBV2T7UemMg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086498" 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; 21 Aug 2020 08:38:21 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:48 +0200 Message-Id: <20200821153807.18613-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 01/20] tests/core_hotunplug: Use igt_assert_fd() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" There is a new library helper that asserts validity of open file descriptors. Use it instead of open coding. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index e03f3b945..7431346b1 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -57,7 +57,7 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) priv->fd.sysfs_drv = openat(priv->fd.sysfs_dev, "device/driver", O_DIRECTORY); - igt_assert(priv->fd.sysfs_drv >= 0); + igt_assert_fd(priv->fd.sysfs_drv); len = readlinkat(priv->fd.sysfs_dev, "device", buf, buflen - 1); buf[len] = '\0'; @@ -72,10 +72,10 @@ static void prepare(struct hotunplug *priv, char *buf, int buflen) { igt_debug("opening device\n"); priv->fd.drm = __drm_open_driver(DRIVER_ANY); - igt_assert(priv->fd.drm >= 0); + igt_assert_fd(priv->fd.drm); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); - igt_assert(priv->fd.sysfs_dev >= 0); + igt_assert_fd(priv->fd.sysfs_dev); if (buf) { prepare_for_unbind(priv, buf, buflen); @@ -83,7 +83,7 @@ static void prepare(struct hotunplug *priv, char *buf, int buflen) /* prepare for bus rescan */ priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev, "device/subsystem", O_DIRECTORY); - igt_assert(priv->fd.sysfs_bus >= 0); + igt_assert_fd(priv->fd.sysfs_bus); } } @@ -261,7 +261,7 @@ igt_main * a device file descriptor open for exit handler use. */ fd_drm = __drm_open_driver(DRIVER_ANY); - igt_assert(fd_drm >= 0); + igt_assert_fd(fd_drm); if (is_i915_device(fd_drm)) igt_require_gem(fd_drm); From patchwork Fri Aug 21 15:37:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729807 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 B7787739 for ; Fri, 21 Aug 2020 15:38: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 A001D2063A for ; Fri, 21 Aug 2020 15:38:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A001D2063A 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 39EFC6E161; Fri, 21 Aug 2020 15:38:28 +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 C605E6E161; Fri, 21 Aug 2020 15:38:25 +0000 (UTC) IronPort-SDR: 2nbG7DGDrgZiJNExFV7RnTEBITrojP83Sa0B2AIvsdk/aM6bX8ecEJkZBqYM6YV0tiYBdocSLT KdPt1DTlGN8w== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381838" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381838" 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; 21 Aug 2020 08:38:25 -0700 IronPort-SDR: A3+p6+ooTNXyxtCoaAy1obi7AFvMczC8fy8hhpyrE+CIu93q/yYJUUwc2xqVjBJzmNi8JUIzlZ cF6kzgT9QulQ== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086514" 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; 21 Aug 2020 08:38:23 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:49 +0200 Message-Id: <20200821153807.18613-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 02/20] tests/core_hotunplug: Constify dev_bus_addr string X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Device bus address structure field is always initialized with a pointer to a substring of the device sysfs path and never used for its modification. Declare it as a constant string. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 7431346b1..a4071f51e 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -44,7 +44,7 @@ struct hotunplug { int sysfs_bus; int sysfs_drv; } fd; - char *dev_bus_addr; + const char *dev_bus_addr; }; /* Helpers */ From patchwork Fri Aug 21 15:37:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729809 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 22290739 for ; Fri, 21 Aug 2020 15:38:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AB582063A for ; Fri, 21 Aug 2020 15:38:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AB582063A 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 AD27A6E221; Fri, 21 Aug 2020 15:38: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 C23326E211; Fri, 21 Aug 2020 15:38:27 +0000 (UTC) IronPort-SDR: yLuK2XYmeKW0OJwTno8mAFbBYTMvRlZZnml3YmELdrnUqYkk5JFxJt64+XhsS5N22JrgFkFcvW 1D+UNm1mlp4Q== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381848" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381848" 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; 21 Aug 2020 08:38:27 -0700 IronPort-SDR: bKV77uRQI3aYY3VjG0XQZK4Dm/ddpoShE2YEoB3VQhuBUzx9a+B6F7Wdg6zDHiB4+EdZDG0Ex0 Jw5aJs88K2pg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086534" 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; 21 Aug 2020 08:38:25 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:50 +0200 Message-Id: <20200821153807.18613-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 03/20] tests/core_hotunplug: Clean up device open error handling X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We don't use drm_driver_open() since in case of an i915 device it keeps an extra file descriptor of the exercised device open for exit handler use, while we would like to be able to close the device completely before running certain test operations. Instead, we call __drm_driver_open() and handle its result ourselves. Unlike drm_driver_open() which skips on device open errors, we always fail or abort the test in such case. Moreover, we don't ensure that the i915 driver is idle before starting subtests like drm_open_driver() does. Skip instead of failing on initial device open error. Also, call gem_quiescent_gpu() if an i915 device is detected. For subsequent device opens, define a local helper that fails on error and use it. If we think we need to abort the test execution on device open error, set our failure marker first to trigger the abort from a follow up igt_fixture section. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index a4071f51e..e576a6c6c 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -49,6 +49,21 @@ struct hotunplug { /* Helpers */ +/** + * Subtests must be able to close examined devices completely. Don't + * use drm_open_driver() since in case of an i915 device it opens it + * twice and keeps a second file descriptor open for exit handler use. + */ +static int local_drm_open_driver(void) +{ + int fd_drm; + + fd_drm = __drm_open_driver(DRIVER_ANY); + igt_assert_fd(fd_drm); + + return fd_drm; +} + static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) { int len; @@ -71,8 +86,7 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) static void prepare(struct hotunplug *priv, char *buf, int buflen) { igt_debug("opening device\n"); - priv->fd.drm = __drm_open_driver(DRIVER_ANY); - igt_assert_fd(priv->fd.drm); + priv->fd.drm = local_drm_open_driver(); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); igt_assert_fd(priv->fd.sysfs_dev); @@ -145,8 +159,9 @@ static void healthcheck(void) igt_devices_scan(true); igt_debug("reopening the device\n"); - fd_drm = __drm_open_driver(DRIVER_ANY); - igt_abort_on_f(fd_drm < 0, "Device reopen failure"); + failure = "Device reopen failure!"; + fd_drm = local_drm_open_driver(); + failure = NULL; if (is_i915_device(fd_drm)) { failure = "GEM failure"; @@ -255,16 +270,13 @@ igt_main igt_fixture { int fd_drm; - /** - * As subtests must be able to close examined devices - * completely, don't use drm_open_driver() as it keeps - * a device file descriptor open for exit handler use. - */ fd_drm = __drm_open_driver(DRIVER_ANY); - igt_assert_fd(fd_drm); + igt_skip_on_f(fd_drm < 0, "No known DRM device found\n"); - if (is_i915_device(fd_drm)) + if (is_i915_device(fd_drm)) { + gem_quiescent_gpu(fd_drm); igt_require_gem(fd_drm); + } /* Make sure subtests always reopen the same device */ set_filter_from_device(fd_drm); From patchwork Fri Aug 21 15:37:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729811 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 4BFD7138C for ; Fri, 21 Aug 2020 15:38:33 +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 349AF2063A for ; Fri, 21 Aug 2020 15:38:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 349AF2063A 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 787F66E211; Fri, 21 Aug 2020 15:38:31 +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 14BC76E211; Fri, 21 Aug 2020 15:38:30 +0000 (UTC) IronPort-SDR: b+mM5YUlx7vqBZYzwFpuIFOMDfXjKPQ/SlTtHLP/a6UBdGbrAq+AeeGj3OLg+8zZPdYijXqCDV AKwpgtmidzRg== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381855" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381855" 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; 21 Aug 2020 08:38:29 -0700 IronPort-SDR: ftkNT0Cwvw1FDw0LvS7/jfPxuM0I7foj7KmCi/KNA9iaKnUekhFOpWpXRk8IhxfZwaUJa70O+O 4P3bGPPjfAIA== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086551" 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; 21 Aug 2020 08:38:27 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:51 +0200 Message-Id: <20200821153807.18613-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 04/20] tests/core_hotunplug: Consolidate duplicated debug messages X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Some debug messages which designate specific test operations, or their greater parts at least, sound always the same, no matter which subtest they are called from. Emit them, possibly updated with subtest specified modifiers, from inside respective helpers instead of duplicating them in subtest bodies. v2: Rebase only. v3: Refresh and extend over new case (local_drm_open_driver), - allow callers to specify a message suffix as well where applicable. 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 Fri Aug 21 15:37:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729813 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 600D3739 for ; Fri, 21 Aug 2020 15:38:34 +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 48E39207BB for ; Fri, 21 Aug 2020 15:38:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48E39207BB 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 3C1396E226; Fri, 21 Aug 2020 15:38:33 +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 B70EE6E226; Fri, 21 Aug 2020 15:38:31 +0000 (UTC) IronPort-SDR: wt4bLwMKbK+Dgc6ZuYDLQph6Oepj8qLT6NAp2LRP0uuR2mAomrZGuMQwMxxiV3+hwBTfOeqeh7 BMdP7X+mA9nw== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381861" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381861" 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; 21 Aug 2020 08:38:31 -0700 IronPort-SDR: opbdSQ605NCi8mnpRs5lNHAt+oLO/GbIJyvq/4AiEt605NkOD+3SSJ2CEjhEYBwpljhQdQ50sd KpFfGlLoxmrA== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086569" 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; 21 Aug 2020 08:38:29 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:52 +0200 Message-Id: <20200821153807.18613-6-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 05/20] 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 Fri Aug 21 15:37:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729815 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 B368A138C for ; Fri, 21 Aug 2020 15:38:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BB9720855 for ; Fri, 21 Aug 2020 15:38:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BB9720855 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 343DE6E167; Fri, 21 Aug 2020 15:38:36 +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 BC51B6E2A8; Fri, 21 Aug 2020 15:38:33 +0000 (UTC) IronPort-SDR: C1Evw9t/A8R5T/2dh0tkEur27m+h9yxfSAimzvPASTnZe7pfy3Flw0V+0DjuqnLgiadeb0uYLr ioJqII9JpkIw== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381870" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381870" 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; 21 Aug 2020 08:38:33 -0700 IronPort-SDR: AZ+VGPdL4Lx5mWb4mwmGazyz//NuyrVmvrgL0mz7m9XMRLLe4XCiuOuszSRWtHv/1yuor32sP7 L448+z8Ks95A== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086579" 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; 21 Aug 2020 08:38:31 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:53 +0200 Message-Id: <20200821153807.18613-7-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 06/20] 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 Fri Aug 21 15:37:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729817 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 547CD739 for ; Fri, 21 Aug 2020 15:38:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CE332063A for ; Fri, 21 Aug 2020 15:38:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CE332063A 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 771AE6E2A8; Fri, 21 Aug 2020 15:38:37 +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 9BE656E2A8; Fri, 21 Aug 2020 15:38:35 +0000 (UTC) IronPort-SDR: g6axu6zLUsqsWcEyLrevPSgIs3s1I9ZX8G5Jeyg3DJ8+LI9Ur74vbHx9okJFyExx0CKONblgh+ n1WpHe+fSIfg== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381874" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381874" 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; 21 Aug 2020 08:38:35 -0700 IronPort-SDR: Fsq/uN9PL8XxGYoFXmRLMC0ihG5hDocfMrHuhG5jz8qgE+k3eVT1bXbB04wlF8Bpoeh+q95Omf kNGye/iDMSdw== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086596" 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; 21 Aug 2020 08:38:33 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:54 +0200 Message-Id: <20200821153807.18613-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 07/20] tests/core_hotunplug: Pass errors via a data structure field X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" A pointer to fatal error messages can be passed around via hotunplug structure, no need to declare it as global. v2: Rebase only. v3: Refresh. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 96 +++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 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 Fri Aug 21 15:37:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729819 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 42C55739 for ; Fri, 21 Aug 2020 15:38:41 +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 2BD3B2078B for ; Fri, 21 Aug 2020 15:38:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2BD3B2078B 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 9F94F6E859; Fri, 21 Aug 2020 15:38:40 +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 B18F76E82B; Fri, 21 Aug 2020 15:38:37 +0000 (UTC) IronPort-SDR: 1gl0D9lH8+2J8nWSPkIxBmHSqiW5AWaC4aXj3wqab8cY8qoHbumIPFis0VwxVO4g4KmdlyjmG7 Cjc24BLBpdxw== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381879" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381879" 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; 21 Aug 2020 08:38:37 -0700 IronPort-SDR: WCICd6r78oQWQD2Ci7XoyHJjAjEbb6reIJgMrUdf6XzESDo4ntk3jKy5v3Atx4BS9DPfmPfx80 2hehqW7KeeXQ== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086607" 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; 21 Aug 2020 08:38:35 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:55 +0200 Message-Id: <20200821153807.18613-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 08/20] 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 Fri Aug 21 15:37:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729821 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 EDD4415E4 for ; Fri, 21 Aug 2020 15:38:41 +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 D6B3E2063A for ; Fri, 21 Aug 2020 15:38:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6B3E2063A 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 B07BB6E85A; Fri, 21 Aug 2020 15:38:40 +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 BC0BC6E82B; Fri, 21 Aug 2020 15:38:39 +0000 (UTC) IronPort-SDR: 9kVPH2rzBu3wkP84NusVbOEjqyggLt6NST8rFMjljue6NDG1WuaKSHfh/t7Osz51LxavOB0ba3 R8iDSYy2DKKg== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381883" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381883" 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; 21 Aug 2020 08:38:39 -0700 IronPort-SDR: v6PTcVwYlkmQ2wSAabnUBPVFMPbiL3TW7/8GGDUa8ljthcgQoG0FAm+rYHH19CT1/wLp/Hqqk1 Uh+D+YAXzRKg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086620" 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; 21 Aug 2020 08:38:37 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:56 +0200 Message-Id: <20200821153807.18613-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 09/20] 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. v2: Rebase only. 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 Fri Aug 21 15:37: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: 11729823 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 3D2C8739 for ; Fri, 21 Aug 2020 15:38:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 265F22078B for ; Fri, 21 Aug 2020 15:38:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 265F22078B 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 98FED6E210; Fri, 21 Aug 2020 15:38:43 +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 B725C6E85C; Fri, 21 Aug 2020 15:38:41 +0000 (UTC) IronPort-SDR: 34T6saXyBC0V3hUW5uJOjFBkk0WEh+dyujqnd2sN7ipjP7bu+niaDdeaDfF+pcwoW5YiTA9wMe /r8EAdslBQvA== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381891" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381891" 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; 21 Aug 2020 08:38:41 -0700 IronPort-SDR: 7Qj++afIHaIAj3NqtJrZ15e+/D9uMlYptPD2I70B8zUgw96vvvYDFg8Qa6BZdIavNn7VjlUFRN UXa4RXbIZAIA== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086637" 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; 21 Aug 2020 08:38:39 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:57 +0200 Message-Id: <20200821153807.18613-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 10/20] tests/core_hotunplug: Skip selectively on sysfs close errors X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since we no longer open a device DRM sysfs node, only a PCI one, driver unbind operations are no longer affected by missed or unsuccessful sysfs file close attempts. Skip only affected subtests if that happens. v2: Rebase only. v3: Refresh. 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 Fri Aug 21 15:37: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: 11729825 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 DFEF6739 for ; Fri, 21 Aug 2020 15:38:46 +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 C8D4C2078B for ; Fri, 21 Aug 2020 15:38:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8D4C2078B 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 4D7E66E85C; Fri, 21 Aug 2020 15:38:46 +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 B13EC6E85D; Fri, 21 Aug 2020 15:38:43 +0000 (UTC) IronPort-SDR: 3NXdAmjukkpQ4fZsJQPXJyRS1po2EtEx3NnIioep/PIEQPi69JgUZi2REUMfNhOD7pcax5Ot7u a0JVnkkW+d6g== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381898" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381898" 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; 21 Aug 2020 08:38:43 -0700 IronPort-SDR: 0dsSTfjKBm2TJ4hialEilmdFfQj1M7ITPlY30BQfTTslCV3G3t/OCEhdD/E496tLVNLOa9WA3Z JPYwBQ0caI1A== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086657" 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; 21 Aug 2020 08:38:41 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:58 +0200 Message-Id: <20200821153807.18613-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 11/20] 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 Fri Aug 21 15:37:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729827 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 49204138C for ; Fri, 21 Aug 2020 15:38: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 325382078B for ; Fri, 21 Aug 2020 15:38:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 325382078B 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 BB3026E982; Fri, 21 Aug 2020 15:38: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 8C3576E85D; Fri, 21 Aug 2020 15:38:45 +0000 (UTC) IronPort-SDR: Dz8bAmkopF1m7I1J/57NYcXNq3gsIEZiZppHtm0dNYqb/RdzjGCZJypay6kheOBzRHAd5ZRYIn USBO5VABn/Lw== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381903" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381903" 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; 21 Aug 2020 08:38:45 -0700 IronPort-SDR: XxBSo2/UtUXpV+qzp1T8RCMa+ftluBrqOm68akE5Gdko55UhM23Jt0ay2UqM3CicRbcY5zQFRd FEZ6s5OT1fhg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086685" 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; 21 Aug 2020 08:38:43 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:59 +0200 Message-Id: <20200821153807.18613-13-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 12/20] tests/core_hotunplug: Fail subtests on device close errors X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since health checks are now run from follow-up fixture sections, it is safe to fail subtests without the need to abort the test execution. Do that on device close errors instead of just emitting warnings. v2: Rebase only. v3: Refresh. 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 Fri Aug 21 15:38:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729829 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 63BF3138C for ; Fri, 21 Aug 2020 15:38: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 4C9812078B for ; Fri, 21 Aug 2020 15:38:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C9812078B 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 D042E6E983; Fri, 21 Aug 2020 15:38: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 82B836E87B; Fri, 21 Aug 2020 15:38:47 +0000 (UTC) IronPort-SDR: kFs8a7r4jmrQ1AtF6s2DGVMR8qy+/7/d/f5FLxSlN47pM9Ul9JlVYL6c9dYIVofgGm/JpRgLLK 1AkV95YdbE1w== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381907" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381907" 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; 21 Aug 2020 08:38:47 -0700 IronPort-SDR: AHUbjR49hasvaAVEv3Qerr0CTpFXliqJszqpKfmbUabL/tR3UgtZUJ89t1MCdm+kdxsejmsggL XO3e5Z/zzZLg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086695" 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; 21 Aug 2020 08:38:45 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:00 +0200 Message-Id: <20200821153807.18613-14-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 13/20] 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 Fri Aug 21 15:38: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: 11729831 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 66C8A739 for ; Fri, 21 Aug 2020 15:38:51 +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 4F1302078B for ; Fri, 21 Aug 2020 15:38:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F1302078B 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 A578C6E87B; Fri, 21 Aug 2020 15:38:50 +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 A39DA6E87B; Fri, 21 Aug 2020 15:38:49 +0000 (UTC) IronPort-SDR: s2ThIvTBEtu5jexLUICfNLzRNAeR2/hQtPJYbae2QMdRco/swbehnxHaVwJB8HbQ+fIKFAfGFA p4NP6b6DK8NQ== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381913" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381913" 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; 21 Aug 2020 08:38:49 -0700 IronPort-SDR: tTxEgwoGIf8xFJiMlp3AhN7/1uoJWSCEK3+++mtKb2y+9dpIocsE82xPtx4Rl7ayrbZbBGL8Qh elVowhw2+9RA== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086708" 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; 21 Aug 2020 08:38:47 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:01 +0200 Message-Id: <20200821153807.18613-15-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 14/20] 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 Fri Aug 21 15:38: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: 11729833 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 A91DA739 for ; Fri, 21 Aug 2020 15:38:54 +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 9200D2078B for ; Fri, 21 Aug 2020 15:38:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9200D2078B 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 204AC6E984; Fri, 21 Aug 2020 15:38:54 +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 5E1776E989; Fri, 21 Aug 2020 15:38:51 +0000 (UTC) IronPort-SDR: RJwwX7Wk0zLFSrfV1n5ntp9caErEcDhcVG67y5k7Pxpi8WZN1qTh2mRufJn2R+IkJRO3DhD2az BFeS4agMBnlQ== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381923" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381923" 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; 21 Aug 2020 08:38:51 -0700 IronPort-SDR: vBzMkEaOzIxgC6Nss7YaPZsT4SzTAs6ZkjsRuJzLbU5w2Jos5L6k0h/T+lzIRfxrMNLCXWjoTU Yret4mzDAdSQ== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086722" 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; 21 Aug 2020 08:38:49 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:02 +0200 Message-Id: <20200821153807.18613-16-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 15/20] 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 Fri Aug 21 15:38: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: 11729835 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 C11AD138C for ; Fri, 21 Aug 2020 15:38:55 +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 AA3922063A for ; Fri, 21 Aug 2020 15:38:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA3922063A 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 E971C6E827; Fri, 21 Aug 2020 15:38:54 +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 47D9E6E82B; Fri, 21 Aug 2020 15:38:53 +0000 (UTC) IronPort-SDR: oESsTqE+GacE/uaqkc3ccjV0upzIPPIAvg20LuBNmeLE6EoWXL1V1z52l85hqdylZU6nL73Upj bP9Fwp2AJ/Jg== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381928" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381928" 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; 21 Aug 2020 08:38:53 -0700 IronPort-SDR: zrTN9PcdtmMlz8pFhjqJpyCykZkNtsSZgDPXesofE2vGOy9f7QmQC6XncqwNarlYcKJK6pq/J2 R4IMW64V4FgA== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086739" 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; 21 Aug 2020 08:38:51 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:03 +0200 Message-Id: <20200821153807.18613-17-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 16/20] 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 Fri Aug 21 15:38:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729839 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 5E3C1739 for ; Fri, 21 Aug 2020 15:38:59 +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 474032078B for ; Fri, 21 Aug 2020 15:38:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 474032078B 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 7633E6E85F; Fri, 21 Aug 2020 15:38:58 +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 4AE946EADF; Fri, 21 Aug 2020 15:38:55 +0000 (UTC) IronPort-SDR: cZMeKTLBCtwaqw6HwfxECPzTAHkVsiQc80LirLdqgK+sELLEem1NGaAgJhwz/wDYliwqmIbI0W 3ytTcCaHRMhA== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381938" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381938" 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; 21 Aug 2020 08:38:55 -0700 IronPort-SDR: rtS7Ds/kFEjWAFAk64Juiwr4tdGvH0wGgf9hgR71q52jvPkxBwx3Jz6O6yI+VUmxVv9PK2l+w6 x839fOp9uHrg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086750" 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; 21 Aug 2020 08:38:53 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:04 +0200 Message-Id: <20200821153807.18613-18-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 17/20] 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. v2: Skip i915 health check if a GPU hang has been already detected by a previous health check run and not yet remediated with a GPU reset, - take care of stopping a hang detector instance possibly left running by a failed health check attempt. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 97 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 8 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 24beed81a..13e7aa46f 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,80 @@ 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 = false; + +static void local_sig_abort(int sig) +{ + errno = 0; /* inside a signal, last errno reporting is confusing */ + hang_detected = true; +} + +static int local_i915_healthcheck(int i915) +{ + const uint32_t bbe = MI_BATCH_BUFFER_END; + struct drm_i915_gem_exec_object2 obj = { }; + struct drm_i915_gem_execbuffer2 execbuf = { + .buffers_ptr = to_user_pointer(&obj), + .buffer_count = 1, + }; + const struct intel_execution_engine2 *engine; + + /* stop our hang detector possibly still runnign if we failed before */ + igt_stop_hang_detector(); + + /* don't run again before GPU reset if hang has been already detected */ + if (hang_detected) + return -EIO; + + igt_debug("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)); + + 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); + hang_detected = false; + + 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 +285,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 +317,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 +351,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 +360,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 +406,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 Fri Aug 21 15:38: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: 11729837 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 1CD10138C for ; Fri, 21 Aug 2020 15:38:59 +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 05C402078B for ; Fri, 21 Aug 2020 15:38:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05C402078B 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 6732E6E85D; Fri, 21 Aug 2020 15:38:58 +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 5B5FC6EB0A; Fri, 21 Aug 2020 15:38:57 +0000 (UTC) IronPort-SDR: oY1XP8li8Lpm/SZSAon/45mjbyLInXiTK8ue2GPOQMGvBdyvZu6Q5gqea9Jl+PLjWWq2+UpaCm iyQoxZLS+VGQ== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381943" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381943" 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; 21 Aug 2020 08:38:57 -0700 IronPort-SDR: w5N9vc9b4KQ1quFPRwJmZtnqOrXhCBm5qWnfHjei0plNbRl5FccEqzf+ZgfuZs+KNSWEPrkYw9 1d4nRQcSntkg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086766" 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; 21 Aug 2020 08:38:55 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:05 +0200 Message-Id: <20200821153807.18613-19-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 18/20] 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 13e7aa46f..f919fa6de 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -369,8 +369,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); @@ -382,11 +380,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 */ @@ -419,7 +475,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); @@ -431,7 +487,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); @@ -463,6 +519,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 Fri Aug 21 15:38:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729843 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 00CDF15E4 for ; Fri, 21 Aug 2020 15:39:05 +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 DDF582078B for ; Fri, 21 Aug 2020 15:39:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDF582078B 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 171166EADD; Fri, 21 Aug 2020 15:39:04 +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 56AAD6E829; Fri, 21 Aug 2020 15:38:59 +0000 (UTC) IronPort-SDR: xaTUvfe6DgfzfQUtS2jEhAvzqh1sHTevyIpUPLEiwIb3Zd98/RzVON6w42+P/wizWkwG+q8hu/ NSLwPcGtL77w== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381947" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381947" 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; 21 Aug 2020 08:38:59 -0700 IronPort-SDR: 4y76+wbC4s28Fr+gzhy5OMkRZcFuUgmW6qCy6Z55hRY3bFh4+08l7ELBNSdpbqomaXzuZfNbPo La1jtS/SiNqA== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086788" 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; 21 Aug 2020 08:38:57 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:06 +0200 Message-Id: <20200821153807.18613-20-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 19/20] tests/core_hotunplug: Duplicate debug messages in dmesg X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The purpose of debug messages displayed by the test is to make identification of a subtest phase that fails more easy. Since issues exhibited by the test are mostly reported to dmesg, print those debug messages to /dev/kmsg as well. v2: Rebase on upstream. v3: Refresh. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index f919fa6de..ae7fe18ad 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -52,6 +52,12 @@ struct hotunplug { /* Helpers */ +#define local_debug(fmt, msg...) \ +({ \ + igt_debug(fmt, msg); \ + igt_kmsg(KMSG_DEBUG "%s: " fmt, igt_test_name(), msg); \ +}) + /** * Subtests must be able to close examined devices completely. Don't * use drm_open_driver() since in case of an i915 device it opens it @@ -61,7 +67,7 @@ static int local_drm_open_driver(const char *prefix, const char *suffix) { int fd_drm; - igt_debug("%sopening device%s\n", prefix, suffix); + local_debug("%sopening device%s\n", prefix, suffix); fd_drm = __drm_open_driver(DRIVER_ANY); igt_assert_fd(fd_drm); @@ -120,7 +126,7 @@ static void prepare(struct hotunplug *priv) static void driver_unbind(struct hotunplug *priv, const char *prefix, int timeout) { - igt_debug("%sunbinding the driver from the device\n", prefix); + local_debug("%sunbinding the driver from the device\n", prefix); priv->failure = "Driver unbind failure!"; igt_set_timeout(timeout, "Driver unbind timeout!"); @@ -136,7 +142,7 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix, /* Re-bind the driver to the device */ static void driver_bind(struct hotunplug *priv, int timeout) { - igt_debug("rebinding the driver to the device\n"); + local_debug("%s\n", "rebinding the driver to the device"); priv->failure = "Driver re-bind failure!"; igt_set_timeout(timeout, "Driver re-bind timeout!"); @@ -160,7 +166,7 @@ static void device_unplug(struct hotunplug *priv, const char *prefix, O_DIRECTORY); igt_assert_fd(priv->fd.sysfs_dev); - igt_debug("%sunplugging the device\n", prefix); + local_debug("%sunplugging the device\n", prefix); priv->failure = "Device unplug failure!"; igt_set_timeout(timeout, "Device unplug timeout!"); @@ -178,7 +184,7 @@ static void device_unplug(struct hotunplug *priv, const char *prefix, /* Re-discover the device by rescanning its bus */ static void bus_rescan(struct hotunplug *priv, int timeout) { - igt_debug("rediscovering the device\n"); + local_debug("%s\n", "rediscovering the device"); priv->failure = "Bus rescan failure!"; igt_set_timeout(timeout, "Bus rescan timeout!"); @@ -231,7 +237,7 @@ static int local_i915_healthcheck(int i915) if (hang_detected) return -EIO; - igt_debug("running i915 GPU healthcheck\n"); + local_debug("%s\n", "running i915 GPU healthcheck"); if (local_i915_is_wedged(i915)) return -EIO; @@ -262,7 +268,7 @@ static int local_i915_healthcheck(int i915) static int local_i915_recover(int i915) { - igt_debug("forcing i915 GPU reset\n"); + local_debug("%s\n", "forcing i915 GPU reset"); igt_force_gpu_reset(i915); hang_detected = false; @@ -369,7 +375,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) driver_unbind(priv, "hot ", 0); - igt_debug("late closing the unbound device instance\n"); + local_debug("%s\n", "late closing the unbound device instance"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); } @@ -380,7 +386,7 @@ static void hotunplug_lateclose(struct hotunplug *priv) device_unplug(priv, "hot ", 0); - igt_debug("late closing the removed device instance\n"); + local_debug("%s\n", "late closing the removed device instance"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); } @@ -391,7 +397,7 @@ static void hotunbind_rebind(struct hotunplug *priv) driver_unbind(priv, "hot ", 60); - igt_debug("late closing the unbound device instance\n"); + local_debug("%s\n", "late closing the unbound device instance"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); @@ -406,7 +412,7 @@ static void hotunplug_rescan(struct hotunplug *priv) device_unplug(priv, "hot ", 60); - igt_debug("late closing the removed device instance\n"); + local_debug("%s\n", "late closing the removed device instance"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); @@ -423,7 +429,7 @@ static void hotrebind_lateclose(struct hotunplug *priv) driver_bind(priv, 0); - igt_debug("late closing the unbound device instance\n"); + local_debug("%s\n", "late closing the unbound device instance"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); @@ -438,7 +444,7 @@ static void hotreplug_lateclose(struct hotunplug *priv) bus_rescan(priv, 0); - igt_debug("late closing the removed device instance\n"); + local_debug("%s\n", "late closing the removed device instance"); priv->fd.drm = close_device(priv->fd.drm); igt_assert_eq(priv->fd.drm, -1); From patchwork Fri Aug 21 15:38:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729841 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 8667B138C for ; Fri, 21 Aug 2020 15:39:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F3C12078B for ; Fri, 21 Aug 2020 15:39:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F3C12078B 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 CAEBD6E82B; Fri, 21 Aug 2020 15:39:03 +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 4CCD86E9BF; Fri, 21 Aug 2020 15:39:01 +0000 (UTC) IronPort-SDR: uIUyVHHiRkgQGHQf071EIPxSfoDQIjtYBfAygFs+ZTCJ17L8CGRhPC9ocqY0Dpr1D66kmDqE2I N7bkoIRBjRfQ== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381957" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381957" 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; 21 Aug 2020 08:39:01 -0700 IronPort-SDR: DeO9PfS/ka5ygu3ejQCJaXFN8+htlrXj+mnxup0Zfiq303wZKyjNlki5CQ3Ly4mzHQxg1evor8 jbgFIIAt/r/Q== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086802" 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; 21 Aug 2020 08:38:59 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:38:07 +0200 Message-Id: <20200821153807.18613-21-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 20/20] 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