[Intel-gfx] [PATCH] drm/i915: Do not leak pages when freeing userptr objects

Barbalho, Rafael rafael.barbalho at intel.com
Fri Sep 26 16:30:43 CEST 2014


> -----Original Message-----
> From: Tvrtko Ursulin [mailto:tvrtko.ursulin at linux.intel.com]
> Sent: Friday, September 26, 2014 3:05 PM
> To: Intel-gfx at lists.freedesktop.org
> Cc: Ursulin, Tvrtko; Chris Wilson; Barbalho, Rafael
> Subject: [PATCH] drm/i915: Do not leak pages when freeing userptr objects
> 
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> sg_alloc_table_from_pages() can build us a table with coalesced ranges
> which
> means we need to iterate over pages and not sg table entries when releasing
> page references.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: "Barbalho, Rafael" <rafael.barbalho at intel.com>

Tested-by: Rafael Barbalho <rafael.barbalho at intel.com>

> ---
>  drivers/gpu/drm/i915/i915_gem_userptr.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c
> b/drivers/gpu/drm/i915/i915_gem_userptr.c
> index d384139..229694d 100644
> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> @@ -682,15 +682,15 @@ static void
>  i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj)
>  {
>  	struct scatterlist *sg;
> -	int i;
> +	struct sg_page_iter sg_iter;
> 
>  	BUG_ON(obj->userptr.work != NULL);
> 
>  	if (obj->madv != I915_MADV_WILLNEED)
>  		obj->dirty = 0;
> 
> -	for_each_sg(obj->pages->sgl, sg, obj->pages->nents, i) {
> -		struct page *page = sg_page(sg);
> +	for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0)
> {
> +		struct page *page = sg_page_iter_page(&sg_iter);
> 
>  		if (obj->dirty)
>  			set_page_dirty(page);
> --
> 2.1.0




More information about the Intel-gfx mailing list