All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API
@ 2017-10-11  9:56 Chris Wilson
  2017-10-11 13:46 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2017-10-11  9:56 UTC (permalink / raw)
  To: intel-gfx

Ignore the unexpected success when the CPU cache is randomly flushed
that makes !llc appear to work without sync. It happens, the cpu cache
is a fickle beast that we do not have sole control over. Instead limit
the test to detect failures when the API is being adhered to.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103168
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/prime_mmap_coherency.c | 71 ++++++++++++++------------------------------
 1 file changed, 22 insertions(+), 49 deletions(-)

diff --git a/tests/prime_mmap_coherency.c b/tests/prime_mmap_coherency.c
index 9831d775..a213ac0f 100644
--- a/tests/prime_mmap_coherency.c
+++ b/tests/prime_mmap_coherency.c
@@ -34,10 +34,7 @@
 IGT_TEST_DESCRIPTION("Test dma-buf mmap on !llc platforms mostly and provoke"
 		" coherency bugs so we know for sure where we need the sync ioctls.");
 
-#define ROUNDS 20
-
 int fd;
-int stale = 0;
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
 static int width = 1024, height = 1024;
@@ -49,13 +46,14 @@ static int width = 1024, height = 1024;
  *   3. write '1's, in GTT domain.
  *   4. read again through the mapped dma-buf.
  */
-static void test_read_flush(bool expect_stale_cache)
+static int test_read_flush(void)
 {
 	drm_intel_bo *bo_1;
 	drm_intel_bo *bo_2;
 	uint32_t *ptr_cpu;
 	uint32_t *ptr_gtt;
 	int dma_buf_fd, i;
+	int stale = 0;
 
 	bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
 
@@ -94,18 +92,16 @@ static void test_read_flush(bool expect_stale_cache)
 	 * stale cachelines from step #2 survive (mostly, a few will be evicted)
 	 * until we try to read them again in step #4. This behavior could be fixed
 	 * by flush CPU read right before accessing the CPU pointer */
-	if (!expect_stale_cache)
-		prime_sync_start(dma_buf_fd, false);
+	prime_sync_start(dma_buf_fd, false);
 
 	for (i = 0; i < (width * height) / 4; i++)
-		if (ptr_cpu[i] != 0xc5c5c5c5) {
-			igt_warn_on_f(!expect_stale_cache,
-				    "Found 0x%08x at offset 0x%08x\n", ptr_cpu[i], i);
+		if (ptr_cpu[i] != 0xc5c5c5c5)
 			stale++;
-		}
 
 	drm_intel_bo_unreference(bo_1);
 	munmap(ptr_cpu, width * height);
+
+	return stale;
 }
 
 /*
@@ -115,13 +111,14 @@ static void test_read_flush(bool expect_stale_cache)
  *   3. copy BO 1 to new BO 2, in GTT domain.
  *   4. read via dma-buf mmap BO 2.
  */
-static void test_write_flush(bool expect_stale_cache)
+static int test_write_flush(void)
 {
 	drm_intel_bo *bo_1;
 	drm_intel_bo *bo_2;
 	uint32_t *ptr_cpu;
 	uint32_t *ptr2_cpu;
 	int dma_buf_fd, dma_buf2_fd, i;
+	int stale = 0;
 
 	bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
 
@@ -143,8 +140,7 @@ static void test_write_flush(bool expect_stale_cache)
 
 	/* This is the main point of this test: !llc hw requires a cache write
 	 * flush right here (explained in step #4). */
-	if (!expect_stale_cache)
-		prime_sync_start(dma_buf_fd, true);
+	prime_sync_start(dma_buf_fd, true);
 
 	memset(ptr_cpu, 0x11, width * height);
 
@@ -164,15 +160,14 @@ static void test_write_flush(bool expect_stale_cache)
 	igt_assert(ptr2_cpu != MAP_FAILED);
 
 	for (i = 0; i < (width * height) / 4; i++)
-		if (ptr2_cpu[i] != 0x11111111) {
-			igt_warn_on_f(!expect_stale_cache,
-				      "Found 0x%08x at offset 0x%08x\n", ptr2_cpu[i], i);
+		if (ptr2_cpu[i] != 0x11111111)
 			stale++;
-		}
 
 	drm_intel_bo_unreference(bo_1);
 	drm_intel_bo_unreference(bo_2);
 	munmap(ptr_cpu, width * height);
+
+	return stale;
 }
 
 static void blit_and_cmp(void)
@@ -279,7 +274,6 @@ static void test_ioctl_errors(void)
 
 int main(int argc, char **argv)
 {
-	int i;
 	igt_subtest_init(argc, argv);
 
 	igt_fixture {
@@ -293,41 +287,20 @@ int main(int argc, char **argv)
 	/* Cache coherency and the eviction are pretty much unpredictable, so
 	 * reproducing boils down to trial and error to hit different scenarios.
 	 * TODO: We may want to improve tests a bit by picking random subranges. */
-	igt_info("%d rounds for each test\n", ROUNDS);
 	igt_subtest("read") {
-		stale = 0;
-		igt_info("exercising read flush\n");
-		for (i = 0; i < ROUNDS; i++)
-			test_read_flush(false);
-		igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
-	}
-
-	/* Only for !llc platforms */
-	igt_subtest("read-and-fail") {
-		igt_require(!gem_has_llc(fd));
-		stale = 0;
-		igt_info("exercising read flush and expect to fail on !llc\n");
-		for (i = 0; i < ROUNDS; i++)
-			test_read_flush(true);
-		igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
+		igt_until_timeout(5) {
+			int stale = test_read_flush();
+			igt_fail_on_f(stale,
+				      "num of stale cache lines %d\n", stale);
+		}
 	}
 
 	igt_subtest("write") {
-		stale = 0;
-		igt_info("exercising write flush\n");
-		for (i = 0; i < ROUNDS; i++)
-			test_write_flush(false);
-		igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
-	}
-
-	/* Only for !llc platforms */
-	igt_subtest("write-and-fail") {
-		igt_require(!gem_has_llc(fd));
-		stale = 0;
-		igt_info("exercising write flush and expect to fail on !llc\n");
-		for (i = 0; i < ROUNDS; i++)
-			test_write_flush(true);
-		igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
+		igt_until_timeout(5) {
+			int stale = test_write_flush();
+			igt_fail_on_f(stale,
+				      "num of stale cache lines %d\n", stale);
+		}
 	}
 
 	igt_subtest("ioctl-errors") {
-- 
2.15.0.rc0

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

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

* ✓ Fi.CI.BAT: success for igt/prime_mmap_coherency: Only assert correct usage of sync API
  2017-10-11  9:56 [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API Chris Wilson
@ 2017-10-11 13:46 ` Patchwork
  2017-10-11 20:14 ` ✓ Fi.CI.IGT: " Patchwork
  2017-10-17 10:43 ` [PATCH igt] " Chris Wilson
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2017-10-11 13:46 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: igt/prime_mmap_coherency: Only assert correct usage of sync API
URL   : https://patchwork.freedesktop.org/series/31729/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
136100c2f00b590bc9485100cce012282c1217cf igt/syncobj_wait: Don't close the timeline early in wait_snapshot

with latest DRM-Tip kernel build CI_DRM_3213
36e0e803d3d7 drm-tip: 2017y-10m-11d-11h-31m-33s UTC integration manifest

Testlist changes:
-igt@prime_mmap_coherency@read-and-fail
-igt@prime_mmap_coherency@write-and-fail

Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                pass       -> INCOMPLETE (fi-kbl-r) fdo#102846

fdo#102846 https://bugs.freedesktop.org/show_bug.cgi?id=102846

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:454s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:465s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:391s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:579s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:286s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:529s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:524s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:549s
fi-cfl-s         total:289  pass:253  dwarn:4   dfail:0   fail:0   skip:32  time:562s
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:640s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:433s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:275s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:596s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:437s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:464s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:510s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:479s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:515s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:580s
fi-kbl-7567u     total:289  pass:265  dwarn:4   dfail:0   fail:0   skip:20  time:490s
fi-kbl-r         total:246  pass:221  dwarn:0   dfail:0   fail:0   skip:24 
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:664s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:463s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:666s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:529s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:513s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:474s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:585s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:438s

== Logs ==

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

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

* ✓ Fi.CI.IGT: success for igt/prime_mmap_coherency: Only assert correct usage of sync API
  2017-10-11  9:56 [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API Chris Wilson
  2017-10-11 13:46 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2017-10-11 20:14 ` Patchwork
  2017-10-17 10:43 ` [PATCH igt] " Chris Wilson
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2017-10-11 20:14 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: igt/prime_mmap_coherency: Only assert correct usage of sync API
URL   : https://patchwork.freedesktop.org/series/31729/
State : success

== Summary ==

Test gem_flink_race:
        Subgroup flink_close:
                pass       -> FAIL       (shard-hsw) fdo#102655

fdo#102655 https://bugs.freedesktop.org/show_bug.cgi?id=102655

shard-hsw        total:2550 pass:1434 dwarn:5   dfail:0   fail:10  skip:1101 time:9645s

== Logs ==

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

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

* Re: [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API
  2017-10-11  9:56 [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API Chris Wilson
  2017-10-11 13:46 ` ✓ Fi.CI.BAT: success for " Patchwork
  2017-10-11 20:14 ` ✓ Fi.CI.IGT: " Patchwork
@ 2017-10-17 10:43 ` Chris Wilson
  2017-10-17 12:05   ` Ville Syrjälä
  2 siblings, 1 reply; 5+ messages in thread
From: Chris Wilson @ 2017-10-17 10:43 UTC (permalink / raw)
  To: intel-gfx

Quoting Chris Wilson (2017-10-11 10:56:29)
> Ignore the unexpected success when the CPU cache is randomly flushed
> that makes !llc appear to work without sync. It happens, the cpu cache
> is a fickle beast that we do not have sole control over. Instead limit
> the test to detect failures when the API is being adhered to.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103168
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Ping?

> ---
>  tests/prime_mmap_coherency.c | 71 ++++++++++++++------------------------------
>  1 file changed, 22 insertions(+), 49 deletions(-)
> 
> diff --git a/tests/prime_mmap_coherency.c b/tests/prime_mmap_coherency.c
> index 9831d775..a213ac0f 100644
> --- a/tests/prime_mmap_coherency.c
> +++ b/tests/prime_mmap_coherency.c
> @@ -34,10 +34,7 @@
>  IGT_TEST_DESCRIPTION("Test dma-buf mmap on !llc platforms mostly and provoke"
>                 " coherency bugs so we know for sure where we need the sync ioctls.");
>  
> -#define ROUNDS 20
> -
>  int fd;
> -int stale = 0;
>  static drm_intel_bufmgr *bufmgr;
>  struct intel_batchbuffer *batch;
>  static int width = 1024, height = 1024;
> @@ -49,13 +46,14 @@ static int width = 1024, height = 1024;
>   *   3. write '1's, in GTT domain.
>   *   4. read again through the mapped dma-buf.
>   */
> -static void test_read_flush(bool expect_stale_cache)
> +static int test_read_flush(void)
>  {
>         drm_intel_bo *bo_1;
>         drm_intel_bo *bo_2;
>         uint32_t *ptr_cpu;
>         uint32_t *ptr_gtt;
>         int dma_buf_fd, i;
> +       int stale = 0;
>  
>         bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
>  
> @@ -94,18 +92,16 @@ static void test_read_flush(bool expect_stale_cache)
>          * stale cachelines from step #2 survive (mostly, a few will be evicted)
>          * until we try to read them again in step #4. This behavior could be fixed
>          * by flush CPU read right before accessing the CPU pointer */
> -       if (!expect_stale_cache)
> -               prime_sync_start(dma_buf_fd, false);
> +       prime_sync_start(dma_buf_fd, false);
>  
>         for (i = 0; i < (width * height) / 4; i++)
> -               if (ptr_cpu[i] != 0xc5c5c5c5) {
> -                       igt_warn_on_f(!expect_stale_cache,
> -                                   "Found 0x%08x at offset 0x%08x\n", ptr_cpu[i], i);
> +               if (ptr_cpu[i] != 0xc5c5c5c5)
>                         stale++;
> -               }
>  
>         drm_intel_bo_unreference(bo_1);
>         munmap(ptr_cpu, width * height);
> +
> +       return stale;
>  }
>  
>  /*
> @@ -115,13 +111,14 @@ static void test_read_flush(bool expect_stale_cache)
>   *   3. copy BO 1 to new BO 2, in GTT domain.
>   *   4. read via dma-buf mmap BO 2.
>   */
> -static void test_write_flush(bool expect_stale_cache)
> +static int test_write_flush(void)
>  {
>         drm_intel_bo *bo_1;
>         drm_intel_bo *bo_2;
>         uint32_t *ptr_cpu;
>         uint32_t *ptr2_cpu;
>         int dma_buf_fd, dma_buf2_fd, i;
> +       int stale = 0;
>  
>         bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
>  
> @@ -143,8 +140,7 @@ static void test_write_flush(bool expect_stale_cache)
>  
>         /* This is the main point of this test: !llc hw requires a cache write
>          * flush right here (explained in step #4). */
> -       if (!expect_stale_cache)
> -               prime_sync_start(dma_buf_fd, true);
> +       prime_sync_start(dma_buf_fd, true);
>  
>         memset(ptr_cpu, 0x11, width * height);
>  
> @@ -164,15 +160,14 @@ static void test_write_flush(bool expect_stale_cache)
>         igt_assert(ptr2_cpu != MAP_FAILED);
>  
>         for (i = 0; i < (width * height) / 4; i++)
> -               if (ptr2_cpu[i] != 0x11111111) {
> -                       igt_warn_on_f(!expect_stale_cache,
> -                                     "Found 0x%08x at offset 0x%08x\n", ptr2_cpu[i], i);
> +               if (ptr2_cpu[i] != 0x11111111)
>                         stale++;
> -               }
>  
>         drm_intel_bo_unreference(bo_1);
>         drm_intel_bo_unreference(bo_2);
>         munmap(ptr_cpu, width * height);
> +
> +       return stale;
>  }
>  
>  static void blit_and_cmp(void)
> @@ -279,7 +274,6 @@ static void test_ioctl_errors(void)
>  
>  int main(int argc, char **argv)
>  {
> -       int i;
>         igt_subtest_init(argc, argv);
>  
>         igt_fixture {
> @@ -293,41 +287,20 @@ int main(int argc, char **argv)
>         /* Cache coherency and the eviction are pretty much unpredictable, so
>          * reproducing boils down to trial and error to hit different scenarios.
>          * TODO: We may want to improve tests a bit by picking random subranges. */
> -       igt_info("%d rounds for each test\n", ROUNDS);
>         igt_subtest("read") {
> -               stale = 0;
> -               igt_info("exercising read flush\n");
> -               for (i = 0; i < ROUNDS; i++)
> -                       test_read_flush(false);
> -               igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
> -       }
> -
> -       /* Only for !llc platforms */
> -       igt_subtest("read-and-fail") {
> -               igt_require(!gem_has_llc(fd));
> -               stale = 0;
> -               igt_info("exercising read flush and expect to fail on !llc\n");
> -               for (i = 0; i < ROUNDS; i++)
> -                       test_read_flush(true);
> -               igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
> +               igt_until_timeout(5) {
> +                       int stale = test_read_flush();
> +                       igt_fail_on_f(stale,
> +                                     "num of stale cache lines %d\n", stale);
> +               }
>         }
>  
>         igt_subtest("write") {
> -               stale = 0;
> -               igt_info("exercising write flush\n");
> -               for (i = 0; i < ROUNDS; i++)
> -                       test_write_flush(false);
> -               igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
> -       }
> -
> -       /* Only for !llc platforms */
> -       igt_subtest("write-and-fail") {
> -               igt_require(!gem_has_llc(fd));
> -               stale = 0;
> -               igt_info("exercising write flush and expect to fail on !llc\n");
> -               for (i = 0; i < ROUNDS; i++)
> -                       test_write_flush(true);
> -               igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
> +               igt_until_timeout(5) {
> +                       int stale = test_write_flush();
> +                       igt_fail_on_f(stale,
> +                                     "num of stale cache lines %d\n", stale);
> +               }
>         }
>  
>         igt_subtest("ioctl-errors") {
> -- 
> 2.15.0.rc0
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API
  2017-10-17 10:43 ` [PATCH igt] " Chris Wilson
@ 2017-10-17 12:05   ` Ville Syrjälä
  0 siblings, 0 replies; 5+ messages in thread
From: Ville Syrjälä @ 2017-10-17 12:05 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Tue, Oct 17, 2017 at 11:43:52AM +0100, Chris Wilson wrote:
> Quoting Chris Wilson (2017-10-11 10:56:29)
> > Ignore the unexpected success when the CPU cache is randomly flushed
> > that makes !llc appear to work without sync. It happens, the cpu cache
> > is a fickle beast that we do not have sole control over. Instead limit
> > the test to detect failures when the API is being adhered to.
> > 
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103168
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Ping?

Rationale makes sense.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> 
> > ---
> >  tests/prime_mmap_coherency.c | 71 ++++++++++++++------------------------------
> >  1 file changed, 22 insertions(+), 49 deletions(-)
> > 
> > diff --git a/tests/prime_mmap_coherency.c b/tests/prime_mmap_coherency.c
> > index 9831d775..a213ac0f 100644
> > --- a/tests/prime_mmap_coherency.c
> > +++ b/tests/prime_mmap_coherency.c
> > @@ -34,10 +34,7 @@
> >  IGT_TEST_DESCRIPTION("Test dma-buf mmap on !llc platforms mostly and provoke"
> >                 " coherency bugs so we know for sure where we need the sync ioctls.");
> >  
> > -#define ROUNDS 20
> > -
> >  int fd;
> > -int stale = 0;
> >  static drm_intel_bufmgr *bufmgr;
> >  struct intel_batchbuffer *batch;
> >  static int width = 1024, height = 1024;
> > @@ -49,13 +46,14 @@ static int width = 1024, height = 1024;
> >   *   3. write '1's, in GTT domain.
> >   *   4. read again through the mapped dma-buf.
> >   */
> > -static void test_read_flush(bool expect_stale_cache)
> > +static int test_read_flush(void)
> >  {
> >         drm_intel_bo *bo_1;
> >         drm_intel_bo *bo_2;
> >         uint32_t *ptr_cpu;
> >         uint32_t *ptr_gtt;
> >         int dma_buf_fd, i;
> > +       int stale = 0;
> >  
> >         bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
> >  
> > @@ -94,18 +92,16 @@ static void test_read_flush(bool expect_stale_cache)
> >          * stale cachelines from step #2 survive (mostly, a few will be evicted)
> >          * until we try to read them again in step #4. This behavior could be fixed
> >          * by flush CPU read right before accessing the CPU pointer */
> > -       if (!expect_stale_cache)
> > -               prime_sync_start(dma_buf_fd, false);
> > +       prime_sync_start(dma_buf_fd, false);
> >  
> >         for (i = 0; i < (width * height) / 4; i++)
> > -               if (ptr_cpu[i] != 0xc5c5c5c5) {
> > -                       igt_warn_on_f(!expect_stale_cache,
> > -                                   "Found 0x%08x at offset 0x%08x\n", ptr_cpu[i], i);
> > +               if (ptr_cpu[i] != 0xc5c5c5c5)
> >                         stale++;
> > -               }
> >  
> >         drm_intel_bo_unreference(bo_1);
> >         munmap(ptr_cpu, width * height);
> > +
> > +       return stale;
> >  }
> >  
> >  /*
> > @@ -115,13 +111,14 @@ static void test_read_flush(bool expect_stale_cache)
> >   *   3. copy BO 1 to new BO 2, in GTT domain.
> >   *   4. read via dma-buf mmap BO 2.
> >   */
> > -static void test_write_flush(bool expect_stale_cache)
> > +static int test_write_flush(void)
> >  {
> >         drm_intel_bo *bo_1;
> >         drm_intel_bo *bo_2;
> >         uint32_t *ptr_cpu;
> >         uint32_t *ptr2_cpu;
> >         int dma_buf_fd, dma_buf2_fd, i;
> > +       int stale = 0;
> >  
> >         bo_1 = drm_intel_bo_alloc(bufmgr, "BO 1", width * height * 4, 4096);
> >  
> > @@ -143,8 +140,7 @@ static void test_write_flush(bool expect_stale_cache)
> >  
> >         /* This is the main point of this test: !llc hw requires a cache write
> >          * flush right here (explained in step #4). */
> > -       if (!expect_stale_cache)
> > -               prime_sync_start(dma_buf_fd, true);
> > +       prime_sync_start(dma_buf_fd, true);
> >  
> >         memset(ptr_cpu, 0x11, width * height);
> >  
> > @@ -164,15 +160,14 @@ static void test_write_flush(bool expect_stale_cache)
> >         igt_assert(ptr2_cpu != MAP_FAILED);
> >  
> >         for (i = 0; i < (width * height) / 4; i++)
> > -               if (ptr2_cpu[i] != 0x11111111) {
> > -                       igt_warn_on_f(!expect_stale_cache,
> > -                                     "Found 0x%08x at offset 0x%08x\n", ptr2_cpu[i], i);
> > +               if (ptr2_cpu[i] != 0x11111111)
> >                         stale++;
> > -               }
> >  
> >         drm_intel_bo_unreference(bo_1);
> >         drm_intel_bo_unreference(bo_2);
> >         munmap(ptr_cpu, width * height);
> > +
> > +       return stale;
> >  }
> >  
> >  static void blit_and_cmp(void)
> > @@ -279,7 +274,6 @@ static void test_ioctl_errors(void)
> >  
> >  int main(int argc, char **argv)
> >  {
> > -       int i;
> >         igt_subtest_init(argc, argv);
> >  
> >         igt_fixture {
> > @@ -293,41 +287,20 @@ int main(int argc, char **argv)
> >         /* Cache coherency and the eviction are pretty much unpredictable, so
> >          * reproducing boils down to trial and error to hit different scenarios.
> >          * TODO: We may want to improve tests a bit by picking random subranges. */
> > -       igt_info("%d rounds for each test\n", ROUNDS);
> >         igt_subtest("read") {
> > -               stale = 0;
> > -               igt_info("exercising read flush\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_read_flush(false);
> > -               igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
> > -       }
> > -
> > -       /* Only for !llc platforms */
> > -       igt_subtest("read-and-fail") {
> > -               igt_require(!gem_has_llc(fd));
> > -               stale = 0;
> > -               igt_info("exercising read flush and expect to fail on !llc\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_read_flush(true);
> > -               igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
> > +               igt_until_timeout(5) {
> > +                       int stale = test_read_flush();
> > +                       igt_fail_on_f(stale,
> > +                                     "num of stale cache lines %d\n", stale);
> > +               }
> >         }
> >  
> >         igt_subtest("write") {
> > -               stale = 0;
> > -               igt_info("exercising write flush\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_write_flush(false);
> > -               igt_fail_on_f(stale, "num of stale cache lines %d\n", stale);
> > -       }
> > -
> > -       /* Only for !llc platforms */
> > -       igt_subtest("write-and-fail") {
> > -               igt_require(!gem_has_llc(fd));
> > -               stale = 0;
> > -               igt_info("exercising write flush and expect to fail on !llc\n");
> > -               for (i = 0; i < ROUNDS; i++)
> > -                       test_write_flush(true);
> > -               igt_fail_on_f(!stale, "couldn't find any stale cache lines\n");
> > +               igt_until_timeout(5) {
> > +                       int stale = test_write_flush();
> > +                       igt_fail_on_f(stale,
> > +                                     "num of stale cache lines %d\n", stale);
> > +               }
> >         }
> >  
> >         igt_subtest("ioctl-errors") {
> > -- 
> > 2.15.0.rc0
> > 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2017-10-17 12:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11  9:56 [PATCH igt] igt/prime_mmap_coherency: Only assert correct usage of sync API Chris Wilson
2017-10-11 13:46 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-10-11 20:14 ` ✓ Fi.CI.IGT: " Patchwork
2017-10-17 10:43 ` [PATCH igt] " Chris Wilson
2017-10-17 12:05   ` Ville Syrjälä

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.