]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/sched/tests: Use one lock for fence context
authorPhilipp Stanner <phasta@kernel.org>
Tue, 27 May 2025 10:10:30 +0000 (12:10 +0200)
committerPhilipp Stanner <phasta@kernel.org>
Mon, 2 Jun 2025 11:27:34 +0000 (13:27 +0200)
There is no need for separate locks for single jobs and the entire
scheduler. The dma_fence context can be protected by the scheduler lock,
allowing for removing the jobs' locks. This simplifies things and
reduces the likelyhood of deadlocks etc.

Replace the jobs' locks with the mock scheduler lock.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://lore.kernel.org/r/20250527101029.56491-2-phasta@kernel.org
drivers/gpu/drm/scheduler/tests/mock_scheduler.c
drivers/gpu/drm/scheduler/tests/sched_tests.h

index fcddaeaa921760715a344b81ebbed6cc921231ac..7f947ab9d32259d72186a6c0bff0b666fdee1821 100644 (file)
@@ -64,7 +64,7 @@ static void drm_mock_sched_job_complete(struct drm_mock_sched_job *job)
 
        job->flags |= DRM_MOCK_SCHED_JOB_DONE;
        list_move_tail(&job->link, &sched->done_list);
-       dma_fence_signal(&job->hw_fence);
+       dma_fence_signal_locked(&job->hw_fence);
        complete(&job->done);
 }
 
@@ -124,7 +124,6 @@ drm_mock_sched_job_new(struct kunit *test,
        job->test = test;
 
        init_completion(&job->done);
-       spin_lock_init(&job->lock);
        INIT_LIST_HEAD(&job->link);
        hrtimer_setup(&job->timer, drm_mock_sched_job_signal_timer,
                      CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
@@ -170,7 +169,7 @@ static struct dma_fence *mock_sched_run_job(struct drm_sched_job *sched_job)
 
        dma_fence_init(&job->hw_fence,
                       &drm_mock_sched_hw_fence_ops,
-                      &job->lock,
+                      &sched->lock,
                       sched->hw_timeline.context,
                       atomic_inc_return(&sched->hw_timeline.next_seqno));
 
index 27caf8285fb74b9f3c9ce2daa1c44d4a0c967e92..fbba38137f0c324cf2472fe5b3a8a78ec016e829 100644 (file)
@@ -106,7 +106,6 @@ struct drm_mock_sched_job {
        unsigned int            duration_us;
        ktime_t                 finish_at;
 
-       spinlock_t              lock;
        struct dma_fence        hw_fence;
 
        struct kunit            *test;