1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2022 Intel Corporation 4 */ 5 6 #ifndef _XE_EXEC_QUEUE_TYPES_H_ 7 #define _XE_EXEC_QUEUE_TYPES_H_ 8 9 #include <linux/kref.h> 10 11 #include <drm/gpu_scheduler.h> 12 13 #include "xe_gpu_scheduler_types.h" 14 #include "xe_hw_engine_types.h" 15 #include "xe_hw_fence_types.h" 16 #include "xe_lrc_types.h" 17 18 struct xe_execlist_exec_queue; 19 struct xe_gt; 20 struct xe_guc_exec_queue; 21 struct xe_hw_engine; 22 struct xe_vm; 23 24 enum xe_exec_queue_priority { 25 XE_EXEC_QUEUE_PRIORITY_UNSET = -2, /* For execlist usage only */ 26 XE_EXEC_QUEUE_PRIORITY_LOW = 0, 27 XE_EXEC_QUEUE_PRIORITY_NORMAL, 28 XE_EXEC_QUEUE_PRIORITY_HIGH, 29 XE_EXEC_QUEUE_PRIORITY_KERNEL, 30 31 XE_EXEC_QUEUE_PRIORITY_COUNT 32 }; 33 34 /** 35 * struct xe_exec_queue - Execution queue 36 * 37 * Contains all state necessary for submissions. Can either be a user object or 38 * a kernel object. 39 */ 40 struct xe_exec_queue { 41 /** @xef: Back pointer to xe file if this is user created exec queue */ 42 struct xe_file *xef; 43 44 /** @gt: graphics tile this exec queue can submit to */ 45 struct xe_gt *gt; 46 /** 47 * @hwe: A hardware of the same class. May (physical engine) or may not 48 * (virtual engine) be where jobs actual engine up running. Should never 49 * really be used for submissions. 50 */ 51 struct xe_hw_engine *hwe; 52 /** @refcount: ref count of this exec queue */ 53 struct kref refcount; 54 /** @vm: VM (address space) for this exec queue */ 55 struct xe_vm *vm; 56 /** @class: class of this exec queue */ 57 enum xe_engine_class class; 58 /** 59 * @logical_mask: logical mask of where job submitted to exec queue can run 60 */ 61 u32 logical_mask; 62 /** @name: name of this exec queue */ 63 char name[MAX_FENCE_NAME_LEN]; 64 /** @width: width (number BB submitted per exec) of this exec queue */ 65 u16 width; 66 /** @fence_irq: fence IRQ used to signal job completion */ 67 struct xe_hw_fence_irq *fence_irq; 68 69 /** 70 * @last_fence: last fence on exec queue, protected by vm->lock in write 71 * mode if bind exec queue, protected by dma resv lock if non-bind exec 72 * queue 73 */ 74 struct dma_fence *last_fence; 75 76 /* queue used for kernel submission only */ 77 #define EXEC_QUEUE_FLAG_KERNEL BIT(0) 78 /* kernel engine only destroyed at driver unload */ 79 #define EXEC_QUEUE_FLAG_PERMANENT BIT(1) 80 /* for VM jobs. Caller needs to hold rpm ref when creating queue with this flag */ 81 #define EXEC_QUEUE_FLAG_VM BIT(2) 82 /* child of VM queue for multi-tile VM jobs */ 83 #define EXEC_QUEUE_FLAG_BIND_ENGINE_CHILD BIT(3) 84 /* kernel exec_queue only, set priority to highest level */ 85 #define EXEC_QUEUE_FLAG_HIGH_PRIORITY BIT(4) 86 87 /** 88 * @flags: flags for this exec queue, should statically setup aside from ban 89 * bit 90 */ 91 unsigned long flags; 92 93 union { 94 /** @multi_gt_list: list head for VM bind engines if multi-GT */ 95 struct list_head multi_gt_list; 96 /** @multi_gt_link: link for VM bind engines if multi-GT */ 97 struct list_head multi_gt_link; 98 }; 99 100 union { 101 /** @execlist: execlist backend specific state for exec queue */ 102 struct xe_execlist_exec_queue *execlist; 103 /** @guc: GuC backend specific state for exec queue */ 104 struct xe_guc_exec_queue *guc; 105 }; 106 107 /** @sched_props: scheduling properties */ 108 struct { 109 /** @sched_props.timeslice_us: timeslice period in micro-seconds */ 110 u32 timeslice_us; 111 /** @sched_props.preempt_timeout_us: preemption timeout in micro-seconds */ 112 u32 preempt_timeout_us; 113 /** @sched_props.job_timeout_ms: job timeout in milliseconds */ 114 u32 job_timeout_ms; 115 /** @sched_props.priority: priority of this exec queue */ 116 enum xe_exec_queue_priority priority; 117 } sched_props; 118 119 /** @lr: long-running exec queue state */ 120 struct { 121 /** @lr.pfence: preemption fence */ 122 struct dma_fence *pfence; 123 /** @lr.context: preemption fence context */ 124 u64 context; 125 /** @lr.seqno: preemption fence seqno */ 126 u32 seqno; 127 /** @lr.link: link into VM's list of exec queues */ 128 struct list_head link; 129 } lr; 130 131 /** @ops: submission backend exec queue operations */ 132 const struct xe_exec_queue_ops *ops; 133 134 /** @ring_ops: ring operations for this exec queue */ 135 const struct xe_ring_ops *ring_ops; 136 /** @entity: DRM sched entity for this exec queue (1 to 1 relationship) */ 137 struct drm_sched_entity *entity; 138 /** 139 * @tlb_flush_seqno: The seqno of the last rebind tlb flush performed 140 * Protected by @vm's resv. Unused if @vm == NULL. 141 */ 142 u64 tlb_flush_seqno; 143 /** @hw_engine_group_link: link into exec queues in the same hw engine group */ 144 struct list_head hw_engine_group_link; 145 /** @lrc: logical ring context for this exec queue */ 146 struct xe_lrc *lrc[]; 147 }; 148 149 /** 150 * struct xe_exec_queue_ops - Submission backend exec queue operations 151 */ 152 struct xe_exec_queue_ops { 153 /** @init: Initialize exec queue for submission backend */ 154 int (*init)(struct xe_exec_queue *q); 155 /** @kill: Kill inflight submissions for backend */ 156 void (*kill)(struct xe_exec_queue *q); 157 /** @fini: Fini exec queue for submission backend */ 158 void (*fini)(struct xe_exec_queue *q); 159 /** @set_priority: Set priority for exec queue */ 160 int (*set_priority)(struct xe_exec_queue *q, 161 enum xe_exec_queue_priority priority); 162 /** @set_timeslice: Set timeslice for exec queue */ 163 int (*set_timeslice)(struct xe_exec_queue *q, u32 timeslice_us); 164 /** @set_preempt_timeout: Set preemption timeout for exec queue */ 165 int (*set_preempt_timeout)(struct xe_exec_queue *q, u32 preempt_timeout_us); 166 /** 167 * @suspend: Suspend exec queue from executing, allowed to be called 168 * multiple times in a row before resume with the caveat that 169 * suspend_wait returns before calling suspend again. 170 */ 171 int (*suspend)(struct xe_exec_queue *q); 172 /** 173 * @suspend_wait: Wait for an exec queue to suspend executing, should be 174 * call after suspend. In dma-fencing path thus must return within a 175 * reasonable amount of time. -ETIME return shall indicate an error 176 * waiting for suspend resulting in associated VM getting killed. 177 */ 178 int (*suspend_wait)(struct xe_exec_queue *q); 179 /** 180 * @resume: Resume exec queue execution, exec queue must be in a suspended 181 * state and dma fence returned from most recent suspend call must be 182 * signalled when this function is called. 183 */ 184 void (*resume)(struct xe_exec_queue *q); 185 /** @reset_status: check exec queue reset status */ 186 bool (*reset_status)(struct xe_exec_queue *q); 187 }; 188 189 #endif 190