diff options
Diffstat (limited to 'drivers/gpu/drm/drm_mm.c')
-rw-r--r-- | drivers/gpu/drm/drm_mm.c | 67 |
1 files changed, 42 insertions, 25 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 4fa33e1283af..fecb4063c018 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c | |||
@@ -115,24 +115,15 @@ static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node) | |||
115 | return next_node->start; | 115 | return next_node->start; |
116 | } | 116 | } |
117 | 117 | ||
118 | struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node, | 118 | static void drm_mm_insert_helper(struct drm_mm_node *hole_node, |
119 | unsigned long size, | 119 | struct drm_mm_node *node, |
120 | unsigned alignment, | 120 | unsigned long size, unsigned alignment) |
121 | int atomic) | ||
122 | { | 121 | { |
123 | |||
124 | struct drm_mm_node *node; | ||
125 | struct drm_mm *mm = hole_node->mm; | 122 | struct drm_mm *mm = hole_node->mm; |
126 | unsigned long tmp = 0, wasted = 0; | 123 | unsigned long tmp = 0, wasted = 0; |
127 | unsigned long hole_start = drm_mm_hole_node_start(hole_node); | 124 | unsigned long hole_start = drm_mm_hole_node_start(hole_node); |
128 | unsigned long hole_end = drm_mm_hole_node_end(hole_node); | 125 | unsigned long hole_end = drm_mm_hole_node_end(hole_node); |
129 | 126 | ||
130 | BUG_ON(!hole_node->hole_follows); | ||
131 | |||
132 | node = drm_mm_kmalloc(mm, atomic); | ||
133 | if (unlikely(node == NULL)) | ||
134 | return NULL; | ||
135 | |||
136 | if (alignment) | 127 | if (alignment) |
137 | tmp = hole_start % alignment; | 128 | tmp = hole_start % alignment; |
138 | 129 | ||
@@ -157,30 +148,37 @@ struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node, | |||
157 | } else { | 148 | } else { |
158 | node->hole_follows = 0; | 149 | node->hole_follows = 0; |
159 | } | 150 | } |
151 | } | ||
152 | |||
153 | struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node, | ||
154 | unsigned long size, | ||
155 | unsigned alignment, | ||
156 | int atomic) | ||
157 | { | ||
158 | struct drm_mm_node *node; | ||
159 | |||
160 | BUG_ON(!hole_node->hole_follows); | ||
161 | |||
162 | node = drm_mm_kmalloc(hole_node->mm, atomic); | ||
163 | if (unlikely(node == NULL)) | ||
164 | return NULL; | ||
165 | |||
166 | drm_mm_insert_helper(hole_node, node, size, alignment); | ||
160 | 167 | ||
161 | return node; | 168 | return node; |
162 | } | 169 | } |
163 | EXPORT_SYMBOL(drm_mm_get_block_generic); | 170 | EXPORT_SYMBOL(drm_mm_get_block_generic); |
164 | 171 | ||
165 | struct drm_mm_node *drm_mm_get_block_range_generic(struct drm_mm_node *hole_node, | 172 | static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, |
166 | unsigned long size, | 173 | struct drm_mm_node *node, |
167 | unsigned alignment, | 174 | unsigned long size, unsigned alignment, |
168 | unsigned long start, | 175 | unsigned long start, unsigned long end) |
169 | unsigned long end, | ||
170 | int atomic) | ||
171 | { | 176 | { |
172 | struct drm_mm_node *node; | ||
173 | struct drm_mm *mm = hole_node->mm; | 177 | struct drm_mm *mm = hole_node->mm; |
174 | unsigned long tmp = 0, wasted = 0; | 178 | unsigned long tmp = 0, wasted = 0; |
175 | unsigned long hole_start = drm_mm_hole_node_start(hole_node); | 179 | unsigned long hole_start = drm_mm_hole_node_start(hole_node); |
176 | unsigned long hole_end = drm_mm_hole_node_end(hole_node); | 180 | unsigned long hole_end = drm_mm_hole_node_end(hole_node); |
177 | 181 | ||
178 | BUG_ON(!hole_node->hole_follows); | ||
179 | |||
180 | node = drm_mm_kmalloc(mm, atomic); | ||
181 | if (unlikely(node == NULL)) | ||
182 | return NULL; | ||
183 | |||
184 | if (hole_start < start) | 182 | if (hole_start < start) |
185 | wasted += start - hole_start; | 183 | wasted += start - hole_start; |
186 | if (alignment) | 184 | if (alignment) |
@@ -210,6 +208,25 @@ struct drm_mm_node *drm_mm_get_block_range_generic(struct drm_mm_node *hole_node | |||
210 | } else { | 208 | } else { |
211 | node->hole_follows = 0; | 209 | node->hole_follows = 0; |
212 | } | 210 | } |
211 | } | ||
212 | |||
213 | struct drm_mm_node *drm_mm_get_block_range_generic(struct drm_mm_node *hole_node, | ||
214 | unsigned long size, | ||
215 | unsigned alignment, | ||
216 | unsigned long start, | ||
217 | unsigned long end, | ||
218 | int atomic) | ||
219 | { | ||
220 | struct drm_mm_node *node; | ||
221 | |||
222 | BUG_ON(!hole_node->hole_follows); | ||
223 | |||
224 | node = drm_mm_kmalloc(hole_node->mm, atomic); | ||
225 | if (unlikely(node == NULL)) | ||
226 | return NULL; | ||
227 | |||
228 | drm_mm_insert_helper_range(hole_node, node, size, alignment, | ||
229 | start, end); | ||
213 | 230 | ||
214 | return node; | 231 | return node; |
215 | } | 232 | } |