[Intel-gfx] [PATCH 47/70] drm/i915: Allocate context objects from stolen

Daniel Vetter daniel at ffwll.ch
Fri Apr 10 01:39:26 PDT 2015


On Tue, Apr 07, 2015 at 04:21:11PM +0100, Chris Wilson wrote:
> 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 at chris-wilson.co.uk>

Queued for -next, thanks for the patch.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_gem_context.c | 4 +++-
>  drivers/gpu/drm/i915/intel_lrc.c        | 2 +-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 18900f745bc6..b9c6b0ad1d0f 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -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);
>  
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index fc57d4111e56..a62ffaa45bd1 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -1711,7 +1711,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);
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list