[Intel-gfx] [PATCH 2/4] drm/i915: Support for creating Stolen memory backed objects

Chris Wilson chris at chris-wilson.co.uk
Tue Sep 15 02:49:42 PDT 2015


On Tue, Sep 15, 2015 at 02:03:25PM +0530, ankitprasad.r.sharma at intel.com wrote:
>  i915_gem_create(struct drm_file *file,
>  		struct drm_device *dev,
>  		uint64_t size,
> +		uint32_t flags,
>  		uint32_t *handle_p)
>  {
>  	struct drm_i915_gem_object *obj;
> @@ -385,8 +386,31 @@ i915_gem_create(struct drm_file *file,
>  	if (size == 0)
>  		return -EINVAL;
>  
> +	if (flags & __I915_CREATE_UNKNOWN_FLAGS)
> +		return -EINVAL;
> +
>  	/* Allocate the new object */
> -	obj = i915_gem_alloc_object(dev, size);
> +	if (flags & I915_CREATE_PLACEMENT_STOLEN) {
> +		mutex_lock(&dev->struct_mutex);
> +		obj = i915_gem_object_create_stolen(dev, size);
> +		if (!obj) {
> +			mutex_unlock(&dev->struct_mutex);
> +			return -ENOMEM;

Note that you should change the i915_gem_object_create_stolen() to
report the precise error, as with the eviction support we may trigger
EINTR. Also ENOSPC will be preferrable for requesting a larger stolen
object than the available space (to help distinguish between true oom).
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list