tests: use "auto" pipe CRC source
PATCH 1/2 tests: use "auto" pipe CRC source
Makes stuff work on DP ports on gmch platforms automatically.
--- lib/igt_debugfs.c | 3 ++- lib/igt_debugfs.h | 1 + tests/debugfs_pipe_crc.c | 11 +++-------- tests/kms_cursor_crc.c | 12 ++---------- 4 files changed, 8 insertions(+), 19 deletions(-)
lib/igt_debugfs.c +2 -1
@@ -154,7 +154,8 @@ static const char *pipe_crc_sources[] = {"TV" ,"DP-B" ,"DP-C" , - "DP-D" +"DP-D" , + "auto" };static const char *pipe_crc_source_name (enum intel_pipe_crc_source source)
lib/igt_debugfs.h +1 -0
@@ -55,6 +55,7 @@ enum intel_pipe_crc_source {INTEL_PIPE_CRC_SOURCE_DP_B ,INTEL_PIPE_CRC_SOURCE_DP_C ,INTEL_PIPE_CRC_SOURCE_DP_D , +INTEL_PIPE_CRC_SOURCE_AUTO , INTEL_PIPE_CRC_SOURCE_MAX, };
tests/debugfs_pipe_crc.c +3 -8
@@ -169,17 +169,12 @@ static void test_read_crc(data_t *data, int pipe, unsigned flags) pipe_crc =igt_pipe_crc_new (&data->debugfs, data->drm_fd, connector->config.pipe, -INTEL_PIPE_CRC_SOURCE_PLANE1 ); +INTEL_PIPE_CRC_SOURCE_AUTO );connector_set_mode (data, connector, &connector->config.default_mode); -if (!pipe_crc || !igt_pipe_crc_start (pipe_crc)) { -igt_pipe_crc_free (pipe_crc); - pipe_crc =igt_pipe_crc_new (&data->debugfs, data->drm_fd, - connector->config.pipe, -INTEL_PIPE_CRC_SOURCE_PIPE ); -igt_assert (igt_pipe_crc_start (pipe_crc)); - } +igt_require (pipe_crc); +igt_assert (igt_pipe_crc_start (pipe_crc));/* wait for 3 vblanks and the corresponding 3 CRCs */ igt_pipe_crc_get_crcs (pipe_crc,3 , &crcs);
tests/kms_cursor_crc.c +2 -10
@@ -110,16 +110,8 @@ static igt_pipe_crc_t *create_crc(data_t *data, int crtc_idx)igt_pipe_crc_t *crc; crc =igt_pipe_crc_new (&data->debugfs, data->drm_fd, crtc_idx, -INTEL_PIPE_CRC_SOURCE_PF ); -if (crc) -return crc; - - crc =igt_pipe_crc_new (&data->debugfs, data->drm_fd, crtc_idx, -INTEL_PIPE_CRC_SOURCE_PIPE ); -if (crc) -return crc; - -return NULL ; +INTEL_PIPE_CRC_SOURCE_AUTO ); +return crc; }static void display_init (data_t *data)
Signature · 1 line
1.8.4.rc3
PATCH 2/2 tests/debugfs_pipe_crc: set mode before creating CRC helper
Otherwise the automagic skipping for DP ports on gmch platforms won't work.
v2: We also need to just skip that connector, not the entire subtest.
kms_cursor_crc still needs to be updated.
--- tests/debugfs_pipe_crc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tests/debugfs_pipe_crc.c +5 -3
@@ -162,18 +162,20 @@ static void test_read_crc(data_t *data, int pipe, unsigned flags)if (!connector->valid)continue ; - valid_connectors++;fprintf (stdout,"%s: Testing connector %u\n" ,igt_subtest_name (), connector->config.connector->connector_id); +connector_set_mode (data, connector, &connector->config.default_mode); + pipe_crc =igt_pipe_crc_new (&data->debugfs, data->drm_fd, connector->config.pipe,INTEL_PIPE_CRC_SOURCE_AUTO ); -connector_set_mode (data, connector, &connector->config.default_mode); +if (!pipe_crc) +continue ; + valid_connectors++; -igt_require (pipe_crc);igt_assert (igt_pipe_crc_start (pipe_crc));/* wait for 3 vblanks and the corresponding 3 CRCs */
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/3 tests/kms_cursor_crc: rework to auto-skip connectors
In reply to Daniel Vetter--- tests/kms_cursor_crc.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
tests/kms_cursor_crc.c +17 -12
@@ -116,25 +116,14 @@ static igt_pipe_crc_t *create_crc(data_t *data, int crtc_idx)static void display_init (data_t *data) { -int i; - data->resources =drmModeGetResources (data->drm_fd);igt_assert (data->resources); data->pipe_crc =calloc (data->resources->count_crtcs,sizeof (data->pipe_crc[0 ])); -for (i =0 ; i < data->resources->count_crtcs; i++) { - data->pipe_crc[i] =create_crc (data, i); -igt_require_f (data->pipe_crc[i], -"pipe/pf crc not supported\n" ); - } }static void display_fini (data_t *data) { -int i; - -for (i =0 ; i < data->resources->count_crtcs; i++) -igt_pipe_crc_free (data->pipe_crc[i]);free (data->pipe_crc);drmModeFreeResources (data->resources);
@@ -236,7 +225,7 @@ static bool prepare_crtc(test_data_t *test_data, uint32_t connector_id)connector_t connector;igt_crc_t *crcs =NULL ;data_t *data = test_data->data; -igt_pipe_crc_t *pipe_crc = data->pipe_crc[test_data->crtc_idx]; +igt_pipe_crc_t *pipe_crc;int ret; ret = kmstest_get_connector_config(data->drm_fd,
@@ -248,6 +237,15 @@ static bool prepare_crtc(test_data_t *test_data, uint32_t connector_id)connector_set_mode (data, &connector, &connector.config.default_mode); + pipe_crc =create_crc (data, test_data->crtc_idx); +if (!pipe_crc) { +printf ("auto crc not supported on this connector with crtc %i\n" , + test_data->crtc_idx); +return false; + } + + data->pipe_crc[test_data->crtc_idx] = pipe_crc; +/* x/y position where the cursor is still fully visible */ test_data->left =0 ; test_data->right = connector.config.default_mode.hdisplay -64 ;
@@ -276,6 +274,7 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen) .data = data, };int i, n; +int valid_tests =0 ;for (i =0 ; i < data->resources->count_connectors; i++) {uint32_t connector_id = data->resources->connectors[i];
@@ -287,6 +286,8 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen)if (!prepare_crtc (&test_data, connector_id))continue ; + valid_tests++; +fprintf (stdout,"Beginning %s on crtc %d, connector %d\n" ,igt_subtest_name (), test_data.crtc_id, connector_id);
@@ -295,8 +296,12 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen)fprintf (stdout,"\n%s on crtc %d, connector %d: PASSED\n\n" ,igt_subtest_name (), test_data.crtc_id, connector_id); + +igt_pipe_crc_free (data->pipe_crc[test_data.crtc_idx]); } } + +igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); }static void exit_handler (int sig)
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/3 lib: consolidate pipe crc exit handler
No need to sprinkle this all over:
- exit handlers will only be registered once
- they're always called when exiting, so no need to explictly call them.
This allows us to hide all the pipe crc cleanup in the library.
--- lib/igt_debugfs.c | 52 ++++++++++++++++++++++++++---------------------- lib/igt_debugfs.h | 1 - tests/debugfs_pipe_crc.c | 7 ------- tests/kms_cursor_crc.c | 7 ------- 4 files changed, 28 insertions(+), 39 deletions(-)
lib/igt_debugfs.c +28 -24
@@ -177,6 +177,32 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)return true; } +static void igt_pipe_crc_pipe_off (int fd,enum pipe pipe) +{ +char buf[32 ]; + +sprintf (buf,"pipe %c none" ,pipe_name (pipe)); +write (fd, buf,strlen (buf)); +} + +static void igt_pipe_crc_reset (void ) +{ +igt_debugfs_t debugfs; +int fd; + +igt_debugfs_init (&debugfs); + fd =igt_debugfs_open (&debugfs,"i915_display_crc_ctl" ,O_WRONLY ); + +igt_pipe_crc_pipe_off (fd,PIPE_A ); +igt_pipe_crc_pipe_off (fd,PIPE_B ); +igt_pipe_crc_pipe_off (fd,PIPE_C ); +} + +static void pipe_crc_exit_handler (int sig) +{ +igt_pipe_crc_reset (); +} +igt_pipe_crc_t *igt_pipe_crc_new (igt_debugfs_t *debugfs,int drm_fd,enum pipe pipe,enum intel_pipe_crc_source source)
@@ -184,6 +210,8 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,igt_pipe_crc_t *pipe_crc;char buf[128 ]; +do_or_die (igt_install_exit_handler (pipe_crc_exit_handler)); + pipe_crc =calloc (1 ,sizeof (struct _igt_pipe_crc )); pipe_crc->ctl_fd = igt_debugfs_open(debugfs,
@@ -211,30 +239,6 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,return pipe_crc; } -static void igt_pipe_crc_pipe_off (int fd,enum pipe pipe) -{ -char buf[32 ]; - -sprintf (buf,"pipe %c none" ,pipe_name (pipe)); -write (fd, buf,strlen (buf)); -} - -/* -* Turn off everything -*/ -void igt_pipe_crc_reset (void ) -{ -igt_debugfs_t debugfs; -int fd; - -igt_debugfs_init (&debugfs); - fd =igt_debugfs_open (&debugfs,"i915_display_crc_ctl" ,O_WRONLY ); - -igt_pipe_crc_pipe_off (fd,PIPE_A ); -igt_pipe_crc_pipe_off (fd,PIPE_B ); -igt_pipe_crc_pipe_off (fd,PIPE_C ); -} -void igt_pipe_crc_free (igt_pipe_crc_t *pipe_crc) {if (!pipe_crc)
lib/igt_debugfs.h +0 -1
@@ -73,7 +73,6 @@ char *igt_crc_to_string(igt_crc_t *crc);igt_pipe_crc_t *igt_pipe_crc_new (igt_debugfs_t *debugfs,int drm_fd,enum pipe pipe,enum intel_pipe_crc_source source); -void igt_pipe_crc_reset (void );void igt_pipe_crc_free (igt_pipe_crc_t *pipe_crc);bool igt_pipe_crc_start (igt_pipe_crc_t *pipe_crc);void igt_pipe_crc_stop (igt_pipe_crc_t *pipe_crc);
tests/debugfs_pipe_crc.c +0 -7
@@ -206,11 +206,6 @@ static void test_read_crc(data_t *data, int pipe, unsigned flags) } -static void exit_handler (int sig) -{ -igt_pipe_crc_reset (); -} -int main (int argc,char **argv) {data_t data = {0 , };
@@ -224,7 +219,6 @@ int main(int argc, char **argv) data.drm_fd =drm_open_any ();do_or_die (igt_set_vt_graphics_mode ()); -do_or_die (igt_install_exit_handler (exit_handler));display_init (&data);
@@ -260,7 +254,6 @@ int main(int argc, char **argv) } igt_fixture { -igt_pipe_crc_reset ();display_fini (&data);fclose (data.ctl); }
tests/kms_cursor_crc.c +0 -7
@@ -304,11 +304,6 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen)igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); } -static void exit_handler (int sig) -{ -igt_pipe_crc_reset (); -} -static void create_cursor_fb (data_t *data,enum cursor_type cursor_type,double r,double g,double b,double a)
@@ -340,7 +335,6 @@ int main(int argc, char **argv) data.drm_fd =drm_open_any ();do_or_die (igt_set_vt_graphics_mode ()); -do_or_die (igt_install_exit_handler (exit_handler));igt_debugfs_init (&data.debugfs); data.ctl = igt_debugfs_fopen(&data.debugfs,
@@ -378,7 +372,6 @@ int main(int argc, char **argv)run_test (&data,BLACK_INVISIBLE , false); igt_fixture { -igt_pipe_crc_reset ();display_fini (&data);fclose (data.ctl); }
Signature · 1 line
1.8.4.rc3
RFC PATCH 3/3 lib: add igt_main macro
In reply to Daniel VetterIn the past new testcases with subtest often forgot to add the call to igt_exit at the end of their main() function. That is now caught with a bit more obnoxious asserts, but it's still a nuissance.
This little igt_main macro takes care of that (and also of calling the subtest machinery initialization code correctly).
If no one objects I'll roll this out for all the simple cases (i.e. those tests that don't have additional argv parsing on top of the subtest machinery).
--- lib/drmtest.h | 10 ++++++++++ tests/kms_cursor_crc.c | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-)
lib/drmtest.h +10 -0
@@ -138,6 +138,16 @@ bool __igt_run_subtest(const char *subtest_name); (setjmp (igt_subtest_jmpbuf) ==0 ); \ igt_success())const char *igt_subtest_name (void ); +#define igt_main \ + static void igt_tokencat(__real_main, __LINE__)(void); \ + int main(int argc, char **argv) { \ + igt_subtest_init(argc, argv); \ + igt_tokencat(__real_main, __LINE__)(); \ + igt_exit(); \ + } \ + static void igt_tokencat(__real_main, __LINE__)(void) \ + +/** * igt_skip - subtest aware test skipping *
tests/kms_cursor_crc.c +1 -4
@@ -321,11 +321,10 @@ static void create_cursor_fb(data_t *data,igt_assert (cairo_status (cr) ==0 ); } -int main (int argc,char **argv) +igt_main {data_t data = {}; -igt_subtest_init (argc, argv);igt_skip_on_simulation (); igt_fixture {
@@ -375,6 +374,4 @@ int main(int argc, char **argv)display_fini (&data);fclose (data.ctl); } - -igt_exit (); }
Signature · 1 line
1.8.4.rc3
PATCH 1/3 lib: make igt_set_vt_graphics_mode never fail
In reply to Daniel VetterAll tests agree that this is a letal failure, so no point to pass it back to callers.
Also add some igt_require calls for the drm_fd where I've noticed that it's missing.
--- lib/drmtest.c | 7 +++---- lib/drmtest.h | 2 +- tests/debugfs_pipe_crc.c | 4 +++- tests/kms_cursor_crc.c | 4 +++- tests/kms_flip.c | 2 +- tests/kms_render.c | 2 +- tests/kms_setmode.c | 2 +- tests/pc8.c | 2 +- tests/testdisplay.c | 2 +- 9 files changed, 15 insertions(+), 12 deletions(-)
lib/drmtest.c +3 -4
@@ -2110,10 +2110,9 @@ static void restore_vt_mode_at_exit(int sig)* original mode. */ -int igt_set_vt_graphics_mode (void ) +void igt_set_vt_graphics_mode (void ) { -if (igt_install_exit_handler (restore_vt_mode_at_exit)) -return -1 ; +do_or_die (igt_install_exit_handler (restore_vt_mode_at_exit));igt_disable_exit_handler (); orig_vt_mode =set_vt_mode (KD_GRAPHICS );
@@ -2121,7 +2120,7 @@ int igt_set_vt_graphics_mode(void) orig_vt_mode =-1UL ;igt_enable_exit_handler (); -return orig_vt_mode <0 ?-1 :0 ; +igt_assert (orig_vt_mode >=0 ); } int kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
lib/drmtest.h +1 -1
@@ -404,7 +404,7 @@ void igt_enable_exit_handler(void);void igt_disable_exit_handler (void );/* set vt into graphics mode, required to prevent fbcon from interfering */ -int igt_set_vt_graphics_mode (void ); +void igt_set_vt_graphics_mode (void );/* prefault disabling, needs the corresponding debugfs interface */ void igt_disable_prefault (void );
tests/debugfs_pipe_crc.c +3 -1
@@ -218,7 +218,9 @@ int main(int argc, char **argv)const char *cmd ="pipe A none" ; data.drm_fd =drm_open_any (); -do_or_die (igt_set_vt_graphics_mode ()); +igt_require (data.drm_fd >=0 ); + +igt_set_vt_graphics_mode ();display_init (&data);
tests/kms_cursor_crc.c +3 -1
@@ -333,7 +333,9 @@ igt_mainconst char *cmd ="pipe A none" ; data.drm_fd =drm_open_any (); -do_or_die (igt_set_vt_graphics_mode ()); +igt_require (data.drm_fd >=0 ); + +igt_set_vt_graphics_mode ();igt_debugfs_init (&data.debugfs); data.ctl = igt_debugfs_fopen(&data.debugfs,
tests/kms_flip.c +1 -1
@@ -1493,7 +1493,7 @@ int main(int argc, char **argv) igt_fixture { drm_fd =drm_open_any (); -do_or_die (igt_set_vt_graphics_mode ()); +igt_set_vt_graphics_mode ();do_or_die (igt_install_exit_handler (kms_flip_exit_handler));get_timestamp_format ();
tests/kms_render.c +1 -1
@@ -242,7 +242,7 @@ int main(int argc, char **argv) devid =intel_get_drm_devid (drm_fd); batch =intel_batchbuffer_alloc (bufmgr, devid); -do_or_die (igt_set_vt_graphics_mode ()); +igt_set_vt_graphics_mode (); }for (i =0 ; i <ARRAY_SIZE (tests); i++) {
tests/kms_setmode.c +1 -1
@@ -702,7 +702,7 @@ int main(int argc, char **argv) igt_fixture { drm_fd =drm_open_any ();if (!dry_run) -do_or_die (igt_set_vt_graphics_mode ()); +igt_set_vt_graphics_mode (); drm_resources =drmModeGetResources (drm_fd);assert (drm_resources);
tests/pc8.c +1 -1
@@ -292,7 +292,7 @@ static void init_mode_set_data(struct mode_set_data *data) data->bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); data->devid =intel_get_drm_devid (drm_fd); -do_or_die (igt_set_vt_graphics_mode ()); +igt_set_vt_graphics_mode ();drm_intel_bufmgr_gem_enable_reuse (data->bufmgr); }
tests/testdisplay.c +1 -1
@@ -801,7 +801,7 @@ int main(int argc, char **argv) goto out_close; } -do_or_die (igt_set_vt_graphics_mode ()); +igt_set_vt_graphics_mode (); mainloop =g_main_loop_new (NULL , FALSE);if (!mainloop) {
Signature · 1 line
1.8.4.rc3
PATCH 2/3 tests: Add a test template
Requested by Paulo.
--- tests/.gitignore | 1 + tests/Makefile.am | 1 + tests/template.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/template.c
tests/.gitignore +1 -0
@@ -109,4 +109,5 @@ prime_self_import prime_udl sysfs_rc6_residency sysfs_rps +template testdisplay
tests/Makefile.am +1 -0
@@ -59,6 +59,7 @@ TESTS_progs_M = \ $(NOUVEAU_TESTS_M) \ pc8 \ prime_self_import \ + template \ $(NULL) TESTS_progs = \
tests/template.c new file +80 -0
80 lines not on this page · raw message
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 lib: make igt_install_exit_handler never fail
In reply to Daniel VetterMost callers didn't bother checking, so just move the asserts into the function itself.
--- lib/drmtest.c | 15 +++++++-------- lib/drmtest.h | 2 +- lib/igt_debugfs.c | 2 +- tests/.gitignore | 1 + tests/kms_flip.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)
lib/drmtest.c +7 -8
@@ -2006,22 +2006,21 @@ static void fatal_sig_handler(int sig)* The handler will be passed the signal number if called due to a signal, or * 0 otherwise. */ -int igt_install_exit_handler (igt_exit_handler_t fn) +void igt_install_exit_handler (igt_exit_handler_t fn) {int i;for (i =0 ; i < exit_handler_count; i++)if (exit_handler_fn[i] == fn) -return 0 ; +return ; -if (exit_handler_count ==MAX_EXIT_HANDLERS ) -return -1 ; +igt_assert (exit_handler_count <MAX_EXIT_HANDLERS ); exit_handler_fn[exit_handler_count] = fn; exit_handler_count++;if (exit_handler_count >1 ) -return 0 ; +return ;for (i =0 ; i <ARRAY_SIZE (handled_signals); i++) { if (install_sig_handler(handled_signals[i],
@@ -2032,12 +2031,12 @@ int igt_install_exit_handler(igt_exit_handler_t fn)if (atexit (igt_atexit_handler)) goto err; -return 0 ; +return ; err:restore_all_sig_handler (); exit_handler_count--; -return -1 ; +igt_assert_f (0 ,"failed to install the signal handler\n" ); }void igt_disable_exit_handler (void )
@@ -2112,7 +2111,7 @@ static void restore_vt_mode_at_exit(int sig)void igt_set_vt_graphics_mode (void ) { -do_or_die (igt_install_exit_handler (restore_vt_mode_at_exit)); +igt_install_exit_handler (restore_vt_mode_at_exit);igt_disable_exit_handler (); orig_vt_mode =set_vt_mode (KD_GRAPHICS );
lib/drmtest.h +1 -1
@@ -399,7 +399,7 @@ uint32_t drm_format_to_bpp(uint32_t drm_format);typedef void (*igt_exit_handler_t )(int sig);/* reliable atexit helpers, also work when killed by a signal (if possible) */ -int igt_install_exit_handler (igt_exit_handler_t fn); +void igt_install_exit_handler (igt_exit_handler_t fn);void igt_enable_exit_handler (void );void igt_disable_exit_handler (void );
lib/igt_debugfs.c +1 -1
@@ -210,7 +210,7 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,igt_pipe_crc_t *pipe_crc;char buf[128 ]; -do_or_die (igt_install_exit_handler (pipe_crc_exit_handler)); +igt_install_exit_handler (pipe_crc_exit_handler); pipe_crc =calloc (1 ,sizeof (struct _igt_pipe_crc ));
tests/.gitignore +1 -0
@@ -98,6 +98,7 @@ getstats getversion igt_fork_helper kms_addfb +kms_cursor_crc kms_flip kms_render kms_setmode
tests/kms_flip.c +1 -1
@@ -1494,7 +1494,7 @@ int main(int argc, char **argv) drm_fd =drm_open_any ();igt_set_vt_graphics_mode (); -do_or_die (igt_install_exit_handler (kms_flip_exit_handler)); +igt_install_exit_handler (kms_flip_exit_handler);get_timestamp_format (); bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 );
Signature · 1 line
1.8.4.rc3