drm/sched: Add a simple timeout test

Add a very simple timeout test which submits a single job and verifies
that the timeout handling will run if the backend failed to complete the
job in time.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
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>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250324092633.49746-4-tvrtko.ursulin@igalia.com
This commit is contained in:
Tvrtko Ursulin
2025-03-24 09:26:30 +00:00
committed by Philipp Stanner
parent 5a99350794
commit 53e6597492
3 changed files with 73 additions and 6 deletions

View File

@@ -12,7 +12,7 @@
static int drm_sched_basic_init(struct kunit *test)
{
test->priv = drm_mock_sched_new(test);
test->priv = drm_mock_sched_new(test, MAX_SCHEDULE_TIMEOUT);
return 0;
}
@@ -24,6 +24,13 @@ static void drm_sched_basic_exit(struct kunit *test)
drm_mock_sched_fini(sched);
}
static int drm_sched_timeout_init(struct kunit *test)
{
test->priv = drm_mock_sched_new(test, HZ);
return 0;
}
static void drm_sched_basic_submit(struct kunit *test)
{
struct drm_mock_scheduler *sched = test->priv;
@@ -195,4 +202,57 @@ static struct kunit_suite drm_sched_basic = {
.test_cases = drm_sched_basic_tests,
};
kunit_test_suite(drm_sched_basic);
static void drm_sched_basic_timeout(struct kunit *test)
{
struct drm_mock_scheduler *sched = test->priv;
struct drm_mock_sched_entity *entity;
struct drm_mock_sched_job *job;
bool done;
/*
* Submit a single job against a scheduler with the timeout configured
* and verify that the timeout handling will run if the backend fails
* to complete it in time.
*/
entity = drm_mock_sched_entity_new(test,
DRM_SCHED_PRIORITY_NORMAL,
sched);
job = drm_mock_sched_job_new(test, entity);
drm_mock_sched_job_submit(job);
done = drm_mock_sched_job_wait_scheduled(job, HZ);
KUNIT_ASSERT_TRUE(test, done);
done = drm_mock_sched_job_wait_finished(job, HZ / 2);
KUNIT_ASSERT_FALSE(test, done);
KUNIT_ASSERT_EQ(test,
job->flags & DRM_MOCK_SCHED_JOB_TIMEDOUT,
0);
done = drm_mock_sched_job_wait_finished(job, HZ);
KUNIT_ASSERT_FALSE(test, done);
KUNIT_ASSERT_EQ(test,
job->flags & DRM_MOCK_SCHED_JOB_TIMEDOUT,
DRM_MOCK_SCHED_JOB_TIMEDOUT);
drm_mock_sched_entity_free(entity);
}
static struct kunit_case drm_sched_timeout_tests[] = {
KUNIT_CASE(drm_sched_basic_timeout),
{}
};
static struct kunit_suite drm_sched_timeout = {
.name = "drm_sched_basic_timeout_tests",
.init = drm_sched_timeout_init,
.exit = drm_sched_basic_exit,
.test_cases = drm_sched_timeout_tests,
};
kunit_test_suites(&drm_sched_basic,
&drm_sched_timeout);