summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_gem_stolen.c
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2013-07-05 14:41:06 -0700
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-07-08 22:04:36 +0200
commitc6cfb325677ea6305fb19acf3a4d14ea267f923e (patch)
tree8660aa760fa3f510e58e93c0a6096b267f4c03ee /drivers/gpu/drm/i915/i915_gem_stolen.c
parentedd41a870f11157a1bf4c15080421f9770912e09 (diff)
drm/i915: Embed drm_mm_node in i915 gem obj
Embedding the node in the obj is more natural in the transition to VMAs which will also have embedded nodes. This change also helps transition away from put_block to remove node. Though it's quite an uncommon occurrence, it's somewhat convenient to not fail at bind time because we cannot allocate the node. Though in practice there are other allocations (like the request structure) which would probably make this point not terribly useful. Quoting Daniel: Note that the only difference between put_block and remove_node is that the former fills up the preallocation cache. Which we don't need anyway and hence is just wasted space. v2: Clean up the stolen preallocation code. Rebased on the reserve_node patches renames ggtt_ stuff to gtt_ stuff WARN_ON if the object is already bound (which doesn't mean it's in the bound list, tricky) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_stolen.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_stolen.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index 559f75450d35..08dd923c87d8 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -374,26 +374,15 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
* setting up the GTT space. The actual reservation will occur
* later.
*/
+ obj->gtt_space.start = gtt_offset;
+ obj->gtt_space.size = size;
if (drm_mm_initialized(&dev_priv->mm.gtt_space)) {
- obj->gtt_space = kzalloc(sizeof(*obj->gtt_space), GFP_KERNEL);
- if (!obj->gtt_space) {
- DRM_DEBUG_KMS("-ENOMEM stolen GTT space\n");
- goto unref_out;
- }
-
- obj->gtt_space->start = gtt_offset;
- obj->gtt_space->size = size;
ret = drm_mm_reserve_node(&dev_priv->mm.gtt_space,
- obj->gtt_space);
+ &obj->gtt_space);
if (ret) {
DRM_DEBUG_KMS("failed to allocate stolen GTT space\n");
- goto free_out;
+ goto unref_out;
}
- } else {
- if (WARN_ON(gtt_offset & ~PAGE_MASK))
- DRM_DEBUG_KMS("Cannot preserve non page aligned offset\n");
- obj->gtt_space =
- (struct drm_mm_node *)((uintptr_t)(I915_GTT_RESERVED | gtt_offset));
}
obj->has_global_gtt_mapping = 1;
@@ -403,9 +392,6 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
return obj;
-free_out:
- kfree(obj->gtt_space);
- obj->gtt_space = NULL;
unref_out:
drm_gem_object_unreference(&obj->base);
return NULL;