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

Chris Wilson chris at chris-wilson.co.uk
Tue Jan 26 02:53:39 PST 2016


On Tue, Jan 26, 2016 at 01:13:31AM +0530, ankitprasad.r.sharma at intel.com wrote:
>  static int
>  i915_gem_create(struct drm_file *file,
>  		struct drm_device *dev,
>  		uint64_t size,
> +		uint64_t flags,
>  		uint32_t *handle_p)
>  {
>  	struct drm_i915_gem_object *obj;
>  	int ret;
>  	u32 handle;
> +	u32 placement = flags & I915_CREATE_PLACEMENT_MASK;
>  
>  	size = roundup(size, PAGE_SIZE);
>  	if (size == 0)
>  		return -EINVAL;
>  
> +	if (flags & __I915_CREATE_UNKNOWN_FLAGS)
> +		return -EINVAL;
> +
>  	/* Allocate the new object */
> -	obj = i915_gem_alloc_object(dev, size);
> +	switch (placement) {

	switch (flags & I915_CREATE_PLACEMENT_MASK) {

is just as descriptive as switch(placement) and we
don't use the placement variable anywhere else.

> +	case I915_CREATE_PLACEMENT_NORMAL:
> +		obj = i915_gem_alloc_object(dev, size);
> +		break;
> +	case I915_CREATE_PLACEMENT_STOLEN:
> +		obj = i915_gem_alloc_object_stolen(dev, size);
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
>  	if (obj == NULL)
>  		return -ENOMEM;

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list