1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2020 Intel Corporation
9 #include <linux/types.h>
19 struct xe_migrate_pt_update;
24 struct xe_vm_pgtable_update;
28 * struct xe_migrate_pt_update_ops - Callbacks for the
29 * xe_migrate_update_pgtables() function.
31 struct xe_migrate_pt_update_ops {
33 * @populate: Populate a command buffer or page-table with ptes.
34 * @pt_update: Embeddable callback argument.
35 * @tile: The tile for the current operation.
36 * @map: struct iosys_map into the memory to be populated.
37 * @pos: If @map is NULL, map into the memory to be populated.
38 * @ofs: qword offset into @map, unused if @map is NULL.
39 * @num_qwords: Number of qwords to write.
40 * @update: Information about the PTEs to be inserted.
42 * This interface is intended to be used as a callback into the
43 * page-table system to populate command buffers or shared
44 * page-tables with PTEs.
46 void (*populate)(struct xe_migrate_pt_update *pt_update,
47 struct xe_tile *tile, struct iosys_map *map,
48 void *pos, u32 ofs, u32 num_qwords,
49 const struct xe_vm_pgtable_update *update);
51 * @clear: Clear a command buffer or page-table with ptes.
52 * @pt_update: Embeddable callback argument.
53 * @tile: The tile for the current operation.
54 * @map: struct iosys_map into the memory to be populated.
55 * @pos: If @map is NULL, map into the memory to be populated.
56 * @ofs: qword offset into @map, unused if @map is NULL.
57 * @num_qwords: Number of qwords to write.
58 * @update: Information about the PTEs to be inserted.
60 * This interface is intended to be used as a callback into the
61 * page-table system to populate command buffers or shared
62 * page-tables with PTEs.
64 void (*clear)(struct xe_migrate_pt_update *pt_update,
65 struct xe_tile *tile, struct iosys_map *map,
66 void *pos, u32 ofs, u32 num_qwords,
67 const struct xe_vm_pgtable_update *update);
70 * @pre_commit: Callback to be called just before arming the
72 * @pt_update: Pointer to embeddable callback argument.
74 * Return: 0 on success, negative error code on error.
76 int (*pre_commit)(struct xe_migrate_pt_update *pt_update);
80 * struct xe_migrate_pt_update - Argument to the
81 * struct xe_migrate_pt_update_ops callbacks.
83 * Intended to be subclassed to support additional arguments if necessary.
85 struct xe_migrate_pt_update {
86 /** @ops: Pointer to the struct xe_migrate_pt_update_ops callbacks */
87 const struct xe_migrate_pt_update_ops *ops;
88 /** @vops: VMA operations */
89 struct xe_vma_ops *vops;
90 /** @job: The job if a GPU page-table update. NULL otherwise */
91 struct xe_sched_job *job;
92 /** @tile_id: Tile ID of the update */
96 struct xe_migrate *xe_migrate_init(struct xe_tile *tile);
98 struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
100 struct xe_bo *dst_bo,
101 struct ttm_resource *src,
102 struct ttm_resource *dst,
105 #define XE_MIGRATE_CLEAR_FLAG_BO_DATA BIT(0)
106 #define XE_MIGRATE_CLEAR_FLAG_CCS_DATA BIT(1)
107 #define XE_MIGRATE_CLEAR_FLAG_FULL (XE_MIGRATE_CLEAR_FLAG_BO_DATA | \
108 XE_MIGRATE_CLEAR_FLAG_CCS_DATA)
109 struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
111 struct ttm_resource *dst,
114 struct xe_vm *xe_migrate_get_vm(struct xe_migrate *m);
117 xe_migrate_update_pgtables(struct xe_migrate *m,
118 struct xe_migrate_pt_update *pt_update);
120 void xe_migrate_wait(struct xe_migrate *m);
122 struct xe_exec_queue *xe_tile_migrate_exec_queue(struct xe_tile *tile);