From patchwork Thu Apr 1 14:36:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 12178167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F143C433ED for ; Thu, 1 Apr 2021 14:37:26 +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 0399E6120F for ; Thu, 1 Apr 2021 14:37:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0399E6120F 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 D872F6E0E4; Thu, 1 Apr 2021 14:37:24 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CEAB6E0D9; Thu, 1 Apr 2021 14:37:24 +0000 (UTC) IronPort-SDR: zykdiMebxdBme3yW0MLKKlYqcjCaI7jDeJXW79t/pEMrWzvei31EWuK0zR4wNHdKd4Dqog1FDa GcrCGH2rf4Dg== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="188996592" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="188996592" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:23 -0700 IronPort-SDR: c/g/QERzQ12qjulx+pzE/7jSomTcHvMKEczvDujbVZDkYuemYMim8vyTPkFWWOrjA3d6zc1udv SZ6ZhIdDZ17A== X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419225262" Received: from jkrzyszt-mobl1.ger.corp.intel.com ([10.213.28.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:21 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 1 Apr 2021 16:36:38 +0200 Message-Id: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t 1/6] tests/core_hotunplug: Add 'GEM context' variants X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Verify if an additional context associated with an open device file descriptor is cleaned up correctly on device hotunbind / hotunplug. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 56a88fefd..4f6c4f625 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -31,6 +31,7 @@ #include #include "i915/gem.h" +#include "i915/gem_context.h" #include "igt.h" #include "igt_device_scan.h" #include "igt_kmod.h" @@ -545,6 +546,60 @@ static void hotreplug_lateclose(struct hotunplug *priv) igt_assert_f(healthcheck(priv, false), "%s\n", priv->failure); } +static void ctx_hotunbind_lateclose(struct hotunplug *priv) +{ + uint32_t ctx; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + gem_require_contexts(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); + + local_debug("%s\n", "creating additional GEM user context"); + ctx = gem_context_create(priv->fd.drm); + + driver_unbind(priv, "hot ", 0); + + local_debug("%s\n", "trying to late destroy the context"); + igt_assert_eq(__gem_context_destroy(priv->fd.drm, ctx), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); +} + +static void ctx_hotunplug_lateclose(struct hotunplug *priv) +{ + uint32_t ctx; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + gem_require_contexts(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); + + local_debug("%s\n", "creating additional GEM user context"); + ctx = gem_context_create(priv->fd.drm); + + device_unplug(priv, "hot ", 0); + + local_debug("%s\n", "trying to late destroy the context"); + igt_assert_eq(__gem_context_destroy(priv->fd.drm, ctx), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); +} + /* Main */ igt_main @@ -682,6 +737,30 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unbound for a still open device with extra GEM context, then released"); + igt_subtest("ctx-hotunbind-lateclose") + ctx_hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a still open device with extra GEM context can be cleanly unplugged, then released"); + igt_subtest("ctx-hotunplug-lateclose") + ctx_hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } + igt_fixture { post_healthcheck(&priv); From patchwork Thu Apr 1 14:36:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 12178169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB4FBC433B4 for ; Thu, 1 Apr 2021 14:37:28 +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 7F3E6610D1 for ; Thu, 1 Apr 2021 14:37:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F3E6610D1 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 11B636ECC5; Thu, 1 Apr 2021 14:37:27 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E0896ECC5; Thu, 1 Apr 2021 14:37:25 +0000 (UTC) IronPort-SDR: IRHCW6v3VceBtxEzEEr/ZblCXIrLjy0Wmq5cIR8JmOn7EdiyjcGck7arWAdKs8I6Cc50icmhXN A7a/3qxbEFWw== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="188996596" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="188996596" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:25 -0700 IronPort-SDR: cmO5/bv/y7nf04/c8kB/UXcFhGALhFeoHxfzR9+5NLv0FHfnQVZCWE4gaApUXHuZeuJTQe4sNu /9s5AcYETo3g== X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419225289" Received: from jkrzyszt-mobl1.ger.corp.intel.com ([10.213.28.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:23 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 1 Apr 2021 16:36:39 +0200 Message-Id: <20210401143643.7867-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> References: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t 2/6] tests/core_hotunplug: Add 'GEM address space' variants X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Verify if an additional address space associated with an open device file descriptor is cleaned up correctly on device hotunbind / hotunplug. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 4f6c4f625..decfcdfda 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -32,6 +32,7 @@ #include "i915/gem.h" #include "i915/gem_context.h" +#include "i915/gem_vm.h" #include "igt.h" #include "igt_device_scan.h" #include "igt_kmod.h" @@ -600,6 +601,60 @@ static void ctx_hotunplug_lateclose(struct hotunplug *priv) igt_assert_eq(priv->fd.drm, -1); } +static void vm_hotunbind_lateclose(struct hotunplug *priv) +{ + int vm; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + gem_require_vm(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); + + local_debug("%s\n", "creating additional GEM user address space"); + vm = gem_vm_create(priv->fd.drm); + + driver_unbind(priv, "hot ", 0); + + local_debug("%s\n", "trying to late remove the address space"); + igt_assert_eq(__gem_vm_destroy(priv->fd.drm, vm), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); +} + +static void vm_hotunplug_lateclose(struct hotunplug *priv) +{ + int vm; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + gem_require_vm(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); + + local_debug("%s\n", "creating additional GEM user address space"); + vm = gem_vm_create(priv->fd.drm); + + device_unplug(priv, "hot ", 0); + + local_debug("%s\n", "trying to late remove the address space"); + igt_assert_eq(__gem_vm_destroy(priv->fd.drm, vm), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); +} + /* Main */ igt_main @@ -761,6 +816,30 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unboound form a still open device with extra GEM address space, then released"); + igt_subtest("vm-hotunbind-lateclose") + vm_hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a still open device with extra GEM address space can be cleanly unplugged, then released"); + igt_subtest("vm-hotunplug-lateclose") + vm_hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } + igt_fixture { post_healthcheck(&priv); From patchwork Thu Apr 1 14:36:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 12178171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85AD2C433ED for ; Thu, 1 Apr 2021 14:37:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EA256120F for ; Thu, 1 Apr 2021 14:37:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EA256120F 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 88F326ECC7; Thu, 1 Apr 2021 14:37:28 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 554136ECC7; Thu, 1 Apr 2021 14:37:27 +0000 (UTC) IronPort-SDR: qNeveWjnaRYqj6N0f/kIKKynBBWA54ho/FLkEa2y4cah2yRiqlUzOC92gxwpIdcg8GOx8Gv45l grRvFWkJikhg== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="188996606" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="188996606" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:27 -0700 IronPort-SDR: Guvucyq6SbDGxpx5kQoPOg4Yrbib9gPdsumxZtd6L36AABKZVRIZgJu7n9Ql5ngaxv7uH1gjez xX+27JH5V00g== X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419225302" Received: from jkrzyszt-mobl1.ger.corp.intel.com ([10.213.28.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:25 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 1 Apr 2021 16:36:40 +0200 Message-Id: <20210401143643.7867-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> References: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t 3/6] tests/core_hotunplug: Add 'GEM object' variants X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" GEM objects belonging to user file descriptors still open on device hotunbind / hotunplug may exhibit still more driver issues. Add subtests that implements these scenarios. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 85 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index decfcdfda..7f61b4446 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -433,6 +433,13 @@ static void set_filter_from_device(int fd) igt_assert_eq(igt_device_filter_add(filter), 1); } +static int local_gem_close(int fd, uint32_t handle) +{ + struct drm_gem_close close_bo = { .handle = handle, }; + + return igt_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close_bo) ? -errno : 0; +} + /* Subtests */ static void unbind_rebind(struct hotunplug *priv) @@ -655,6 +662,60 @@ static void vm_hotunplug_lateclose(struct hotunplug *priv) igt_assert_eq(priv->fd.drm, -1); } +static void gem_hotunbind_lateclose(struct hotunplug *priv) +{ + uint32_t handle; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); + + local_debug("%s\n", "creating a GEM user object"); + handle = gem_create(priv->fd.drm, 4096); + + driver_unbind(priv, "hot", 0); + + local_debug("%s\n", "trying to late remove the object"); + igt_assert_eq(local_gem_close(priv->fd.drm, handle), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); +} + +static void gem_hotunplug_lateclose(struct hotunplug *priv) +{ + uint32_t handle; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); + + local_debug("%s\n", "creating a GEM user object"); + handle = gem_create(priv->fd.drm, 4096); + + device_unplug(priv, "hot", 0); + + local_debug("%s\n", "trying to late remove the object"); + igt_assert_eq(local_gem_close(priv->fd.drm, handle), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); +} + /* Main */ igt_main @@ -840,6 +901,30 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unbound from a device with a still open GEM object, then released"); + igt_subtest("gem-hotunbind-lateclose") + gem_hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a device with a still open GEM object can be cleanly unplugged, then released"); + igt_subtest("gem-hotunplug-lateclose") + gem_hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } + igt_fixture { post_healthcheck(&priv); From patchwork Thu Apr 1 14:36:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 12178173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F290C433B4 for ; Thu, 1 Apr 2021 14:37: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 D9080610D1 for ; Thu, 1 Apr 2021 14:37:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9080610D1 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 538326ECCE; Thu, 1 Apr 2021 14:37:31 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 428BE6ECCB; Thu, 1 Apr 2021 14:37:29 +0000 (UTC) IronPort-SDR: QD3qMpsFJmOR3jtu8Lz/03mIcwTFhIqWXsZc9vSSM/0S5PtE54HR64+9+RJY3QMBzMOFyyPNX8 6wMYIfrZBywQ== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="188996614" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="188996614" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:29 -0700 IronPort-SDR: vHuGWJxy7iph/g+E/KV9FHMb/0fKzTu+hmOxTR0MPhbUW7F30xfyCR5PClAqj6reuKdJVeFzoG cY6ysW9r9DWQ== X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419225314" Received: from jkrzyszt-mobl1.ger.corp.intel.com ([10.213.28.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:27 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 1 Apr 2021 16:36:41 +0200 Message-Id: <20210401143643.7867-4-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> References: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t 4/6] tests/core_hotunplug: Add 'userptr GEM object' variants X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Verify if userptr GM objects are cleaned up equally well as regular GEM objects on device hotunbind / hotunplug. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 7f61b4446..6f3b3b3d3 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -716,6 +716,72 @@ static void gem_hotunplug_lateclose(struct hotunplug *priv) igt_assert_eq(priv->fd.drm, -1); } +static void userptr_hotunbind_lateclose(struct hotunplug *priv) +{ + uint32_t handle; + void *ptr; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + igt_assert_eq(posix_memalign(&ptr, 4096, 4096), 0); + igt_require(!__gem_userptr(priv->fd.drm, ptr, 4096, 0, 0, &handle)); + gem_close(priv->fd.drm, handle); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); + + local_debug("%s\n", "creating a userptr GEM object"); + gem_userptr(priv->fd.drm, ptr, 4096, 0, 0, &handle); + + driver_unbind(priv, "hot ", 0); + + local_debug("%s\n", "trying to late remove the object"); + igt_assert_eq(local_gem_close(priv->fd.drm, handle), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); + + igt_fail_on_f(munmap(ptr, 4096), "Userptr unmap failure!"); +} + +static void userptr_hotunplug_lateclose(struct hotunplug *priv) +{ + uint32_t handle; + void *ptr; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + igt_assert_eq(posix_memalign(&ptr, 4096, 4096), 0); + igt_require(!__gem_userptr(priv->fd.drm, ptr, 4096, 0, 0, &handle)); + gem_close(priv->fd.drm, handle); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); + + local_debug("%s\n", "creating a userptr GEM object"); + gem_userptr(priv->fd.drm, ptr, 4096, 0, 0, &handle); + + device_unplug(priv, "hot ", 0); + + local_debug("%s\n", "trying to late remove the object"); + igt_assert_eq(local_gem_close(priv->fd.drm, handle), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); + + igt_fail_on_f(munmap(ptr, 4096), "Userptr unmap failure!"); +} + /* Main */ igt_main @@ -925,6 +991,30 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unbound from a device with a still open userptr GEM object, then released"); + igt_subtest("userptr-hotunbind-lateclose") + userptr_hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a device with a still open userptr GEM object can be cleanly unplugged, then released"); + igt_subtest("userptr-hotunplug-lateclose") + userptr_hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } + igt_fixture { post_healthcheck(&priv); From patchwork Thu Apr 1 14:36:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 12178175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32682C43460 for ; Thu, 1 Apr 2021 14:37:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE8306120F for ; Thu, 1 Apr 2021 14:37:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE8306120F 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 76A0A6ECC9; Thu, 1 Apr 2021 14:37:33 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 497A16ECC9; Thu, 1 Apr 2021 14:37:31 +0000 (UTC) IronPort-SDR: KeMrh4J7Qj8hJUOKFR0FykFshIrICCLOBRRgzftFIitiScF8hvxHzXBZaAt58nvJlzHUuEkrOp dZbjNSIYQ4oQ== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="188996622" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="188996622" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:31 -0700 IronPort-SDR: kFaycvYi3nm4pN/GEZyefiUDUu1pEI2COak6fv/rtvRKD/JlEbwLf6Y95+xMrMzlGiGNlKwVD3 GogpIhMcN2oA== X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419225318" Received: from jkrzyszt-mobl1.ger.corp.intel.com ([10.213.28.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:29 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 1 Apr 2021 16:36:42 +0200 Message-Id: <20210401143643.7867-5-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> References: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t 5/6] tests/core_hotunplug: Add 'PRIME handle' variants X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Even if all device file descriptors are closed on device hotunbind / hotunplug, PRIME exported objects may still exists, referenced by still open dma-buf file descriptors. Add subtests that keep such descriptor open on device hotunbind / hotunplug. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 104 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 6f3b3b3d3..0cb1267ae 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -782,6 +782,86 @@ static void userptr_hotunplug_lateclose(struct hotunplug *priv) igt_fail_on_f(munmap(ptr, 4096), "Userptr unmap failure!"); } +static void prime_hotunbind_lateclose(struct hotunplug *priv) +{ + uint32_t handle; + int dmabuf, ret; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); + + local_debug("%s\n", "creating and PRIME-exporting a GEM object"); + handle = gem_create(priv->fd.drm, 4096); + dmabuf = prime_handle_to_fd(priv->fd.drm, handle); + + ret = local_gem_close(priv->fd.drm, handle); + priv->fd.drm = close_device(priv->fd.drm, "", "exported "); + + if (priv->fd.drm != -1) { + igt_ignore_warn(close(dmabuf)); + igt_assert_eq(priv->fd.drm, -1); + } + + /* once device close succeeds, take care of open dmabuf like if it was a device fd */ + priv->fd.drm = dmabuf; + igt_assert_f(!ret, "gem_close failed with errno %d\n", ret); + + driver_unbind(priv, "hot ", 0); + + igt_debug("late closing the PRIME file descriptor\n"); + dmabuf = local_close(dmabuf, "PRIME file descriptor late close failure"); + priv->fd.drm = dmabuf; + igt_assert_eq(dmabuf, -1); +} + +static void prime_hotunplug_lateclose(struct hotunplug *priv) +{ + uint32_t handle; + int dmabuf, ret; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); + + local_debug("%s\n", "creating and PRIME-exporting a GEM object"); + handle = gem_create(priv->fd.drm, 4096); + dmabuf = prime_handle_to_fd(priv->fd.drm, handle); + + ret = local_gem_close(priv->fd.drm, handle); + priv->fd.drm = close_device(priv->fd.drm, "", "exported "); + + if (priv->fd.drm != -1) { + igt_ignore_warn(close(dmabuf)); + igt_assert_eq(priv->fd.drm, -1); + } + + /* once device close succeeds, take care of open dmabuf like if it was a device fd */ + priv->fd.drm = dmabuf; + igt_assert_f(!ret, "gem_close failed with errno %d\n", ret); + + device_unplug(priv, "hot ", 0); + + igt_debug("late closing the PRIME file descriptor\n"); + dmabuf = local_close(dmabuf, "PRIME file descriptor late close failure"); + priv->fd.drm = dmabuf; + igt_assert_eq(dmabuf, -1); +} + /* Main */ igt_main @@ -1015,6 +1095,30 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unbound from a device with a still open PRIME-exported object, then released"); + igt_subtest("prime-hotunbind-lateclose") + prime_hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a device with a still open PRIME-exported object can be cleanly unplugged, then released"); + igt_subtest("prime-hotunplug-lateclose") + prime_hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } + igt_fixture { post_healthcheck(&priv); From patchwork Thu Apr 1 14:36:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 12178177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9C23C433ED for ; Thu, 1 Apr 2021 14:37:35 +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 6BF6B6120F for ; Thu, 1 Apr 2021 14:37:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BF6B6120F 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 EB37C6ECD0; Thu, 1 Apr 2021 14:37:34 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8C06F6ECCF; Thu, 1 Apr 2021 14:37:33 +0000 (UTC) IronPort-SDR: pF9f95B2QIBWt1TYvw1IStI/88f8mcojPM8c2U/NG48hBgexk4+c1WzwLTIGpyVEq5aKPj/3va Cg+GBNQzwBnA== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="188996632" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="188996632" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:33 -0700 IronPort-SDR: P1TGdPaHf9EIRJxv3HrRjZuIhcK4sqq28mc9KYilAjKZzeXEu9+2SxhlCwFytOHjecNGuw2MAW UH3U/KmA8vXA== X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419225327" Received: from jkrzyszt-mobl1.ger.corp.intel.com ([10.213.28.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 07:37:31 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Date: Thu, 1 Apr 2021 16:36:43 +0200 Message-Id: <20210401143643.7867-6-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> References: <20210401143643.7867-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC PATCH i-g-t 6/6] tests/core_hotunplug: Add 'GEM spin' variants X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Verify if a device with a GEM spin batch job still running on a GPU can be hot-unbound/unplugged cleanly and released. Signed-off-by: Janusz Krzysztofik --- tests/core_hotunplug.c | 124 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c index 0cb1267ae..f93545402 100644 --- a/tests/core_hotunplug.c +++ b/tests/core_hotunplug.c @@ -35,6 +35,7 @@ #include "i915/gem_vm.h" #include "igt.h" #include "igt_device_scan.h" +#include "igt_dummyload.h" #include "igt_kmod.h" #include "igt_sysfs.h" #include "sw_sync.h" @@ -440,6 +441,37 @@ static int local_gem_close(int fd, uint32_t handle) return igt_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close_bo) ? -errno : 0; } +static int local_bo_busy(int fd, uint32_t handle) +{ + struct drm_i915_gem_busy busy = { .handle = handle, }; + + return igt_ioctl(fd, DRM_IOCTL_I915_GEM_BUSY, &busy) ? -errno : 0; +} + +static void local_spin_free(struct hotunplug *priv, igt_spin_t *spin) +{ + igt_spin_end(spin); + + spin->poll_handle = 0; + spin->handle = 0; + + if (spin->poll) { + void *ptr = spin->poll; + + spin->poll = NULL; + igt_assert(!gem_munmap(ptr, 4096)); + } + + if (spin->batch) { + void *ptr = spin->poll; + + spin->batch = NULL; + igt_assert(!gem_munmap(ptr, 4096)); + } + + igt_spin_free(priv->fd.drm, spin); +} + /* Subtests */ static void unbind_rebind(struct hotunplug *priv) @@ -862,6 +894,74 @@ static void prime_hotunplug_lateclose(struct hotunplug *priv) igt_assert_eq(dmabuf, -1); } +static void spin_hotunbind_lateclose(struct hotunplug *priv) +{ + igt_spin_t *spin; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unbind"); + + local_debug("%s\n", "running dummy load"); + spin = igt_spin_new(priv->fd.drm, .flags = IGT_SPIN_POLL_RUN); + igt_spin_busywait_until_started(spin); + + driver_unbind(priv, "hot ", 0); + + local_debug("%s\n", "trying to late query the dummy load related GEM object status"); + igt_assert_eq(local_bo_busy(priv->fd.drm, spin->handle), -ENODEV); + local_debug("%s\n", "trying to late close the dummy load related GEM objects"); + igt_assert_eq(local_gem_close(priv->fd.drm, spin->poll_handle), -ENODEV); + igt_assert_eq(local_gem_close(priv->fd.drm, spin->handle), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "unbound "); + igt_assert_eq(priv->fd.drm, -1); + + local_debug("%s\n", "trying to late free the dummy load"); + local_spin_free(priv, spin); +} + +static void spin_hotunplug_lateclose(struct hotunplug *priv) +{ + igt_spin_t *spin; + + igt_require(priv->fd.drm = -1); + priv->fd.drm = local_drm_open_driver(false, "pre-", " for prerequisites check"); + + igt_require_intel(priv->fd.drm); + igt_require_gem(priv->fd.drm); + priv->fd.drm = close_device(priv->fd.drm, "", "pre-checked "); + + pre_check(priv); + + priv->fd.drm = local_drm_open_driver(false, "", " for hot unplug"); + + local_debug("%s\n", "running dummy load"); + spin = igt_spin_new(priv->fd.drm, .flags = IGT_SPIN_POLL_RUN); + igt_spin_busywait_until_started(spin); + + device_unplug(priv, "hot ", 0); + + local_debug("%s\n", "trying to late query the dummy load related GEM object status"); + igt_assert_eq(local_bo_busy(priv->fd.drm, spin->handle), -ENODEV); + local_debug("%s\n", "trying to late close the dummy load related GEM objects"); + igt_assert_eq(local_gem_close(priv->fd.drm, spin->poll_handle), -ENODEV); + igt_assert_eq(local_gem_close(priv->fd.drm, spin->handle), -ENODEV); + + priv->fd.drm = close_device(priv->fd.drm, "late ", "removed "); + igt_assert_eq(priv->fd.drm, -1); + + local_debug("%s\n", "trying to late free the dummy load"); + local_spin_free(priv, spin); +} + /* Main */ igt_main @@ -1119,6 +1219,30 @@ igt_main recover(&priv); } + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if the driver can be cleanly unbound from a device with a still running spin batch, then released"); + igt_subtest("spin-hotunbind-lateclose") + spin_hotunbind_lateclose(&priv); + + igt_fixture + recover(&priv); + } + + igt_fixture + post_healthcheck(&priv); + + igt_subtest_group { + igt_describe("Check if a device with a still running spin batch can be cleanly unplugged, then released"); + igt_subtest("spin-hotunplug-lateclose") + spin_hotunplug_lateclose(&priv); + + igt_fixture + recover(&priv); + } + igt_fixture { post_healthcheck(&priv);