Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/sched: Add a basic test for modifying entities scheduler list

Add a basic test for exercising modifying the entities scheduler list at
runtime.

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-6-tvrtko.ursulin@igalia.com

authored by

Tvrtko Ursulin and committed by
Philipp Stanner
c85fc5db 7b765cda

+68 -1
+68 -1
drivers/gpu/drm/scheduler/tests/tests_basic.c
··· 346 346 .test_cases = drm_sched_priority_tests, 347 347 }; 348 348 349 + static void drm_sched_test_modify_sched(struct kunit *test) 350 + { 351 + unsigned int i, cur_ent = 0, cur_sched = 0; 352 + struct drm_mock_sched_entity *entity[13]; 353 + struct drm_mock_scheduler *sched[3]; 354 + struct drm_mock_sched_job *job; 355 + const unsigned int qd = 1000; 356 + 357 + /* 358 + * Submit a bunch of jobs against entities configured with different 359 + * schedulers and while waiting for them to complete, periodically keep 360 + * changing schedulers associated with each entity. 361 + * 362 + * We set up the queue-depth (qd) and job duration so the sched modify 363 + * loop has some time to interact with submissions to the backend and 364 + * job completions as they progress. 365 + * 366 + * For the number of schedulers and entities we use primes in order to 367 + * perturb the entity->sched assignments with less of a regular pattern. 368 + */ 369 + 370 + for (i = 0; i < ARRAY_SIZE(sched); i++) 371 + sched[i] = drm_mock_sched_new(test, MAX_SCHEDULE_TIMEOUT); 372 + 373 + for (i = 0; i < ARRAY_SIZE(entity); i++) 374 + entity[i] = drm_mock_sched_entity_new(test, 375 + DRM_SCHED_PRIORITY_NORMAL, 376 + sched[i % ARRAY_SIZE(sched)]); 377 + 378 + for (i = 0; i < qd; i++) { 379 + job = drm_mock_sched_job_new(test, entity[cur_ent++]); 380 + cur_ent %= ARRAY_SIZE(entity); 381 + drm_mock_sched_job_set_duration_us(job, 1000); 382 + drm_mock_sched_job_submit(job); 383 + } 384 + 385 + do { 386 + struct drm_gpu_scheduler *modify; 387 + 388 + usleep_range(200, 500); 389 + cur_ent++; 390 + cur_ent %= ARRAY_SIZE(entity); 391 + cur_sched++; 392 + cur_sched %= ARRAY_SIZE(sched); 393 + modify = &sched[cur_sched]->base; 394 + drm_sched_entity_modify_sched(&entity[cur_ent]->base, &modify, 395 + 1); 396 + } while (!drm_mock_sched_job_is_finished(job)); 397 + 398 + for (i = 0; i < ARRAY_SIZE(entity); i++) 399 + drm_mock_sched_entity_free(entity[i]); 400 + 401 + for (i = 0; i < ARRAY_SIZE(sched); i++) 402 + drm_mock_sched_fini(sched[i]); 403 + } 404 + 405 + static struct kunit_case drm_sched_modify_sched_tests[] = { 406 + KUNIT_CASE(drm_sched_test_modify_sched), 407 + {} 408 + }; 409 + 410 + static struct kunit_suite drm_sched_modify_sched = { 411 + .name = "drm_sched_basic_modify_sched_tests", 412 + .test_cases = drm_sched_modify_sched_tests, 413 + }; 414 + 349 415 kunit_test_suites(&drm_sched_basic, 350 416 &drm_sched_timeout, 351 - &drm_sched_priority); 417 + &drm_sched_priority, 418 + &drm_sched_modify_sched);