Skip to contentSkip to conversation

drm/i915: Simplify page allocation loop a bit

RFC In review Tvrtko Ursulin 3 participants 6 messages Mar 26, 2014 – Mar 27, 2014

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

RFC 1/1 drm/i915: Simplify page allocation loop a bit

From: Tvrtko Ursulin <[email protected]>

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

I haven't tested this so just RFC please.

---
 drivers/gpu/drm/i915/i915_gem.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -13
index 00c8361..5af3537 100644
@@ -1912,15 +1912,8 @@ 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);
 		}
-#ifdef CONFIG_SWIOTLB
-		if (swiotlb_nr_tbl()) {
-			st->nents++;
-			sg_set_page(sg, page, PAGE_SIZE, 0);
-			sg = sg_next(sg);
-			continue;
-		}
-#endif
-		if (!i || page_to_pfn(page) != last_pfn + 1) {
+		if (!i || page_to_pfn(page) != last_pfn + 1
+		       || swiotlb_nr_tbl()) {
 			if (i)
 				sg = sg_next(sg);
 			st->nents++;
@@ -1933,10 +1926,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))
Signature · 1 line
1.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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

I haven't tested this so just RFC please.

Looks good to me. Fwiw:

Quoted 28 lines
---
 drivers/gpu/drm/i915/i915_gem.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -9
index 00c8361..5af3537 100644
@@ -1912,15 +1912,8 @@ 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);
 		}
-#ifdef CONFIG_SWIOTLB
-		if (swiotlb_nr_tbl()) {
-			st->nents++;
-			sg_set_page(sg, page, PAGE_SIZE, 0);
-			sg = sg_next(sg);
-			continue;
-		}
-#endif
-		if (!i || page_to_pfn(page) != last_pfn + 1) {
+		if (!i || page_to_pfn(page) != last_pfn + 1
+		       || swiotlb_nr_tbl()) {
 			if (i)
 				sg = sg_next(sg);
 			st->nents++;
@@ -1933,10 +1926,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
 		/* Check that the i965g/gm workaround works. */

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) · line 1932

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +1 -4
 		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))

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Tvrtko Ursulin
Quoted 9 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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

I haven't tested this so just RFC please.

I am pretty sure we can't drop CONFIG_SWIOTLB as swiotlb_nr_tbl only exists when lib/swiotlb.c is built i.e. #if IS_ENABLED(CONFIG_SWIOTLB). -Chris

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

From: Tvrtko Ursulin <[email protected]>

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

Quoted 7 lines
Quoted 4 lines

I haven't tested this so just RFC please.

I am pretty sure we can't drop CONFIG_SWIOTLB as swiotlb_nr_tbl only exists when lib/swiotlb.c is built i.e. #if IS_ENABLED(CONFIG_SWIOTLB).

I think you're right. I'll repost. Although it diminishes the attractiveness of the whole line reducing enterprise a bit.

Thanks,

Tvrtko

#4 lore raw

RFC 1/1 drm/i915: Simplify page allocation loop a bit

In reply to Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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...".

---
 drivers/gpu/drm/i915/i915_gem.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +4 -11
index 00c8361..b435db1 100644
@@ -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))
Signature · 1 line
1.9.0
#5 lore raw
Quoted 11 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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...".

For what it is worth, this builds and doesn't blow up on some smoke tests.

Tvrtko