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>
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index 559f754..08dd923 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -374,26 +374,15 @@
* 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 @@
return obj;
-free_out:
- kfree(obj->gtt_space);
- obj->gtt_space = NULL;
unref_out:
drm_gem_object_unreference(&obj->base);
return NULL;