Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 357868
b: refs/heads/master
c: 5973c7e
h: refs/heads/master
v: v3
  • Loading branch information
Chris Wilson authored and Daniel Vetter committed Nov 30, 2012
1 parent cb0c4a3 commit d59b0e8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: acd15b6cc20f85bcef9e08b6ed4f142c34791c32
refs/heads/master: 5973c7ee519e2a240c68b290a1836bdb25ed3701
50 changes: 50 additions & 0 deletions trunk/drivers/gpu/drm/drm_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,56 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,
}
}

struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm,
unsigned long start,
unsigned long size,
bool atomic)
{
struct drm_mm_node *hole, *node;
unsigned long end = start + size;

list_for_each_entry(hole, &mm->hole_stack, hole_stack) {
unsigned long hole_start;
unsigned long hole_end;

BUG_ON(!hole->hole_follows);
hole_start = drm_mm_hole_node_start(hole);
hole_end = drm_mm_hole_node_end(hole);

if (hole_start > start || hole_end < end)
continue;

node = drm_mm_kmalloc(mm, atomic);
if (unlikely(node == NULL))
return NULL;

node->start = start;
node->size = size;
node->mm = mm;
node->allocated = 1;

INIT_LIST_HEAD(&node->hole_stack);
list_add(&node->node_list, &hole->node_list);

if (start == hole_start) {
hole->hole_follows = 0;
list_del_init(&hole->hole_stack);
}

node->hole_follows = 0;
if (end != hole_end) {
list_add(&node->hole_stack, &mm->hole_stack);
node->hole_follows = 1;
}

return node;
}

WARN(1, "no hole found for block 0x%lx + 0x%lx\n", start, size);
return NULL;
}
EXPORT_SYMBOL(drm_mm_create_block);

struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node,
unsigned long size,
unsigned alignment,
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/drm/drm_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ static inline bool drm_mm_initialized(struct drm_mm *mm)
/*
* Basic range manager support (drm_mm.c)
*/
extern struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm,
unsigned long start,
unsigned long size,
bool atomic);
extern struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *node,
unsigned long size,
unsigned alignment,
Expand Down

0 comments on commit d59b0e8

Please sign in to comment.