[Intel-gfx] [RFC] drm/i915: Simplify page allocation loop a bit

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Thu Mar 27 11:18:57 CET 2014


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Looks like there are some redundant lines in the main loop of
i915_gem_object_get_pages_gtt.

v2: Put CONFIG_SWIOTLB back in.

I haven't tested this so just RFC please. Not sure that
seven lines net less is worth this. It just made it clerer
to a newby to sg building to think of it in terms of
"merge entries always except when...".

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: Imre Deak <imre.deak at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 00c8361..b435db1 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1912,15 +1912,11 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 			gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD;
 			gfp &= ~(__GFP_IO | __GFP_WAIT);
 		}
+		if (!i || page_to_pfn(page) != last_pfn + 1
 #ifdef CONFIG_SWIOTLB
-		if (swiotlb_nr_tbl()) {
-			st->nents++;
-			sg_set_page(sg, page, PAGE_SIZE, 0);
-			sg = sg_next(sg);
-			continue;
-		}
+		       || swiotlb_nr_tbl()
 #endif
-		if (!i || page_to_pfn(page) != last_pfn + 1) {
+		  ) {
 			if (i)
 				sg = sg_next(sg);
 			st->nents++;
@@ -1933,10 +1929,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 		/* Check that the i965g/gm workaround works. */
 		WARN_ON((gfp & __GFP_DMA32) && (last_pfn >= 0x00100000UL));
 	}
-#ifdef CONFIG_SWIOTLB
-	if (!swiotlb_nr_tbl())
-#endif
-		sg_mark_end(sg);
+	sg_mark_end(sg);
 	obj->pages = st;
 
 	if (i915_gem_object_needs_bit17_swizzle(obj))
-- 
1.9.0




More information about the Intel-gfx mailing list