From patchwork Fri Aug 21 15:37:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729811 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BFD7138C for ; Fri, 21 Aug 2020 15:38:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 349AF2063A for ; Fri, 21 Aug 2020 15:38:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 349AF2063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 787F66E211; Fri, 21 Aug 2020 15:38:31 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 14BC76E211; Fri, 21 Aug 2020 15:38:30 +0000 (UTC) IronPort-SDR: b+mM5YUlx7vqBZYzwFpuIFOMDfXjKPQ/SlTtHLP/a6UBdGbrAq+AeeGj3OLg+8zZPdYijXqCDV AKwpgtmidzRg== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381855" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381855" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 08:38:29 -0700 IronPort-SDR: ftkNT0Cwvw1FDw0LvS7/jfPxuM0I7foj7KmCi/KNA9iaKnUekhFOpWpXRk8IhxfZwaUJa70O+O 4P3bGPPjfAIA== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086551" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 08:38:27 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:51 +0200 Message-Id: <20200821153807.18613-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 04/20] tests/core_hotunplug: Consolidate duplicated debug messages X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Some debug messages which designate specific test operations, or their greater parts at least, sound always the same, no matter which subtest they are called from. Emit them, possibly updated with subtest specified modifiers, from inside respective helpers instead of duplicating them in subtest bodies. v2: Rebase only. v3: Refresh and extend over new case (local_drm_open_driver), - allow callers to specify a message suffix as well where applicable. Signed-off-by: Janusz Krzysztofik Reviewed-by: MichaƂ Winiarski # v1 --- tests/core_hotunplug.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index e576a6c6c..5093233d7 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -54,10 +54,12 @@ struct hotunplug { * use drm_open_driver() since in case of an i915 device it opens it * twice and keeps a second file descriptor open for exit handler use. */ -static int local_drm_open_driver(void) +static int local_drm_open_driver(const char *prefix, const char *suffix) { int fd_drm; + igt_debug("%sopening device%s\n", prefix, suffix); + fd_drm = __drm_open_driver(DRIVER_ANY); igt_assert_fd(fd_drm); @@ -85,8 +87,7 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) static void prepare(struct hotunplug *priv, char *buf, int buflen) { - igt_debug("opening device\n"); - priv->fd.drm = local_drm_open_driver(); + priv->fd.drm = local_drm_open_driver("", " for subtest"); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); igt_assert_fd(priv->fd.sysfs_dev); @@ -104,8 +105,11 @@ static void prepare(struct hotunplug *priv, char *buf, int buflen) static const char *failure; /* Unbind the driver from the device */ -static void driver_unbind(int fd_sysfs_drv, const char *dev_bus_addr) +static void driver_unbind(int fd_sysfs_drv, const char *dev_bus_addr, + const char *prefix) { + igt_debug("%sunbinding the driver from the device\n", prefix); + failure = "Driver unbind timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_drv, "unbind", dev_bus_addr); @@ -118,6 +122,8 @@ static void driver_unbind(int fd_sysfs_drv, const char *dev_bus_addr) /* Re-bind the driver to the device */ static void driver_bind(int fd_sysfs_drv, const char *dev_bus_addr) { + igt_debug("rebinding the driver to the device\n"); + failure = "Driver re-bind timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_drv, "bind", dev_bus_addr); @@ -128,8 +134,10 @@ static void driver_bind(int fd_sysfs_drv, const char *dev_bus_addr) } /* Remove (virtually unplug) the device from its bus */ -static void device_unplug(int fd_sysfs_dev) +static void device_unplug(int fd_sysfs_dev, const char *prefix) { + igt_debug("%sunplugging the device\n", prefix); + failure = "Device unplug timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_dev, "device/remove", "1"); @@ -142,6 +150,8 @@ static void device_unplug(int fd_sysfs_dev) /* Re-discover the device by rescanning its bus */ static void bus_rescan(int fd_sysfs_bus) { + igt_debug("rediscovering the device\n"); + failure = "Bus rescan timeout!"; igt_set_timeout(60, failure); igt_sysfs_set(fd_sysfs_bus, "rescan", "1"); @@ -158,9 +168,8 @@ static void healthcheck(void) /* device name may have changed, rebuild IGT device list */ igt_devices_scan(true); - igt_debug("reopening the device\n"); failure = "Device reopen failure!"; - fd_drm = local_drm_open_driver(); + fd_drm = local_drm_open_driver("re", " for healthcheck"); failure = NULL; if (is_i915_device(fd_drm)) { @@ -199,10 +208,8 @@ static void unbind_rebind(void) igt_debug("closing the device\n"); close(priv.fd.drm); - igt_debug("unbinding the driver from the device\n"); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, ""); - igt_debug("rebinding the driver to the device\n"); driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); healthcheck(); @@ -217,10 +224,8 @@ static void unplug_rescan(void) igt_debug("closing the device\n"); close(priv.fd.drm); - igt_debug("unplugging the device\n"); - device_unplug(priv.fd.sysfs_dev); + device_unplug(priv.fd.sysfs_dev, ""); - igt_debug("recovering the device\n"); bus_rescan(priv.fd.sysfs_bus); healthcheck(); @@ -233,10 +238,8 @@ static void hotunbind_lateclose(void) prepare(&priv, buf, sizeof(buf)); - igt_debug("hot unbinding the driver from the device\n"); - driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr); + driver_unbind(priv.fd.sysfs_drv, priv.dev_bus_addr, "hot "); - igt_debug("rebinding the driver to the device\n"); driver_bind(priv.fd.sysfs_drv, priv.dev_bus_addr); igt_debug("late closing the unbound device instance\n"); @@ -251,10 +254,8 @@ static void hotunplug_lateclose(void) prepare(&priv, NULL, 0); - igt_debug("hot unplugging the device\n"); - device_unplug(priv.fd.sysfs_dev); + device_unplug(priv.fd.sysfs_dev, "hot "); - igt_debug("recovering the device\n"); bus_rescan(priv.fd.sysfs_bus); igt_debug("late closing the removed device instance\n");