drm/xe/migrate: Add kerneldoc for the migrate subsystem
[linux-2.6-microblaze.git] / drivers / gpu / drm / xe / xe_migrate.h
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2020 Intel Corporation
4  */
5
6 #ifndef __XE_MIGRATE__
7 #define __XE_MIGRATE__
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;
17 struct xe_engine;
18 struct xe_migrate;
19 struct xe_migrate_pt_update;
20 struct xe_sync_entry;
21 struct xe_pt;
22 struct xe_vm;
23 struct xe_vm_pgtable_update;
24 struct xe_vma;
25
26 /**
27  * struct xe_migrate_pt_update_ops - Callbacks for the
28  * xe_migrate_update_pgtables() function.
29  */
30 struct xe_migrate_pt_update_ops {
31         /**
32          * @populate: Populate a command buffer or page-table with ptes.
33          * @pt_update: Embeddable callback argument.
34          * @gt: The gt for the current operation.
35          * @map: struct iosys_map into the memory to be populated.
36          * @pos: If @map is NULL, map into the memory to be populated.
37          * @ofs: qword offset into @map, unused if @map is NULL.
38          * @num_qwords: Number of qwords to write.
39          * @update: Information about the PTEs to be inserted.
40          *
41          * This interface is intended to be used as a callback into the
42          * page-table system to populate command buffers or shared
43          * page-tables with PTEs.
44          */
45         void (*populate)(struct xe_migrate_pt_update *pt_update,
46                          struct xe_gt *gt, struct iosys_map *map,
47                          void *pos, u32 ofs, u32 num_qwords,
48                          const struct xe_vm_pgtable_update *update);
49
50         /**
51          * @pre_commit: Callback to be called just before arming the
52          * sched_job.
53          * @pt_update: Pointer to embeddable callback argument.
54          *
55          * Return: 0 on success, negative error code on error.
56          */
57         int (*pre_commit)(struct xe_migrate_pt_update *pt_update);
58 };
59
60 /**
61  * struct xe_migrate_pt_update - Argument to the
62  * struct xe_migrate_pt_update_ops callbacks.
63  *
64  * Intended to be subclassed to support additional arguments if necessary.
65  */
66 struct xe_migrate_pt_update {
67         /** @ops: Pointer to the struct xe_migrate_pt_update_ops callbacks */
68         const struct xe_migrate_pt_update_ops *ops;
69         /** @vma: The vma we're updating the pagetable for. */
70         struct xe_vma *vma;
71 };
72
73 struct xe_migrate *xe_migrate_init(struct xe_gt *gt);
74
75 struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
76                                   struct xe_bo *bo,
77                                   struct ttm_resource *src,
78                                   struct ttm_resource *dst);
79
80 struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
81                                    struct xe_bo *bo,
82                                    struct ttm_resource *dst,
83                                    u32 value);
84
85 struct xe_vm *xe_migrate_get_vm(struct xe_migrate *m);
86
87 struct dma_fence *
88 xe_migrate_update_pgtables(struct xe_migrate *m,
89                            struct xe_vm *vm,
90                            struct xe_bo *bo,
91                            struct xe_engine *eng,
92                            const struct xe_vm_pgtable_update *updates,
93                            u32 num_updates,
94                            struct xe_sync_entry *syncs, u32 num_syncs,
95                            struct xe_migrate_pt_update *pt_update);
96
97 void xe_migrate_wait(struct xe_migrate *m);
98
99 struct xe_engine *xe_gt_migrate_engine(struct xe_gt *gt);
100 #endif