All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] lib: fix exit handler when multiple handlers are registered
@ 2013-05-22 14:40 Imre Deak
  2013-05-22 14:40 ` [PATCH 2/4] lib: export the exit handler interface Imre Deak
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Imre Deak @ 2013-05-22 14:40 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 lib/drmtest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 981ab4b..9fc03a0 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1065,7 +1065,7 @@ static void call_exit_handlers(int sig)
 		return;
 	}
 
-	for (i = 0; i < exit_handler_count; i++)
+	for (i = exit_handler_count - 1; i >= 0; i--)
 		exit_handler_fn[i](sig);
 }
 
@@ -1111,6 +1111,9 @@ static int drmtest_install_exit_handler(drmtest_exit_handler_t fn)
 	exit_handler_fn[exit_handler_count] = fn;
 	exit_handler_count++;
 
+	if (exit_handler_count > 1)
+		return 0;
+
 	for (i = 0; i < ARRAY_SIZE(handled_signals); i++) {
 		if (install_sig_handler(handled_signals[i],
 					drmtest_sig_handler))
-- 
1.8.1.2

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

* [PATCH 2/4] lib: export the exit handler interface
  2013-05-22 14:40 [PATCH 1/4] lib: fix exit handler when multiple handlers are registered Imre Deak
@ 2013-05-22 14:40 ` Imre Deak
  2013-05-22 14:40 ` [PATCH 3/4] kms_flip: do a DPMS ON when exiting with error Imre Deak
  2013-05-22 14:40 ` [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence Imre Deak
  2 siblings, 0 replies; 5+ messages in thread
From: Imre Deak @ 2013-05-22 14:40 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 lib/drmtest.c | 7 +++----
 lib/drmtest.h | 6 ++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 9fc03a0..16f5be1 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1022,7 +1022,6 @@ static struct {
 	bool installed;
 } orig_sig[MAX_SIGNALS];
 
-typedef void (*drmtest_exit_handler_t)(int sig);
 static drmtest_exit_handler_t exit_handler_fn[MAX_EXIT_HANDLERS];
 static int exit_handler_count;
 static bool exit_handler_disabled;
@@ -1101,7 +1100,7 @@ static void drmtest_sig_handler(int sig)
  * The handler will be passed the signal number if called due to a signal, or
  * 0 otherwise.
  */
-static int drmtest_install_exit_handler(drmtest_exit_handler_t fn)
+int drmtest_install_exit_handler(drmtest_exit_handler_t fn)
 {
 	int i;
 
@@ -1131,7 +1130,7 @@ err:
 	return -1;
 }
 
-static void drmtest_disable_exit_handler(void)
+void drmtest_disable_exit_handler(void)
 {
 	sigset_t set;
 	int i;
@@ -1151,7 +1150,7 @@ static void drmtest_disable_exit_handler(void)
 	exit_handler_disabled = true;
 }
 
-static void drmtest_enable_exit_handler(void)
+void drmtest_enable_exit_handler(void)
 {
 	if (!exit_handler_disabled)
 		return;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 6f78102..7202ad5 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -132,4 +132,10 @@ inline static void _do_or_die(const char *function, int line, int ret)
 #define do_or_die(x) _do_or_die(__FUNCTION__, __LINE__, x)
 #define do_ioctl(fd, ptr, sz) do_or_die(drmIoctl((fd), (ptr), (sz)))
 
+typedef void (*drmtest_exit_handler_t)(int sig);
+
+int drmtest_install_exit_handler(drmtest_exit_handler_t fn);
+void drmtest_enable_exit_handler(void);
+void drmtest_disable_exit_handler(void);
+
 int drmtest_set_vt_graphics_mode(void);
-- 
1.8.1.2

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

* [PATCH 3/4] kms_flip: do a DPMS ON when exiting with error
  2013-05-22 14:40 [PATCH 1/4] lib: fix exit handler when multiple handlers are registered Imre Deak
  2013-05-22 14:40 ` [PATCH 2/4] lib: export the exit handler interface Imre Deak
@ 2013-05-22 14:40 ` Imre Deak
  2013-05-22 14:40 ` [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence Imre Deak
  2 siblings, 0 replies; 5+ messages in thread
From: Imre Deak @ 2013-05-22 14:40 UTC (permalink / raw)
  To: intel-gfx

Currently when exiting with error, we'll get stuck in a DPMS OFF state
if the error happens while we have DPMS OFF set in the test sequence.
This happens even though we switch back to text mode at exit. This might
be a bug in itself to be fixed later, but in any case we want a working
console, so do an explicit DPMS ON.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 tests/kms_flip.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 85e5c11..83293ba 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -78,6 +78,8 @@ uint32_t devid;
 int test_time = 3;
 static bool monotonic_timestamp;
 
+static drmModeConnector *last_connector;
+
 uint32_t *fb_ptr;
 
 struct type_name {
@@ -190,14 +192,14 @@ static void emit_dummy_load(struct test_output *o)
 	drm_intel_bo_unreference(target_bo);
 }
 
-static int set_dpms(struct test_output *o, int mode)
+static int set_connector_dpms(drmModeConnector *connector, int mode)
 {
 	int i, dpms = 0;
 
-	for (i = 0; i < o->connector->count_props; i++) {
+	for (i = 0; i < connector->count_props; i++) {
 		struct drm_mode_get_property prop;
 
-		prop.prop_id = o->connector->props[i];
+		prop.prop_id = connector->props[i];
 		prop.count_values = 0;
 		prop.count_enum_blobs = 0;
 		if (drmIoctl(drm_fd, DRM_IOCTL_MODE_GETPROPERTY, &prop))
@@ -210,12 +212,19 @@ static int set_dpms(struct test_output *o, int mode)
 		break;
 	}
 	if (!dpms) {
-		fprintf(stderr, "DPMS property not found on %d\n", o->id);
+		fprintf(stderr, "DPMS property not found on %d\n",
+			connector->connector_id);
 		errno = ENOENT;
 		return -1;
 	}
 
-	return drmModeConnectorSetProperty(drm_fd, o->id, dpms, mode);
+	return drmModeConnectorSetProperty(drm_fd, connector->connector_id,
+					   dpms, mode);
+}
+
+static int set_dpms(struct test_output *o, int mode)
+{
+	return set_connector_dpms(o->connector, mode);
 }
 
 static void set_flag(unsigned int *v, unsigned int flag)
@@ -1037,6 +1046,8 @@ static void run_test_on_crtc(struct test_output *o, int crtc, int duration)
 	if (!o->mode_valid)
 		return;
 
+	last_connector = o->connector;
+
 	fprintf(stdout, "Beginning %s on crtc %d, connector %d\n",
 		o->test_name, crtc, o->id);
 
@@ -1104,6 +1115,8 @@ static void run_test_on_crtc(struct test_output *o, int crtc, int duration)
 	kmstest_remove_fb(drm_fd, o->fb_ids[1]);
 	kmstest_remove_fb(drm_fd, o->fb_ids[0]);
 
+	last_connector = NULL;
+
 	drmModeFreeEncoder(o->encoder);
 	drmModeFreeConnector(o->connector);
 }
@@ -1154,6 +1167,12 @@ static void get_timestamp_format(void)
 		monotonic_timestamp ? "monotonic" : "real");
 }
 
+static void kms_flip_exit_handler(int sig)
+{
+	if (last_connector)
+		set_connector_dpms(last_connector, DRM_MODE_DPMS_ON);
+}
+
 int main(int argc, char **argv)
 {
 	struct {
@@ -1208,6 +1227,7 @@ int main(int argc, char **argv)
 
 	if (!drmtest_only_list_subtests()) {
 		do_or_die(drmtest_set_vt_graphics_mode());
+		do_or_die(drmtest_install_exit_handler(kms_flip_exit_handler));
 		get_timestamp_format();
 	}
 
-- 
1.8.1.2

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

* [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence
  2013-05-22 14:40 [PATCH 1/4] lib: fix exit handler when multiple handlers are registered Imre Deak
  2013-05-22 14:40 ` [PATCH 2/4] lib: export the exit handler interface Imre Deak
  2013-05-22 14:40 ` [PATCH 3/4] kms_flip: do a DPMS ON when exiting with error Imre Deak
@ 2013-05-22 14:40 ` Imre Deak
  2013-05-22 16:18   ` Daniel Vetter
  2 siblings, 1 reply; 5+ messages in thread
From: Imre Deak @ 2013-05-22 14:40 UTC (permalink / raw)
  To: intel-gfx

Add a double buffer and a single buffer version of the above sequence,
to check if the modeset does a DPMS ON.

Tested on IVB, with and without the relevant kernel fix, got the
expected results.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 tests/kms_flip.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 83293ba..735b4dd 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -62,6 +62,8 @@
 #define TEST_HANG		(1 << 14)
 #define TEST_NOEVENT		(1 << 15)
 #define TEST_FB_BAD_TILING	(1 << 16)
+#define TEST_SINGLE_BUFFER	(1 << 17)
+#define TEST_DPMS_OFF		(1 << 18)
 
 #define EVENT_FLIP		(1 << 0)
 #define EVENT_VBLANK		(1 << 1)
@@ -678,7 +680,9 @@ static unsigned int run_test_step(struct test_output *o)
 		emit_dummy_load(o);
 
 
-	o->current_fb_id = !o->current_fb_id;
+	if (!(o->flags & TEST_SINGLE_BUFFER))
+		o->current_fb_id = !o->current_fb_id;
+
 	if (o->flags & TEST_FB_RECREATE)
 		recreate_fb(o);
 	new_fb_id = o->fb_ids[o->current_fb_id];
@@ -712,6 +716,9 @@ static unsigned int run_test_step(struct test_output *o)
 		assert(do_wait_for_vblank(o, o->pipe, target_seq, &vbl_reply)
 		       == -EINVAL);
 
+	if (o->flags & TEST_DPMS_OFF)
+		do_or_die(set_dpms(o, DRM_MODE_DPMS_OFF));
+
 	if (o->flags & TEST_MODESET) {
 		if (drmModeSetCrtc(drm_fd, o->crtc,
 				   o->fb_ids[o->current_fb_id],
@@ -1218,6 +1225,11 @@ int main(int argc, char **argv)
 		{ 15, TEST_FLIP | TEST_MODESET | TEST_HANG | TEST_NOEVENT, "flip-vs-modeset-vs-hang" },
 		{ 15, TEST_FLIP | TEST_PAN | TEST_HANG, "flip-vs-panning-vs-hang" },
 		{ 1, TEST_FLIP | TEST_EINVAL | TEST_FB_BAD_TILING, "flip-vs-bad-tiling" },
+
+		{ 1, TEST_DPMS_OFF | TEST_MODESET | TEST_FLIP,
+					"flip-vs-dpms-off-vs-modeset" },
+		{ 1, TEST_DPMS_OFF | TEST_MODESET | TEST_FLIP | TEST_SINGLE_BUFFER,
+					"single-buffer-flip-vs-dpms-off-vs-modeset" },
 	};
 	int i;
 
-- 
1.8.1.2

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

* Re: [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence
  2013-05-22 14:40 ` [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence Imre Deak
@ 2013-05-22 16:18   ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2013-05-22 16:18 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx

On Wed, May 22, 2013 at 05:40:48PM +0300, Imre Deak wrote:
> Add a double buffer and a single buffer version of the above sequence,
> to check if the modeset does a DPMS ON.
> 
> Tested on IVB, with and without the relevant kernel fix, got the
> expected results.
> 
> Signed-off-by: Imre Deak <imre.deak@intel.com>

All four patches applied, thanks.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

end of thread, other threads:[~2013-05-22 16:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-22 14:40 [PATCH 1/4] lib: fix exit handler when multiple handlers are registered Imre Deak
2013-05-22 14:40 ` [PATCH 2/4] lib: export the exit handler interface Imre Deak
2013-05-22 14:40 ` [PATCH 3/4] kms_flip: do a DPMS ON when exiting with error Imre Deak
2013-05-22 14:40 ` [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence Imre Deak
2013-05-22 16:18   ` Daniel Vetter

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.