[Intel-gfx] [PATCH 5/5] drm/i915: Add support for getting size of the stolen region

Chris Wilson chris at chris-wilson.co.uk
Wed Apr 29 03:27:32 PDT 2015


On Wed, Apr 29, 2015 at 03:01:59PM +0530, ankitprasad.r.sharma at intel.com wrote:
> From: Ankitprasad Sharma <ankitprasad.r.sharma at intel.com>
> 
> This patch extends the get_aperture_ioctl to add support
> for getting total size of the stolen region and available
> size of the stolen region.
> 
> testcase: igt/gem_create_stolen
> 
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma at intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h |  6 ++++++
>  drivers/gpu/drm/i915/i915_gem.c | 15 ++++++++++++++-
>  include/uapi/drm/i915_drm.h     |  6 ++++++
>  3 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index a568cd1..a40b44f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3277,4 +3277,10 @@ inline static bool i915_gem_obj_is_prw_allowed(struct drm_i915_gem_object *obj)
>  	return !obj->userptr.mm;
>  }
>  
> +inline static bool i915_gem_obj_is_stolen_used(struct drm_i915_gem_object *obj)
> +{
> +	return obj->stolen && (i915_gem_obj_is_pinned(obj)
> +			       || obj->madv == I915_MADV_WILLNEED);
> +}
> +
>  #endif
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 3491bd3..ee93508 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -150,17 +150,30 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct drm_i915_gem_get_aperture *args = data;
>  	struct drm_i915_gem_object *obj;
> -	size_t pinned;
> +	size_t pinned, pinned_stolen;
>  
>  	pinned = 0;
> +	pinned_stolen = 0;
>  	mutex_lock(&dev->struct_mutex);
>  	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
>  		if (i915_gem_obj_is_pinned(obj))
>  			pinned += i915_gem_obj_ggtt_size(obj);
> +
> +	/* Calculating available stolen size */
> +	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
> +		if (i915_gem_obj_is_stolen_used(obj))
> +			pinned_stolen += i915_gem_obj_ggtt_size(obj);
> +
> +	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list)
> +		if (i915_gem_obj_is_stolen_used(obj))
> +			pinned_stolen += i915_gem_obj_ggtt_size(obj);

Ah, here you will want to iterate over the stolen drm_mm range manager
to get an accurate count.

Could you respin this on top of
id:1422276205-8532-5-git-send-email-rodrigo.vivi at intel.com ?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list