From patchwork Wed Mar 5 15:53:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 14002923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9780C282E5 for ; Wed, 5 Mar 2025 15:54:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 256DC10E7DE; Wed, 5 Mar 2025 15:54:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="nFqJpVOM"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id D352A10E7D8 for ; Wed, 5 Mar 2025 15:54:12 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 0ADA6A45A27; Wed, 5 Mar 2025 15:48:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BB09C4CED1; Wed, 5 Mar 2025 15:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741190051; bh=zIEeetKUTm0IuyongYlHLFcQs8fidnoZvNOum1B6Meo=; h=From:To:Cc:Subject:Date:From; b=nFqJpVOMRycveemwDsbazoTPRUFoTsgImJC9/7MOjvuExCby4x7ZoLePxanm60LBk WpHfohZbhGi9Dc2NVPE2qGIskN8V/IzqkSv/bz2PmNfLyfX+Fhe2Zjv1j+DjwLAu9i 9YqdUAZchQfxDzMsbGcD/uL97nsJ8ZpdSdzgJIKIKEeedDJ7xjoMl26i3HOKdkxmVE zSD7jRicSA3GPZdPQeRx63DYNvks7bJ0LYOB1UqLjf3Upe5IKgUo52gkfYlygh3kZI BbwSG5dS6WDbh5uA5iUtLZalMsv/c/dNk73hmKyegBxajFIVFIgrza6Nw+ubBFVyBH oIVDCFWMlLY1A== From: Philipp Stanner To: Matthew Brost , Danilo Krummrich , Philipp Stanner , =?utf-8?q?Christian_K=C3=B6nig?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sumit Semwal Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] drm/sched: Fix outdated comments referencing thread Date: Wed, 5 Mar 2025 16:53:26 +0100 Message-ID: <20250305155326.153596-2-phasta@kernel.org> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The GPU scheduler's comments refer to a "thread" at various places. Those are leftovers from commit a6149f039369 ("drm/sched: Convert drm scheduler to use a work queue rather than kthread"). Replace all references to kthreads. Signed-off-by: Philipp Stanner --- Changes in v2: - Speak consistently about work items. (Danilo) - Remove Fixes: tags. (Danilo) --- drivers/gpu/drm/scheduler/sched_entity.c | 8 ++++---- drivers/gpu/drm/scheduler/sched_main.c | 24 +++++++++++++----------- include/drm/gpu_scheduler.h | 10 +++++----- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 87f88259ddf6..f9811420c787 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -538,10 +538,10 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity) return; /* - * Only when the queue is empty are we guaranteed that the scheduler - * thread cannot change ->last_scheduled. To enforce ordering we need - * a read barrier here. See drm_sched_entity_pop_job() for the other - * side. + * Only when the queue is empty are we guaranteed that + * drm_sched_run_job_work() cannot change entity->last_scheduled. To + * enforce ordering we need a read barrier here. See + * drm_sched_entity_pop_job() for the other side. */ smp_rmb(); diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index c634993f1346..c97655aa7ab4 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -389,7 +389,7 @@ static void drm_sched_run_free_queue(struct drm_gpu_scheduler *sched) * drm_sched_job_done - complete a job * @s_job: pointer to the job which is done * - * Finish the job's fence and wake up the worker thread. + * Finish the job's fence and resubmit the work items. */ static void drm_sched_job_done(struct drm_sched_job *s_job, int result) { @@ -549,9 +549,10 @@ static void drm_sched_job_timedout(struct work_struct *work) if (job) { /* - * Remove the bad job so it cannot be freed by concurrent - * drm_sched_cleanup_jobs. It will be reinserted back after sched->thread - * is parked at which point it's safe. + * Remove the bad job so it cannot be freed by a concurrent + * &struct drm_sched_backend_ops.free_job. It will be + * reinserted after the scheduler's work items have been + * cancelled, at which point it's safe. */ list_del_init(&job->list); spin_unlock(&sched->job_list_lock); @@ -597,10 +598,10 @@ void drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad) /* * Reinsert back the bad job here - now it's safe as - * drm_sched_get_finished_job cannot race against us and release the + * drm_sched_get_finished_job() cannot race against us and release the * bad job at this point - we parked (waited for) any in progress - * (earlier) cleanups and drm_sched_get_finished_job will not be called - * now until the scheduler thread is unparked. + * (earlier) cleanups and drm_sched_get_finished_job() will not be + * called now until the scheduler's work items are submitted again. */ if (bad && bad->sched == sched) /* @@ -613,7 +614,8 @@ void drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad) * Iterate the job list from later to earlier one and either deactive * their HW callbacks or remove them from pending list if they already * signaled. - * This iteration is thread safe as sched thread is stopped. + * This iteration is thread safe as the scheduler's work items have been + * cancelled. */ list_for_each_entry_safe_reverse(s_job, tmp, &sched->pending_list, list) { @@ -678,9 +680,9 @@ void drm_sched_start(struct drm_gpu_scheduler *sched, int errno) struct drm_sched_job *s_job, *tmp; /* - * Locking the list is not required here as the sched thread is parked - * so no new jobs are being inserted or removed. Also concurrent - * GPU recovers can't run in parallel. + * Locking the list is not required here as the scheduler's work items + * are currently not running, so no new jobs are being inserted or + * removed. Also concurrent GPU recovers can't run in parallel. */ list_for_each_entry_safe(s_job, tmp, &sched->pending_list, list) { struct dma_fence *fence = s_job->s_fence->parent; diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 50928a7ae98e..d8bfd46c1117 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -192,7 +192,7 @@ struct drm_sched_entity { * @last_scheduled: * * Points to the finished fence of the last scheduled job. Only written - * by the scheduler thread, can be accessed locklessly from + * by drm_sched_entity_pop_job(). Can be accessed locklessly from * drm_sched_job_arm() if the queue is empty. */ struct dma_fence __rcu *last_scheduled; @@ -426,14 +426,14 @@ struct drm_sched_backend_ops { * Drivers typically issue a reset to recover from GPU hangs, and this * procedure usually follows the following workflow: * - * 1. Stop the scheduler using drm_sched_stop(). This will park the - * scheduler thread and cancel the timeout work, guaranteeing that - * nothing is queued while we reset the hardware queue + * 1. Stop the scheduler using drm_sched_stop(). This will cancel the + * scheduler's work items, guaranteeing that nothing is queued while + * we reset the hardware queue. * 2. Try to gracefully stop non-faulty jobs (optional) * 3. Issue a GPU reset (driver-specific) * 4. Re-submit jobs using drm_sched_resubmit_jobs() * 5. Restart the scheduler using drm_sched_start(). At that point, new - * jobs can be queued, and the scheduler thread is unblocked + * jobs can be queued, and the scheduler's work items are resubmitted. * * Note that some GPUs have distinct hardware queues but need to reset * the GPU globally, which requires extra synchronization between the From patchwork Wed Mar 5 15:53:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 14002922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5558C19F32 for ; Wed, 5 Mar 2025 15:54:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0068310E7D8; Wed, 5 Mar 2025 15:54:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="YjatVu0u"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5107D10E7DE for ; Wed, 5 Mar 2025 15:54:15 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id B3183A45A31; Wed, 5 Mar 2025 15:48:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E02A8C4CEEA; Wed, 5 Mar 2025 15:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741190054; bh=hjKg1gDFgtmx4nrhI0ndame1TsHOJmcFeEivWJNbSco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YjatVu0uHiwI2J/y+PPIKOC4X8mTngak0sPMk/cR4/SX6/MuzU459KjcIg1SFe/jA 75jCEF4Itbfq2PNLhmvioXcSkOQB5y8pSydjDRWDLQGbwPEVe/GpSzXqalZ0x5Nxck 5c5zneYao891QDGdLVxaeDTHKAQKNubSU0CtsnS4r+kXptlRuY5XE8fcptatCEcdy1 D952VYh//2AKcNK6RW/coWrp37vAPRZA5GuY/YCi56a7AiqdZtQuK/iAyrvl34N23c 7LtAKleE5CfqldcjhL5RSEeLPnrXz+0C/DzK60E8r+SXAsJfknMZPipVAyYVPvqZQp VWMBHUZSnxhAQ== From: Philipp Stanner To: Matthew Brost , Danilo Krummrich , Philipp Stanner , =?utf-8?q?Christian_K=C3=B6nig?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sumit Semwal Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] drm/sched: Remove kthread header Date: Wed, 5 Mar 2025 16:53:27 +0100 Message-ID: <20250305155326.153596-3-phasta@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305155326.153596-2-phasta@kernel.org> References: <20250305155326.153596-2-phasta@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The kthread header doesn't need to be included anymore. It's a relict from commit a6149f039369 ("drm/sched: Convert drm scheduler to use a work queue rather than kthread"). Remove the unneeded includes. Signed-off-by: Philipp Stanner --- drivers/gpu/drm/scheduler/sched_entity.c | 1 - drivers/gpu/drm/scheduler/sched_fence.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index f9811420c787..e55b98af8a50 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -21,7 +21,6 @@ * */ -#include #include #include diff --git a/drivers/gpu/drm/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c index e971528504a5..d6239e015b66 100644 --- a/drivers/gpu/drm/scheduler/sched_fence.c +++ b/drivers/gpu/drm/scheduler/sched_fence.c @@ -21,7 +21,6 @@ * */ -#include #include #include #include