From nobody Sat Feb 7 14:04:15 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3737142E6F for ; Tue, 27 May 2025 10:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748340639; cv=none; b=eZEmO0crTclyHDXcU15KUK0jDWw+pprmVJpAiQ4vAzajR0HmPEdACkhNbOo1Uxb7lzT6wbAsaVJnHCVn+Ln47FaPaTlKTibnPm2VD0dy/ONu3q1PGsXLIjzZqDB8pZ8CLw0GqCrbsgC7f4benGG7AczmiLknwxSWR2DfAVBFK3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748340639; c=relaxed/simple; bh=aCPm9UB1pDOz4HurjnnTFfxQ6vwCbfeokcrzhchT7aQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fBJ5Pjir01X5bQMiq39DIQSk0JdTkcfoJjfIUaPLG0Gr21ddeNFf2ilIguVAmgrBg7yz4AeV/Cek3/bm/w32sdY9YYXKR5XfvBbOQg0G4HJjG26lukKjlSzqaUVhX4/ZmzKEDKpHglRPtgS4af+l6fGsHe0FhfKW3kFxZKgwnoA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pxShTHkP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pxShTHkP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A7C9C4CEE9; Tue, 27 May 2025 10:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748340638; bh=aCPm9UB1pDOz4HurjnnTFfxQ6vwCbfeokcrzhchT7aQ=; h=From:To:Cc:Subject:Date:From; b=pxShTHkP9iE/yHaPe3B3Y4ljXScAclIMdLqcS8Twha/nK9uh2qhxDsdIrmItXgBxZ 6PDd3+OleVFca5SbZg8KQgeBMnJrQk6ffuqdUxEni6K/0AXpMsv3vrmFY8ZJu3Jr7e iXHo3YMXUfYug77hJSipMkAQdhSMipKj7g6pE5XWbn8h/d3SNW+/lHbkRASHKmusea h5l9/Mz6cRPzn2sSIywd1NzUWE2HnR2VPkCxSRK0DXAvgeDBhItEaOU3IVUI7A0w2n 0w5sWYmafDW/jBisErFBLsWVppFnpMxNjEApNIMUPBtlLL235BNopnPuIjDFeOiwVL JO3Qscyzoaztw== From: Philipp Stanner To: Matthew Brost , Danilo Krummrich , Philipp Stanner , =?UTF-8?q?Christian=20K=C3=B6nig?= , airlied@gmail.com, Simona Vetter , Tvrtko Ursulin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/sched/tests: Use one lock for fence context Date: Tue, 27 May 2025 12:10:30 +0200 Message-ID: <20250527101029.56491-2-phasta@kernel.org> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Philipp Stanner Reviewed-by: Tvrtko Ursulin --- Changes in v2: - Make commit message more neutral by stating it's about simplifying the code. (Tvrtko) --- drivers/gpu/drm/scheduler/tests/mock_scheduler.c | 5 ++--- drivers/gpu/drm/scheduler/tests/sched_tests.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu= /drm/scheduler/tests/mock_scheduler.c index f999c8859cf7..17023276f4b0 100644 --- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c +++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c @@ -64,7 +64,7 @@ static void drm_mock_sched_job_complete(struct drm_mock_s= ched_job *job) =20 job->flags |=3D 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); } =20 @@ -123,7 +123,6 @@ drm_mock_sched_job_new(struct kunit *test, job->test =3D test; =20 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); @@ -169,7 +168,7 @@ static struct dma_fence *mock_sched_run_job(struct drm_= sched_job *sched_job) =20 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)); =20 diff --git a/drivers/gpu/drm/scheduler/tests/sched_tests.h b/drivers/gpu/dr= m/scheduler/tests/sched_tests.h index 27caf8285fb7..fbba38137f0c 100644 --- a/drivers/gpu/drm/scheduler/tests/sched_tests.h +++ b/drivers/gpu/drm/scheduler/tests/sched_tests.h @@ -106,7 +106,6 @@ struct drm_mock_sched_job { unsigned int duration_us; ktime_t finish_at; =20 - spinlock_t lock; struct dma_fence hw_fence; =20 struct kunit *test; --=20 2.49.0