[RFC v4 03/16] drm/sched: De-clutter drm_sched_init

Christian König christian.koenig at amd.com
Tue Apr 29 15:16:24 UTC 2025


On 4/25/25 12:20, Tvrtko Ursulin wrote:
> Move work queue allocation into a helper for a more streamlined function
> body.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Danilo Krummrich <dakr at kernel.org>
> Cc: Matthew Brost <matthew.brost at intel.com>
> Cc: Philipp Stanner <phasta at kernel.org>
> ---
>  drivers/gpu/drm/scheduler/sched_main.c | 27 +++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index ca5028f7a4e9..86e40157b09b 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -83,12 +83,6 @@
>  #define CREATE_TRACE_POINTS
>  #include "gpu_scheduler_trace.h"
>  
> -#ifdef CONFIG_LOCKDEP
> -static struct lockdep_map drm_sched_lockdep_map = {
> -	.name = "drm_sched_lockdep_map"
> -};
> -#endif
> -
>  int drm_sched_policy = DRM_SCHED_POLICY_FIFO;
>  
>  /**
> @@ -1258,6 +1252,19 @@ static void drm_sched_run_job_work(struct work_struct *w)
>  	drm_sched_run_job_queue(sched);
>  }
>  
> +static struct workqueue_struct *drm_sched_alloc_wq(const char *name)
> +{
> +#if (IS_ENABLED(CONFIG_LOCKDEP))
> +	static struct lockdep_map map = {
> +		.name = "drm_sched_lockdep_map"
> +	};
> +
> +	return alloc_ordered_workqueue_lockdep_map(name, WQ_MEM_RECLAIM, &map);

Some comment why we have a separate lockdep map would be really nice to have here.

Apart from that looks good to me,
Christian.

> +#else
> +	return alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
> +#endif
> +}
> +
>  /**
>   * drm_sched_init - Init a gpu scheduler instance
>   *
> @@ -1298,13 +1305,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, const struct drm_sched_init_
>  		sched->submit_wq = args->submit_wq;
>  		sched->own_submit_wq = false;
>  	} else {
> -#ifdef CONFIG_LOCKDEP
> -		sched->submit_wq = alloc_ordered_workqueue_lockdep_map(args->name,
> -								       WQ_MEM_RECLAIM,
> -								       &drm_sched_lockdep_map);
> -#else
> -		sched->submit_wq = alloc_ordered_workqueue(args->name, WQ_MEM_RECLAIM);
> -#endif
> +		sched->submit_wq = drm_sched_alloc_wq(args->name);
>  		if (!sched->submit_wq)
>  			return -ENOMEM;
>  



More information about the amd-gfx mailing list