1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2021 Intel Corporation 4 */ 5 6 #ifndef _XE_EXEC_QUEUE_H_ 7 #define _XE_EXEC_QUEUE_H_ 8 9 #include "xe_exec_queue_types.h" 10 #include "xe_vm_types.h" 11 12 struct drm_device; 13 struct drm_file; 14 struct xe_device; 15 struct xe_file; 16 17 #define for_each_tlb_inval(__i) \ 18 for (__i = XE_EXEC_QUEUE_TLB_INVAL_PRIMARY_GT; \ 19 __i <= XE_EXEC_QUEUE_TLB_INVAL_MEDIA_GT; ++__i) 20 21 struct xe_exec_queue *xe_exec_queue_create(struct xe_device *xe, struct xe_vm *vm, 22 u32 logical_mask, u16 width, 23 struct xe_hw_engine *hw_engine, u32 flags, 24 u64 extensions); 25 struct xe_exec_queue *xe_exec_queue_create_class(struct xe_device *xe, struct xe_gt *gt, 26 struct xe_vm *vm, 27 enum xe_engine_class class, 28 u32 flags, u64 extensions); 29 struct xe_exec_queue *xe_exec_queue_create_bind(struct xe_device *xe, 30 struct xe_tile *tile, 31 u32 flags, u64 extensions); 32 33 void xe_exec_queue_fini(struct xe_exec_queue *q); 34 void xe_exec_queue_destroy(struct kref *ref); 35 void xe_exec_queue_assign_name(struct xe_exec_queue *q, u32 instance); 36 37 static inline struct xe_exec_queue * 38 xe_exec_queue_get_unless_zero(struct xe_exec_queue *q) 39 { 40 if (kref_get_unless_zero(&q->refcount)) 41 return q; 42 43 return NULL; 44 } 45 46 struct xe_exec_queue *xe_exec_queue_lookup(struct xe_file *xef, u32 id); 47 48 static inline struct xe_exec_queue *xe_exec_queue_get(struct xe_exec_queue *q) 49 { 50 kref_get(&q->refcount); 51 return q; 52 } 53 54 static inline void xe_exec_queue_put(struct xe_exec_queue *q) 55 { 56 kref_put(&q->refcount, xe_exec_queue_destroy); 57 } 58 59 static inline bool xe_exec_queue_is_parallel(struct xe_exec_queue *q) 60 { 61 return q->width > 1; 62 } 63 64 static inline bool xe_exec_queue_uses_pxp(struct xe_exec_queue *q) 65 { 66 return q->pxp.type; 67 } 68 69 bool xe_exec_queue_is_lr(struct xe_exec_queue *q); 70 71 bool xe_exec_queue_is_idle(struct xe_exec_queue *q); 72 73 void xe_exec_queue_kill(struct xe_exec_queue *q); 74 75 int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data, 76 struct drm_file *file); 77 int xe_exec_queue_destroy_ioctl(struct drm_device *dev, void *data, 78 struct drm_file *file); 79 int xe_exec_queue_get_property_ioctl(struct drm_device *dev, void *data, 80 struct drm_file *file); 81 enum xe_exec_queue_priority xe_exec_queue_device_get_max_priority(struct xe_device *xe); 82 83 void xe_exec_queue_last_fence_put(struct xe_exec_queue *e, struct xe_vm *vm); 84 void xe_exec_queue_last_fence_put_unlocked(struct xe_exec_queue *e); 85 struct dma_fence *xe_exec_queue_last_fence_get(struct xe_exec_queue *e, 86 struct xe_vm *vm); 87 struct dma_fence *xe_exec_queue_last_fence_get_for_resume(struct xe_exec_queue *e, 88 struct xe_vm *vm); 89 void xe_exec_queue_last_fence_set(struct xe_exec_queue *e, struct xe_vm *vm, 90 struct dma_fence *fence); 91 92 void xe_exec_queue_tlb_inval_last_fence_put(struct xe_exec_queue *q, 93 struct xe_vm *vm, 94 unsigned int type); 95 96 void xe_exec_queue_tlb_inval_last_fence_put_unlocked(struct xe_exec_queue *q, 97 unsigned int type); 98 99 struct dma_fence *xe_exec_queue_tlb_inval_last_fence_get(struct xe_exec_queue *q, 100 struct xe_vm *vm, 101 unsigned int type); 102 103 void xe_exec_queue_tlb_inval_last_fence_set(struct xe_exec_queue *q, 104 struct xe_vm *vm, 105 struct dma_fence *fence, 106 unsigned int type); 107 108 void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q); 109 110 int xe_exec_queue_contexts_hwsp_rebase(struct xe_exec_queue *q, void *scratch); 111 112 struct xe_lrc *xe_exec_queue_lrc(struct xe_exec_queue *q); 113 114 #endif 115