1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2021 Intel Corporation 4 */ 5 6 #ifndef _XE_SCHED_JOB_H_ 7 #define _XE_SCHED_JOB_H_ 8 9 #include "xe_sched_job_types.h" 10 11 struct xe_vm; 12 13 #define XE_SCHED_HANG_LIMIT 1 14 #define XE_SCHED_JOB_TIMEOUT LONG_MAX 15 16 int xe_sched_job_module_init(void); 17 void xe_sched_job_module_exit(void); 18 19 struct xe_sched_job *xe_sched_job_create(struct xe_exec_queue *q, 20 u64 *batch_addr); 21 void xe_sched_job_destroy(struct kref *ref); 22 23 /** 24 * xe_sched_job_get - get reference to XE schedule job 25 * @job: XE schedule job object 26 * 27 * Increment XE schedule job's reference count 28 */ 29 static inline struct xe_sched_job *xe_sched_job_get(struct xe_sched_job *job) 30 { 31 kref_get(&job->refcount); 32 return job; 33 } 34 35 /** 36 * xe_sched_job_put - put reference to XE schedule job 37 * @job: XE schedule job object 38 * 39 * Decrement XE schedule job's reference count, call xe_sched_job_destroy when 40 * reference count == 0. 41 */ 42 static inline void xe_sched_job_put(struct xe_sched_job *job) 43 { 44 kref_put(&job->refcount, xe_sched_job_destroy); 45 } 46 47 void xe_sched_job_set_error(struct xe_sched_job *job, int error); 48 static inline bool xe_sched_job_is_error(struct xe_sched_job *job) 49 { 50 return job->fence->error < 0; 51 } 52 53 bool xe_sched_job_started(struct xe_sched_job *job); 54 bool xe_sched_job_completed(struct xe_sched_job *job); 55 56 void xe_sched_job_arm(struct xe_sched_job *job); 57 void xe_sched_job_push(struct xe_sched_job *job); 58 59 int xe_sched_job_last_fence_add_dep(struct xe_sched_job *job, struct xe_vm *vm); 60 61 static inline struct xe_sched_job * 62 to_xe_sched_job(struct drm_sched_job *drm) 63 { 64 return container_of(drm, struct xe_sched_job, drm); 65 } 66 67 static inline u32 xe_sched_job_seqno(struct xe_sched_job *job) 68 { 69 return job->fence->seqno; 70 } 71 72 static inline void 73 xe_sched_job_add_migrate_flush(struct xe_sched_job *job, u32 flags) 74 { 75 job->migrate_flush_flags = flags; 76 } 77 78 bool xe_sched_job_is_migration(struct xe_exec_queue *q); 79 80 #endif 81