mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	drm/sched: Add new test for DRM_GPU_SCHED_STAT_NO_HANG
Add a test to submit a single job against a scheduler with the timeout configured and verify that if the job is still running, the timeout handler will skip the reset and allow the job to complete. Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Reviewed-by: Philipp Stanner <phasta@kernel.org> Link: https://lore.kernel.org/r/20250714-sched-skip-reset-v6-4-5c5ba4f55039@igalia.com Signed-off-by: Maíra Canal <mcanal@igalia.com>
This commit is contained in:
		
							parent
							
								
									9b9b5a3605
								
							
						
					
					
						commit
						1472e7549f
					
				
					 3 changed files with 49 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -218,6 +218,11 @@ mock_sched_timedout_job(struct drm_sched_job *sched_job)
 | 
			
		|||
	struct drm_mock_sched_job *job = drm_sched_job_to_mock_job(sched_job);
 | 
			
		||||
	unsigned long flags;
 | 
			
		||||
 | 
			
		||||
	if (job->flags & DRM_MOCK_SCHED_JOB_DONT_RESET) {
 | 
			
		||||
		job->flags &= ~DRM_MOCK_SCHED_JOB_DONT_RESET;
 | 
			
		||||
		return DRM_GPU_SCHED_STAT_NO_HANG;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	spin_lock_irqsave(&sched->lock, flags);
 | 
			
		||||
	if (!dma_fence_is_signaled_locked(&job->hw_fence)) {
 | 
			
		||||
		list_del(&job->link);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -97,6 +97,7 @@ struct drm_mock_sched_job {
 | 
			
		|||
 | 
			
		||||
#define DRM_MOCK_SCHED_JOB_DONE		0x1
 | 
			
		||||
#define DRM_MOCK_SCHED_JOB_TIMEDOUT	0x2
 | 
			
		||||
#define DRM_MOCK_SCHED_JOB_DONT_RESET	0x4
 | 
			
		||||
	unsigned long		flags;
 | 
			
		||||
 | 
			
		||||
	struct list_head	link;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -287,8 +287,51 @@ static void drm_sched_basic_timeout(struct kunit *test)
 | 
			
		|||
	drm_mock_sched_entity_free(entity);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void drm_sched_skip_reset(struct kunit *test)
 | 
			
		||||
{
 | 
			
		||||
	struct drm_mock_scheduler *sched = test->priv;
 | 
			
		||||
	struct drm_mock_sched_entity *entity;
 | 
			
		||||
	struct drm_mock_sched_job *job;
 | 
			
		||||
	unsigned int i;
 | 
			
		||||
	bool done;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Submit a single job against a scheduler with the timeout configured
 | 
			
		||||
	 * and verify that if the job is still running, the timeout handler
 | 
			
		||||
	 * will skip the reset and allow the job to complete.
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	entity = drm_mock_sched_entity_new(test,
 | 
			
		||||
					   DRM_SCHED_PRIORITY_NORMAL,
 | 
			
		||||
					   sched);
 | 
			
		||||
	job = drm_mock_sched_job_new(test, entity);
 | 
			
		||||
 | 
			
		||||
	job->flags = DRM_MOCK_SCHED_JOB_DONT_RESET;
 | 
			
		||||
 | 
			
		||||
	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, 2 * MOCK_TIMEOUT);
 | 
			
		||||
	KUNIT_ASSERT_FALSE(test, done);
 | 
			
		||||
 | 
			
		||||
	KUNIT_ASSERT_EQ(test,
 | 
			
		||||
			job->flags & DRM_MOCK_SCHED_JOB_DONT_RESET,
 | 
			
		||||
			0);
 | 
			
		||||
 | 
			
		||||
	i = drm_mock_sched_advance(sched, 1);
 | 
			
		||||
	KUNIT_ASSERT_EQ(test, i, 1);
 | 
			
		||||
 | 
			
		||||
	done = drm_mock_sched_job_wait_finished(job, HZ);
 | 
			
		||||
	KUNIT_ASSERT_TRUE(test, done);
 | 
			
		||||
 | 
			
		||||
	drm_mock_sched_entity_free(entity);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct kunit_case drm_sched_timeout_tests[] = {
 | 
			
		||||
	KUNIT_CASE(drm_sched_basic_timeout),
 | 
			
		||||
	KUNIT_CASE(drm_sched_skip_reset),
 | 
			
		||||
	{}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue