diff options
author | Deepak Nibade <dnibade@nvidia.com> | 2017-04-11 09:59:10 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-04-19 15:15:57 -0400 |
commit | a54fee533a2e3244343642b1ba1b211e2b53961c (patch) | |
tree | e17d4a8ef4a6559c8a1aa0a5bf17228f705914f6 /drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h | |
parent | 71c85c225ec205388fbaf5b482bfc3e54e7aa12e (diff) |
gpu: nvgpu: use nvgpu list for buddy allocator
Use nvgpu list APIs instead of linux list APIs
for buddy allocator lists
Jira NVGPU-13
Change-Id: I69a506a9aef77eaa9da0f89609627f4c2f5a7b28
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1462079
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h | 20 |
1 files changed, 14 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 935b3f1c..549ab3d1 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h | |||
@@ -17,9 +17,10 @@ | |||
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/list.h> | ||
21 | #include <linux/rbtree.h> | 20 | #include <linux/rbtree.h> |
22 | 21 | ||
22 | #include <nvgpu/list.h> | ||
23 | |||
23 | struct nvgpu_kmem_cache; | 24 | struct nvgpu_kmem_cache; |
24 | struct nvgpu_allocator; | 25 | struct nvgpu_allocator; |
25 | struct vm_gk20a; | 26 | struct vm_gk20a; |
@@ -33,7 +34,7 @@ struct nvgpu_buddy { | |||
33 | struct nvgpu_buddy *left; /* Lower address sub-node. */ | 34 | struct nvgpu_buddy *left; /* Lower address sub-node. */ |
34 | struct nvgpu_buddy *right; /* Higher address sub-node. */ | 35 | struct nvgpu_buddy *right; /* Higher address sub-node. */ |
35 | 36 | ||
36 | struct list_head buddy_entry; /* List entry for various lists. */ | 37 | struct nvgpu_list_node buddy_entry; /* List entry for various lists. */ |
37 | struct rb_node alloced_entry; /* RB tree of allocations. */ | 38 | struct rb_node alloced_entry; /* RB tree of allocations. */ |
38 | 39 | ||
39 | u64 start; /* Start address of this buddy. */ | 40 | u64 start; /* Start address of this buddy. */ |
@@ -54,6 +55,13 @@ struct nvgpu_buddy { | |||
54 | int pte_size; | 55 | int pte_size; |
55 | }; | 56 | }; |
56 | 57 | ||
58 | static inline struct nvgpu_buddy * | ||
59 | nvgpu_buddy_from_buddy_entry(struct nvgpu_list_node *node) | ||
60 | { | ||
61 | return (struct nvgpu_buddy *) | ||
62 | ((uintptr_t)node - offsetof(struct nvgpu_buddy, buddy_entry)); | ||
63 | }; | ||
64 | |||
57 | #define __buddy_flag_ops(flag, flag_up) \ | 65 | #define __buddy_flag_ops(flag, flag_up) \ |
58 | static inline int buddy_is_ ## flag(struct nvgpu_buddy *b) \ | 66 | static inline int buddy_is_ ## flag(struct nvgpu_buddy *b) \ |
59 | { \ | 67 | { \ |
@@ -89,7 +97,7 @@ __buddy_flag_ops(in_list, IN_LIST); | |||
89 | * Keeps info for a fixed allocation. | 97 | * Keeps info for a fixed allocation. |
90 | */ | 98 | */ |
91 | struct nvgpu_fixed_alloc { | 99 | struct nvgpu_fixed_alloc { |
92 | struct list_head buddies; /* List of buddies. */ | 100 | struct nvgpu_list_node buddies; /* List of buddies. */ |
93 | struct rb_node alloced_entry; /* RB tree of fixed allocations. */ | 101 | struct rb_node alloced_entry; /* RB tree of fixed allocations. */ |
94 | 102 | ||
95 | u64 start; /* Start of fixed block. */ | 103 | u64 start; /* Start of fixed block. */ |
@@ -125,7 +133,7 @@ struct nvgpu_buddy_allocator { | |||
125 | struct rb_root alloced_buddies; /* Outstanding allocations. */ | 133 | struct rb_root alloced_buddies; /* Outstanding allocations. */ |
126 | struct rb_root fixed_allocs; /* Outstanding fixed allocations. */ | 134 | struct rb_root fixed_allocs; /* Outstanding fixed allocations. */ |
127 | 135 | ||
128 | struct list_head co_list; | 136 | struct nvgpu_list_node co_list; |
129 | 137 | ||
130 | struct nvgpu_kmem_cache *buddy_cache; | 138 | struct nvgpu_kmem_cache *buddy_cache; |
131 | 139 | ||
@@ -134,7 +142,7 @@ struct nvgpu_buddy_allocator { | |||
134 | */ | 142 | */ |
135 | #define GPU_BALLOC_ORDER_LIST_LEN (GPU_BALLOC_MAX_ORDER + 1) | 143 | #define GPU_BALLOC_ORDER_LIST_LEN (GPU_BALLOC_MAX_ORDER + 1) |
136 | 144 | ||
137 | struct list_head buddy_list[GPU_BALLOC_ORDER_LIST_LEN]; | 145 | struct nvgpu_list_node buddy_list[GPU_BALLOC_ORDER_LIST_LEN]; |
138 | u64 buddy_list_len[GPU_BALLOC_ORDER_LIST_LEN]; | 146 | u64 buddy_list_len[GPU_BALLOC_ORDER_LIST_LEN]; |
139 | u64 buddy_list_split[GPU_BALLOC_ORDER_LIST_LEN]; | 147 | u64 buddy_list_split[GPU_BALLOC_ORDER_LIST_LEN]; |
140 | u64 buddy_list_alloced[GPU_BALLOC_ORDER_LIST_LEN]; | 148 | u64 buddy_list_alloced[GPU_BALLOC_ORDER_LIST_LEN]; |
@@ -162,7 +170,7 @@ static inline struct nvgpu_buddy_allocator *buddy_allocator( | |||
162 | return (struct nvgpu_buddy_allocator *)(a)->priv; | 170 | return (struct nvgpu_buddy_allocator *)(a)->priv; |
163 | } | 171 | } |
164 | 172 | ||
165 | static inline struct list_head *balloc_get_order_list( | 173 | static inline struct nvgpu_list_node *balloc_get_order_list( |
166 | struct nvgpu_buddy_allocator *a, int order) | 174 | struct nvgpu_buddy_allocator *a, int order) |
167 | { | 175 | { |
168 | return &a->buddy_list[order]; | 176 | return &a->buddy_list[order]; |