drm/xe/pat: Keep track of relevant indexes
[linux-2.6-microblaze.git] / drivers / gpu / drm / xe / xe_pt_types.h
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5
6 #ifndef _XE_PT_TYPES_H_
7 #define _XE_PT_TYPES_H_
8
9 #include <linux/types.h>
10
11 #include "xe_pt_walk.h"
12
13 struct xe_bo;
14 struct xe_vma;
15
16 enum xe_cache_level {
17         XE_CACHE_NONE,
18         XE_CACHE_WT,
19         XE_CACHE_WB,
20         __XE_CACHE_LEVEL_COUNT,
21 };
22
23 #define XE_VM_MAX_LEVEL 4
24
25 struct xe_pt {
26         struct xe_ptw base;
27         struct xe_bo *bo;
28         unsigned int level;
29         unsigned int num_live;
30         bool rebind;
31         bool is_compact;
32 #if IS_ENABLED(CONFIG_DRM_XE_DEBUG_VM)
33         /** addr: Virtual address start address of the PT. */
34         u64 addr;
35 #endif
36 };
37
38 struct xe_pt_ops {
39         u64 (*pte_encode_bo)(struct xe_bo *bo, u64 bo_offset,
40                              enum xe_cache_level cache, u32 pt_level);
41         u64 (*pte_encode_vma)(u64 pte, struct xe_vma *vma,
42                               enum xe_cache_level cache, u32 pt_level);
43         u64 (*pte_encode_addr)(u64 addr, enum xe_cache_level cache,
44                                u32 pt_level, bool devmem, u64 flags);
45         u64 (*pde_encode_bo)(struct xe_bo *bo, u64 bo_offset,
46                              const enum xe_cache_level cache);
47 };
48
49 struct xe_pt_entry {
50         struct xe_pt *pt;
51         u64 pte;
52 };
53
54 struct xe_vm_pgtable_update {
55         /** @bo: page table bo to write to */
56         struct xe_bo *pt_bo;
57
58         /** @ofs: offset inside this PTE to begin writing to (in qwords) */
59         u32 ofs;
60
61         /** @qwords: number of PTE's to write */
62         u32 qwords;
63
64         /** @pt: opaque pointer useful for the caller of xe_migrate_update_pgtables */
65         struct xe_pt *pt;
66
67         /** @pt_entries: Newly added pagetable entries */
68         struct xe_pt_entry *pt_entries;
69
70         /** @flags: Target flags */
71         u32 flags;
72 };
73
74 #endif