* [PATCH] drm/i915: Do not leak pages when freeing userptr objects
@ 2014-09-26 14:05 Tvrtko Ursulin
2014-09-26 14:30 ` Barbalho, Rafael
2014-09-26 14:55 ` Chris Wilson
0 siblings, 2 replies; 5+ messages in thread
From: Tvrtko Ursulin @ 2014-09-26 14:05 UTC (permalink / raw)
To: Intel-gfx
From: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: "Barbalho, Rafael" <rafael.barbalho@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Do not leak pages when freeing userptr objects
2014-09-26 14:05 [PATCH] drm/i915: Do not leak pages when freeing userptr objects Tvrtko Ursulin
@ 2014-09-26 14:30 ` Barbalho, Rafael
2014-09-26 14:55 ` Chris Wilson
1 sibling, 0 replies; 5+ messages in thread
From: Barbalho, Rafael @ 2014-09-26 14:30 UTC (permalink / raw)
To: Tvrtko Ursulin, Intel-gfx
> -----Original Message-----
> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@linux.intel.com]
> Sent: Friday, September 26, 2014 3:05 PM
> To: Intel-gfx@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@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@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: "Barbalho, Rafael" <rafael.barbalho@intel.com>
Tested-by: Rafael Barbalho <rafael.barbalho@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Do not leak pages when freeing userptr objects
2014-09-26 14:05 [PATCH] drm/i915: Do not leak pages when freeing userptr objects Tvrtko Ursulin
2014-09-26 14:30 ` Barbalho, Rafael
@ 2014-09-26 14:55 ` Chris Wilson
2014-09-29 13:18 ` Jani Nikula
2014-09-29 13:22 ` Daniel Vetter
1 sibling, 2 replies; 5+ messages in thread
From: Chris Wilson @ 2014-09-26 14:55 UTC (permalink / raw)
To: Tvrtko Ursulin; +Cc: Intel-gfx
On Fri, Sep 26, 2014 at 03:05:22PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: "Barbalho, Rafael" <rafael.barbalho@intel.com>
Oh that's fun. I blame Imre for the recent invention of for_each_sg_page()!
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: stable@vger.kernel.org
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Do not leak pages when freeing userptr objects
2014-09-26 14:55 ` Chris Wilson
@ 2014-09-29 13:18 ` Jani Nikula
2014-09-29 13:22 ` Daniel Vetter
1 sibling, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2014-09-29 13:18 UTC (permalink / raw)
To: Chris Wilson, Tvrtko Ursulin; +Cc: Intel-gfx
On Fri, 26 Sep 2014, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Fri, Sep 26, 2014 at 03:05:22PM +0100, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: "Barbalho, Rafael" <rafael.barbalho@intel.com>
>
> Oh that's fun. I blame Imre for the recent invention of for_each_sg_page()!
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: stable@vger.kernel.org
Pushed to drm-intel-fixes, with the unused struct scatterlist *sg
variable removed. Thanks for the patch, review, and testing.
BR,
Jani.
> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: Do not leak pages when freeing userptr objects
2014-09-26 14:55 ` Chris Wilson
2014-09-29 13:18 ` Jani Nikula
@ 2014-09-29 13:22 ` Daniel Vetter
1 sibling, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2014-09-29 13:22 UTC (permalink / raw)
To: Chris Wilson, Tvrtko Ursulin, Intel-gfx, Tvrtko Ursulin,
Barbalho, Rafael
On Fri, Sep 26, 2014 at 03:55:51PM +0100, Chris Wilson wrote:
> On Fri, Sep 26, 2014 at 03:05:22PM +0100, Tvrtko Ursulin wrote:
> > From: Tvrtko Ursulin <tvrtko.ursulin@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@intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: "Barbalho, Rafael" <rafael.barbalho@intel.com>
>
> Oh that's fun. I blame Imre for the recent invention of for_each_sg_page()!
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: stable@vger.kernel.org
Again merged to dinf for vetting time, thanks for patch&review.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-29 13:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-26 14:05 [PATCH] drm/i915: Do not leak pages when freeing userptr objects Tvrtko Ursulin
2014-09-26 14:30 ` Barbalho, Rafael
2014-09-26 14:55 ` Chris Wilson
2014-09-29 13:18 ` Jani Nikula
2014-09-29 13:22 ` Daniel Vetter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.