From patchwork Fri Aug 7 09:19:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11705259 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 CCD1D1392 for ; Fri, 7 Aug 2020 09:21: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 B6CB920855 for ; Fri, 7 Aug 2020 09:21:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6CB920855 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 228F96E995; Fri, 7 Aug 2020 09:21:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DCCF6E993; Fri, 7 Aug 2020 09:21:50 +0000 (UTC) IronPort-SDR: jFKwzgAD8gIswx+roVPHB647mJHFYMHdt7sp/854JsZgFYSxcPXYG73bhKAgezKt/fRkdiOY6b 8muT4yxecxLQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106837" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106837" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:41 -0700 IronPort-SDR: 3SD5FxXhwU9thSVzNNl1lEMyMz0qexejE0UWzNu4BjfAWpB5likXGLmevamUjRJePNw1Xr1VSY Xw7WXI01Kk2A== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492064" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:40 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:47 +0200 Message-Id: <20200807092002.32350-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 01/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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. v2: Rebase on current upstream master. 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 7 09:19: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: 11705261 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 D6BEC1392 for ; Fri, 7 Aug 2020 09:21:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C159520855 for ; Fri, 7 Aug 2020 09:21:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C159520855 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 7356D6E993; Fri, 7 Aug 2020 09:21:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id A7D796E993; Fri, 7 Aug 2020 09:21:50 +0000 (UTC) IronPort-SDR: L99x32KjNr2sMri5hLWDJzT9A+A7jI17N2X95oaJzfysE202rXKKgj/Ev/WPRl0LMzuKaHJe13 LPKH9Ot5bG9A== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106842" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106842" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:43 -0700 IronPort-SDR: q6bHAa/bVVhSmAwX33LdWERJa8kFy1/tOky/TMRRtEpDXG9xxAqG5Jp34A2rTSi36Q/ZUCIPCD qK6yrsrSt/9g== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492074" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:41 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:48 +0200 Message-Id: <20200807092002.32350-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 02/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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. v2: Rebase on current upstream master. 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 7 09:19: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: 11705269 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 96C4A13B6 for ; Fri, 7 Aug 2020 09:21: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 8140320855 for ; Fri, 7 Aug 2020 09:21:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8140320855 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 9B28A6E99D; Fri, 7 Aug 2020 09:21:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6BCE6E994; Fri, 7 Aug 2020 09:21:50 +0000 (UTC) IronPort-SDR: M0NZPx0WsyO0gbY7EgWg2J1XIHkwrJAvKeyR5ETa4mzPF6Sz5VuClmuxH42dyxDoUZzkSJwQDt NepX3AT2rusw== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106852" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106852" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:45 -0700 IronPort-SDR: kSZRtnu7DslXcmmhO7uawlr4LYPtuT4IkPgbkP206JaY6QkicpWVVfktUTRfLBuWQ/z0jLVASn L1U5GuZqMwmw== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492087" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:43 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:49 +0200 Message-Id: <20200807092002.32350-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 03/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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 on current upstream master. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index a4071f51e..557f9e3fa 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -90,8 +90,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); @@ -104,6 +107,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); @@ -114,8 +119,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"); @@ -128,6 +135,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("recovering the device\n"); + failure = "Bus rescan timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_bus, "rescan", "1"); @@ -184,10 +193,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(); @@ -202,10 +209,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(); @@ -218,10 +223,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"); @@ -236,10 +239,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 7 09:19:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11705265 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 56E481392 for ; Fri, 7 Aug 2020 09:21:57 +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 416DB20855 for ; Fri, 7 Aug 2020 09:21:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 416DB20855 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 548E46E99B; Fri, 7 Aug 2020 09:21:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id E80786E993; Fri, 7 Aug 2020 09:21:50 +0000 (UTC) IronPort-SDR: 6i+Qi8OOJUq9OUg1BGu6Ft3uvTlcmluJEP8jwrK6Gxb/YAKdMdQ1Y2jpFQDf+UfjtQ7nux2TAa cvnz4oTCpu5A== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106859" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106859" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:47 -0700 IronPort-SDR: CsocQ8NlYZRToEOghWEQVxhJ/M9DdKJNIP8S74rBlgHBmjt3gWvrblUJE4EN3mS2o7JMs0VAE3 ulWAePMy+c1w== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492096" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:45 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:50 +0200 Message-Id: <20200807092002.32350-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 04/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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. v2: Rebase on current upstream master. 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 557f9e3fa..6ceb325ad 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -178,7 +178,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 7 09:19: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: 11705267 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 92C8613B6 for ; Fri, 7 Aug 2020 09:21:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D8A820855 for ; Fri, 7 Aug 2020 09:21:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D8A820855 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 94CA06E99F; Fri, 7 Aug 2020 09:21:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 092CD6E994; Fri, 7 Aug 2020 09:21:51 +0000 (UTC) IronPort-SDR: KsgYjusgdPRU4XmjsHjQT1QR+QnE+wv9mMP88q4/iBOLlh/dUvQvhu6RDcbQxZcKMlTKRINRqu goX5z4RRKDJw== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106872" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106872" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:49 -0700 IronPort-SDR: aBCriUWNsMlkRq7VwKq/4XIo5Z/6P5g14qGQt4JJiR0I8sI7FbhbkFIq88tmn0nfa9qGXF0vH/ 9bc3vuGepEDQ== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492103" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:47 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:51 +0200 Message-Id: <20200807092002.32350-6-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 05/16] tests/core_hotunplug: Fix missing newline X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" A trailing newline is missing from one of fatal error messages, fix it. v2: Rebase on current upstream master. 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 6ceb325ad..cac88c2f3 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -155,7 +155,7 @@ static void healthcheck(void) igt_debug("reopening the device\n"); fd_drm = __drm_open_driver(DRIVER_ANY); - igt_abort_on_f(fd_drm < 0, "Device reopen failure"); + igt_abort_on_f(fd_drm < 0, "Device reopen failure\n"); if (is_i915_device(fd_drm)) { failure = "GEM failure"; From patchwork Fri Aug 7 09:19: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: 11705271 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 CAF2E1392 for ; Fri, 7 Aug 2020 09:22:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B42B920855 for ; Fri, 7 Aug 2020 09:22:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B42B920855 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 00E036E9A1; Fri, 7 Aug 2020 09:21:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 001686E998; Fri, 7 Aug 2020 09:21:51 +0000 (UTC) IronPort-SDR: eX10jH9rM3F7AZxGi0NDerIbHGpei8VcZO9orbQ9J7EKMGpScuIw8PvK3y3VfP+pZTur5lc7bC VQj2SRrlQREQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106880" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106880" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:51 -0700 IronPort-SDR: PH+70IW9NlKGQhjcmunH/h1eeLaywxqhSu8Hq8lbyuBwR+zhohy2IHi2rplSulKzWNH8PjwbPc 4Rqx4k0AQeow== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492113" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:49 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:52 +0200 Message-Id: <20200807092002.32350-7-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 06/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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. v2: Rebase on current upstream master. 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 cac88c2f3..0e61da2d0 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -183,68 +183,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(); } @@ -253,6 +247,8 @@ static void hotunplug_lateclose(void) igt_main { + struct hotunplug priv; + igt_fixture { int fd_drm; @@ -275,28 +271,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 7 09:19: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: 11705273 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 B486013B6 for ; Fri, 7 Aug 2020 09:22:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F1E320855 for ; Fri, 7 Aug 2020 09:22:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F1E320855 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 C98BF6E9A4; Fri, 7 Aug 2020 09:21:56 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 968A86E9A0; Fri, 7 Aug 2020 09:21:55 +0000 (UTC) IronPort-SDR: BopkCzHlBbb/3o6GnoOOtO4vnAKdU5bRo/3+32o1EqeF3qLz8kF8yOivrWMJvU2KdQNMKfXtE8 n3G5ZNng3jOg== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106884" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106884" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:53 -0700 IronPort-SDR: nUMo0zlMgXfkco5Spol3pqyPoxxjyoxF+6XFAzHGzHmQjkNdF2lR0lunYFoRO5z5n2cJ0gJzt3 tfx2gJuSY8SQ== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492117" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:51 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:53 +0200 Message-Id: <20200807092002.32350-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 07/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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 on current upstream master. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 92 +++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 0e61da2d0..6070b7d95 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 */ @@ -87,66 +88,63 @@ 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("recovering 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; @@ -158,9 +156,9 @@ static void healthcheck(void) igt_abort_on_f(fd_drm < 0, "Device reopen failure\n"); 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); @@ -192,11 +190,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) @@ -206,11 +204,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) @@ -219,35 +217,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; @@ -274,26 +272,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 7 09:19: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: 11705277 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 B2C591392 for ; Fri, 7 Aug 2020 09:22:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CF3120855 for ; Fri, 7 Aug 2020 09:22:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CF3120855 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 BF4946E9A9; Fri, 7 Aug 2020 09:21:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC5D06E9A2; Fri, 7 Aug 2020 09:21:55 +0000 (UTC) IronPort-SDR: 1Z+EwaVv5YnMTodySGPjwALgBepasyYhQwxzQ+cmf5I/ckx3Fov+LsoFNVGQOeUWJsa2cgQaKC S0Kde5Jc2tIw== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106886" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106886" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:55 -0700 IronPort-SDR: B5u7J7syRZxWHyPasrqBS/7BOa6MKWc9m2ELBDVy0nH2UgIlFsnj24xy8dV9UvwYbT3eqFumSX mRoUmrIKHdRg== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492122" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:53 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:54 +0200 Message-Id: <20200807092002.32350-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 08/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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 and also skip subsequent subtests. However, once a driver unbind or device unplug operation has been attempted by a subtest, we can't just fail without checking 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, 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, - rebase on current upstream master. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 61 ++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 6070b7d95..ffba32568 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -43,13 +43,22 @@ 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; }; /* Helpers */ +static int local_close(int fd) +{ + errno = 0; + if (close(fd)) /* close failure - return -errno (never -1) */ + return -errno; + + return -1; /* success - return 'closed' */ +} + static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) { int len; @@ -66,7 +75,9 @@ 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 = local_close(priv->fd.sysfs_dev); + igt_assert_f(priv->fd.sysfs_dev == -1, + "Device sysfs node close failed\n"); } static void prepare(struct hotunplug *priv, char *buf, int buflen) @@ -127,7 +138,9 @@ 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 = local_close(priv->fd.sysfs_dev); + igt_warn_on_f(priv->fd.sysfs_dev != -1, + "Device sysfs node close failed\n"); } /* Re-discover the device by rescanning its bus */ @@ -146,6 +159,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 */ @@ -161,7 +175,19 @@ static void healthcheck(struct hotunplug *priv) priv->failure = NULL; } - close(fd_drm); + fd_drm = local_close(fd_drm); + if (priv->fd.drm == -1) + priv->fd.drm = fd_drm; + igt_assert_f(fd_drm == -1, "Device close failed\n"); +} + +static void post_healthcheck(struct hotunplug *priv) +{ + igt_abort_on_f(priv->failure, "%s\n", priv->failure); + + igt_require_f(priv->fd.drm == -1, "Device not closed properly\n"); + igt_require_f(priv->fd.sysfs_dev == -1, + "Device sysfs node not closed properly\n"); } static void set_filter_from_device(int fd) @@ -188,7 +214,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 = local_close(priv->fd.drm); + igt_assert_f(priv->fd.drm == -1, "Device close failed\n"); driver_unbind(priv, ""); @@ -202,7 +229,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 = local_close(priv->fd.drm); + igt_assert_f(priv->fd.drm == -1, "Device close failed\n"); device_unplug(priv, ""); @@ -222,7 +250,8 @@ 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 = local_close(priv->fd.drm); + igt_warn_on_f(priv->fd.drm != -1, "Device close failed\n"); healthcheck(priv); } @@ -236,7 +265,8 @@ 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 = local_close(priv->fd.drm); + igt_warn_on_f(priv->fd.drm != -1, "Device close failed\n"); healthcheck(priv); } @@ -245,7 +275,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; @@ -264,7 +297,7 @@ igt_main /* Make sure subtests always reopen the same device */ set_filter_from_device(fd_drm); - close(fd_drm); + igt_fail_on_f(close(fd_drm), "Device close failed\n"); } igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); @@ -272,26 +305,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 7 09:19: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: 11705275 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 E86DE13B6 for ; Fri, 7 Aug 2020 09:22:02 +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 D327420855 for ; Fri, 7 Aug 2020 09:22:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D327420855 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 475446E9A8; Fri, 7 Aug 2020 09:21:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC30E6E9A6; Fri, 7 Aug 2020 09:21:57 +0000 (UTC) IronPort-SDR: hpkL5KXHjDkZ/8YbLKvdUgH2tpjeYpkXruaFoVA9RndgNFDgN6YUStVvv6YbV7wJjaJJOD8+Mz 0PIhQ+B+ahDQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106895" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106895" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:57 -0700 IronPort-SDR: H1PQUzWjxaGQQuYT42vymCiMcA8EfOYIk+OkpUlQlSxK7qykav1eO5IUVIyW2UyO0qEZnUsk3L vTHypIsTgMuw== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492128" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:55 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:55 +0200 Message-Id: <20200807092002.32350-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 09/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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 on current upstream master. Suggested-by: Michał Winiarski Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 91 ++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 56 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index ffba32568..71ac4d169 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -59,46 +59,33 @@ static int local_close(int fd) return -1; /* success - return 'closed' */ } -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); + priv->dev_bus_addr = strrchr(filter, '/'); + igt_assert(priv->dev_bus_addr++); + + sysfs_path = strchr(filter, ':'); + igt_assert(sysfs_path++); + + priv->fd.sysfs_dev = open(sysfs_path, O_DIRECTORY); + igt_assert_fd(priv->fd.sysfs_dev); + + priv->fd.sysfs_drv = openat(priv->fd.sysfs_dev, "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, '/'); - igt_assert(priv->dev_bus_addr++); + priv->fd.sysfs_bus = openat(priv->fd.sysfs_dev, "subsystem/devices", + O_DIRECTORY); + igt_assert_fd(priv->fd.sysfs_bus); - /* sysfs_dev no longer needed */ priv->fd.sysfs_dev = local_close(priv->fd.sysfs_dev); igt_assert_f(priv->fd.sysfs_dev == -1, "Device sysfs node close failed\n"); } -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.sysfs_dev = igt_sysfs_open(priv->fd.drm); - 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); - } -} - /* Unbind the driver from the device */ static void driver_unbind(struct hotunplug *priv, const char *prefix) { @@ -109,8 +96,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 */ @@ -123,18 +108,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; @@ -150,11 +137,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) @@ -209,14 +194,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 = local_close(priv->fd.drm); - igt_assert_f(priv->fd.drm == -1, "Device close failed\n"); - driver_unbind(priv, ""); driver_bind(priv); @@ -226,12 +203,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 = local_close(priv->fd.drm); - igt_assert_f(priv->fd.drm == -1, "Device close failed\n"); - device_unplug(priv, ""); bus_rescan(priv); @@ -241,9 +212,9 @@ static void unplug_rescan(struct hotunplug *priv) static void hotunbind_lateclose(struct hotunplug *priv) { - char buf[PATH_MAX]; - - prepare(priv, buf, sizeof(buf)); + igt_debug("opening device\n"); + priv->fd.drm = __drm_open_driver(DRIVER_ANY); + igt_assert_fd(priv->fd.drm); driver_unbind(priv, "hot "); @@ -258,7 +229,9 @@ static void hotunbind_lateclose(struct hotunplug *priv) static void hotunplug_lateclose(struct hotunplug *priv) { - prepare(priv, NULL, 0); + igt_debug("opening device\n"); + priv->fd.drm = __drm_open_driver(DRIVER_ANY); + igt_assert_fd(priv->fd.drm); device_unplug(priv, "hot "); @@ -298,6 +271,8 @@ igt_main set_filter_from_device(fd_drm); igt_fail_on_f(close(fd_drm), "Device close failed\n"); + + prepare(&priv); } igt_describe("Check if the driver can be cleanly unbound from a device believed to be closed"); @@ -325,6 +300,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 7 09:19: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: 11705279 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 A2B5813B6 for ; Fri, 7 Aug 2020 09:22: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 8C76720855 for ; Fri, 7 Aug 2020 09:22:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C76720855 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 269D46E997; Fri, 7 Aug 2020 09:22:02 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 958536E994; Fri, 7 Aug 2020 09:21:59 +0000 (UTC) IronPort-SDR: KK+kfQjKg/twdnvJx8Qf+WyOGK+92DFv02rtpBmbH8b5y2wJYbAzaGZBN8huSx4+c6Ffu0tW7b eneqXN8Vq+BA== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106906" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106906" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:59 -0700 IronPort-SDR: JbMqfUXVlT4RGkF+z80xEsLTO+rSVOVMiWjmne0tUUIqOg9riOCxuEy/+hxTsH5ViHgjszofZP uxKl4zLNgOwg== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492133" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:57 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:56 +0200 Message-Id: <20200807092002.32350-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 10/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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 on current upstream master. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 71ac4d169..b9982b330 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -82,8 +82,8 @@ static void prepare(struct hotunplug *priv) igt_assert_fd(priv->fd.sysfs_bus); priv->fd.sysfs_dev = local_close(priv->fd.sysfs_dev); - igt_assert_f(priv->fd.sysfs_dev == -1, - "Device sysfs node close failed\n"); + igt_warn_on_f(priv->fd.sysfs_dev != -1, + "Device sysfs node close failed\n"); } /* Unbind the driver from the device */ @@ -113,6 +113,9 @@ 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_f(priv->fd.sysfs_dev == -1, + "Device sysfs node not closed properly\n"); + priv->fd.sysfs_dev = openat(priv->fd.sysfs_bus, priv->dev_bus_addr, O_DIRECTORY); igt_assert_fd(priv->fd.sysfs_dev); @@ -171,8 +174,6 @@ static void post_healthcheck(struct hotunplug *priv) igt_abort_on_f(priv->failure, "%s\n", priv->failure); igt_require_f(priv->fd.drm == -1, "Device not closed properly\n"); - igt_require_f(priv->fd.sysfs_dev == -1, - "Device sysfs node not closed properly\n"); } static void set_filter_from_device(int fd) From patchwork Fri Aug 7 09:19: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: 11705281 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 5D47013B6 for ; Fri, 7 Aug 2020 09:22: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 4807820855 for ; Fri, 7 Aug 2020 09:22:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4807820855 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 057006E994; Fri, 7 Aug 2020 09:22:03 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id DDA2B6E994; Fri, 7 Aug 2020 09:22:01 +0000 (UTC) IronPort-SDR: mTQo26ML3moA9dHa2c2BZd149xgapvLy2ssHp30sADRc2hwNkotxdTP6B6ZYJY3hG9jRaRoLNf nC9onYxLrnbQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106917" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106917" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:01 -0700 IronPort-SDR: 0Bddb+sc7oRV488dQ90VUKiC2mb1rqIJwNytVmDhyse/dC+dVDF8+7WgTyue8/Xie7jREu+eTW i4Qb8LWz5+wA== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492146" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:21:59 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:57 +0200 Message-Id: <20200807092002.32350-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 11/16] tests/core_hotunplug: Follow failed subtests with health checks X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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 when a subtest enters a chunk of critical steps which must be followed by a successful health check in order to avoid aborting the test execution. Then, move health checks from inside each subtest body to its individual follow-up igt_fixture section from where device file descriptors potentially left open are closed and the health check is run if theigt_subtest section has been exited with the marker set. Also, precede health check operations with a driver rebind or bus rescan attempt as needed. 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. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski # v1 --- tests/core_hotunplug.c | 108 +++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index b9982b330..313c44784 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -52,6 +52,9 @@ struct hotunplug { static int local_close(int fd) { + if (fd < 0) /* not open - return current status */ + return fd; + errno = 0; if (close(fd)) /* close failure - return -errno (never -1) */ return -errno; @@ -91,11 +94,9 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix) { igt_debug("%sunbinding the driver from the device\n", prefix); - 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 */ @@ -103,11 +104,9 @@ static void driver_bind(struct hotunplug *priv) { igt_debug("rebinding the driver to the device\n"); - 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 */ @@ -122,11 +121,9 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) igt_debug("%sunplugging the device\n", prefix); - 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 = local_close(priv->fd.sysfs_dev); igt_warn_on_f(priv->fd.sysfs_dev != -1, @@ -138,11 +135,15 @@ static void bus_rescan(struct hotunplug *priv) { igt_debug("recovering the device\n"); - 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 = local_close(priv->fd.drm); + priv->fd.sysfs_dev = local_close(priv->fd.sysfs_dev); } static void healthcheck(struct hotunplug *priv) @@ -150,6 +151,18 @@ static void healthcheck(struct hotunplug *priv) /* preserve error code potentially stored before in priv->fd.drm */ int fd_drm; + if (faccessat(priv->fd.sysfs_bus, priv->dev_bus_addr, F_OK, 0)) { + priv->failure = "Bus rescan failed!"; + bus_rescan(priv); + priv->failure = NULL; + } + + if (faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr, F_OK, 0)) { + priv->failure = "Driver re-bind failed!"; + driver_bind(priv); + priv->failure = NULL; + } + /* device name may have changed, rebuild IGT device list */ igt_devices_scan(true); @@ -169,6 +182,17 @@ static void healthcheck(struct hotunplug *priv) igt_assert_f(fd_drm == -1, "Device close failed\n"); } +static void recover(struct hotunplug *priv) +{ + cleanup(priv); + + if (!priv->failure) + return; + priv->failure = NULL; + + healthcheck(priv); +} + static void post_healthcheck(struct hotunplug *priv) { igt_abort_on_f(priv->failure, "%s\n", priv->failure); @@ -195,20 +219,20 @@ static void set_filter_from_device(int fd) static void unbind_rebind(struct hotunplug *priv) { + priv->failure = "need healthcheck"; + driver_unbind(priv, ""); driver_bind(priv); - - healthcheck(priv); } static void unplug_rescan(struct hotunplug *priv) { + priv->failure = "need healthcheck"; + device_unplug(priv, ""); bus_rescan(priv); - - healthcheck(priv); } static void hotunbind_lateclose(struct hotunplug *priv) @@ -217,6 +241,8 @@ static void hotunbind_lateclose(struct hotunplug *priv) priv->fd.drm = __drm_open_driver(DRIVER_ANY); igt_assert_fd(priv->fd.drm); + priv->failure = "need healthcheck"; + driver_unbind(priv, "hot "); driver_bind(priv); @@ -224,8 +250,6 @@ static void hotunbind_lateclose(struct hotunplug *priv) igt_debug("late closing the unbound device instance\n"); priv->fd.drm = local_close(priv->fd.drm); igt_warn_on_f(priv->fd.drm != -1, "Device close failed\n"); - - healthcheck(priv); } static void hotunplug_lateclose(struct hotunplug *priv) @@ -234,6 +258,8 @@ static void hotunplug_lateclose(struct hotunplug *priv) priv->fd.drm = __drm_open_driver(DRIVER_ANY); igt_assert_fd(priv->fd.drm); + priv->failure = "need healthcheck"; + device_unplug(priv, "hot "); bus_rescan(priv); @@ -241,8 +267,6 @@ static void hotunplug_lateclose(struct hotunplug *priv) igt_debug("late closing the removed device instance\n"); priv->fd.drm = local_close(priv->fd.drm); igt_warn_on_f(priv->fd.drm != -1, "Device close failed\n"); - - healthcheck(priv); } /* Main */ @@ -276,30 +300,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 7 09:19: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: 11705283 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 7B4FB1392 for ; Fri, 7 Aug 2020 09:22:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65D332177B for ; Fri, 7 Aug 2020 09:22:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65D332177B 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 806586E9A0; Fri, 7 Aug 2020 09:22:05 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 71B2C6E9A0; Fri, 7 Aug 2020 09:22:03 +0000 (UTC) IronPort-SDR: nGM5EgguUjLyKBa10x6mNqJZwa37bkZ4DpULginHVqakiCT7Jq0m8bt/EHboMMKGjhbahVdEz/ SBZLR+MNqrzg== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106931" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106931" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:03 -0700 IronPort-SDR: T9C992AVEukgJJe1rnsSDonUxz67XWSUBtvsljj5Z9DA2IexBFn9rUXCfuA3nwj0DUq5WMs7TQ tYpagpI7k8eQ== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492156" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:01 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:58 +0200 Message-Id: <20200807092002.32350-13-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 12/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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 emitting warnings. v2: Rebase on current upstream master. Signed-off-by: Janusz Krzysztofik Reviewed-by: Michał Winiarski --- tests/core_hotunplug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 313c44784..a4902eba2 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -126,8 +126,8 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) igt_reset_timeout(); priv->fd.sysfs_dev = local_close(priv->fd.sysfs_dev); - igt_warn_on_f(priv->fd.sysfs_dev != -1, - "Device sysfs node close failed\n"); + igt_assert_f(priv->fd.sysfs_dev == -1, + "Device sysfs node close failed\n"); } /* Re-discover the device by rescanning its bus */ @@ -249,7 +249,7 @@ static void hotunbind_lateclose(struct hotunplug *priv) igt_debug("late closing the unbound device instance\n"); priv->fd.drm = local_close(priv->fd.drm); - igt_warn_on_f(priv->fd.drm != -1, "Device close failed\n"); + igt_assert_f(priv->fd.drm == -1, "Device close failed\n"); } static void hotunplug_lateclose(struct hotunplug *priv) @@ -266,7 +266,7 @@ static void hotunplug_lateclose(struct hotunplug *priv) igt_debug("late closing the removed device instance\n"); priv->fd.drm = local_close(priv->fd.drm); - igt_warn_on_f(priv->fd.drm != -1, "Device close failed\n"); + igt_assert_f(priv->fd.drm == -1, "Device close failed\n"); } /* Main */ From patchwork Fri Aug 7 09:19: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: 11705285 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 DA0E61392 for ; Fri, 7 Aug 2020 09:22:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C51632177B for ; Fri, 7 Aug 2020 09:22:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C51632177B 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 359586E990; Fri, 7 Aug 2020 09:22:08 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id A3FE56E9A2; Fri, 7 Aug 2020 09:22:05 +0000 (UTC) IronPort-SDR: R47qZmtaOENKpIKAdSdxpmicamiF7Z8h2Np4PHrMYYwxhSM2HHNyNNvNDRkoTWWNb3DmfbXr/N E9xSpbh5aXjQ== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106941" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106941" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:05 -0700 IronPort-SDR: 4Gv9oreMlteAmQUlhXWTDutsHQ9nJ0V11IMkAntuvxGLogyXjd1yJ8PLDBl7fn8NS/vhDZNE9k ntsgVWWitM0Q== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492173" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:03 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:19:59 +0200 Message-Id: <20200807092002.32350-14-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 13/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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, - rebase on current upstream master. 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 a4902eba2..48affce9b 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -95,7 +95,9 @@ static void driver_unbind(struct hotunplug *priv, const char *prefix) igt_debug("%sunbinding the driver from the device\n", prefix); igt_set_timeout(60, "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(); } @@ -105,7 +107,9 @@ static void driver_bind(struct hotunplug *priv) igt_debug("rebinding the driver to the device\n"); igt_set_timeout(60, "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(); } @@ -122,7 +126,8 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) igt_debug("%sunplugging the device\n", prefix); igt_set_timeout(60, "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 = local_close(priv->fd.sysfs_dev); @@ -136,7 +141,8 @@ static void bus_rescan(struct hotunplug *priv) igt_debug("recovering the device\n"); igt_set_timeout(60, "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 7 09:20:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11705287 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 3952014DD for ; Fri, 7 Aug 2020 09:22:09 +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 241A52177B for ; Fri, 7 Aug 2020 09:22:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 241A52177B 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 202726E98F; Fri, 7 Aug 2020 09:22:08 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 614B16E990; Fri, 7 Aug 2020 09:22:07 +0000 (UTC) IronPort-SDR: s5RgdEHG0Jfq7pzDGx8AweYPw71CeudLO+AmDHSz+cIv5QImIQdUmwnxXd/O0XKU+4FdcwnAbR CGqItRSVflvw== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106950" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106950" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:06 -0700 IronPort-SDR: nlFdy6dj93Wq2We3gsp/tYsgRc9EUkgU+0koAL9TePmdTYrB0C3Al3e7g23bH0Ouca6XLLQVPO fXGsoUOENTNQ== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492189" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:05 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:20:00 +0200 Message-Id: <20200807092002.32350-15-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 14/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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. v2: Rebase on current upstream master. 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 48affce9b..e8d04f8a7 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -99,6 +99,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 */ @@ -111,6 +114,10 @@ static void driver_bind(struct hotunplug *priv) 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 */ @@ -133,6 +140,9 @@ static void device_unplug(struct hotunplug *priv, const char *prefix) priv->fd.sysfs_dev = local_close(priv->fd.sysfs_dev); igt_assert_f(priv->fd.sysfs_dev == -1, "Device sysfs node close failed\n"); + + 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 */ @@ -144,6 +154,10 @@ static void bus_rescan(struct hotunplug *priv) 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 7 09:20: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: 11705289 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 CC72C1392 for ; Fri, 7 Aug 2020 09:22:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B6EF42177B for ; Fri, 7 Aug 2020 09:22:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6EF42177B 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 1F5F16E9A3; Fri, 7 Aug 2020 09:22:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 44D836E99A; Fri, 7 Aug 2020 09:22:09 +0000 (UTC) IronPort-SDR: kGoAeNKiDfJXoFAfCGWDQp2YOpKX5otp7X1AuZQdYD4D9Ddc4zoybGvpes+43rcOzyIoRaowzM DK5KKHIk1kmg== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106961" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106961" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:08 -0700 IronPort-SDR: j2uMm60s8w7oWtoTl1wAmGg3cX+ekNOmj4ae1IXcY6uyU2mjVazQjkWadAq57m9Yg9MFGMZiHp B/9TLCvbw8rg== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492197" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:07 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:20:01 +0200 Message-Id: <20200807092002.32350-16-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v2 15/16] 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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. v2: Rebase on current upstream master. 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 e8d04f8a7..759cb8079 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -228,7 +228,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(); @@ -368,7 +368,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 7 09:20:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11705291 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 6022C1392 for ; Fri, 7 Aug 2020 09:22:13 +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 4B2C22177B for ; Fri, 7 Aug 2020 09:22:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B2C22177B 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 7F4526E998; Fri, 7 Aug 2020 09:22:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 387F76E9A7; Fri, 7 Aug 2020 09:22:11 +0000 (UTC) IronPort-SDR: 9bT92Bcw3d7Mz82w1i9dUf+TVV5owNPvj/A7Rt4GAOwB1MUEBXnxQ3OsQTDFMePwSgssR33Afh lYNzw0mLTr7A== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="171106969" X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="171106969" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:10 -0700 IronPort-SDR: XqRHvMW5XwVQcJ5m8Hl/lzFZmAzTsmnCa7CkCFOVUIeffXUfp3K3GudHB0I0tJoAEjc/oxK4BI BdI86Hpqr8og== X-IronPort-AV: E=Sophos;i="5.75,445,1589266800"; d="scan'208";a="333492203" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2020 02:22:09 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 7 Aug 2020 11:20:02 +0200 Message-Id: <20200807092002.32350-17-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> References: <20200807092002.32350-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 16/16] tests/core_hotunplug: Un-blocklist *unbind* 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: intel-gfx@lists.freedesktop.org, =?utf-8?q?Micha=C5=82_Winiarski?= 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