Commit | Line | Data |
---|---|---|
dd08ebf6 MB |
1 | /* SPDX-License-Identifier: MIT */ |
2 | /* | |
3 | * Copyright © 2020 Intel Corporation | |
4 | */ | |
5 | ||
3457388f LDM |
6 | #ifndef _XE_MIGRATE_ |
7 | #define _XE_MIGRATE_ | |
dd08ebf6 MB |
8 | |
9 | #include <drm/drm_mm.h> | |
10 | ||
11 | struct dma_fence; | |
12 | struct iosys_map; | |
13 | struct ttm_resource; | |
14 | ||
15 | struct xe_bo; | |
16 | struct xe_gt; | |
9b9529ce | 17 | struct xe_exec_queue; |
dd08ebf6 MB |
18 | struct xe_migrate; |
19 | struct xe_migrate_pt_update; | |
20 | struct xe_sync_entry; | |
21 | struct xe_pt; | |
876611c2 | 22 | struct xe_tile; |
dd08ebf6 MB |
23 | struct xe_vm; |
24 | struct xe_vm_pgtable_update; | |
25 | struct xe_vma; | |
26 | ||
e9d285ff TH |
27 | /** |
28 | * struct xe_migrate_pt_update_ops - Callbacks for the | |
29 | * xe_migrate_update_pgtables() function. | |
30 | */ | |
dd08ebf6 MB |
31 | struct xe_migrate_pt_update_ops { |
32 | /** | |
e9d285ff | 33 | * @populate: Populate a command buffer or page-table with ptes. |
dd08ebf6 | 34 | * @pt_update: Embeddable callback argument. |
876611c2 | 35 | * @tile: The tile for the current operation. |
dd08ebf6 MB |
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. | |
41 | * | |
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. | |
45 | */ | |
46 | void (*populate)(struct xe_migrate_pt_update *pt_update, | |
876611c2 | 47 | struct xe_tile *tile, struct iosys_map *map, |
dd08ebf6 MB |
48 | void *pos, u32 ofs, u32 num_qwords, |
49 | const struct xe_vm_pgtable_update *update); | |
50 | ||
51 | /** | |
e9d285ff | 52 | * @pre_commit: Callback to be called just before arming the |
dd08ebf6 MB |
53 | * sched_job. |
54 | * @pt_update: Pointer to embeddable callback argument. | |
55 | * | |
56 | * Return: 0 on success, negative error code on error. | |
57 | */ | |
58 | int (*pre_commit)(struct xe_migrate_pt_update *pt_update); | |
59 | }; | |
60 | ||
e9d285ff TH |
61 | /** |
62 | * struct xe_migrate_pt_update - Argument to the | |
63 | * struct xe_migrate_pt_update_ops callbacks. | |
64 | * | |
65 | * Intended to be subclassed to support additional arguments if necessary. | |
66 | */ | |
dd08ebf6 | 67 | struct xe_migrate_pt_update { |
e9d285ff | 68 | /** @ops: Pointer to the struct xe_migrate_pt_update_ops callbacks */ |
dd08ebf6 | 69 | const struct xe_migrate_pt_update_ops *ops; |
e9d285ff | 70 | /** @vma: The vma we're updating the pagetable for. */ |
dd08ebf6 | 71 | struct xe_vma *vma; |
fd84041d MB |
72 | /** @job: The job if a GPU page-table update. NULL otherwise */ |
73 | struct xe_sched_job *job; | |
74 | /** @start: Start of update for the range fence */ | |
75 | u64 start; | |
76 | /** @last: Last of update for the range fence */ | |
77 | u64 last; | |
78 | /** @tile_id: Tile ID of the update */ | |
79 | u8 tile_id; | |
dd08ebf6 MB |
80 | }; |
81 | ||
08dea767 | 82 | struct xe_migrate *xe_migrate_init(struct xe_tile *tile); |
dd08ebf6 MB |
83 | |
84 | struct dma_fence *xe_migrate_copy(struct xe_migrate *m, | |
3690a01b TH |
85 | struct xe_bo *src_bo, |
86 | struct xe_bo *dst_bo, | |
dd08ebf6 | 87 | struct ttm_resource *src, |
266c8588 HPG |
88 | struct ttm_resource *dst, |
89 | bool copy_only_ccs); | |
dd08ebf6 MB |
90 | |
91 | struct dma_fence *xe_migrate_clear(struct xe_migrate *m, | |
92 | struct xe_bo *bo, | |
11a2407e | 93 | struct ttm_resource *dst); |
dd08ebf6 MB |
94 | |
95 | struct xe_vm *xe_migrate_get_vm(struct xe_migrate *m); | |
96 | ||
97 | struct dma_fence * | |
98 | xe_migrate_update_pgtables(struct xe_migrate *m, | |
99 | struct xe_vm *vm, | |
100 | struct xe_bo *bo, | |
9b9529ce | 101 | struct xe_exec_queue *q, |
dd08ebf6 MB |
102 | const struct xe_vm_pgtable_update *updates, |
103 | u32 num_updates, | |
104 | struct xe_sync_entry *syncs, u32 num_syncs, | |
105 | struct xe_migrate_pt_update *pt_update); | |
106 | ||
107 | void xe_migrate_wait(struct xe_migrate *m); | |
108 | ||
9b9529ce | 109 | struct xe_exec_queue *xe_tile_migrate_engine(struct xe_tile *tile); |
dd08ebf6 | 110 | #endif |