summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2017-04-10 02:51:48 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-04-20 14:35:24 -0400
commite8e33f4f05d067fdbe6d5114b6111df407447c21 (patch)
tree482e300346af024f2a121d13b14d4546a50bb6ac /drivers/gpu/nvgpu/common/mm/buddy_allocator_priv.h
parentc9042a1f45324e87b267b758288ba645a6ea0808 (diff)
gpu: nvgpu: use nvgpu rbtree for buddy allocator
Use nvgpu rbtree instead of linux rbtree for buddy allocator Move to use nvgpu_rbtree_node structure and nvgpu_rbtree_* APIs Jira NVGPU-13 Change-Id: I8041a9634898b23638d14884a772e8fa6fb61074 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: http://git-master/r/1466549 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@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.h25
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
24struct nvgpu_kmem_cache; 23struct 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
64static inline struct nvgpu_buddy *
65nvgpu_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 */
99struct nvgpu_fixed_alloc { 105struct 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
113static inline struct nvgpu_fixed_alloc *
114nvgpu_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