提交 338710e7 编写于 作者: B Ben Widawsky 提交者: Daniel Vetter

drm: Change create block to reserve node

With the previous patch we no longer actually create a node, we simply
find the correct hole and occupy it. This very well could have been
squashed with the last patch, but since I already had David's review, I
figured it's easiest to keep it distinct.

Also update the users in i915. Conveniently this is the only user of the
interface.

CC: David Airlie <airlied@linux.ie>
CC: <dri-devel@lists.freedesktop.org>
Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
Acked-by: NDavid Airlie <airlied@linux.ie>
Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
上级 b3a070cc
...@@ -147,27 +147,27 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, ...@@ -147,27 +147,27 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,
} }
} }
int drm_mm_create_block(struct drm_mm *mm, struct drm_mm_node *node, int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)
unsigned long start, unsigned long size)
{ {
struct drm_mm_node *hole; struct drm_mm_node *hole;
unsigned long end = start + size; unsigned long end = node->start + node->size;
unsigned long hole_start; unsigned long hole_start;
unsigned long hole_end; unsigned long hole_end;
BUG_ON(node == NULL);
/* Find the relevant hole to add our node to */
drm_mm_for_each_hole(hole, mm, hole_start, hole_end) { drm_mm_for_each_hole(hole, mm, hole_start, hole_end) {
if (hole_start > start || hole_end < end) if (hole_start > node->start || hole_end < end)
continue; continue;
node->start = start;
node->size = size;
node->mm = mm; node->mm = mm;
node->allocated = 1; node->allocated = 1;
INIT_LIST_HEAD(&node->hole_stack); INIT_LIST_HEAD(&node->hole_stack);
list_add(&node->node_list, &hole->node_list); list_add(&node->node_list, &hole->node_list);
if (start == hole_start) { if (node->start == hole_start) {
hole->hole_follows = 0; hole->hole_follows = 0;
list_del_init(&hole->hole_stack); list_del_init(&hole->hole_stack);
} }
...@@ -181,10 +181,11 @@ int drm_mm_create_block(struct drm_mm *mm, struct drm_mm_node *node, ...@@ -181,10 +181,11 @@ int drm_mm_create_block(struct drm_mm *mm, struct drm_mm_node *node,
return 0; return 0;
} }
WARN(1, "no hole found for block 0x%lx + 0x%lx\n", start, size); WARN(1, "no hole found for node 0x%lx + 0x%lx\n",
node->start, node->size);
return -ENOSPC; return -ENOSPC;
} }
EXPORT_SYMBOL(drm_mm_create_block); EXPORT_SYMBOL(drm_mm_reserve_node);
struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node, struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node,
unsigned long size, unsigned long size,
......
...@@ -640,10 +640,10 @@ void i915_gem_setup_global_gtt(struct drm_device *dev, ...@@ -640,10 +640,10 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
obj->gtt_offset); obj->gtt_offset);
continue; continue;
} }
ret = drm_mm_create_block(&dev_priv->mm.gtt_space, obj->gtt_space->start = obj->gtt_offset;
obj->gtt_space, obj->gtt_space->size = obj->base.size;
obj->gtt_offset, ret = drm_mm_reserve_node(&dev_priv->mm.gtt_space,
obj->base.size); obj->gtt_space);
if (ret) { if (ret) {
DRM_DEBUG_KMS("Reservation failed\n"); DRM_DEBUG_KMS("Reservation failed\n");
kfree(obj->gtt_space); kfree(obj->gtt_space);
......
...@@ -349,8 +349,9 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, ...@@ -349,8 +349,9 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
if (!stolen) if (!stolen)
return NULL; return NULL;
ret = drm_mm_create_block(&dev_priv->mm.stolen, stolen, stolen_offset, stolen->start = stolen_offset;
size); stolen->size = size;
ret = drm_mm_reserve_node(&dev_priv->mm.stolen, stolen);
if (ret) { if (ret) {
DRM_DEBUG_KMS("failed to allocate stolen space\n"); DRM_DEBUG_KMS("failed to allocate stolen space\n");
kfree(stolen); kfree(stolen);
...@@ -380,9 +381,10 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, ...@@ -380,9 +381,10 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
goto unref_out; goto unref_out;
} }
ret = drm_mm_create_block(&dev_priv->mm.gtt_space, obj->gtt_space->start = gtt_offset;
obj->gtt_space, obj->gtt_space->size = size;
gtt_offset, size); ret = drm_mm_reserve_node(&dev_priv->mm.gtt_space,
obj->gtt_space);
if (ret) { if (ret) {
DRM_DEBUG_KMS("failed to allocate stolen GTT space\n"); DRM_DEBUG_KMS("failed to allocate stolen GTT space\n");
goto free_out; goto free_out;
......
...@@ -138,10 +138,7 @@ static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node) ...@@ -138,10 +138,7 @@ static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node)
/* /*
* Basic range manager support (drm_mm.c) * Basic range manager support (drm_mm.c)
*/ */
extern int drm_mm_create_block(struct drm_mm *mm, extern int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node);
struct drm_mm_node *node,
unsigned long start,
unsigned long size);
extern struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *node, extern struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *node,
unsigned long size, unsigned long size,
unsigned alignment, unsigned alignment,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册