gpu_scheduler.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #ifndef _DRM_GPU_SCHEDULER_H_
  24. #define _DRM_GPU_SCHEDULER_H_
  25. #include <drm/spsc_queue.h>
  26. #include <linux/dma-fence.h>
  27. #include <linux/completion.h>
  28. #include <linux/xarray.h>
  29. #include <linux/workqueue.h>
  30. #define MAX_WAIT_SCHED_ENTITY_Q_EMPTY msecs_to_jiffies(1000)
  31. /**
  32. * DRM_SCHED_FENCE_DONT_PIPELINE - Prefent dependency pipelining
  33. *
  34. * Setting this flag on a scheduler fence prevents pipelining of jobs depending
  35. * on this fence. In other words we always insert a full CPU round trip before
  36. * dependen jobs are pushed to the hw queue.
  37. */
  38. #define DRM_SCHED_FENCE_DONT_PIPELINE DMA_FENCE_FLAG_USER_BITS
  39. /**
  40. * DRM_SCHED_FENCE_FLAG_HAS_DEADLINE_BIT - A fence deadline hint has been set
  41. *
  42. * Because we could have a deadline hint can be set before the backing hw
  43. * fence is created, we need to keep track of whether a deadline has already
  44. * been set.
  45. */
  46. #define DRM_SCHED_FENCE_FLAG_HAS_DEADLINE_BIT (DMA_FENCE_FLAG_USER_BITS + 1)
  47. enum dma_resv_usage;
  48. struct dma_resv;
  49. struct drm_gem_object;
  50. struct drm_gpu_scheduler;
  51. struct drm_sched_rq;
  52. struct drm_file;
  53. /* These are often used as an (initial) index
  54. * to an array, and as such should start at 0.
  55. */
  56. enum drm_sched_priority {
  57. DRM_SCHED_PRIORITY_KERNEL,
  58. DRM_SCHED_PRIORITY_HIGH,
  59. DRM_SCHED_PRIORITY_NORMAL,
  60. DRM_SCHED_PRIORITY_LOW,
  61. DRM_SCHED_PRIORITY_COUNT
  62. };
  63. /* Used to chose between FIFO and RR jobs scheduling */
  64. extern int drm_sched_policy;
  65. #define DRM_SCHED_POLICY_RR 0
  66. #define DRM_SCHED_POLICY_FIFO 1
  67. /**
  68. * struct drm_sched_entity - A wrapper around a job queue (typically
  69. * attached to the DRM file_priv).
  70. *
  71. * Entities will emit jobs in order to their corresponding hardware
  72. * ring, and the scheduler will alternate between entities based on
  73. * scheduling policy.
  74. */
  75. struct drm_sched_entity {
  76. /**
  77. * @list:
  78. *
  79. * Used to append this struct to the list of entities in the runqueue
  80. * @rq under &drm_sched_rq.entities.
  81. *
  82. * Protected by &drm_sched_rq.lock of @rq.
  83. */
  84. struct list_head list;
  85. /**
  86. * @rq:
  87. *
  88. * Runqueue on which this entity is currently scheduled.
  89. *
  90. * FIXME: Locking is very unclear for this. Writers are protected by
  91. * @rq_lock, but readers are generally lockless and seem to just race
  92. * with not even a READ_ONCE.
  93. */
  94. struct drm_sched_rq *rq;
  95. /**
  96. * @sched_list:
  97. *
  98. * A list of schedulers (struct drm_gpu_scheduler). Jobs from this entity can
  99. * be scheduled on any scheduler on this list.
  100. *
  101. * This can be modified by calling drm_sched_entity_modify_sched().
  102. * Locking is entirely up to the driver, see the above function for more
  103. * details.
  104. *
  105. * This will be set to NULL if &num_sched_list equals 1 and @rq has been
  106. * set already.
  107. *
  108. * FIXME: This means priority changes through
  109. * drm_sched_entity_set_priority() will be lost henceforth in this case.
  110. */
  111. struct drm_gpu_scheduler **sched_list;
  112. /**
  113. * @num_sched_list:
  114. *
  115. * Number of drm_gpu_schedulers in the @sched_list.
  116. */
  117. unsigned int num_sched_list;
  118. /**
  119. * @priority:
  120. *
  121. * Priority of the entity. This can be modified by calling
  122. * drm_sched_entity_set_priority(). Protected by &rq_lock.
  123. */
  124. enum drm_sched_priority priority;
  125. /**
  126. * @rq_lock:
  127. *
  128. * Lock to modify the runqueue to which this entity belongs.
  129. */
  130. spinlock_t rq_lock;
  131. /**
  132. * @job_queue: the list of jobs of this entity.
  133. */
  134. struct spsc_queue job_queue;
  135. /**
  136. * @fence_seq:
  137. *
  138. * A linearly increasing seqno incremented with each new
  139. * &drm_sched_fence which is part of the entity.
  140. *
  141. * FIXME: Callers of drm_sched_job_arm() need to ensure correct locking,
  142. * this doesn't need to be atomic.
  143. */
  144. atomic_t fence_seq;
  145. /**
  146. * @fence_context:
  147. *
  148. * A unique context for all the fences which belong to this entity. The
  149. * &drm_sched_fence.scheduled uses the fence_context but
  150. * &drm_sched_fence.finished uses fence_context + 1.
  151. */
  152. uint64_t fence_context;
  153. /**
  154. * @dependency:
  155. *
  156. * The dependency fence of the job which is on the top of the job queue.
  157. */
  158. struct dma_fence *dependency;
  159. /**
  160. * @cb:
  161. *
  162. * Callback for the dependency fence above.
  163. */
  164. struct dma_fence_cb cb;
  165. /**
  166. * @guilty:
  167. *
  168. * Points to entities' guilty.
  169. */
  170. atomic_t *guilty;
  171. /**
  172. * @last_scheduled:
  173. *
  174. * Points to the finished fence of the last scheduled job. Only written
  175. * by the scheduler thread, can be accessed locklessly from
  176. * drm_sched_job_arm() iff the queue is empty.
  177. */
  178. struct dma_fence __rcu *last_scheduled;
  179. /**
  180. * @last_user: last group leader pushing a job into the entity.
  181. */
  182. struct task_struct *last_user;
  183. /**
  184. * @stopped:
  185. *
  186. * Marks the enity as removed from rq and destined for
  187. * termination. This is set by calling drm_sched_entity_flush() and by
  188. * drm_sched_fini().
  189. */
  190. bool stopped;
  191. /**
  192. * @entity_idle:
  193. *
  194. * Signals when entity is not in use, used to sequence entity cleanup in
  195. * drm_sched_entity_fini().
  196. */
  197. struct completion entity_idle;
  198. /**
  199. * @oldest_job_waiting:
  200. *
  201. * Marks earliest job waiting in SW queue
  202. */
  203. ktime_t oldest_job_waiting;
  204. /**
  205. * @rb_tree_node:
  206. *
  207. * The node used to insert this entity into time based priority queue
  208. */
  209. struct rb_node rb_tree_node;
  210. };
  211. /**
  212. * struct drm_sched_rq - queue of entities to be scheduled.
  213. *
  214. * @lock: to modify the entities list.
  215. * @sched: the scheduler to which this rq belongs to.
  216. * @entities: list of the entities to be scheduled.
  217. * @current_entity: the entity which is to be scheduled.
  218. * @rb_tree_root: root of time based priory queue of entities for FIFO scheduling
  219. *
  220. * Run queue is a set of entities scheduling command submissions for
  221. * one specific ring. It implements the scheduling policy that selects
  222. * the next entity to emit commands from.
  223. */
  224. struct drm_sched_rq {
  225. spinlock_t lock;
  226. struct drm_gpu_scheduler *sched;
  227. struct list_head entities;
  228. struct drm_sched_entity *current_entity;
  229. struct rb_root_cached rb_tree_root;
  230. };
  231. /**
  232. * struct drm_sched_fence - fences corresponding to the scheduling of a job.
  233. */
  234. struct drm_sched_fence {
  235. /**
  236. * @scheduled: this fence is what will be signaled by the scheduler
  237. * when the job is scheduled.
  238. */
  239. struct dma_fence scheduled;
  240. /**
  241. * @finished: this fence is what will be signaled by the scheduler
  242. * when the job is completed.
  243. *
  244. * When setting up an out fence for the job, you should use
  245. * this, since it's available immediately upon
  246. * drm_sched_job_init(), and the fence returned by the driver
  247. * from run_job() won't be created until the dependencies have
  248. * resolved.
  249. */
  250. struct dma_fence finished;
  251. /**
  252. * @deadline: deadline set on &drm_sched_fence.finished which
  253. * potentially needs to be propagated to &drm_sched_fence.parent
  254. */
  255. ktime_t deadline;
  256. /**
  257. * @parent: the fence returned by &drm_sched_backend_ops.run_job
  258. * when scheduling the job on hardware. We signal the
  259. * &drm_sched_fence.finished fence once parent is signalled.
  260. */
  261. struct dma_fence *parent;
  262. /**
  263. * @sched: the scheduler instance to which the job having this struct
  264. * belongs to.
  265. */
  266. struct drm_gpu_scheduler *sched;
  267. /**
  268. * @lock: the lock used by the scheduled and the finished fences.
  269. */
  270. spinlock_t lock;
  271. /**
  272. * @owner: job owner for debugging
  273. */
  274. void *owner;
  275. };
  276. struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f);
  277. /**
  278. * struct drm_sched_job - A job to be run by an entity.
  279. *
  280. * @queue_node: used to append this struct to the queue of jobs in an entity.
  281. * @list: a job participates in a "pending" and "done" lists.
  282. * @sched: the scheduler instance on which this job is scheduled.
  283. * @s_fence: contains the fences for the scheduling of job.
  284. * @finish_cb: the callback for the finished fence.
  285. * @credits: the number of credits this job contributes to the scheduler
  286. * @work: Helper to reschdeule job kill to different context.
  287. * @id: a unique id assigned to each job scheduled on the scheduler.
  288. * @karma: increment on every hang caused by this job. If this exceeds the hang
  289. * limit of the scheduler then the job is marked guilty and will not
  290. * be scheduled further.
  291. * @s_priority: the priority of the job.
  292. * @entity: the entity to which this job belongs.
  293. * @cb: the callback for the parent fence in s_fence.
  294. *
  295. * A job is created by the driver using drm_sched_job_init(), and
  296. * should call drm_sched_entity_push_job() once it wants the scheduler
  297. * to schedule the job.
  298. */
  299. struct drm_sched_job {
  300. struct spsc_node queue_node;
  301. struct list_head list;
  302. struct drm_gpu_scheduler *sched;
  303. struct drm_sched_fence *s_fence;
  304. u32 credits;
  305. /*
  306. * work is used only after finish_cb has been used and will not be
  307. * accessed anymore.
  308. */
  309. union {
  310. struct dma_fence_cb finish_cb;
  311. struct work_struct work;
  312. };
  313. uint64_t id;
  314. atomic_t karma;
  315. enum drm_sched_priority s_priority;
  316. struct drm_sched_entity *entity;
  317. struct dma_fence_cb cb;
  318. /**
  319. * @dependencies:
  320. *
  321. * Contains the dependencies as struct dma_fence for this job, see
  322. * drm_sched_job_add_dependency() and
  323. * drm_sched_job_add_implicit_dependencies().
  324. */
  325. struct xarray dependencies;
  326. /** @last_dependency: tracks @dependencies as they signal */
  327. unsigned long last_dependency;
  328. /**
  329. * @submit_ts:
  330. *
  331. * When the job was pushed into the entity queue.
  332. */
  333. ktime_t submit_ts;
  334. };
  335. static inline bool drm_sched_invalidate_job(struct drm_sched_job *s_job,
  336. int threshold)
  337. {
  338. return s_job && atomic_inc_return(&s_job->karma) > threshold;
  339. }
  340. enum drm_gpu_sched_stat {
  341. DRM_GPU_SCHED_STAT_NONE, /* Reserve 0 */
  342. DRM_GPU_SCHED_STAT_NOMINAL,
  343. DRM_GPU_SCHED_STAT_ENODEV,
  344. };
  345. /**
  346. * struct drm_sched_backend_ops - Define the backend operations
  347. * called by the scheduler
  348. *
  349. * These functions should be implemented in the driver side.
  350. */
  351. struct drm_sched_backend_ops {
  352. /**
  353. * @prepare_job:
  354. *
  355. * Called when the scheduler is considering scheduling this job next, to
  356. * get another struct dma_fence for this job to block on. Once it
  357. * returns NULL, run_job() may be called.
  358. *
  359. * Can be NULL if no additional preparation to the dependencies are
  360. * necessary. Skipped when jobs are killed instead of run.
  361. */
  362. struct dma_fence *(*prepare_job)(struct drm_sched_job *sched_job,
  363. struct drm_sched_entity *s_entity);
  364. /**
  365. * @run_job: Called to execute the job once all of the dependencies
  366. * have been resolved. This may be called multiple times, if
  367. * timedout_job() has happened and drm_sched_job_recovery()
  368. * decides to try it again.
  369. */
  370. struct dma_fence *(*run_job)(struct drm_sched_job *sched_job);
  371. /**
  372. * @timedout_job: Called when a job has taken too long to execute,
  373. * to trigger GPU recovery.
  374. *
  375. * This method is called in a workqueue context.
  376. *
  377. * Drivers typically issue a reset to recover from GPU hangs, and this
  378. * procedure usually follows the following workflow:
  379. *
  380. * 1. Stop the scheduler using drm_sched_stop(). This will park the
  381. * scheduler thread and cancel the timeout work, guaranteeing that
  382. * nothing is queued while we reset the hardware queue
  383. * 2. Try to gracefully stop non-faulty jobs (optional)
  384. * 3. Issue a GPU reset (driver-specific)
  385. * 4. Re-submit jobs using drm_sched_resubmit_jobs()
  386. * 5. Restart the scheduler using drm_sched_start(). At that point, new
  387. * jobs can be queued, and the scheduler thread is unblocked
  388. *
  389. * Note that some GPUs have distinct hardware queues but need to reset
  390. * the GPU globally, which requires extra synchronization between the
  391. * timeout handler of the different &drm_gpu_scheduler. One way to
  392. * achieve this synchronization is to create an ordered workqueue
  393. * (using alloc_ordered_workqueue()) at the driver level, and pass this
  394. * queue to drm_sched_init(), to guarantee that timeout handlers are
  395. * executed sequentially. The above workflow needs to be slightly
  396. * adjusted in that case:
  397. *
  398. * 1. Stop all schedulers impacted by the reset using drm_sched_stop()
  399. * 2. Try to gracefully stop non-faulty jobs on all queues impacted by
  400. * the reset (optional)
  401. * 3. Issue a GPU reset on all faulty queues (driver-specific)
  402. * 4. Re-submit jobs on all schedulers impacted by the reset using
  403. * drm_sched_resubmit_jobs()
  404. * 5. Restart all schedulers that were stopped in step #1 using
  405. * drm_sched_start()
  406. *
  407. * Return DRM_GPU_SCHED_STAT_NOMINAL, when all is normal,
  408. * and the underlying driver has started or completed recovery.
  409. *
  410. * Return DRM_GPU_SCHED_STAT_ENODEV, if the device is no longer
  411. * available, i.e. has been unplugged.
  412. */
  413. enum drm_gpu_sched_stat (*timedout_job)(struct drm_sched_job *sched_job);
  414. /**
  415. * @free_job: Called once the job's finished fence has been signaled
  416. * and it's time to clean it up.
  417. */
  418. void (*free_job)(struct drm_sched_job *sched_job);
  419. /**
  420. * @update_job_credits: Called when the scheduler is considering this
  421. * job for execution.
  422. *
  423. * This callback returns the number of credits the job would take if
  424. * pushed to the hardware. Drivers may use this to dynamically update
  425. * the job's credit count. For instance, deduct the number of credits
  426. * for already signalled native fences.
  427. *
  428. * This callback is optional.
  429. */
  430. u32 (*update_job_credits)(struct drm_sched_job *sched_job);
  431. };
  432. /**
  433. * struct drm_gpu_scheduler - scheduler instance-specific data
  434. *
  435. * @ops: backend operations provided by the driver.
  436. * @credit_limit: the credit limit of this scheduler
  437. * @credit_count: the current credit count of this scheduler
  438. * @timeout: the time after which a job is removed from the scheduler.
  439. * @name: name of the ring for which this scheduler is being used.
  440. * @num_rqs: Number of run-queues. This is at most DRM_SCHED_PRIORITY_COUNT,
  441. * as there's usually one run-queue per priority, but could be less.
  442. * @sched_rq: An allocated array of run-queues of size @num_rqs;
  443. * @job_scheduled: once @drm_sched_entity_do_release is called the scheduler
  444. * waits on this wait queue until all the scheduled jobs are
  445. * finished.
  446. * @job_id_count: used to assign unique id to the each job.
  447. * @submit_wq: workqueue used to queue @work_run_job and @work_free_job
  448. * @timeout_wq: workqueue used to queue @work_tdr
  449. * @work_run_job: work which calls run_job op of each scheduler.
  450. * @work_free_job: work which calls free_job op of each scheduler.
  451. * @work_tdr: schedules a delayed call to @drm_sched_job_timedout after the
  452. * timeout interval is over.
  453. * @pending_list: the list of jobs which are currently in the job queue.
  454. * @job_list_lock: lock to protect the pending_list.
  455. * @hang_limit: once the hangs by a job crosses this limit then it is marked
  456. * guilty and it will no longer be considered for scheduling.
  457. * @score: score to help loadbalancer pick a idle sched
  458. * @_score: score used when the driver doesn't provide one
  459. * @ready: marks if the underlying HW is ready to work
  460. * @free_guilty: A hit to time out handler to free the guilty job.
  461. * @pause_submit: pause queuing of @work_run_job on @submit_wq
  462. * @own_submit_wq: scheduler owns allocation of @submit_wq
  463. * @dev: system &struct device
  464. *
  465. * One scheduler is implemented for each hardware ring.
  466. */
  467. struct drm_gpu_scheduler {
  468. const struct drm_sched_backend_ops *ops;
  469. u32 credit_limit;
  470. atomic_t credit_count;
  471. long timeout;
  472. const char *name;
  473. u32 num_rqs;
  474. struct drm_sched_rq **sched_rq;
  475. wait_queue_head_t job_scheduled;
  476. atomic64_t job_id_count;
  477. struct workqueue_struct *submit_wq;
  478. struct workqueue_struct *timeout_wq;
  479. struct work_struct work_run_job;
  480. struct work_struct work_free_job;
  481. struct delayed_work work_tdr;
  482. struct list_head pending_list;
  483. spinlock_t job_list_lock;
  484. int hang_limit;
  485. atomic_t *score;
  486. atomic_t _score;
  487. bool ready;
  488. bool free_guilty;
  489. bool pause_submit;
  490. bool own_submit_wq;
  491. struct device *dev;
  492. };
  493. int drm_sched_init(struct drm_gpu_scheduler *sched,
  494. const struct drm_sched_backend_ops *ops,
  495. struct workqueue_struct *submit_wq,
  496. u32 num_rqs, u32 credit_limit, unsigned int hang_limit,
  497. long timeout, struct workqueue_struct *timeout_wq,
  498. atomic_t *score, const char *name, struct device *dev);
  499. void drm_sched_fini(struct drm_gpu_scheduler *sched);
  500. int drm_sched_job_init(struct drm_sched_job *job,
  501. struct drm_sched_entity *entity,
  502. u32 credits, void *owner);
  503. void drm_sched_job_arm(struct drm_sched_job *job);
  504. int drm_sched_job_add_dependency(struct drm_sched_job *job,
  505. struct dma_fence *fence);
  506. int drm_sched_job_add_syncobj_dependency(struct drm_sched_job *job,
  507. struct drm_file *file,
  508. u32 handle,
  509. u32 point);
  510. int drm_sched_job_add_resv_dependencies(struct drm_sched_job *job,
  511. struct dma_resv *resv,
  512. enum dma_resv_usage usage);
  513. int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job,
  514. struct drm_gem_object *obj,
  515. bool write);
  516. void drm_sched_entity_modify_sched(struct drm_sched_entity *entity,
  517. struct drm_gpu_scheduler **sched_list,
  518. unsigned int num_sched_list);
  519. void drm_sched_tdr_queue_imm(struct drm_gpu_scheduler *sched);
  520. void drm_sched_job_cleanup(struct drm_sched_job *job);
  521. void drm_sched_wakeup(struct drm_gpu_scheduler *sched);
  522. bool drm_sched_wqueue_ready(struct drm_gpu_scheduler *sched);
  523. void drm_sched_wqueue_stop(struct drm_gpu_scheduler *sched);
  524. void drm_sched_wqueue_start(struct drm_gpu_scheduler *sched);
  525. void drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad);
  526. void drm_sched_start(struct drm_gpu_scheduler *sched);
  527. void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched);
  528. void drm_sched_increase_karma(struct drm_sched_job *bad);
  529. void drm_sched_reset_karma(struct drm_sched_job *bad);
  530. void drm_sched_increase_karma_ext(struct drm_sched_job *bad, int type);
  531. bool drm_sched_dependency_optimized(struct dma_fence* fence,
  532. struct drm_sched_entity *entity);
  533. void drm_sched_fault(struct drm_gpu_scheduler *sched);
  534. void drm_sched_rq_add_entity(struct drm_sched_rq *rq,
  535. struct drm_sched_entity *entity);
  536. void drm_sched_rq_remove_entity(struct drm_sched_rq *rq,
  537. struct drm_sched_entity *entity);
  538. void drm_sched_rq_update_fifo(struct drm_sched_entity *entity, ktime_t ts);
  539. int drm_sched_entity_init(struct drm_sched_entity *entity,
  540. enum drm_sched_priority priority,
  541. struct drm_gpu_scheduler **sched_list,
  542. unsigned int num_sched_list,
  543. atomic_t *guilty);
  544. long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout);
  545. void drm_sched_entity_fini(struct drm_sched_entity *entity);
  546. void drm_sched_entity_destroy(struct drm_sched_entity *entity);
  547. void drm_sched_entity_select_rq(struct drm_sched_entity *entity);
  548. struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity);
  549. void drm_sched_entity_push_job(struct drm_sched_job *sched_job);
  550. void drm_sched_entity_set_priority(struct drm_sched_entity *entity,
  551. enum drm_sched_priority priority);
  552. bool drm_sched_entity_is_ready(struct drm_sched_entity *entity);
  553. int drm_sched_entity_error(struct drm_sched_entity *entity);
  554. struct drm_sched_fence *drm_sched_fence_alloc(
  555. struct drm_sched_entity *s_entity, void *owner);
  556. void drm_sched_fence_init(struct drm_sched_fence *fence,
  557. struct drm_sched_entity *entity);
  558. void drm_sched_fence_free(struct drm_sched_fence *fence);
  559. void drm_sched_fence_scheduled(struct drm_sched_fence *fence,
  560. struct dma_fence *parent);
  561. void drm_sched_fence_finished(struct drm_sched_fence *fence, int result);
  562. unsigned long drm_sched_suspend_timeout(struct drm_gpu_scheduler *sched);
  563. void drm_sched_resume_timeout(struct drm_gpu_scheduler *sched,
  564. unsigned long remaining);
  565. struct drm_gpu_scheduler *
  566. drm_sched_pick_best(struct drm_gpu_scheduler **sched_list,
  567. unsigned int num_sched_list);
  568. #endif