@@ -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
@@ -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));
+ }
}
/**
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 <tvrtko.ursulin@igalia.com> Suggested-by: Philipp Stanner <phasta@kernel.org> Cc: Christian König <christian.koenig@amd.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Philipp Stanner <phasta@kernel.org> --- drivers/gpu/drm/Kconfig.debug | 13 +++++++++++++ drivers/gpu/drm/scheduler/tests/mock_scheduler.c | 10 ++++++++++ 2 files changed, 23 insertions(+)