lib: fix exit handler when multiple handlers are registered
PATCH 1/4 lib: fix exit handler when multiple handlers are registered
--- lib/drmtest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/drmtest.c +4 -1
@@ -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))
Signature · 1 line
1.8.1.2
PATCH 2/4 lib: export the exit handler interface
--- lib/drmtest.c | 7 +++---- lib/drmtest.h | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-)
lib/drmtest.c +3 -4
@@ -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 ;
lib/drmtest.h +6 -0
@@ -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 );
Signature · 1 line
1.8.1.2
PATCH 3/4 kms_flip: do a DPMS ON when exiting with error
In reply to Imre DeakCurrently 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.
--- tests/kms_flip.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
tests/kms_flip.c +25 -5
@@ -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 (); }
Signature · 1 line
1.8.1.2
PATCH 4/4 kms_flip: add subtests for the DPMS OFF->modeset->flip sequence
In reply to Imre DeakAdd 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.
--- tests/kms_flip.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tests/kms_flip.c +13 -1
@@ -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;
Signature · 1 line
1.8.1.2
Re: [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence
Quoted 7 lines · Imre Deak
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 <[email protected]>
All four patches applied, thanks.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch