kms_flip: make sure we are unblanked during the test
Subsystems (3)
PATCH 1/1 kms_flip: make sure we are unblanked during the test
This is a probable reason for some of the sporadic kms_flip failures. One such is https://bugs.freedesktop.org/show_bug.cgi?id=59834.
--- tests/kms_flip.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
tests/kms_flip.c +31 -1
@@ -36,6 +36,7 @@#include <sys/time.h> #include <sys/mman.h> #include <sys/ioctl.h> +#include <linux/kd.h> #include "i915_drm.h" #include "drmtest.h"
@@ -1072,6 +1073,13 @@ static void run_test_on_crtc(struct test_output *o, int crtc, int duration) }assert (fb_is_bound (o, o->fb_ids[0 ])); +/* +* Make sure we're unblanked if for example the test was started with +* the console blanked. In this case the kernel might do a DPMS_ON in +* the above mode set call, but it's not guaranteed. +*/ +do_or_die (set_dpms (o,DRM_MODE_DPMS_ON )); +/* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags &TEST_CHECK_TS )sleep (1 );
@@ -1153,6 +1161,20 @@ static void get_timestamp_format(void) monotonic_timestamp ? "monotonic" : "real"); } +static unsigned set_vt_mode (unsigned mode) +{ +int fd; +unsigned long prev_mode; + + fd =open ("/dev/tty0" ,O_RDONLY ); +assert (fd >=0 ); + +drmIoctl (fd,KDGETMODE , &prev_mode); +drmIoctl (fd,KDSETMODE , &mode); + +return prev_mode; +} +int main (int argc,char **argv) {struct {
@@ -1200,13 +1222,18 @@ int main(int argc, char **argv) { 1, TEST_FLIP | TEST_EINVAL | TEST_FB_BAD_TILING, "flip-vs-bad-tiling" }, };int i; +bool dry_run; +unsigned prev_vt_mode;drmtest_subtest_init (argc, argv); drm_fd =drm_open_any (); -if (!drmtest_only_list_subtests ()) + dry_run =drmtest_only_list_subtests (); +if (!dry_run) { + prev_vt_mode =set_vt_mode (KD_GRAPHICS );get_timestamp_format (); + } bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); devid =intel_get_drm_devid (drm_fd);
@@ -1219,6 +1246,9 @@ int main(int argc, char **argv) } } +if (!dry_run) +set_vt_mode (prev_vt_mode); +close (drm_fd);return 0 ;
Signature · 1 line
1.7.10.4
PATCH v2 1/1 kms_flip: make sure we are unblanked during the test
This is a probable reason for some of the sporadic kms_flip failures. One such is https://bugs.freedesktop.org/show_bug.cgi?id=59834.
v2:
- use unsigned long for KDSETMODE/KDGETMODE
- fix passing the parameter to KDGETMODE as it should be by value
- actually testing that it works..
--- tests/kms_flip.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
tests/kms_flip.c +32 -1
@@ -36,6 +36,7 @@#include <sys/time.h> #include <sys/mman.h> #include <sys/ioctl.h> +#include <linux/kd.h> #include "i915_drm.h" #include "drmtest.h"
@@ -1072,6 +1073,13 @@ static void run_test_on_crtc(struct test_output *o, int crtc, int duration) }assert (fb_is_bound (o, o->fb_ids[0 ])); +/* +* Make sure we're unblanked if for example the test was started with +* the console blanked. In this case the kernel might do a DPMS_ON in +* the above mode set call, but it's not guaranteed. +*/ +do_or_die (set_dpms (o,DRM_MODE_DPMS_ON )); +/* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags &TEST_CHECK_TS )sleep (1 );
@@ -1153,6 +1161,21 @@ static void get_timestamp_format(void) monotonic_timestamp ? "monotonic" : "real"); } +static unsigned long set_vt_mode (unsigned long mode) +{ +int fd; +unsigned long prev_mode; + + fd =open ("/dev/tty0" ,O_RDONLY ); +assert (fd >=0 ); + + prev_mode =0 ; +drmIoctl (fd,KDGETMODE , &prev_mode); +drmIoctl (fd,KDSETMODE , (void *)mode); + +return prev_mode; +} +int main (int argc,char **argv) {struct {
@@ -1200,13 +1223,18 @@ int main(int argc, char **argv) { 1, TEST_FLIP | TEST_EINVAL | TEST_FB_BAD_TILING, "flip-vs-bad-tiling" }, };int i; +bool dry_run; +unsigned long prev_vt_mode;drmtest_subtest_init (argc, argv); drm_fd =drm_open_any (); -if (!drmtest_only_list_subtests ()) + dry_run =drmtest_only_list_subtests (); +if (!dry_run) { + prev_vt_mode =set_vt_mode (KD_GRAPHICS );get_timestamp_format (); + } bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); devid =intel_get_drm_devid (drm_fd);
@@ -1219,6 +1247,9 @@ int main(int argc, char **argv) } } +if (!dry_run) +set_vt_mode (prev_vt_mode); +close (drm_fd);return 0 ;
Signature · 1 line
1.7.10.4
PATCH v3 1/1 kms_flip: make sure we are unblanked during the test
This is one reason for some of the sporadic kms_flip failures. One such is https://bugs.freedesktop.org/show_bug.cgi?id=59834.
v2:
- use unsigned long for KDSETMODE/KDGETMODE
- fix passing the parameter to KDGETMODE as it should be by value
- actually testing that it works..
v3:
- don't do an explicit DPMS_ON, only switch to graphics mode.
--- tests/kms_flip.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
tests/kms_flip.c +25 -1
@@ -36,6 +36,7 @@#include <sys/time.h> #include <sys/mman.h> #include <sys/ioctl.h> +#include <linux/kd.h> #include "i915_drm.h" #include "drmtest.h"
@@ -1153,6 +1154,21 @@ static void get_timestamp_format(void) monotonic_timestamp ? "monotonic" : "real"); } +static unsigned long set_vt_mode (unsigned long mode) +{ +int fd; +unsigned long prev_mode; + + fd =open ("/dev/tty0" ,O_RDONLY ); +assert (fd >=0 ); + + prev_mode =0 ; +drmIoctl (fd,KDGETMODE , &prev_mode); +drmIoctl (fd,KDSETMODE , (void *)mode); + +return prev_mode; +} +int main (int argc,char **argv) {struct {
@@ -1200,13 +1216,18 @@ int main(int argc, char **argv) { 1, TEST_FLIP | TEST_EINVAL | TEST_FB_BAD_TILING, "flip-vs-bad-tiling" }, };int i; +bool dry_run; +unsigned long prev_vt_mode;drmtest_subtest_init (argc, argv); drm_fd =drm_open_any (); -if (!drmtest_only_list_subtests ()) + dry_run =drmtest_only_list_subtests (); +if (!dry_run) { + prev_vt_mode =set_vt_mode (KD_GRAPHICS );get_timestamp_format (); + } bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); devid =intel_get_drm_devid (drm_fd);
@@ -1219,6 +1240,9 @@ int main(int argc, char **argv) } } +if (!dry_run) +set_vt_mode (prev_vt_mode); +close (drm_fd);return 0 ;
Signature · 1 line
1.7.10.4
PATCH v4 1/4 kms_flip: suppress uninitialized var warning
--- tests/kms_flip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/kms_flip.c +1 -1
@@ -649,7 +649,7 @@ static unsigned int run_test_step(struct test_output *o)bool do_vblank;struct vblank_reply vbl_reply;unsigned int target_seq; -uint32_t handle; +uint32_t handle =0 ;/* Suppress GCC warning */ target_seq = o->vblank_state.seq_step;if (o->flags &TEST_VBLANK_ABSOLUTE )
Signature · 1 line
1.7.10.4
PATCH v4 2/4 lib: add helper to set VT graphics mode
--- lib/drmtest.c | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/drmtest.h | 2 + 2 files changed, 201 insertions(+)
lib/drmtest.c +199 -0
@@ -38,6 +38,7 @@#include <math.h> #include <getopt.h> #include <stdlib.h> +#include <linux/kd.h> #include "drmtest.h" #include "i915_drm.h"
@@ -968,3 +969,201 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)return pfci.pipe; } +#define MAX_SIGNALS 32 +#define MAX_EXIT_HANDLERS 5 + +static struct { +sighandler_t handler; +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; +static sigset_t saved_sig_mask; +static const int handled_signals[] = + {SIGINT ,SIGHUP ,SIGTERM ,SIGQUIT ,SIGPIPE ,SIGABRT }; + +static int install_sig_handler (int sig_num,sighandler_t handler) +{ + orig_sig[sig_num].handler =signal (sig_num, handler); + +if (orig_sig[sig_num].handler ==SIG_ERR ) +return -1 ; + + orig_sig[sig_num].installed = true; + +return 0 ; +} + +static void restore_sig_handler (int sig_num) +{ +if (orig_sig[sig_num].installed) +signal (sig_num, orig_sig[sig_num].handler); +} + +static void restore_all_sig_handler (void ) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (orig_sig); i++) +restore_sig_handler (i); +} + +static void call_exit_handlers (int sig) +{ +int i; + +if (!exit_handler_count) { +fprintf (stderr,"no exit handlers?\n" ); +return ; + } + +for (i =0 ; i < exit_handler_count; i++) + exit_handler_fn[i](sig); +} + +static void drmtest_atexit_handler (void ) +{ +restore_all_sig_handler (); + +if (!exit_handler_disabled) +call_exit_handlers (0 ); +} + +static void drmtest_sig_handler (int sig) +{ +restore_all_sig_handler (); + +/* +* exit_handler_disabled is always false here, since when we set it +* we also block signals. +*/ +call_exit_handlers (sig); + +raise (sig); +} + +/* +* Set a handler that will be called either when the process calls exit() or +* returns from the main function, or one of the signals in 'handled_signals' +* is raised. MAX_EXIT_HANDLERS handlers can be installed, each of which will +* be called only once, even if a subsequent signal is raised. If the exit +* handlers are called due to a signal, the signal will be re-raised with the +* original signal disposition after all handlers returned. +* +* 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 i; + +if (exit_handler_count ==MAX_EXIT_HANDLERS ) +return -1 ; + + exit_handler_fn[exit_handler_count] = fn; + exit_handler_count++; + +for (i =0 ; i <ARRAY_SIZE (handled_signals); i++) { +if (install_sig_handler (handled_signals[i], + drmtest_sig_handler)) + goto err; + } + +if (atexit (drmtest_atexit_handler)) + goto err; + +return 0 ; +err: +restore_all_sig_handler (); + exit_handler_count--; + +return -1 ; +} + +static void drmtest_disable_exit_handler (void ) +{ +sigset_t set; +int i; + +if (exit_handler_disabled) +return ; + +sigemptyset (&set); +for (i =0 ; i <ARRAY_SIZE (handled_signals); i++) +sigaddset (&set, handled_signals[i]); + +if (sigprocmask (SIG_BLOCK , &set, &saved_sig_mask)) { +perror ("sigprocmask" ); +return ; + } + + exit_handler_disabled = true; +} + +static void drmtest_enable_exit_handler (void ) +{ +if (!exit_handler_disabled) +return ; + +if (sigprocmask (SIG_SETMASK , &saved_sig_mask,NULL )) { +perror ("sigprocmask" ); +return ; + } + + exit_handler_disabled = false; +} + +static signed long set_vt_mode (unsigned long mode) +{ +int fd; +unsigned long prev_mode; + + fd =open ("/dev/tty0" ,O_RDONLY ); +if (fd <0 ) +return -errno; + + prev_mode =0 ; +if (drmIoctl (fd,KDGETMODE , &prev_mode)) + goto err; +if (drmIoctl (fd,KDSETMODE , (void *)mode)) + goto err; + +close (fd); + +return prev_mode; +err: +close (fd); + +return -errno; +} + +static unsigned long orig_vt_mode =-1UL ; + +static void restore_vt_mode_at_exit (int sig) +{ +if (orig_vt_mode !=-1UL ) +set_vt_mode (orig_vt_mode); +} + +/* +* Set the VT to graphics mode and install an exit handler to restore the +* original mode. +*/ + +int drmtest_set_vt_graphics_mode (void ) +{ +if (drmtest_install_exit_handler (restore_vt_mode_at_exit)) +return -1 ; + +drmtest_disable_exit_handler (); + orig_vt_mode =set_vt_mode (KD_GRAPHICS ); +if (orig_vt_mode <0 ) + orig_vt_mode =-1UL ; +drmtest_enable_exit_handler (); + +return orig_vt_mode <0 ?-1 :0 ; +} +
lib/drmtest.h +2 -0
@@ -127,3 +127,5 @@ 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))) + +int drmtest_set_vt_graphics_mode (void );
Signature · 1 line
1.7.10.4
PATCH v4 3/4 kms_flip: set VT graphics mode
In reply to Imre DeakThis is one reason for some of the sporadic kms_flip failures. One such is https://bugs.freedesktop.org/show_bug.cgi?id=59834.
v2:
- use unsigned long for KDSETMODE/KDGETMODE
- fix passing the parameter to KDGETMODE as it should be by value
- actually testing that it works..
v3:
- don't do an explicit DPMS_ON, only switch to graphics mode.
v4:
- use the newly added drmtest_set_vt_graphics_mode(), which will also take care of restoring the original mode. (Daniel)
--- tests/kms_flip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tests/kms_flip.c +4 -1
@@ -36,6 +36,7 @@#include <sys/time.h> #include <sys/mman.h> #include <sys/ioctl.h> +#include <linux/kd.h> #include "i915_drm.h" #include "drmtest.h"
@@ -1205,8 +1206,10 @@ int main(int argc, char **argv) drm_fd =drm_open_any (); -if (!drmtest_only_list_subtests ()) +if (!drmtest_only_list_subtests ()) { +do_or_die (drmtest_set_vt_graphics_mode ());get_timestamp_format (); + } bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); devid =intel_get_drm_devid (drm_fd);
Signature · 1 line
1.7.10.4
PATCH v4 4/4 testdisplay: set VT graphics mode
In reply to Imre Deak--- tests/testdisplay.c | 2 ++ 1 file changed, 2 insertions(+)
tests/testdisplay.c +2 -0
@@ -735,6 +735,8 @@ int main(int argc, char **argv) drm_fd =drm_open_any (); +do_or_die (drmtest_set_vt_graphics_mode ()); + mainloop =g_main_loop_new (NULL , FALSE);if (!mainloop) {fprintf (stderr,"failed to create glib mainloop\n" );
Signature · 1 line
1.7.10.4
Re: [i-g-t PATCH v4 4/4] testdisplay: set VT graphics mode
Quoted 1 line · Imre Deak
Signed-off-by Imre Deak <[email protected]>
Entire series merged, thanks a lot for doing this. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH v2 3/7 drm/i915: ilk-ivb: replace !is_pch_edp() with port==PORT_A
In reply to Imre DeakOn ILK-IVB the CPU side eDP is always on port-A.
Also reduce somewhat the debug verbosity.
v2:
- reduce debug verbosity
--- drivers/gpu/drm/i915/intel_display.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -7
@@ -5052,7 +5052,6 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)u32 val, final;bool has_lvds = false;bool has_cpu_edp = false; -bool has_pch_edp = false;bool has_panel = false;bool has_ck505 = false;bool can_ssc = false;
@@ -5067,9 +5066,7 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)break ;case INTEL_OUTPUT_EDP : has_panel = true; -if (intel_encoder_is_pch_edp (&encoder->base)) - has_pch_edp = true; -else +if (enc_to_dig_port (&encoder->base)->port ==PORT_A ) has_cpu_edp = true;break ; }
@@ -5083,9 +5080,8 @@ static void ironlake_init_pch_refclk(struct drm_device *dev) can_ssc = true; } -DRM_DEBUG_KMS ("has_panel %d has_lvds %d has_pch_edp %d has_cpu_edp %d has_ck505 %d\n" , - has_panel, has_lvds, has_pch_edp, has_cpu_edp, - has_ck505); +DRM_DEBUG_KMS ("has_panel %d has_lvds %d has_ck505 %d\n" , + has_panel, has_lvds, has_ck505);/* Ironlake: try to setup display ref clock before DPLL * enabling. This is only under driver's control after
Signature · 1 line
1.7.10.4