From patchwork Fri Aug 28 07:59:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11742309 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 5CCA414E5 for ; Fri, 28 Aug 2020 07:59:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4467F20C56 for ; Fri, 28 Aug 2020 07:59:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4467F20C56 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 C9C816EB7F; Fri, 28 Aug 2020 07:59:53 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4622B6EB7F; Fri, 28 Aug 2020 07:59:52 +0000 (UTC) IronPort-SDR: UHpBoWF1hUJPKDQafOQhDGDRKh/Uus0n3LSUK4Ql9K5HVE3Yuc0I8risWxiW0IIlWxkCkdvX2L DQEnT58CFIbQ== X-IronPort-AV: E=McAfee;i="6000,8403,9726"; a="136690208" X-IronPort-AV: E=Sophos;i="5.76,362,1592895600"; d="scan'208";a="136690208" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 00:59:52 -0700 IronPort-SDR: ZSeG8YHpQjLxtstj1i4i7dGZlkTow8ZrFyr7XgyNdmjpad/L06fFoqSwgISUeW2/eo8IrU8Sk/ Gumf3FXlkAGg== X-IronPort-AV: E=Sophos;i="5.76,362,1592895600"; d="scan'208";a="444755840" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 00:59:48 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 28 Aug 2020 09:59:10 +0200 Message-Id: <20200828075927.17061-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200828075927.17061-1-janusz.krzysztofik@linux.intel.com> References: <20200828075927.17061-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v5 04/21] 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");