diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h b/drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h index 549ab3d1..5c0b31c9 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h | |||
@@ -17,8 +17,7 @@ | |||
17 | #ifndef BUDDY_ALLOCATOR_PRIV_H | 17 | #ifndef BUDDY_ALLOCATOR_PRIV_H |
18 | #define BUDDY_ALLOCATOR_PRIV_H | 18 | #define BUDDY_ALLOCATOR_PRIV_H |
19 | 19 | ||
20 | #include <linux/rbtree.h> | 20 | #include <nvgpu/rbtree.h> |
21 | |||
22 | #include <nvgpu/list.h> | 21 | #include <nvgpu/list.h> |
23 | 22 | ||
24 | struct nvgpu_kmem_cache; | 23 | struct nvgpu_kmem_cache; |
@@ -35,7 +34,7 @@ struct nvgpu_buddy { | |||
35 | struct nvgpu_buddy *right; /* Higher address sub-node. */ | 34 | struct nvgpu_buddy *right; /* Higher address sub-node. */ |
36 | 35 | ||
37 | struct nvgpu_list_node buddy_entry; /* List entry for various lists. */ | 36 | struct nvgpu_list_node buddy_entry; /* List entry for various lists. */ |
38 | struct rb_node alloced_entry; /* RB tree of allocations. */ | 37 | struct nvgpu_rbtree_node alloced_entry; /* RB tree of allocations. */ |
39 | 38 | ||
40 | u64 start; /* Start address of this buddy. */ | 39 | u64 start; /* Start address of this buddy. */ |
41 | u64 end; /* End address of this buddy. */ | 40 | u64 end; /* End address of this buddy. */ |
@@ -62,6 +61,13 @@ nvgpu_buddy_from_buddy_entry(struct nvgpu_list_node *node) | |||
62 | ((uintptr_t)node - offsetof(struct nvgpu_buddy, buddy_entry)); | 61 | ((uintptr_t)node - offsetof(struct nvgpu_buddy, buddy_entry)); |
63 | }; | 62 | }; |
64 | 63 | ||
64 | static inline struct nvgpu_buddy * | ||
65 | nvgpu_buddy_from_rbtree_node(struct nvgpu_rbtree_node *node) | ||
66 | { | ||
67 | return (struct nvgpu_buddy *) | ||
68 | ((uintptr_t)node - offsetof(struct nvgpu_buddy, alloced_entry)); | ||
69 | }; | ||
70 | |||
65 | #define __buddy_flag_ops(flag, flag_up) \ | 71 | #define __buddy_flag_ops(flag, flag_up) \ |
66 | static inline int buddy_is_ ## flag(struct nvgpu_buddy *b) \ | 72 | static inline int buddy_is_ ## flag(struct nvgpu_buddy *b) \ |
67 | { \ | 73 | { \ |
@@ -98,12 +104,19 @@ __buddy_flag_ops(in_list, IN_LIST); | |||
98 | */ | 104 | */ |
99 | struct nvgpu_fixed_alloc { | 105 | struct nvgpu_fixed_alloc { |
100 | struct nvgpu_list_node buddies; /* List of buddies. */ | 106 | struct nvgpu_list_node buddies; /* List of buddies. */ |
101 | struct rb_node alloced_entry; /* RB tree of fixed allocations. */ | 107 | struct nvgpu_rbtree_node alloced_entry; /* RB tree of fixed allocations. */ |
102 | 108 | ||
103 | u64 start; /* Start of fixed block. */ | 109 | u64 start; /* Start of fixed block. */ |
104 | u64 end; /* End address. */ | 110 | u64 end; /* End address. */ |
105 | }; | 111 | }; |
106 | 112 | ||
113 | static inline struct nvgpu_fixed_alloc * | ||
114 | nvgpu_fixed_alloc_from_rbtree_node(struct nvgpu_rbtree_node *node) | ||
115 | { | ||
116 | return (struct nvgpu_fixed_alloc *) | ||
117 | ((uintptr_t)node - offsetof(struct nvgpu_fixed_alloc, alloced_entry)); | ||
118 | }; | ||
119 | |||
107 | /* | 120 | /* |
108 | * GPU buddy allocator for the various GPU address spaces. Each addressable unit | 121 | * GPU buddy allocator for the various GPU address spaces. Each addressable unit |
109 | * doesn't have to correspond to a byte. In some cases each unit is a more | 122 | * doesn't have to correspond to a byte. In some cases each unit is a more |
@@ -130,8 +143,8 @@ struct nvgpu_buddy_allocator { | |||
130 | u64 blks; /* Count of blks in the space. */ | 143 | u64 blks; /* Count of blks in the space. */ |
131 | u64 max_order; /* Specific maximum order. */ | 144 | u64 max_order; /* Specific maximum order. */ |
132 | 145 | ||
133 | struct rb_root alloced_buddies; /* Outstanding allocations. */ | 146 | struct nvgpu_rbtree_node *alloced_buddies; /* Outstanding allocations. */ |
134 | struct rb_root fixed_allocs; /* Outstanding fixed allocations. */ | 147 | struct nvgpu_rbtree_node *fixed_allocs; /* Outstanding fixed allocations. */ |
135 | 148 | ||
136 | struct nvgpu_list_node co_list; | 149 | struct nvgpu_list_node co_list; |
137 | 150 | ||