drm/i915/selftests: Use sgt_iter for huge_pages_free
diff mbox series

Message ID 20191128232946.546831-1-chris@chris-wilson.co.uk
State New
Headers show
Series
  • drm/i915/selftests: Use sgt_iter for huge_pages_free
Related show

Commit Message

Chris Wilson Nov. 28, 2019, 11:29 p.m. UTC
Use the normal sgt_iter to walk the pages scatterlist on free so that we
handle the error path correctly.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gem/selftests/huge_gem_object.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Matthew Auld Nov. 29, 2019, 10:21 a.m. UTC | #1
On Thu, 28 Nov 2019 at 23:29, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Use the normal sgt_iter to walk the pages scatterlist on free so that we
> handle the error path correctly.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_gem_object.c b/drivers/gpu/drm/i915/gem/selftests/huge_gem_object.c
index 892d12db6c49..fa16f2c3f3ac 100644
--- a/drivers/gpu/drm/i915/gem/selftests/huge_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/selftests/huge_gem_object.c
@@ -12,10 +12,14 @@  static void huge_free_pages(struct drm_i915_gem_object *obj,
 			    struct sg_table *pages)
 {
 	unsigned long nreal = obj->scratch / PAGE_SIZE;
-	struct scatterlist *sg;
+	struct sgt_iter sgt_iter;
+	struct page *page;
 
-	for (sg = pages->sgl; sg && nreal--; sg = __sg_next(sg))
-		__free_page(sg_page(sg));
+	for_each_sgt_page(page, sgt_iter, pages) {
+		__free_page(page);
+		if (!--nreal)
+			break;
+	}
 
 	sg_free_table(pages);
 	kfree(pages);
@@ -70,7 +74,6 @@  static int huge_get_pages(struct drm_i915_gem_object *obj)
 
 err:
 	huge_free_pages(obj, pages);
-
 	return -ENOMEM;
 #undef GFP
 }