aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_mm.c48
-rw-r--r--include/drm/drm_mm.h21
2 files changed, 22 insertions, 47 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index a912a0ff11cc..3e47869d6dae 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -187,9 +187,10 @@ static struct drm_mm_node *drm_mm_split_at_start(struct drm_mm_node *parent,
187} 187}
188 188
189 189
190 190struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *node,
191struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *node, 191 unsigned long size,
192 unsigned long size, unsigned alignment) 192 unsigned alignment,
193 int atomic)
193{ 194{
194 195
195 struct drm_mm_node *align_splitoff = NULL; 196 struct drm_mm_node *align_splitoff = NULL;
@@ -200,7 +201,7 @@ struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *node,
200 201
201 if (tmp) { 202 if (tmp) {
202 align_splitoff = 203 align_splitoff =
203 drm_mm_split_at_start(node, alignment - tmp, 0); 204 drm_mm_split_at_start(node, alignment - tmp, atomic);
204 if (unlikely(align_splitoff == NULL)) 205 if (unlikely(align_splitoff == NULL))
205 return NULL; 206 return NULL;
206 } 207 }
@@ -209,7 +210,7 @@ struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *node,
209 list_del_init(&node->fl_entry); 210 list_del_init(&node->fl_entry);
210 node->free = 0; 211 node->free = 0;
211 } else { 212 } else {
212 node = drm_mm_split_at_start(node, size, 0); 213 node = drm_mm_split_at_start(node, size, atomic);
213 } 214 }
214 215
215 if (align_splitoff) 216 if (align_splitoff)
@@ -217,42 +218,7 @@ struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *node,
217 218
218 return node; 219 return node;
219} 220}
220 221EXPORT_SYMBOL(drm_mm_get_block_generic);
221EXPORT_SYMBOL(drm_mm_get_block);
222
223struct drm_mm_node *drm_mm_get_block_atomic(struct drm_mm_node *parent,
224 unsigned long size,
225 unsigned alignment)
226{
227
228 struct drm_mm_node *align_splitoff = NULL;
229 struct drm_mm_node *child;
230 unsigned tmp = 0;
231
232 if (alignment)
233 tmp = parent->start % alignment;
234
235 if (tmp) {
236 align_splitoff =
237 drm_mm_split_at_start(parent, alignment - tmp, 1);
238 if (unlikely(align_splitoff == NULL))
239 return NULL;
240 }
241
242 if (parent->size == size) {
243 list_del_init(&parent->fl_entry);
244 parent->free = 0;
245 return parent;
246 } else {
247 child = drm_mm_split_at_start(parent, size, 1);
248 }
249
250 if (align_splitoff)
251 drm_mm_put_block(align_splitoff);
252
253 return child;
254}
255EXPORT_SYMBOL(drm_mm_get_block_atomic);
256 222
257/* 223/*
258 * Put a block. Merge with the previous and / or next block if they are free. 224 * Put a block. Merge with the previous and / or next block if they are free.
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index 5662f4278ef3..f8332073d277 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -59,13 +59,22 @@ struct drm_mm {
59/* 59/*
60 * Basic range manager support (drm_mm.c) 60 * Basic range manager support (drm_mm.c)
61 */ 61 */
62 62extern struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *node,
63extern struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *parent, 63 unsigned long size,
64 unsigned long size, 64 unsigned alignment,
65 unsigned alignment); 65 int atomic);
66extern struct drm_mm_node *drm_mm_get_block_atomic(struct drm_mm_node *parent, 66static inline struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *parent,
67 unsigned long size, 67 unsigned long size,
68 unsigned alignment); 68 unsigned alignment)
69{
70 return drm_mm_get_block_generic(parent, size, alignment, 0);
71}
72static inline struct drm_mm_node *drm_mm_get_block_atomic(struct drm_mm_node *parent,
73 unsigned long size,
74 unsigned alignment)
75{
76 return drm_mm_get_block_generic(parent, size, alignment, 1);
77}
69extern void drm_mm_put_block(struct drm_mm_node *cur); 78extern void drm_mm_put_block(struct drm_mm_node *cur);
70extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, 79extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
71 unsigned long size, 80 unsigned long size,