All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Simplify guard logic for setup_scratch_page()
@ 2018-01-29 10:28 Chris Wilson
  2018-01-29 10:32 ` Chris Wilson
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Chris Wilson @ 2018-01-29 10:28 UTC (permalink / raw)
  To: intel-gfx; +Cc: Matthew Auld

Older gcc is complaining it can't follow the guards and thinks that
addr may be used uninitialised

In the process, we can simplify down to one loop,
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-131 (-131)
Function                                     old     new   delta
setup_scratch_page                           545     414    -131

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 68 +++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index be227512430a..0a0030e4cb10 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -543,9 +543,7 @@ static void fill_page_dma_32(struct i915_address_space *vm,
 static int
 setup_scratch_page(struct i915_address_space *vm, gfp_t gfp)
 {
-	struct page *page = NULL;
-	dma_addr_t addr;
-	int order;
+	unsigned long size;
 
 	/*
 	 * In order to utilize 64K pages for an object with a size < 2M, we will
@@ -559,48 +557,46 @@ setup_scratch_page(struct i915_address_space *vm, gfp_t gfp)
 	 * TODO: we should really consider write-protecting the scratch-page and
 	 * sharing between ppgtt
 	 */
+	size = I915_GTT_PAGE_SIZE_4K;
 	if (i915_vm_is_48bit(vm) &&
 	    HAS_PAGE_SIZES(vm->i915, I915_GTT_PAGE_SIZE_64K)) {
-		order = get_order(I915_GTT_PAGE_SIZE_64K);
-		page = alloc_pages(gfp | __GFP_ZERO | __GFP_NOWARN, order);
-		if (page) {
-			addr = dma_map_page(vm->dma, page, 0,
-					    I915_GTT_PAGE_SIZE_64K,
-					    PCI_DMA_BIDIRECTIONAL);
-			if (unlikely(dma_mapping_error(vm->dma, addr))) {
-				__free_pages(page, order);
-				page = NULL;
-			}
-
-			if (!IS_ALIGNED(addr, I915_GTT_PAGE_SIZE_64K)) {
-				dma_unmap_page(vm->dma, addr,
-					       I915_GTT_PAGE_SIZE_64K,
-					       PCI_DMA_BIDIRECTIONAL);
-				__free_pages(page, order);
-				page = NULL;
-			}
-		}
+		size = I915_GTT_PAGE_SIZE_64K;
+		gfp |= __GFP_NOWARN;
 	}
 
-	if (!page) {
-		order = 0;
-		page = alloc_page(gfp | __GFP_ZERO);
+	do {
+		int order = get_order(size);
+		struct page *page;
+		dma_addr_t addr;
+
+		page = alloc_pages(gfp | __GFP_ZERO, order);
 		if (unlikely(!page))
-			return -ENOMEM;
+			goto skip;
 
-		addr = dma_map_page(vm->dma, page, 0, PAGE_SIZE,
+		addr = dma_map_page(vm->dma, page, 0, size,
 				    PCI_DMA_BIDIRECTIONAL);
-		if (unlikely(dma_mapping_error(vm->dma, addr))) {
-			__free_page(page);
-			return -ENOMEM;
-		}
-	}
+		if (unlikely(dma_mapping_error(vm->dma, addr)))
+			goto free_page;
 
-	vm->scratch_page.page = page;
-	vm->scratch_page.daddr = addr;
-	vm->scratch_page.order = order;
+		if (unlikely(!IS_ALIGNED(addr, size)))
+			goto unmap_page;
 
-	return 0;
+		vm->scratch_page.page = page;
+		vm->scratch_page.daddr = addr;
+		vm->scratch_page.order = order;
+		return 0;
+
+unmap_page:
+		dma_unmap_page(vm->dma, addr, size, PCI_DMA_BIDIRECTIONAL);
+free_page:
+		__free_pages(page, order);
+skip:
+		if (size == I915_GTT_PAGE_SIZE_4K)
+			return -ENOMEM;
+
+		size = I915_GTT_PAGE_SIZE_4K;
+		gfp &= ~__GFP_NOWARN;
+	} while (1);
 }
 
 static void cleanup_scratch_page(struct i915_address_space *vm)
-- 
2.15.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: Simplify guard logic for setup_scratch_page()
  2018-01-29 10:28 [PATCH] drm/i915: Simplify guard logic for setup_scratch_page() Chris Wilson
@ 2018-01-29 10:32 ` Chris Wilson
  2018-01-29 10:54 ` Matthew Auld
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2018-01-29 10:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Matthew Auld

Quoting Chris Wilson (2018-01-29 10:28:40)
> Older gcc is complaining it can't follow the guards and thinks that
> addr may be used uninitialised
> 
> In the process, we can simplify down to one loop,
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-131 (-131)
> Function                                     old     new   delta
> setup_scratch_page                           545     414    -131
> 
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld@intel.com>
> ---
> +       size = I915_GTT_PAGE_SIZE_4K;
>         if (i915_vm_is_48bit(vm) &&
>             HAS_PAGE_SIZES(vm->i915, I915_GTT_PAGE_SIZE_64K)) {
> +               size = I915_GTT_PAGE_SIZE_64K;
> +               gfp |= __GFP_NOWARN;

We may want to sneak in a __GFP_RETRY_MAYFAIL here.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: Simplify guard logic for setup_scratch_page()
  2018-01-29 10:28 [PATCH] drm/i915: Simplify guard logic for setup_scratch_page() Chris Wilson
  2018-01-29 10:32 ` Chris Wilson
@ 2018-01-29 10:54 ` Matthew Auld
  2018-01-29 20:53   ` Chris Wilson
  2018-01-29 11:48 ` ✓ Fi.CI.BAT: success for " Patchwork
  2018-01-29 16:28 ` ✗ Fi.CI.IGT: warning " Patchwork
  3 siblings, 1 reply; 6+ messages in thread
From: Matthew Auld @ 2018-01-29 10:54 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Intel Graphics Development, Matthew Auld

On 29 January 2018 at 10:28, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Older gcc is complaining it can't follow the guards and thinks that
> addr may be used uninitialised
>
> In the process, we can simplify down to one loop,
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-131 (-131)
> Function                                     old     new   delta
> setup_scratch_page                           545     414    -131
>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld@intel.com>

With or without __GFP_RETRY_MAYFAIL:

Reviewed-by: Matthew Auld <matthew.auld@intel.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915: Simplify guard logic for setup_scratch_page()
  2018-01-29 10:28 [PATCH] drm/i915: Simplify guard logic for setup_scratch_page() Chris Wilson
  2018-01-29 10:32 ` Chris Wilson
  2018-01-29 10:54 ` Matthew Auld
@ 2018-01-29 11:48 ` Patchwork
  2018-01-29 16:28 ` ✗ Fi.CI.IGT: warning " Patchwork
  3 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2018-01-29 11:48 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Simplify guard logic for setup_scratch_page()
URL   : https://patchwork.freedesktop.org/series/37265/
State : success

== Summary ==

Series 37265v1 drm/i915: Simplify guard logic for setup_scratch_page()
https://patchwork.freedesktop.org/api/1.0/series/37265/revisions/1/mbox/

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:419s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:425s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:370s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:489s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:281s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:484s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:484s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:470s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:460s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:565s
fi-elk-e7500     total:224  pass:168  dwarn:9   dfail:1   fail:0   skip:45 
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:279s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:513s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:391s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:398s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:413s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:462s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:414s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:456s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:497s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:455s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:500s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:576s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:431s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:511s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:527s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:489s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:497s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:415s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:431s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:533s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:398s
Blacklisted hosts:
fi-cnl-y2        total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:538s
fi-glk-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:477s

2bbded26cfa2309e876e69069c85acae21b09920 drm-tip: 2018y-01m-29d-10h-43m-15s UTC integration manifest
51145ced7dd5 drm/i915: Simplify guard logic for setup_scratch_page()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7806/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* ✗ Fi.CI.IGT: warning for drm/i915: Simplify guard logic for setup_scratch_page()
  2018-01-29 10:28 [PATCH] drm/i915: Simplify guard logic for setup_scratch_page() Chris Wilson
                   ` (2 preceding siblings ...)
  2018-01-29 11:48 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-01-29 16:28 ` Patchwork
  3 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2018-01-29 16:28 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Simplify guard logic for setup_scratch_page()
URL   : https://patchwork.freedesktop.org/series/37265/
State : warning

== Summary ==

Test kms_frontbuffer_tracking:
        Subgroup fbc-suspend:
                skip       -> PASS       (shard-snb) fdo#101623 +2
Test kms_draw_crc:
        Subgroup draw-method-xrgb2101010-render-untiled:
                pass       -> SKIP       (shard-snb)
Test gem_exec_suspend:
        Subgroup basic-s3:
                pass       -> SKIP       (shard-snb) fdo#103880
Test kms_plane:
        Subgroup plane-panning-bottom-right-suspend-pipe-a-planes:
                skip       -> PASS       (shard-snb) fdo#102365
Test perf:
        Subgroup oa-exponents:
                pass       -> FAIL       (shard-apl) fdo#102254
Test gem_eio:
        Subgroup in-flight:
                dmesg-warn -> PASS       (shard-snb) fdo#104058
Test syncobj_wait:
        Subgroup wait-any-snapshot:
                fail       -> PASS       (shard-apl)

fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#103880 https://bugs.freedesktop.org/show_bug.cgi?id=103880
fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#104058 https://bugs.freedesktop.org/show_bug.cgi?id=104058

shard-apl        total:2838 pass:1751 dwarn:1   dfail:0   fail:22  skip:1064 time:12639s
shard-hsw        total:2838 pass:1736 dwarn:1   dfail:0   fail:10  skip:1090 time:12058s
shard-snb        total:2838 pass:1328 dwarn:1   dfail:0   fail:10  skip:1499 time:6693s
Blacklisted hosts:
shard-kbl        total:2838 pass:1870 dwarn:4   dfail:0   fail:22  skip:942 time:9622s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7806/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/i915: Simplify guard logic for setup_scratch_page()
  2018-01-29 10:54 ` Matthew Auld
@ 2018-01-29 20:53   ` Chris Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2018-01-29 20:53 UTC (permalink / raw)
  To: Matthew Auld; +Cc: Intel Graphics Development, Matthew Auld

Quoting Matthew Auld (2018-01-29 10:54:35)
> On 29 January 2018 at 10:28, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > Older gcc is complaining it can't follow the guards and thinks that
> > addr may be used uninitialised
> >
> > In the process, we can simplify down to one loop,
> > add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-131 (-131)
> > Function                                     old     new   delta
> > setup_scratch_page                           545     414    -131
> >
> > Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Matthew Auld <matthew.auld@intel.com>
> 
> With or without __GFP_RETRY_MAYFAIL:

Snuck it in.
 
> Reviewed-by: Matthew Auld <matthew.auld@intel.com>

Ta, pushed. Remind me in 6 months (4.17) to see if we're finally clean.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-29 20:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-29 10:28 [PATCH] drm/i915: Simplify guard logic for setup_scratch_page() Chris Wilson
2018-01-29 10:32 ` Chris Wilson
2018-01-29 10:54 ` Matthew Auld
2018-01-29 20:53   ` Chris Wilson
2018-01-29 11:48 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-01-29 16:28 ` ✗ Fi.CI.IGT: warning " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.