drm/i915: Allocate context objects from stolen
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 7 Apr 2015 15:21:11 +0000 (16:21 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 10 Apr 2015 08:41:24 +0000 (10:41 +0200)
As we never expose context objects directly to userspace, we can forgo
allocating a first-class GEM object for them and prefer to use the
limited resource of reserved/stolen memory for them. Note this means
that their initial contents are undefined.

However, a downside of using stolen objects for execlists is that we
cannot access the physical address directly (thanks MCH!) which prevents
their use.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/intel_lrc.c

index f3e84c44d0091a00195d3b827c36de435d755ed5..e4c57a3981b35ec78409a546762af75cc482320d 100644 (file)
@@ -157,7 +157,9 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
        struct drm_i915_gem_object *obj;
        int ret;
 
-       obj = i915_gem_alloc_object(dev, size);
+       obj = i915_gem_object_create_stolen(dev, size);
+       if (obj == NULL)
+               obj = i915_gem_alloc_object(dev, size);
        if (obj == NULL)
                return ERR_PTR(-ENOMEM);
 
index 88c577cdd0386bfc79bc493a930e1424a23bb215..aa3ea64e481562354dedac7426fb74268107a107 100644 (file)
@@ -1845,7 +1845,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
 
        context_size = round_up(get_lr_context_size(ring), 4096);
 
-       ctx_obj = i915_gem_alloc_context_obj(dev, context_size);
+       ctx_obj = i915_gem_alloc_object(dev, context_size);
        if (IS_ERR(ctx_obj)) {
                ret = PTR_ERR(ctx_obj);
                DRM_DEBUG_DRIVER("Alloc LRC backing obj failed: %d\n", ret);