From patchwork Fri Aug 21 15:37:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11729809 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22290739 for ; Fri, 21 Aug 2020 15:38:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AB582063A for ; Fri, 21 Aug 2020 15:38:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AB582063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD27A6E221; Fri, 21 Aug 2020 15:38:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id C23326E211; Fri, 21 Aug 2020 15:38:27 +0000 (UTC) IronPort-SDR: yLuK2XYmeKW0OJwTno8mAFbBYTMvRlZZnml3YmELdrnUqYkk5JFxJt64+XhsS5N22JrgFkFcvW 1D+UNm1mlp4Q== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="240381848" X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="240381848" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 08:38:27 -0700 IronPort-SDR: bKV77uRQI3aYY3VjG0XQZK4Dm/ddpoShE2YEoB3VQhuBUzx9a+B6F7Wdg6zDHiB4+EdZDG0Ex0 Jw5aJs88K2pg== X-IronPort-AV: E=Sophos;i="5.76,337,1592895600"; d="scan'208";a="473086534" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 08:38:25 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Fri, 21 Aug 2020 17:37:50 +0200 Message-Id: <20200821153807.18613-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> References: <20200821153807.18613-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v4 03/20] tests/core_hotunplug: Clean up device open error handling X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We don't use drm_driver_open() since in case of an i915 device it keeps an extra file descriptor of the exercised device open for exit handler use, while we would like to be able to close the device completely before running certain test operations. Instead, we call __drm_driver_open() and handle its result ourselves. Unlike drm_driver_open() which skips on device open errors, we always fail or abort the test in such case. Moreover, we don't ensure that the i915 driver is idle before starting subtests like drm_open_driver() does. Skip instead of failing on initial device open error. Also, call gem_quiescent_gpu() if an i915 device is detected. For subsequent device opens, define a local helper that fails on error and use it. If we think we need to abort the test execution on device open error, set our failure marker first to trigger the abort from a follow up igt_fixture section. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index a4071f51e..e576a6c6c 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -49,6 +49,21 @@ struct hotunplug { /* Helpers */ +/** + * Subtests must be able to close examined devices completely. Don't + * use drm_open_driver() since in case of an i915 device it opens it + * twice and keeps a second file descriptor open for exit handler use. + */ +static int local_drm_open_driver(void) +{ + int fd_drm; + + fd_drm = __drm_open_driver(DRIVER_ANY); + igt_assert_fd(fd_drm); + + return fd_drm; +} + static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) { int len; @@ -71,8 +86,7 @@ static void prepare_for_unbind(struct hotunplug *priv, char *buf, int buflen) static void prepare(struct hotunplug *priv, char *buf, int buflen) { igt_debug("opening device\n"); - priv->fd.drm = __drm_open_driver(DRIVER_ANY); - igt_assert_fd(priv->fd.drm); + priv->fd.drm = local_drm_open_driver(); priv->fd.sysfs_dev = igt_sysfs_open(priv->fd.drm); igt_assert_fd(priv->fd.sysfs_dev); @@ -145,8 +159,9 @@ static void healthcheck(void) igt_devices_scan(true); igt_debug("reopening the device\n"); - fd_drm = __drm_open_driver(DRIVER_ANY); - igt_abort_on_f(fd_drm < 0, "Device reopen failure"); + failure = "Device reopen failure!"; + fd_drm = local_drm_open_driver(); + failure = NULL; if (is_i915_device(fd_drm)) { failure = "GEM failure"; @@ -255,16 +270,13 @@ igt_main igt_fixture { int fd_drm; - /** - * As subtests must be able to close examined devices - * completely, don't use drm_open_driver() as it keeps - * a device file descriptor open for exit handler use. - */ fd_drm = __drm_open_driver(DRIVER_ANY); - igt_assert_fd(fd_drm); + igt_skip_on_f(fd_drm < 0, "No known DRM device found\n"); - if (is_i915_device(fd_drm)) + if (is_i915_device(fd_drm)) { + gem_quiescent_gpu(fd_drm); igt_require_gem(fd_drm); + } /* Make sure subtests always reopen the same device */ set_filter_from_device(fd_drm);