diff mbox series

[i-g-t,1/3] i915/gem_eio: Race kms on/off vs reset

Message ID 20190911101501.7182-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [i-g-t,1/3] i915/gem_eio: Race kms on/off vs reset | expand

Commit Message

Chris Wilson Sept. 11, 2019, 10:14 a.m. UTC
On older platforms, performing a GPU reset clobbers the display.
Exercise the interactions between reset/wedge and the display and
hopefully prevent any races creeping in.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/i915/gem_eio.c | 79 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

Comments

Andi Shyti Sept. 19, 2019, 2:08 p.m. UTC | #1
Hi Chris,

On Wed, Sep 11, 2019 at 11:14:59AM +0100, Chris Wilson wrote:
> On older platforms, performing a GPU reset clobbers the display.
> Exercise the interactions between reset/wedge and the display and
> hopefully prevent any races creeping in.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>

Is Ville Cc'ed for real or just nominally?

looks straight forward,

Reviewed-by: Andi Shyti <andi.shyti@intel.com>

Andi
Chris Wilson Sept. 19, 2019, 2:20 p.m. UTC | #2
Quoting Andi Shyti (2019-09-19 15:08:57)
> Hi Chris,
> 
> On Wed, Sep 11, 2019 at 11:14:59AM +0100, Chris Wilson wrote:
> > On older platforms, performing a GPU reset clobbers the display.
> > Exercise the interactions between reset/wedge and the display and
> > hopefully prevent any races creeping in.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Is Ville Cc'ed for real or just nominally?

He's in the original cc. As it is using "Syrjälä", that means I copied
his email address from one of his commits, so it should be the right
address.

mailman naturally drops cc of list members...
-Chris
Ville Syrjälä Sept. 19, 2019, 2:28 p.m. UTC | #3
On Wed, Sep 11, 2019 at 11:14:59AM +0100, Chris Wilson wrote:
> On older platforms, performing a GPU reset clobbers the display.
> Exercise the interactions between reset/wedge and the display and
> hopefully prevent any races creeping in.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  tests/i915/gem_eio.c | 79 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 79 insertions(+)
> 
> diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
> index 9b086a039..e0213c76c 100644
> --- a/tests/i915/gem_eio.c
> +++ b/tests/i915/gem_eio.c
> @@ -42,6 +42,8 @@
>  
>  #include "igt.h"
>  #include "igt_device.h"
> +#include "igt_fb.h"
> +#include "igt_kms.h"
>  #include "igt_stats.h"
>  #include "igt_sysfs.h"
>  #include "sw_sync.h"
> @@ -813,6 +815,67 @@ static void test_reset_stress(int fd, unsigned int flags)
>  	gem_context_destroy(fd, ctx0);
>  }
>  
> +/*
> + * Modesetting vs wedged
> + */
> +
> +static void display_helper(igt_display_t *dpy, int *done)
> +{
> +	const int commit = dpy->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY;
> +	struct igt_fb fb = {};
> +
> +	while (!READ_ONCE(*done)) {
> +		drmModeModeInfoPtr mode;
> +		igt_plane_t *primary;
> +		igt_output_t *output;
> +		int pipe;
> +
> +		pipe = rand() % dpy->n_pipes;

I guess this ends up doing nothing if we get the same pipe twice in a
row? Hmm, I guess it does actually do something but since nothing
significant would change the kernel likely just downgrades it to a
fastset. But maybe that's fine.

There are some reset vs. modeset type of tests in kms_flip, but those
are rather more carefully sequenced so they are probably not so great
at finding new races.

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

> +		output = igt_get_single_output_for_pipe(dpy, pipe);
> +		if (!output)
> +			continue;
> +
> +		igt_output_set_pipe(output, pipe);
> +		mode = igt_output_get_mode(output);
> +
> +		if (fb.width != mode->hdisplay || fb.height != mode->vdisplay) {
> +			igt_remove_fb(dpy->drm_fd, &fb);
> +			igt_create_pattern_fb(dpy->drm_fd,
> +					      mode->hdisplay, mode->vdisplay,
> +					      DRM_FORMAT_XRGB8888,
> +					      LOCAL_I915_FORMAT_MOD_X_TILED,
> +					      &fb);
> +		}
> +
> +		primary = igt_output_get_plane_type(output,
> +						    DRM_PLANE_TYPE_PRIMARY);
> +		igt_plane_set_fb(primary, &fb);
> +
> +		igt_display_commit2(dpy, commit);
> +		igt_display_reset(dpy);
> +	}
> +
> +	igt_remove_fb(dpy->drm_fd, &fb);
> +}
> +
> +static void test_kms(int i915, igt_display_t *dpy)
> +{
> +	int *shared;
> +
> +	shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
> +	igt_assert(shared != MAP_FAILED);
> +
> +	igt_fork(child, 1)
> +		display_helper(dpy, shared);
> +
> +	test_reset_stress(i915, 0);
> +	test_reset_stress(i915, TEST_WEDGE);
> +
> +	*shared = 1;
> +	igt_waitchildren();
> +	munmap(shared, 4096);
> +}
> +
>  static int fd = -1;
>  
>  static void
> @@ -906,4 +969,20 @@ igt_main
>  			}
>  		}
>  	}
> +
> +	igt_subtest_group {
> +		igt_display_t display = {
> +			.drm_fd = -1, .n_pipes = IGT_MAX_PIPES
> +		};
> +
> +		igt_fixture {
> +			igt_device_set_master(fd);
> +
> +			igt_display_require(&display, fd);
> +			igt_display_require_output(&display);
> +		}
> +
> +		igt_subtest("kms")
> +			test_kms(fd, &display);
> +	}
>  }
> -- 
> 2.23.0
diff mbox series

Patch

diff --git a/tests/i915/gem_eio.c b/tests/i915/gem_eio.c
index 9b086a039..e0213c76c 100644
--- a/tests/i915/gem_eio.c
+++ b/tests/i915/gem_eio.c
@@ -42,6 +42,8 @@ 
 
 #include "igt.h"
 #include "igt_device.h"
+#include "igt_fb.h"
+#include "igt_kms.h"
 #include "igt_stats.h"
 #include "igt_sysfs.h"
 #include "sw_sync.h"
@@ -813,6 +815,67 @@  static void test_reset_stress(int fd, unsigned int flags)
 	gem_context_destroy(fd, ctx0);
 }
 
+/*
+ * Modesetting vs wedged
+ */
+
+static void display_helper(igt_display_t *dpy, int *done)
+{
+	const int commit = dpy->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY;
+	struct igt_fb fb = {};
+
+	while (!READ_ONCE(*done)) {
+		drmModeModeInfoPtr mode;
+		igt_plane_t *primary;
+		igt_output_t *output;
+		int pipe;
+
+		pipe = rand() % dpy->n_pipes;
+		output = igt_get_single_output_for_pipe(dpy, pipe);
+		if (!output)
+			continue;
+
+		igt_output_set_pipe(output, pipe);
+		mode = igt_output_get_mode(output);
+
+		if (fb.width != mode->hdisplay || fb.height != mode->vdisplay) {
+			igt_remove_fb(dpy->drm_fd, &fb);
+			igt_create_pattern_fb(dpy->drm_fd,
+					      mode->hdisplay, mode->vdisplay,
+					      DRM_FORMAT_XRGB8888,
+					      LOCAL_I915_FORMAT_MOD_X_TILED,
+					      &fb);
+		}
+
+		primary = igt_output_get_plane_type(output,
+						    DRM_PLANE_TYPE_PRIMARY);
+		igt_plane_set_fb(primary, &fb);
+
+		igt_display_commit2(dpy, commit);
+		igt_display_reset(dpy);
+	}
+
+	igt_remove_fb(dpy->drm_fd, &fb);
+}
+
+static void test_kms(int i915, igt_display_t *dpy)
+{
+	int *shared;
+
+	shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	igt_assert(shared != MAP_FAILED);
+
+	igt_fork(child, 1)
+		display_helper(dpy, shared);
+
+	test_reset_stress(i915, 0);
+	test_reset_stress(i915, TEST_WEDGE);
+
+	*shared = 1;
+	igt_waitchildren();
+	munmap(shared, 4096);
+}
+
 static int fd = -1;
 
 static void
@@ -906,4 +969,20 @@  igt_main
 			}
 		}
 	}
+
+	igt_subtest_group {
+		igt_display_t display = {
+			.drm_fd = -1, .n_pipes = IGT_MAX_PIPES
+		};
+
+		igt_fixture {
+			igt_device_set_master(fd);
+
+			igt_display_require(&display, fd);
+			igt_display_require_output(&display);
+		}
+
+		igt_subtest("kms")
+			test_kms(fd, &display);
+	}
 }