Commit 9cbc4052 authored by Tvrtko Ursulin's avatar Tvrtko Ursulin Committed by Philipp Stanner
Browse files

drm/sched: De-clutter drm_sched_init



Move work queue allocation into a helper for a more streamlined function
body.

Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
Reviewed-by: default avatarMaíra Canal <mcanal@igalia.com>
Signed-off-by: default avatarPhilipp Stanner <phasta@kernel.org>
Link: https://lore.kernel.org/r/20250704130754.89935-1-tvrtko.ursulin@igalia.com
parent 86c947b3
Loading
Loading
Loading
Loading
+20 −13
Original line number Diff line number Diff line
@@ -84,12 +84,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;

/**
@@ -1261,6 +1255,25 @@ 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"
	};

	/*
	 * Avoid leaking a lockdep map on each drm sched creation and
	 * destruction by using a single lockdep map for all drm sched
	 * allocated submit_wq.
	 */

	return alloc_ordered_workqueue_lockdep_map(name, WQ_MEM_RECLAIM, &map);
#else
	return alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
#endif
}

/**
 * drm_sched_init - Init a gpu scheduler instance
 *
@@ -1301,13 +1314,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;