xref: /linux/drivers/gpu/drm/xe/xe_ggtt.h (revision 260f6f4fda93c8485c8037865c941b42b9cba5d2)
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 
14 struct xe_ggtt *xe_ggtt_alloc(struct xe_tile *tile);
15 int xe_ggtt_init_early(struct xe_ggtt *ggtt);
16 int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size);
17 int xe_ggtt_init(struct xe_ggtt *ggtt);
18 
19 struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt);
20 void xe_ggtt_node_fini(struct xe_ggtt_node *node);
21 int xe_ggtt_node_insert_balloon_locked(struct xe_ggtt_node *node,
22 				       u64 start, u64 size);
23 void xe_ggtt_node_remove_balloon_locked(struct xe_ggtt_node *node);
24 void xe_ggtt_shift_nodes_locked(struct xe_ggtt *ggtt, s64 shift);
25 
26 int xe_ggtt_node_insert(struct xe_ggtt_node *node, u32 size, u32 align);
27 int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
28 			       u32 size, u32 align, u32 mm_flags);
29 void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate);
30 bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
31 void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
32 		    struct xe_bo *bo, u16 pat_index);
33 void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo);
34 int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
35 int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
36 			 u64 start, u64 end);
37 void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
38 u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
39 
40 int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
41 u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p);
42 
43 #ifdef CONFIG_PCI_IOV
44 void xe_ggtt_assign(const struct xe_ggtt_node *node, u16 vfid);
45 #endif
46 
47 #ifndef CONFIG_LOCKDEP
xe_ggtt_might_lock(struct xe_ggtt * ggtt)48 static inline void xe_ggtt_might_lock(struct xe_ggtt *ggtt)
49 { }
50 #else
51 void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
52 #endif
53 
54 u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_index);
55 u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
56 
57 #endif
58