1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2026 Intel Corporation 4 */ 5 6 #ifndef _XE_CPU_BIND_H_ 7 #define _XE_CPU_BIND_H_ 8 9 #include <linux/types.h> 10 11 struct dma_fence; 12 struct iosys_map; 13 struct xe_cpu_bind; 14 struct xe_cpu_bind_pt_update; 15 struct xe_device; 16 struct xe_tlb_inval_job; 17 struct xe_tile; 18 struct xe_vm; 19 struct xe_vm_pgtable_update; 20 struct xe_vm_pgtable_update_op; 21 struct xe_vma_ops; 22 23 /** 24 * struct xe_cpu_bind_pt_update_ops - Callbacks for the 25 * xe_cpu_bind_update_pgtables() function. 26 */ 27 struct xe_cpu_bind_pt_update_ops { 28 /** 29 * @populate: Populate a page-table with ptes. 30 * @tile: The tile for the current operation. 31 * @map: struct iosys_map into the memory to be populated. 32 * @update: Information about the PTEs to be inserted. 33 * 34 * This interface is intended to be used as a callback into the 35 * page-table system to populate shared page-tables with PTEs. 36 */ 37 void (*populate)(struct xe_tile *tile, struct iosys_map *map, 38 const struct xe_vm_pgtable_update *update); 39 /** 40 * @clear: Clear a page-table's ptes. 41 * @vm: VM being updated 42 * @tile: The tile for the current operation. 43 * @map: struct iosys_map into the page-table to be cleared. 44 * @update: Information about the PTEs to be cleared. 45 * 46 * This interface is intended to be used as a callback into the 47 * page-table system to clear PTEs from shared page-tables. 48 */ 49 void (*clear)(struct xe_vm *vm, struct xe_tile *tile, 50 struct iosys_map *map, 51 const struct xe_vm_pgtable_update *update); 52 53 /** 54 * @pre_commit: Callback to be called just before arming the 55 * sched_job. 56 * @pt_update: Pointer to embeddable callback argument. 57 * 58 * Return: 0 on success, negative error code on error. 59 */ 60 int (*pre_commit)(struct xe_cpu_bind_pt_update *pt_update); 61 }; 62 63 /** 64 * struct xe_cpu_bind_pt_update - Argument to the struct 65 * xe_cpu_bind_pt_update_ops callbacks. 66 * 67 * Intended to be subclassed to support additional arguments if necessary. 68 */ 69 struct xe_cpu_bind_pt_update { 70 /** @ops: Pointer to the struct xe_cpu_bind_pt_update_ops callbacks */ 71 const struct xe_cpu_bind_pt_update_ops *ops; 72 /** @vops: VMA operations */ 73 struct xe_vma_ops *vops; 74 /** @job: The bind job, or NULL if the update is issued immediatel */ 75 struct xe_sched_job *job; 76 /** 77 * @ijobs: The TLB invalidation jobs, individual instances can be NULL 78 */ 79 #define XE_CPU_BIND_INVAL_JOB_COUNT 4 80 struct xe_tlb_inval_job *ijobs[XE_CPU_BIND_INVAL_JOB_COUNT]; 81 }; 82 83 int xe_cpu_bind_init(struct xe_device *xe); 84 85 struct xe_exec_queue *xe_cpu_bind_queue(struct xe_cpu_bind *cpu_bind); 86 87 void 88 xe_cpu_bind_update_pgtables_execute(struct xe_vm *vm, struct xe_tile *tile, 89 const struct xe_cpu_bind_pt_update_ops *ops, 90 struct xe_vm_pgtable_update_op *pt_op, 91 u32 num_ops, bool force_clear); 92 93 struct dma_fence * 94 xe_cpu_bind_update_pgtables(struct xe_cpu_bind *cpu_bind, 95 struct xe_cpu_bind_pt_update *pt_update); 96 97 void xe_cpu_bind_job_lock(struct xe_cpu_bind *cpu_bind, 98 struct xe_exec_queue *q); 99 100 void xe_cpu_bind_job_unlock(struct xe_cpu_bind *cpu_bind, 101 struct xe_exec_queue *q); 102 103 #if IS_ENABLED(CONFIG_PROVE_LOCKING) 104 void xe_cpu_bind_job_lock_assert(struct xe_exec_queue *q); 105 #else 106 static inline void xe_cpu_bind_job_lock_assert(struct xe_exec_queue *q) 107 { 108 } 109 #endif 110 111 #endif 112