xref: /linux/drivers/gpu/drm/xe/xe_ggtt.h (revision 55a42f78ffd386e01a5404419f8c5ded7db70a21)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2021 Intel Corporation
4  */
5 
6 #ifndef _XE_GGTT_H_
7 #define _XE_GGTT_H_
8 
9 #include "xe_ggtt_types.h"
10 
11 struct drm_printer;
12 struct xe_tile;
13 struct drm_exec;
14 
15 struct xe_ggtt *xe_ggtt_alloc(struct xe_tile *tile);
16 int xe_ggtt_init_early(struct xe_ggtt *ggtt);
17 int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size);
18 int xe_ggtt_init(struct xe_ggtt *ggtt);
19 
20 struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt);
21 void xe_ggtt_node_fini(struct xe_ggtt_node *node);
22 int xe_ggtt_node_insert_balloon_locked(struct xe_ggtt_node *node,
23 				       u64 start, u64 size);
24 void xe_ggtt_node_remove_balloon_locked(struct xe_ggtt_node *node);
25 void xe_ggtt_shift_nodes_locked(struct xe_ggtt *ggtt, s64 shift);
26 
27 int xe_ggtt_node_insert(struct xe_ggtt_node *node, u32 size, u32 align);
28 int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
29 			       u32 size, u32 align, u32 mm_flags);
30 void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate);
31 bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
32 void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
33 		    struct xe_bo *bo, u16 pat_index);
34 void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo);
35 int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo, struct drm_exec *exec);
36 int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
37 			 u64 start, u64 end, struct drm_exec *exec);
38 void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
39 u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
40 
41 int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
42 u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p);
43 
44 #ifdef CONFIG_PCI_IOV
45 void xe_ggtt_assign(const struct xe_ggtt_node *node, u16 vfid);
46 #endif
47 
48 #ifndef CONFIG_LOCKDEP
49 static inline void xe_ggtt_might_lock(struct xe_ggtt *ggtt)
50 { }
51 #else
52 void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
53 #endif
54 
55 u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_index);
56 u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
57 
58 #endif
59