[Intel-gfx] [PATCH 1/4] drm/i915: Clearing buffer objects via CPU/GTT

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Wed Jul 22 08:01:33 PDT 2015


Hi,

On 07/22/2015 02:51 PM, ankitprasad.r.sharma at intel.com wrote:
> From: Ankitprasad Sharma <ankitprasad.r.sharma at intel.com>
>
> This patch adds support for clearing buffer objects via CPU/GTT. This
> is particularly useful for clearing out the non shmem backed objects.
> Currently intend to use this only for buffers allocated from stolen
> region.
>
> Testcase: igt/gem_stolen
>
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma at intel.com>
> ---
>   drivers/gpu/drm/i915/i915_drv.h |  1 +
>   drivers/gpu/drm/i915/i915_gem.c | 34 ++++++++++++++++++++++++++++++++++
>   2 files changed, 35 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index ea9caf2..f6af9c0 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2764,6 +2764,7 @@ int i915_gem_obj_prepare_shmem_read(struct drm_i915_gem_object *obj,
>   				    int *needs_clflush);
>
>   int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
> +int i915_gem_clear_object(struct drm_i915_gem_object *obj);
>
>   static inline int __sg_page_count(struct scatterlist *sg)
>   {
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a2a4a27..fc434ae 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -5469,3 +5469,37 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
>   	return false;
>   }
>
> +int i915_gem_clear_object(struct drm_i915_gem_object *obj)

Please add kernel doc for the function.

> +{
> +	int ret = 0;

No need to set to zero.

> +	char __iomem *base;
> +	int size = obj->base.size;

I think obj->base.size is a size_t at the moment so this could cause 
compiler to warn?

> +	struct drm_i915_private *dev_priv = obj->base.dev->dev_private;

Again compiler should warn here due implicit pointer casting? I think 
correct is "dev_priv = to_i915(obj->base.dev)".

> +	unsigned alignment = 0;

Don't even need this as variable since it is used only once.

> +
> +	ret = i915_gem_obj_ggtt_pin(obj, alignment, PIN_MAPPABLE);
> +	if (ret) {
> +		DRM_ERROR("Mapping of gem object to GTT failed\n");

Maybe end the sentence with "!" ?

> +		return ret;
> +	}
> +
> +	ret = i915_gem_object_put_fence(obj);
> +	if (ret)
> +		goto unpin;

This I don't understand. Why it is OK to release a fence and never 
re-establish it? Could that surprise some callers?

Regards,

Tvrtko


More information about the Intel-gfx mailing list