From patchwork Mon Mar 10 16:15:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 14010393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C2122C282DE for ; Mon, 10 Mar 2025 16:15:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 958E010E4AA; Mon, 10 Mar 2025 16:15:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="OiotV5pG"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id 778B910E480 for ; Mon, 10 Mar 2025 16:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=TkvCdGqsOLPVAtwvMfdp4GA8VI0AUKRvpqoDXz229Cc=; b=OiotV5pGXNsD5Hroq9qP0Xibco RVJ7FYZXavBGd2gzeg7hJiz7WUVogqmke4GHSmm3Ww5q185DTm/zvdoSvvtAxf7FnEYSk54YD1Onu KUpki9nvNuG7prQR09WG+HzefH0Ut8GxRotf5473FCziV6Je8cOhGkn9/47zBCIDbGsqPMWrl6GIY Sezn5HjnARFw7y/q73BuVKI6qP041UlUs8SiQARhOjA2Zj5oen9dnRMnYG/8u0jXDehmKv3tIyD7o LAtPEz97jzOcm71BheqsdkEkGLoqr1D6+zbAdk9pN8BnEeSLpo9G7hSzD20ElkeJVFEhXvArgiLap /QikOrfw==; Received: from [90.241.98.187] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1trfmc-006YAf-Uo; Mon, 10 Mar 2025 17:15:20 +0100 From: Tvrtko Ursulin To: dri-devel@lists.freedesktop.org Cc: kernel-dev@igalia.com, Tvrtko Ursulin , Philipp Stanner , =?utf-8?q?Christian_K=C3=B6nig?= , Danilo Krummrich , Matthew Brost Subject: [PATCH v6 2/6] drm/sched: Add aspirational unit test mode Date: Mon, 10 Mar 2025 16:15:12 +0000 Message-ID: <20250310161516.39942-3-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250310161516.39942-1-tvrtko.ursulin@igalia.com> References: <20250310161516.39942-1-tvrtko.ursulin@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Aspirational unit test mode can be activated via CONFIG_DRM_SCHED_KUNIT_TEST_ASPIRATIONAL and will test the scheduler not against the criteria of how it is implemented today, but according to the future design goals and agreements. First example of this is the scheduler cleanup flow which currently can leak jobs from drivers which fail to implement own tear down of in-flight submissions. The test which can demonstrate this is drm_sched_basic_entity_cleanup which, based on this kconfig, will skip the mock scheduler specific cleanup and instead rely on drm_sched_fini to idle and free everything. That will not currently happen and therefore drm_mock_sched_fini will assert on test exit. Signed-off-by: Tvrtko Ursulin Suggested-by: Philipp Stanner Cc: Christian König Cc: Danilo Krummrich Cc: Matthew Brost Cc: Philipp Stanner --- drivers/gpu/drm/Kconfig.debug | 13 +++++++++++++ drivers/gpu/drm/scheduler/tests/mock_scheduler.c | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/gpu/drm/Kconfig.debug b/drivers/gpu/drm/Kconfig.debug index 6fd4c5669400..e98ff556e4c4 100644 --- a/drivers/gpu/drm/Kconfig.debug +++ b/drivers/gpu/drm/Kconfig.debug @@ -111,5 +111,18 @@ config DRM_SCHED_KUNIT_TEST If in doubt, say "N". +config DRM_SCHED_KUNIT_TEST_ASPIRATIONAL + bool "Aspirational mode for DRM scheduler unit tests" if !KUNIT_ALL_TESTS + depends on DRM && KUNIT && DRM_SCHED_KUNIT_TEST + default n + help + Choose this option to make the DRM scheduler unit tests test for + behaviour which was agreed as a design goal, even if the current + implementation can make specific tests fail. + + Recommended for driver developers only. + + If in doubt, say "N". + config DRM_EXPORT_FOR_TESTS bool diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c index b7d4890a1651..69b963b619d5 100644 --- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c +++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c @@ -261,9 +261,13 @@ struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test) void drm_mock_sched_fini(struct drm_mock_scheduler *sched) { struct drm_mock_sched_job *job, *next; + struct kunit *test = sched->test; unsigned long flags; LIST_HEAD(signal); + if (IS_ENABLED(CONFIG_DRM_SCHED_KUNIT_TEST_ASPIRATIONAL)) + goto sched_fini; + drm_sched_wqueue_stop(&sched->base); spin_lock_irqsave(&sched->lock, flags); @@ -278,7 +282,13 @@ void drm_mock_sched_fini(struct drm_mock_scheduler *sched) drm_sched_job_cleanup(&job->base); } +sched_fini: drm_sched_fini(&sched->base); + + if (IS_ENABLED(CONFIG_DRM_SCHED_KUNIT_TEST_ASPIRATIONAL)) { + KUNIT_ASSERT_TRUE(test, list_empty(&sched->job_list)); + KUNIT_ASSERT_TRUE(test, list_empty(&sched->base.pending_list)); + } } /**