Skip to contentSkip to conversation

drm/i915: Do not leak pages when freeing userptr objects

PATCH Applied Tvrtko Ursulin 5 participants 5 messages Sep 26, 2014 – Sep 29, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Do not leak pages when freeing userptr objects

From: Tvrtko Ursulin <[email protected]>

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.

Cc Chris Wilson <[email protected]>
Cc "Barbalho, Rafael" <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_userptr.c +3 -3
index d384139..229694d 100644
@@ -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);
Signature · 1 line
2.1.0
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines

-----Original Message-----
From: Tvrtko Ursulin [mailto:[email protected]]
Sent: Friday, September 26, 2014 3:05 PM
To: [email protected]
Cc: Ursulin, Tvrtko; Chris Wilson; Barbalho, Rafael
Subject: [PATCH] drm/i915: Do not leak pages when freeing userptr objects

From: Tvrtko Ursulin <[email protected]>

Quoted 8 lines

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.

Cc Chris Wilson <[email protected]>
Cc "Barbalho, Rafael" <[email protected]>
Quoted 31 lines
---
 drivers/gpu/drm/i915/i915_gem_userptr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_userptr.c +3 -3
index d384139..229694d 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Tvrtko Ursulin
Quoted 9 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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.

Cc Chris Wilson <[email protected]>
Cc "Barbalho, Rafael" <[email protected]>

Oh that's fun. I blame Imre for the recent invention of for_each_sg_page()!

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
maintainer Applied
#3 lore raw
Quoted 7 lines · Chris Wilson
Quoted 6 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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.

Quoted 7 lines
Quoted 3 lines
Cc Chris Wilson <[email protected]>
Cc "Barbalho, Rafael" <[email protected]>

Oh that's fun. I blame Imre for the recent invention of for_each_sg_page()!

Pushed to drm-intel-fixes, with the unused struct scatterlist *sg variable removed. Thanks for the patch, review, and testing.

BR,
Jani.

Quoted 8 lines

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
#4 lore raw
In reply to Chris Wilson
Quoted 7 lines · Chris Wilson
Quoted 6 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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.

Quoted 7 lines
Quoted 3 lines
Cc Chris Wilson <[email protected]>
Cc "Barbalho, Rafael" <[email protected]>

Oh that's fun. I blame Imre for the recent invention of for_each_sg_page()!

Again merged to dinf for vetting time, thanks for patch&review. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch