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 checking credit limit

Add a basic test for checking whether scheduler respects the configured
credit limit.

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

authored by

Tvrtko Ursulin and committed by
Philipp Stanner
909bda22 c85fc5db

+59 -1
+59 -1
drivers/gpu/drm/scheduler/tests/tests_basic.c
··· 412 412 .test_cases = drm_sched_modify_sched_tests, 413 413 }; 414 414 415 + static void drm_sched_test_credits(struct kunit *test) 416 + { 417 + struct drm_mock_sched_entity *entity; 418 + struct drm_mock_scheduler *sched; 419 + struct drm_mock_sched_job *job[2]; 420 + bool done; 421 + int i; 422 + 423 + /* 424 + * Check that the configured credit limit is respected. 425 + */ 426 + 427 + sched = drm_mock_sched_new(test, MAX_SCHEDULE_TIMEOUT); 428 + sched->base.credit_limit = 1; 429 + 430 + entity = drm_mock_sched_entity_new(test, 431 + DRM_SCHED_PRIORITY_NORMAL, 432 + sched); 433 + 434 + job[0] = drm_mock_sched_job_new(test, entity); 435 + job[1] = drm_mock_sched_job_new(test, entity); 436 + 437 + drm_mock_sched_job_submit(job[0]); 438 + drm_mock_sched_job_submit(job[1]); 439 + 440 + done = drm_mock_sched_job_wait_scheduled(job[0], HZ); 441 + KUNIT_ASSERT_TRUE(test, done); 442 + 443 + done = drm_mock_sched_job_wait_scheduled(job[1], HZ); 444 + KUNIT_ASSERT_FALSE(test, done); 445 + 446 + i = drm_mock_sched_advance(sched, 1); 447 + KUNIT_ASSERT_EQ(test, i, 1); 448 + 449 + done = drm_mock_sched_job_wait_scheduled(job[1], HZ); 450 + KUNIT_ASSERT_TRUE(test, done); 451 + 452 + i = drm_mock_sched_advance(sched, 1); 453 + KUNIT_ASSERT_EQ(test, i, 1); 454 + 455 + done = drm_mock_sched_job_wait_finished(job[1], HZ); 456 + KUNIT_ASSERT_TRUE(test, done); 457 + 458 + drm_mock_sched_entity_free(entity); 459 + drm_mock_sched_fini(sched); 460 + } 461 + 462 + static struct kunit_case drm_sched_credits_tests[] = { 463 + KUNIT_CASE(drm_sched_test_credits), 464 + {} 465 + }; 466 + 467 + static struct kunit_suite drm_sched_credits = { 468 + .name = "drm_sched_basic_credits_tests", 469 + .test_cases = drm_sched_credits_tests, 470 + }; 471 + 415 472 kunit_test_suites(&drm_sched_basic, 416 473 &drm_sched_timeout, 417 474 &drm_sched_priority, 418 - &drm_sched_modify_sched); 475 + &drm_sched_modify_sched, 476 + &drm_sched_credits);