18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2015 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#ifndef _DRM_GPU_SCHEDULER_H_
258c2ecf20Sopenharmony_ci#define _DRM_GPU_SCHEDULER_H_
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include <drm/spsc_queue.h>
288c2ecf20Sopenharmony_ci#include <linux/dma-fence.h>
298c2ecf20Sopenharmony_ci#include <linux/completion.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define MAX_WAIT_SCHED_ENTITY_Q_EMPTY msecs_to_jiffies(1000)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistruct drm_gpu_scheduler;
348c2ecf20Sopenharmony_cistruct drm_sched_rq;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* These are often used as an (initial) index
378c2ecf20Sopenharmony_ci * to an array, and as such should start at 0.
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_cienum drm_sched_priority {
408c2ecf20Sopenharmony_ci	DRM_SCHED_PRIORITY_MIN,
418c2ecf20Sopenharmony_ci	DRM_SCHED_PRIORITY_NORMAL,
428c2ecf20Sopenharmony_ci	DRM_SCHED_PRIORITY_HIGH,
438c2ecf20Sopenharmony_ci	DRM_SCHED_PRIORITY_KERNEL,
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	DRM_SCHED_PRIORITY_COUNT,
468c2ecf20Sopenharmony_ci	DRM_SCHED_PRIORITY_UNSET = -2
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/**
508c2ecf20Sopenharmony_ci * struct drm_sched_entity - A wrapper around a job queue (typically
518c2ecf20Sopenharmony_ci * attached to the DRM file_priv).
528c2ecf20Sopenharmony_ci *
538c2ecf20Sopenharmony_ci * @list: used to append this struct to the list of entities in the
548c2ecf20Sopenharmony_ci *        runqueue.
558c2ecf20Sopenharmony_ci * @rq: runqueue on which this entity is currently scheduled.
568c2ecf20Sopenharmony_ci * @sched_list: A list of schedulers (drm_gpu_schedulers).
578c2ecf20Sopenharmony_ci *              Jobs from this entity can be scheduled on any scheduler
588c2ecf20Sopenharmony_ci *              on this list.
598c2ecf20Sopenharmony_ci * @num_sched_list: number of drm_gpu_schedulers in the sched_list.
608c2ecf20Sopenharmony_ci * @priority: priority of the entity
618c2ecf20Sopenharmony_ci * @rq_lock: lock to modify the runqueue to which this entity belongs.
628c2ecf20Sopenharmony_ci * @job_queue: the list of jobs of this entity.
638c2ecf20Sopenharmony_ci * @fence_seq: a linearly increasing seqno incremented with each
648c2ecf20Sopenharmony_ci *             new &drm_sched_fence which is part of the entity.
658c2ecf20Sopenharmony_ci * @fence_context: a unique context for all the fences which belong
668c2ecf20Sopenharmony_ci *                 to this entity.
678c2ecf20Sopenharmony_ci *                 The &drm_sched_fence.scheduled uses the
688c2ecf20Sopenharmony_ci *                 fence_context but &drm_sched_fence.finished uses
698c2ecf20Sopenharmony_ci *                 fence_context + 1.
708c2ecf20Sopenharmony_ci * @dependency: the dependency fence of the job which is on the top
718c2ecf20Sopenharmony_ci *              of the job queue.
728c2ecf20Sopenharmony_ci * @cb: callback for the dependency fence above.
738c2ecf20Sopenharmony_ci * @guilty: points to ctx's guilty.
748c2ecf20Sopenharmony_ci * @fini_status: contains the exit status in case the process was signalled.
758c2ecf20Sopenharmony_ci * @last_scheduled: points to the finished fence of the last scheduled job.
768c2ecf20Sopenharmony_ci * @last_user: last group leader pushing a job into the entity.
778c2ecf20Sopenharmony_ci * @stopped: Marks the enity as removed from rq and destined for termination.
788c2ecf20Sopenharmony_ci * @entity_idle: Signals when enityt is not in use
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci * Entities will emit jobs in order to their corresponding hardware
818c2ecf20Sopenharmony_ci * ring, and the scheduler will alternate between entities based on
828c2ecf20Sopenharmony_ci * scheduling policy.
838c2ecf20Sopenharmony_ci */
848c2ecf20Sopenharmony_cistruct drm_sched_entity {
858c2ecf20Sopenharmony_ci	struct list_head		list;
868c2ecf20Sopenharmony_ci	struct drm_sched_rq		*rq;
878c2ecf20Sopenharmony_ci	struct drm_gpu_scheduler        **sched_list;
888c2ecf20Sopenharmony_ci	unsigned int                    num_sched_list;
898c2ecf20Sopenharmony_ci	enum drm_sched_priority         priority;
908c2ecf20Sopenharmony_ci	spinlock_t			rq_lock;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	struct spsc_queue		job_queue;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	atomic_t			fence_seq;
958c2ecf20Sopenharmony_ci	uint64_t			fence_context;
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	struct dma_fence		*dependency;
988c2ecf20Sopenharmony_ci	struct dma_fence_cb		cb;
998c2ecf20Sopenharmony_ci	atomic_t			*guilty;
1008c2ecf20Sopenharmony_ci	struct dma_fence                *last_scheduled;
1018c2ecf20Sopenharmony_ci	struct task_struct		*last_user;
1028c2ecf20Sopenharmony_ci	bool 				stopped;
1038c2ecf20Sopenharmony_ci	struct completion		entity_idle;
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/**
1078c2ecf20Sopenharmony_ci * struct drm_sched_rq - queue of entities to be scheduled.
1088c2ecf20Sopenharmony_ci *
1098c2ecf20Sopenharmony_ci * @lock: to modify the entities list.
1108c2ecf20Sopenharmony_ci * @sched: the scheduler to which this rq belongs to.
1118c2ecf20Sopenharmony_ci * @entities: list of the entities to be scheduled.
1128c2ecf20Sopenharmony_ci * @current_entity: the entity which is to be scheduled.
1138c2ecf20Sopenharmony_ci *
1148c2ecf20Sopenharmony_ci * Run queue is a set of entities scheduling command submissions for
1158c2ecf20Sopenharmony_ci * one specific ring. It implements the scheduling policy that selects
1168c2ecf20Sopenharmony_ci * the next entity to emit commands from.
1178c2ecf20Sopenharmony_ci */
1188c2ecf20Sopenharmony_cistruct drm_sched_rq {
1198c2ecf20Sopenharmony_ci	spinlock_t			lock;
1208c2ecf20Sopenharmony_ci	struct drm_gpu_scheduler	*sched;
1218c2ecf20Sopenharmony_ci	struct list_head		entities;
1228c2ecf20Sopenharmony_ci	struct drm_sched_entity		*current_entity;
1238c2ecf20Sopenharmony_ci};
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/**
1268c2ecf20Sopenharmony_ci * struct drm_sched_fence - fences corresponding to the scheduling of a job.
1278c2ecf20Sopenharmony_ci */
1288c2ecf20Sopenharmony_cistruct drm_sched_fence {
1298c2ecf20Sopenharmony_ci        /**
1308c2ecf20Sopenharmony_ci         * @scheduled: this fence is what will be signaled by the scheduler
1318c2ecf20Sopenharmony_ci         * when the job is scheduled.
1328c2ecf20Sopenharmony_ci         */
1338c2ecf20Sopenharmony_ci	struct dma_fence		scheduled;
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci        /**
1368c2ecf20Sopenharmony_ci         * @finished: this fence is what will be signaled by the scheduler
1378c2ecf20Sopenharmony_ci         * when the job is completed.
1388c2ecf20Sopenharmony_ci         *
1398c2ecf20Sopenharmony_ci         * When setting up an out fence for the job, you should use
1408c2ecf20Sopenharmony_ci         * this, since it's available immediately upon
1418c2ecf20Sopenharmony_ci         * drm_sched_job_init(), and the fence returned by the driver
1428c2ecf20Sopenharmony_ci         * from run_job() won't be created until the dependencies have
1438c2ecf20Sopenharmony_ci         * resolved.
1448c2ecf20Sopenharmony_ci         */
1458c2ecf20Sopenharmony_ci	struct dma_fence		finished;
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci        /**
1488c2ecf20Sopenharmony_ci         * @parent: the fence returned by &drm_sched_backend_ops.run_job
1498c2ecf20Sopenharmony_ci         * when scheduling the job on hardware. We signal the
1508c2ecf20Sopenharmony_ci         * &drm_sched_fence.finished fence once parent is signalled.
1518c2ecf20Sopenharmony_ci         */
1528c2ecf20Sopenharmony_ci	struct dma_fence		*parent;
1538c2ecf20Sopenharmony_ci        /**
1548c2ecf20Sopenharmony_ci         * @sched: the scheduler instance to which the job having this struct
1558c2ecf20Sopenharmony_ci         * belongs to.
1568c2ecf20Sopenharmony_ci         */
1578c2ecf20Sopenharmony_ci	struct drm_gpu_scheduler	*sched;
1588c2ecf20Sopenharmony_ci        /**
1598c2ecf20Sopenharmony_ci         * @lock: the lock used by the scheduled and the finished fences.
1608c2ecf20Sopenharmony_ci         */
1618c2ecf20Sopenharmony_ci	spinlock_t			lock;
1628c2ecf20Sopenharmony_ci        /**
1638c2ecf20Sopenharmony_ci         * @owner: job owner for debugging
1648c2ecf20Sopenharmony_ci         */
1658c2ecf20Sopenharmony_ci	void				*owner;
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistruct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci/**
1718c2ecf20Sopenharmony_ci * struct drm_sched_job - A job to be run by an entity.
1728c2ecf20Sopenharmony_ci *
1738c2ecf20Sopenharmony_ci * @queue_node: used to append this struct to the queue of jobs in an entity.
1748c2ecf20Sopenharmony_ci * @sched: the scheduler instance on which this job is scheduled.
1758c2ecf20Sopenharmony_ci * @s_fence: contains the fences for the scheduling of job.
1768c2ecf20Sopenharmony_ci * @finish_cb: the callback for the finished fence.
1778c2ecf20Sopenharmony_ci * @node: used to append this struct to the @drm_gpu_scheduler.ring_mirror_list.
1788c2ecf20Sopenharmony_ci * @id: a unique id assigned to each job scheduled on the scheduler.
1798c2ecf20Sopenharmony_ci * @karma: increment on every hang caused by this job. If this exceeds the hang
1808c2ecf20Sopenharmony_ci *         limit of the scheduler then the job is marked guilty and will not
1818c2ecf20Sopenharmony_ci *         be scheduled further.
1828c2ecf20Sopenharmony_ci * @s_priority: the priority of the job.
1838c2ecf20Sopenharmony_ci * @entity: the entity to which this job belongs.
1848c2ecf20Sopenharmony_ci * @cb: the callback for the parent fence in s_fence.
1858c2ecf20Sopenharmony_ci *
1868c2ecf20Sopenharmony_ci * A job is created by the driver using drm_sched_job_init(), and
1878c2ecf20Sopenharmony_ci * should call drm_sched_entity_push_job() once it wants the scheduler
1888c2ecf20Sopenharmony_ci * to schedule the job.
1898c2ecf20Sopenharmony_ci */
1908c2ecf20Sopenharmony_cistruct drm_sched_job {
1918c2ecf20Sopenharmony_ci	struct spsc_node		queue_node;
1928c2ecf20Sopenharmony_ci	struct drm_gpu_scheduler	*sched;
1938c2ecf20Sopenharmony_ci	struct drm_sched_fence		*s_fence;
1948c2ecf20Sopenharmony_ci	struct dma_fence_cb		finish_cb;
1958c2ecf20Sopenharmony_ci	struct list_head		node;
1968c2ecf20Sopenharmony_ci	uint64_t			id;
1978c2ecf20Sopenharmony_ci	atomic_t			karma;
1988c2ecf20Sopenharmony_ci	enum drm_sched_priority		s_priority;
1998c2ecf20Sopenharmony_ci	struct drm_sched_entity  *entity;
2008c2ecf20Sopenharmony_ci	struct dma_fence_cb		cb;
2018c2ecf20Sopenharmony_ci};
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_cistatic inline bool drm_sched_invalidate_job(struct drm_sched_job *s_job,
2048c2ecf20Sopenharmony_ci					    int threshold)
2058c2ecf20Sopenharmony_ci{
2068c2ecf20Sopenharmony_ci	return (s_job && atomic_inc_return(&s_job->karma) > threshold);
2078c2ecf20Sopenharmony_ci}
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci/**
2108c2ecf20Sopenharmony_ci * struct drm_sched_backend_ops
2118c2ecf20Sopenharmony_ci *
2128c2ecf20Sopenharmony_ci * Define the backend operations called by the scheduler,
2138c2ecf20Sopenharmony_ci * these functions should be implemented in driver side.
2148c2ecf20Sopenharmony_ci */
2158c2ecf20Sopenharmony_cistruct drm_sched_backend_ops {
2168c2ecf20Sopenharmony_ci	/**
2178c2ecf20Sopenharmony_ci         * @dependency: Called when the scheduler is considering scheduling
2188c2ecf20Sopenharmony_ci         * this job next, to get another struct dma_fence for this job to
2198c2ecf20Sopenharmony_ci	 * block on.  Once it returns NULL, run_job() may be called.
2208c2ecf20Sopenharmony_ci	 */
2218c2ecf20Sopenharmony_ci	struct dma_fence *(*dependency)(struct drm_sched_job *sched_job,
2228c2ecf20Sopenharmony_ci					struct drm_sched_entity *s_entity);
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	/**
2258c2ecf20Sopenharmony_ci         * @run_job: Called to execute the job once all of the dependencies
2268c2ecf20Sopenharmony_ci         * have been resolved.  This may be called multiple times, if
2278c2ecf20Sopenharmony_ci	 * timedout_job() has happened and drm_sched_job_recovery()
2288c2ecf20Sopenharmony_ci	 * decides to try it again.
2298c2ecf20Sopenharmony_ci	 */
2308c2ecf20Sopenharmony_ci	struct dma_fence *(*run_job)(struct drm_sched_job *sched_job);
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci	/**
2338c2ecf20Sopenharmony_ci         * @timedout_job: Called when a job has taken too long to execute,
2348c2ecf20Sopenharmony_ci         * to trigger GPU recovery.
2358c2ecf20Sopenharmony_ci	 */
2368c2ecf20Sopenharmony_ci	void (*timedout_job)(struct drm_sched_job *sched_job);
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	/**
2398c2ecf20Sopenharmony_ci         * @free_job: Called once the job's finished fence has been signaled
2408c2ecf20Sopenharmony_ci         * and it's time to clean it up.
2418c2ecf20Sopenharmony_ci	 */
2428c2ecf20Sopenharmony_ci	void (*free_job)(struct drm_sched_job *sched_job);
2438c2ecf20Sopenharmony_ci};
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci/**
2468c2ecf20Sopenharmony_ci * struct drm_gpu_scheduler
2478c2ecf20Sopenharmony_ci *
2488c2ecf20Sopenharmony_ci * @ops: backend operations provided by the driver.
2498c2ecf20Sopenharmony_ci * @hw_submission_limit: the max size of the hardware queue.
2508c2ecf20Sopenharmony_ci * @timeout: the time after which a job is removed from the scheduler.
2518c2ecf20Sopenharmony_ci * @name: name of the ring for which this scheduler is being used.
2528c2ecf20Sopenharmony_ci * @sched_rq: priority wise array of run queues.
2538c2ecf20Sopenharmony_ci * @wake_up_worker: the wait queue on which the scheduler sleeps until a job
2548c2ecf20Sopenharmony_ci *                  is ready to be scheduled.
2558c2ecf20Sopenharmony_ci * @job_scheduled: once @drm_sched_entity_do_release is called the scheduler
2568c2ecf20Sopenharmony_ci *                 waits on this wait queue until all the scheduled jobs are
2578c2ecf20Sopenharmony_ci *                 finished.
2588c2ecf20Sopenharmony_ci * @hw_rq_count: the number of jobs currently in the hardware queue.
2598c2ecf20Sopenharmony_ci * @job_id_count: used to assign unique id to the each job.
2608c2ecf20Sopenharmony_ci * @work_tdr: schedules a delayed call to @drm_sched_job_timedout after the
2618c2ecf20Sopenharmony_ci *            timeout interval is over.
2628c2ecf20Sopenharmony_ci * @thread: the kthread on which the scheduler which run.
2638c2ecf20Sopenharmony_ci * @ring_mirror_list: the list of jobs which are currently in the job queue.
2648c2ecf20Sopenharmony_ci * @job_list_lock: lock to protect the ring_mirror_list.
2658c2ecf20Sopenharmony_ci * @hang_limit: once the hangs by a job crosses this limit then it is marked
2668c2ecf20Sopenharmony_ci *              guilty and it will be considered for scheduling further.
2678c2ecf20Sopenharmony_ci * @score: score to help loadbalancer pick a idle sched
2688c2ecf20Sopenharmony_ci * @ready: marks if the underlying HW is ready to work
2698c2ecf20Sopenharmony_ci * @free_guilty: A hit to time out handler to free the guilty job.
2708c2ecf20Sopenharmony_ci *
2718c2ecf20Sopenharmony_ci * One scheduler is implemented for each hardware ring.
2728c2ecf20Sopenharmony_ci */
2738c2ecf20Sopenharmony_cistruct drm_gpu_scheduler {
2748c2ecf20Sopenharmony_ci	const struct drm_sched_backend_ops	*ops;
2758c2ecf20Sopenharmony_ci	uint32_t			hw_submission_limit;
2768c2ecf20Sopenharmony_ci	long				timeout;
2778c2ecf20Sopenharmony_ci	const char			*name;
2788c2ecf20Sopenharmony_ci	struct drm_sched_rq		sched_rq[DRM_SCHED_PRIORITY_COUNT];
2798c2ecf20Sopenharmony_ci	wait_queue_head_t		wake_up_worker;
2808c2ecf20Sopenharmony_ci	wait_queue_head_t		job_scheduled;
2818c2ecf20Sopenharmony_ci	atomic_t			hw_rq_count;
2828c2ecf20Sopenharmony_ci	atomic64_t			job_id_count;
2838c2ecf20Sopenharmony_ci	struct delayed_work		work_tdr;
2848c2ecf20Sopenharmony_ci	struct task_struct		*thread;
2858c2ecf20Sopenharmony_ci	struct list_head		ring_mirror_list;
2868c2ecf20Sopenharmony_ci	spinlock_t			job_list_lock;
2878c2ecf20Sopenharmony_ci	int				hang_limit;
2888c2ecf20Sopenharmony_ci	atomic_t                        score;
2898c2ecf20Sopenharmony_ci	bool				ready;
2908c2ecf20Sopenharmony_ci	bool				free_guilty;
2918c2ecf20Sopenharmony_ci};
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ciint drm_sched_init(struct drm_gpu_scheduler *sched,
2948c2ecf20Sopenharmony_ci		   const struct drm_sched_backend_ops *ops,
2958c2ecf20Sopenharmony_ci		   uint32_t hw_submission, unsigned hang_limit, long timeout,
2968c2ecf20Sopenharmony_ci		   const char *name);
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_civoid drm_sched_fini(struct drm_gpu_scheduler *sched);
2998c2ecf20Sopenharmony_ciint drm_sched_job_init(struct drm_sched_job *job,
3008c2ecf20Sopenharmony_ci		       struct drm_sched_entity *entity,
3018c2ecf20Sopenharmony_ci		       void *owner);
3028c2ecf20Sopenharmony_civoid drm_sched_entity_modify_sched(struct drm_sched_entity *entity,
3038c2ecf20Sopenharmony_ci				    struct drm_gpu_scheduler **sched_list,
3048c2ecf20Sopenharmony_ci                                   unsigned int num_sched_list);
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_civoid drm_sched_job_cleanup(struct drm_sched_job *job);
3078c2ecf20Sopenharmony_civoid drm_sched_wakeup(struct drm_gpu_scheduler *sched);
3088c2ecf20Sopenharmony_civoid drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad);
3098c2ecf20Sopenharmony_civoid drm_sched_start(struct drm_gpu_scheduler *sched, bool full_recovery);
3108c2ecf20Sopenharmony_civoid drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched);
3118c2ecf20Sopenharmony_civoid drm_sched_increase_karma(struct drm_sched_job *bad);
3128c2ecf20Sopenharmony_cibool drm_sched_dependency_optimized(struct dma_fence* fence,
3138c2ecf20Sopenharmony_ci				    struct drm_sched_entity *entity);
3148c2ecf20Sopenharmony_civoid drm_sched_fault(struct drm_gpu_scheduler *sched);
3158c2ecf20Sopenharmony_civoid drm_sched_job_kickout(struct drm_sched_job *s_job);
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_civoid drm_sched_rq_add_entity(struct drm_sched_rq *rq,
3188c2ecf20Sopenharmony_ci			     struct drm_sched_entity *entity);
3198c2ecf20Sopenharmony_civoid drm_sched_rq_remove_entity(struct drm_sched_rq *rq,
3208c2ecf20Sopenharmony_ci				struct drm_sched_entity *entity);
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ciint drm_sched_entity_init(struct drm_sched_entity *entity,
3238c2ecf20Sopenharmony_ci			  enum drm_sched_priority priority,
3248c2ecf20Sopenharmony_ci			  struct drm_gpu_scheduler **sched_list,
3258c2ecf20Sopenharmony_ci			  unsigned int num_sched_list,
3268c2ecf20Sopenharmony_ci			  atomic_t *guilty);
3278c2ecf20Sopenharmony_cilong drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout);
3288c2ecf20Sopenharmony_civoid drm_sched_entity_fini(struct drm_sched_entity *entity);
3298c2ecf20Sopenharmony_civoid drm_sched_entity_destroy(struct drm_sched_entity *entity);
3308c2ecf20Sopenharmony_civoid drm_sched_entity_select_rq(struct drm_sched_entity *entity);
3318c2ecf20Sopenharmony_cistruct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity);
3328c2ecf20Sopenharmony_civoid drm_sched_entity_push_job(struct drm_sched_job *sched_job,
3338c2ecf20Sopenharmony_ci			       struct drm_sched_entity *entity);
3348c2ecf20Sopenharmony_civoid drm_sched_entity_set_priority(struct drm_sched_entity *entity,
3358c2ecf20Sopenharmony_ci				   enum drm_sched_priority priority);
3368c2ecf20Sopenharmony_cibool drm_sched_entity_is_ready(struct drm_sched_entity *entity);
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_cistruct drm_sched_fence *drm_sched_fence_create(
3398c2ecf20Sopenharmony_ci	struct drm_sched_entity *s_entity, void *owner);
3408c2ecf20Sopenharmony_civoid drm_sched_fence_scheduled(struct drm_sched_fence *fence);
3418c2ecf20Sopenharmony_civoid drm_sched_fence_finished(struct drm_sched_fence *fence);
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ciunsigned long drm_sched_suspend_timeout(struct drm_gpu_scheduler *sched);
3448c2ecf20Sopenharmony_civoid drm_sched_resume_timeout(struct drm_gpu_scheduler *sched,
3458c2ecf20Sopenharmony_ci		                unsigned long remaining);
3468c2ecf20Sopenharmony_cistruct drm_gpu_scheduler *
3478c2ecf20Sopenharmony_cidrm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
3488c2ecf20Sopenharmony_ci		     unsigned int num_sched_list);
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci#endif
351