[Intel-gfx] [PATCH 15/24] drm/i915: Differentiate between prime and stolen objects

Jesse Barnes jbarnes at virtuousgeek.org
Thu Oct 11 20:50:57 CEST 2012


On Tue,  4 Sep 2012 21:03:07 +0100
Chris Wilson <chris at chris-wilson.co.uk> wrote:

> Stolen objects also share the property that they have no backing shmemfs
> filp, but they can be used with pwrite/pread/gtt-mapping.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_drv.h |    5 +++++
>  drivers/gpu/drm/i915/i915_gem.c |    4 ++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 637babb..cc3cc4f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1049,6 +1049,11 @@ struct drm_i915_gem_object {
>  	atomic_t pending_flip;
>  };
>  
> +inline static bool i915_gem_object_is_prime(struct drm_i915_gem_object *obj)
> +{
> +	return obj->base.import_attach != NULL;
> +}
> +
>  #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base)
>  
>  /**
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 58075e3..f1cef1f 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -553,7 +553,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
>  	/* prime objects have no backing filp to GEM pread/pwrite
>  	 * pages from.
>  	 */
> -	if (!obj->base.filp) {
> +	if (i915_gem_object_is_prime(obj)) {
>  		ret = -EINVAL;
>  		goto out;
>  	}
> @@ -902,7 +902,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
>  	/* prime objects have no backing filp to GEM pread/pwrite
>  	 * pages from.
>  	 */
> -	if (!obj->base.filp) {
> +	if (i915_gem_object_is_prime(obj)) {
>  		ret = -EINVAL;
>  		goto out;
>  	}

Reviewed-by: Jesse Barnes <jbarnes at virtuousgeek.org>

-- 
Jesse Barnes, Intel Open Source Technology Center



More information about the Intel-gfx mailing list