[PATCH] drm/i915: fixup i915_gem_object_get_page inline helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The obj->pages to obj->pages->sgl rework introduced this helper, but
it doesn't actually work for n >= SG_MAX_SINGLE_ALLOC.

For simplicity (and since right now I seem to be too stupid to see
the bug), let's just grab the right page with a for_each_sg loop.

This is exercised by the improved hangman tests and the gem_exec_big
test in i-g-t.

v2: Compared to v1, don't try to be clever since I seemingly only
manage to prove that I'm not clever.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 drivers/gpu/drm/i915/i915_drv.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 4f2831a..32a2e47 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1340,12 +1340,14 @@ void i915_gem_lastclose(struct drm_device *dev);
 int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
 static inline struct page *i915_gem_object_get_page(struct drm_i915_gem_object *obj, int n)
 {
-	struct scatterlist *sg = obj->pages->sgl;
-	while (n >= SG_MAX_SINGLE_ALLOC) {
-		sg = sg_chain_ptr(sg + SG_MAX_SINGLE_ALLOC - 1);
-		n -= SG_MAX_SINGLE_ALLOC - 1;
+	struct scatterlist *sg;
+	int i;
+
+	for_each_sg(obj->pages->sgl, sg, obj->pages->nents, i) {
+		if (i == n)
+			return sg_page(sg);
 	}
-	return sg_page(sg+n);
+	return NULL;
 }
 static inline void i915_gem_object_pin_pages(struct drm_i915_gem_object *obj)
 {
-- 
1.7.11.2



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux