tests/kms_concurrent: Concurrent and interruptible subtests for atomic
PATCH v2 1/1 tests/kms_concurrent: Concurrent and interruptible subtests for atomic
This test case introduces concurrently running test cases for atomic modesetting.
The first test or thread draws blue backround with black holes on it. These holes are covered by rectangular, blue planes that are placed randomly like in test case 'kms_plane_multiple'.
The second thread changes resolution from higher to lower one and back. The delay between resolution changes is randomly selected between 20 and 50 milliseconds.
The test runs by default 32 iterations to increase the coverage.
v2: use igt_fork instead of pthreads to create concurrent test runs (Maarten)
--- tests/Makefile.sources | 1 + tests/kms_concurrent.c | 630 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 631 insertions(+) create mode 100644 tests/kms_concurrent.c
tests/Makefile.sources +1 -0
@@ -114,6 +114,7 @@ TESTS_progs_M = \ kms_plane \ kms_plane_multiple \ kms_plane_lowres \ + kms_concurrent \ kms_properties \ kms_psr_sink_crc \ kms_render \
tests/kms_concurrent.c new file +630 -0
630 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 15-03-17 om 09:43 schreef Mika Kahola:
Quoted 370 lines
This test case introduces concurrently running test cases for atomic modesetting.
The first test or thread draws blue backround with black holes on it. These holes are covered by rectangular, blue planes that are placed randomly like in test case '
kms_plane_multiple'.The second thread changes resolution from higher to lower one and back. The delay between resolution changes is randomly selected between 20 and 50 milliseconds.
The test runs by default 32 iterations to increase the coverage.
v2: use
igt_forkinstead of pthreads to create concurrent test runs (Maarten)Signed-off-by Mika Kahola <[email protected]>--- tests/Makefile.sources | 1 + tests/kms_concurrent.c | 630 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 631 insertions(+) create mode 100644 tests/kms_concurrent.c<snip>
tests/kms_concurrent.c new file +347
-0+static int +display_commit_mode (data_t *data,igt_crc_t *crc) +{ +char buf[256 ]; +struct drm_event *e = (void *)buf; +int n, ret; +int flags =DRM_MODE_PAGE_FLIP_EVENT |DRM_MODE_ATOMIC_ALLOW_MODESET |DRM_MODE_ATOMIC_NONBLOCK ; + + ret =igt_display_try_commit_atomic (&data->display, + flags, +NULL ); +igt_skip_on (ret !=0 ); + +igt_set_timeout (1 ,"Stuck on page flip" ); + ret =read (data->display.drm_fd, buf,sizeof (buf)); +igt_assert (ret >=0 ); + +igt_assert_eq (e->type,DRM_EVENT_FLIP_COMPLETE ); +igt_reset_timeout (); + +return n; +} + +static void +test_grab_crc (data_t *data,color_t *color,igt_crc_t *crc/* out */ ) +{ +drmModeModeInfo *mode; +igt_plane_t *primary; +int ret; + +igt_output_set_pipe (data->output, data->pipe); + + primary =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_PRIMARY ); + data->plane[primary->index] = primary; + + mode =igt_output_get_mode (data->output); + +igt_create_color_fb (data->drm_fd, mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , +LOCAL_I915_FORMAT_MOD_X_TILED , + color->red, color->green, color->blue, + &data->fb[primary->index]); + +igt_plane_set_fb (data->plane[primary->index], &data->fb[primary->index]); + + ret =igt_display_try_commit2 (&data->display,COMMIT_ATOMIC ); +igt_skip_on (ret !=0 ); +} + +/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned +* out on the primary plane +* - Then we scannout number of planes: +* * the primary plane uses a blue fb with a black rectangle hole +* * planes, on top of the primary plane, with a blue fb that is set-up +* to cover the black rectangles of the primary plane fb +* The resulting CRC should be identical to the reference CRC +*/ + +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, +color_t *color,int *rect_x,int *rect_y, +int *rect_w,int *rect_h,uint64_t tiling, +int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; +igt_plane_t *primary; + + primary =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_PRIMARY ); + + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + tiling, + &data->fb[primary->index]); +igt_assert (fb_id); + + cr =igt_get_cairo_ctx (data->drm_fd, &data->fb[primary->index]); +igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =0 ; i < max_planes; i++) { +if (data->plane[i]->type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; +igt_paint_color (cr, rect_x[i], rect_y[i], + rect_w[i], rect_h[i],0.0 ,0.0 ,0.0 ); + } + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + +static void +prepare_planes (data_t *data,color_t *color,int max_planes) +{ +drmModeModeInfo *mode; +igt_pipe_t *pipe; +igt_plane_t *primary; +int *x; +int *y; +int *size; +int i; + +igt_output_set_pipe (data->output, data->pipe); + primary =igt_output_get_plane_type (data->output,DRM_PLANE_TYPE_PRIMARY ); + pipe = primary->pipe; + + x =malloc (pipe->n_planes *sizeof (*x)); +igt_assert_f (x,"Failed to allocate %ld bytes for variable x\n" , (long int ) (pipe->n_planes *sizeof (*x))); + y =malloc (pipe->n_planes *sizeof (*y)); +igt_assert_f (y,"Failed to allocate %ld bytes for variable y\n" , (long int ) (pipe->n_planes *sizeof (*y))); + size =malloc (pipe->n_planes *sizeof (*size)); +igt_assert_f (size,"Failed to allocate %ld bytes for variable size\n" , (long int ) (pipe->n_planes *sizeof (*size))); + + mode =igt_output_get_mode (data->output); + +/* planes with random positions */ + x[primary->index] =0 ; + y[primary->index] =0 ; +for (i =0 ; i < max_planes; i++) { +igt_plane_t *plane =igt_output_get_plane (data->output, i); + +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; +else if (plane->type ==DRM_PLANE_TYPE_CURSOR ) + size[i] =SIZE_CURSOR ; +else + size[i] =SIZE_PLANE ; + + x[i] =rand () % (mode->hdisplay - size[i]); + y[i] =rand () % (mode->vdisplay - size[i]); + + data->plane[i] = plane; + +igt_create_color_fb (data->drm_fd, + size[i], size[i], + data->plane[i]->type ==DRM_PLANE_TYPE_CURSOR ?DRM_FORMAT_ARGB8888 :DRM_FORMAT_XRGB8888 , + data->plane[i]->type ==DRM_PLANE_TYPE_CURSOR ?LOCAL_DRM_FORMAT_MOD_NONE :LOCAL_I915_FORMAT_MOD_X_TILED , + color->red, color->green, color->blue, + &data->fb[i]); + +igt_plane_set_position (data->plane[i], x[i], y[i]); +igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[primary->index] = primary; +create_fb_for_mode_position (data, mode, color, x, y, size, size, +LOCAL_I915_FORMAT_MOD_X_TILED , max_planes); +igt_plane_set_fb (data->plane[primary->index], &data->fb[primary->index]); +} + +static void +test_plane_position_with_output (data_t *data) +{ +igt_crc_t *crc; +color_t blue = {0.0f ,0.0f ,1.0f }; +int i; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +char info[256 ]; +int max_planes = data->display.pipes[data->pipe].n_planes; + +if (opt.iterations ==LOOP_FOREVER ) { + loop_forever = true; +sprintf (info,"forever" ); + }else { + loop_forever = false; +sprintf (info,"for %d %s" , + iterations, iterations >1 ?"iterations" :"iteration" ); + } + +igt_info ("Testing connector %s using pipe %s with %d planes %s with seed %d\n" , +igt_output_name (data->output),kmstest_pipe_name (data->pipe), max_planes, + info, opt.seed); + + i =0 ; +while (i < iterations || loop_forever) { +prepare_planes (data, &blue, max_planes); + +display_commit_mode (data, crc); + + i++; + } +} + +static drmModeConnector * +get_connector_connected (int drm_fd) +{ +drmModeRes *resources =drmModeGetResources (drm_fd); +drmModeConnector *connector; +int i; + +for (i =0 ; i < resources->count_connectors; i++) { + connector =drmModeGetConnector (drm_fd, + resources->connectors[i]); + +if (connector->connection ==DRM_MODE_CONNECTED ) +break ; + +drmModeFreeConnector (connector); + connector =NULL ; + } + +drmModeFreeResources (resources); + +return connector; +} + +static int get_crtc_for_encoder (drmModeRes *resources, +drmModeEncoder *encoder) +{ +int mask, id; +int i; +bool found; + +for (i =0 ; i < resources->count_crtcs; i++) { + mask =1 << i; + id = resources->crtcs[i]; + + found = encoder->possible_crtcs & mask; +if (found) +break ; + } + +if (!found) +return -EINVAL ; + +return id; +} + +static int get_crtc_for_connector (int drm_fd,drmModeRes *resources, +drmModeConnector *connector) +{ +drmModeEncoder *encoder; +int encoder_id; +int crtc_id; +int i; + +for (i =0 ; i < connector->count_encoders; i++) { + encoder_id = connector->encoders[i]; + encoder =drmModeGetEncoder (drm_fd, encoder_id); + +if (encoder) { + crtc_id =get_crtc_for_encoder (resources, encoder); + +drmModeFreeEncoder (encoder); + +if (crtc_id !=0 ) +break ; + } + } + +if (crtc_id ==0 ) +return -EINVAL ; + +return crtc_id; +} + +static int get_crtc (int drm_fd) +{ +drmModeRes *resources; +drmModeConnector *connector; +drmModeEncoder *encoder; +int i, id; + + resources =drmModeGetResources (drm_fd); + connector =get_connector_connected (drm_fd); + +for (i =0 ; i < resources->count_encoders; i++) { + encoder =drmModeGetEncoder (drm_fd, resources->encoders[i]); + +if (encoder->encoder_id == connector->encoder_id) +break ; + +drmModeFreeEncoder (encoder); + encoder =NULL ; + } + +if (encoder) +return encoder->crtc_id; + + id =get_crtc_for_connector (drm_fd, resources, connector); +igt_assert (id !=0 ); + +return id; +} + +static drmModeModeInfo * +get_lowres_mode (data_t *data,drmModeModeInfo *mode_default) +{ +drmModeRes *resources =drmModeGetResources (data->drm_fd); +drmModeModeInfo std_1024_mode = { + .clock =65000 , + .hdisplay =1024 , + .hsync_start =1048 , + .hsync_end =1184 , + .htotal =1344 , + .hskew =0 , + .vdisplay =768 , + .vsync_start =771 , + .vsync_end =777 , + .vtotal =806 , + .vscan =0 , + .vrefresh =60 , + .flags =0xA , + .type =0x40 , + .name ="Custom 1024x768" , + }; +drmModeModeInfo *mode; +drmModeConnector *connector; +bool found; +int limit = mode_default->vdisplay-SIZE_PLANE ; +int i, j; + +if (!resources) { +igt_warn ("drmModeGetResources failed: %s\n" ,strerror (errno)); +return mode; + } + + found = false; +for (i =0 ; i < resources->count_connectors; i++) { + + connector =drmModeGetConnectorCurrent (data->drm_fd, + resources->connectors[i]); + +if (!connector) { +igt_warn ("could not get connector %i: %s\n" , + resources->connectors[i],strerror (errno)); +continue ; + } + +if (!connector->count_modes) +continue ; + +for (j =0 ; j < connector->count_modes; j++) { + mode = &connector->modes[j]; + +if (mode->vdisplay < limit) { + found = true; +break ; + } + } +
tests/kms_concurrent.c line 469
Quoted 10 lines
tests/kms_concurrent.c new file +10
-0+drmModeFreeConnector (connector); + } + +drmModeFreeResources (resources); + +if (!found) + mode = &std_1024_mode; + +return mode; +}
Still not completely happy about this part.
I would look at data->output->config.connector for modes, and return 1024 mode if nothing's found.
Saves a whole lot of drm calls.
Quoted 25 lines
tests/kms_concurrent.c new file +25
-0+static void +test_resolution_with_output (data_t *data) +{ +drmModeModeInfo *mode_hi, *mode_lo; +int ret; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +int i; + +if (opt.iterations ==LOOP_FOREVER ) + loop_forever = true; +else + loop_forever = false; + +igt_info ("Testing resolution with connector %s using pipe %s with seed %d\n" , +igt_output_name (data->output),kmstest_pipe_name (data->pipe), opt.seed); + + mode_hi =igt_output_get_mode (data->output); + mode_lo =get_lowres_mode (data, mode_hi); + + i =0 ; +while (i < iterations || loop_forever) { +/* switch to lower resolution */ + ret =drmModeSetCrtc (data->drm_fd, data->crtc_id, data->fb->fb_id,0 ,0 , + &data->connector_id,1 , mode_lo);
tests/kms_concurrent.c line 505
Quoted 10 lines
tests/kms_concurrent.c new file +10
-0+igt_assert_eq (ret,0 ); + +/* switch back to higher resolution */ + ret =drmModeSetCrtc (data->drm_fd, data->crtc_id, data->fb->fb_id,0 ,0 , + &data->connector_id,1 , mode_hi); +igt_assert_eq (ret,0 ); + + i++; + } +}
Use igt_output_override_mode + igt_display calls? With the thread being a fork now, you can use igt_display. :)
Quoted 6 lines
tests/kms_concurrent.c new file +6
-0+static void +run_test (data_t *data,enum pipe pipe) +{ +color_t blue = {0.0f ,0.0f ,1.0f }; +test_position_t test = { .data = data }; +int connected_outs;
tests/kms_concurrent.c line 522
Quoted 10 lines
tests/kms_concurrent.c new file +10
-0+int max_planes = data->display.pipes[data->pipe].n_planes; + +if (!opt.user_seed) + opt.seed =time (NULL ); + + connected_outs =0 ; +for_each_valid_output_on_pipe (&data->display, pipe, data->output) { + data->pipe = pipe; + + data->connector_id =get_connector_connected (data->drm_fd)->connector_id;
data->output->config.connector->connector_id ? Though I don't think we still need it if you use the igt display calls.
tests/kms_concurrent.c line 525
Quoted 3 lines
tests/kms_concurrent.c new file +3
-0+igt_assert (data->connector_id != -EINVAL ); + + data->crtc_id =get_crtc (data->drm_fd);
igt_output_set_pipe(output, pipe);
Again, shouldn't need crtc_id, but if you did display->pipes[pipe].crtc_id
With those fixed, I don't think you need raw drm calls in this test at all. :)
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 430 lines · Maarten Lankhorst
Op 15-03-17 om 09:43 schreef Mika Kahola:
Quoted 417 lines
This test case introduces concurrently running test cases for atomic
modesetting.The first test or thread draws blue backround with black holes on it.
These holes are covered by rectangular, blue planes that are placed randomly like in test case 'kms_plane_multiple'.The second thread changes resolution from higher to lower one and back.
The delay between resolution changes is randomly selected between 20 and
50 milliseconds.The test runs by default 32 iterations to increase the coverage.
v2: use
igt_forkinstead of pthreads to create concurrent test runs (Maarten)Signed-off-by Mika Kahola <[email protected]>---
tests/Makefile.sources | 1 +
tests/kms_concurrent.c | 630
+++++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 631 insertions(+)create mode 100644
tests/kms_concurrent.c<snip>
tests/kms_concurrent.c new file +7
-0+static int +display_commit_mode (data_t *data,igt_crc_t *crc) +{ +char buf[256 ]; +struct drm_event *e = (void *)buf; +int n, ret; + int flags = DRM_MODE_PAGE_FLIP_EVENT |
DRM_MODE_ATOMIC_ALLOW_MODESET|DRM_MODE_ATOMIC_NONBLOCK;tests/kms_concurrent.c new file +18
-0+ + ret =igt_display_try_commit_atomic (&data->display, + flags, + NULL); +igt_skip_on (ret !=0 ); + +igt_set_timeout (1 ,"Stuck on page flip" ); + ret =read (data->display.drm_fd, buf,sizeof (buf)); +igt_assert (ret >=0 ); + +igt_assert_eq (e->type,DRM_EVENT_FLIP_COMPLETE ); +igt_reset_timeout (); + +return n; +} + +static void +test_grab_crc (data_t *data,color_t *color,igt_crc_t *crc/* out */)
tests/kms_concurrent.c new file +8
-0+{ +drmModeModeInfo *mode; +igt_plane_t *primary; +int ret; + +igt_output_set_pipe (data->output, data->pipe); + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +5
-0+ data->plane[primary->index] = primary; + + mode =igt_output_get_mode (data->output); + + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode-Quoted 1 line
vdisplay,
tests/kms_concurrent.c new file +6
-0+ DRM_FORMAT_XRGB8888, + LOCAL_I915_FORMAT_MOD_X_TILED, + color->red, color->green, color->blue, + &data->fb[primary->index]); + + igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
(quoted diff) +2
-0+ + ret = igt_display_try_commit2(&data->display,
COMMIT_ATOMIC);tests/kms_concurrent.c new file +6
-0+igt_skip_on (ret !=0 ); +} + +/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned
+ * out on the primary plane
+ * - Then we scannout number of planes:
+ * * the primary plane uses a blue fb with a black rectangle hole
+ * * planes, on top of the primary plane, with a blue fb that is set-up
+ * to cover the black rectangles of the primary plane fb
+ * The resulting CRC should be identical to the reference CRC
+ */tests/kms_concurrent.c new file +4
-0+ +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, + color_t *color, int *rect_x, int
*rect_y,(quoted diff) +1
-0+ int *rect_w, int *rect_h, uint64_ttiling,
tests/kms_concurrent.c new file +7
-0+ int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; +igt_plane_t *primary; + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +9
-0+ + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + tiling, + &data->fb[primary->index]); +igt_assert (fb_id); + + cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[primary-Quoted 1 line
index]);
tests/kms_concurrent.c new file +6
-0+igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =0 ; i < max_planes; i++) { + if (data->plane[i]->type ==
DRM_PLANE_TYPE_PRIMARY)tests/kms_concurrent.c new file +3
-0+continue ; + igt_paint_color(cr, rect_x[i], rect_y[i], + rect_w[i], rect_h[i], 0.0, 0.0,0.0);
tests/kms_concurrent.c new file +19
-0+ } + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + +static void +prepare_planes (data_t *data,color_t *color,int max_planes) +{ +drmModeModeInfo *mode; +igt_pipe_t *pipe; +igt_plane_t *primary; +int *x; +int *y; +int *size; +int i; + +igt_output_set_pipe (data->output, data->pipe); + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +4
-0+ pipe = primary->pipe; + + x =malloc (pipe->n_planes *sizeof (*x)); + igt_assert_f(x, "Failed to allocate %ld bytes for variablex\n", (long int) (
pipe->n_planes*sizeof(*x)));(quoted diff) +2
-0+ y = malloc(pipe->n_planes * sizeof(*y)); + igt_assert_f(y, "Failed to allocate %ld bytes for variabley\n", (long int) (
pipe->n_planes*sizeof(*y)));(quoted diff) +2
-0+ size = malloc(pipe->n_planes * sizeof(*size)); + igt_assert_f(size, "Failed to allocate %ld bytes forvariable size\n", (long int) (
pipe->n_planes*sizeof(*size)));tests/kms_concurrent.c new file +8
-0+ + mode =igt_output_get_mode (data->output); + +/* planes with random positions */ + x[primary->index] =0 ; + y[primary->index] =0 ; +for (i =0 ; i < max_planes; i++) { + igt_plane_t *plane = igt_output_get_plane(data-Quoted 1 line
output, i);
tests/kms_concurrent.c new file +16
-0+ +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; +else if (plane->type ==DRM_PLANE_TYPE_CURSOR ) + size[i] =SIZE_CURSOR ; +else + size[i] =SIZE_PLANE ; + + x[i] =rand () % (mode->hdisplay - size[i]); + y[i] =rand () % (mode->vdisplay - size[i]); + + data->plane[i] = plane; + + igt_create_color_fb(data->drm_fd, + size[i], size[i], + data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?DRM_FORMAT_ARGB8888:DRM_FORMAT_XRGB8888,(quoted diff) +1
-0+ data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?LOCAL_DRM_FORMAT_MOD_NONE:LOCAL_I915_FORMAT_MOD_X_TILED,(quoted diff) +1
-0+ color->red, color->green,
color->blue,tests/kms_concurrent.c new file +3
-0+ &data->fb[i]); + + igt_plane_set_position(data->plane[i], x[i],y[i]);
tests/kms_concurrent.c new file +6
-0+igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[primary->index] = primary; + create_fb_for_mode_position(data, mode, color, x, y, size,size,
tests/kms_concurrent.c new file +1
-0+ LOCAL_I915_FORMAT_MOD_X_TILED,
max_planes);(quoted diff) +1
-0+ igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
tests/kms_concurrent.c new file +20
-0+} + +static void +test_plane_position_with_output (data_t *data) +{ +igt_crc_t *crc; + color_t blue = { 0.0f, 0.0f, 1.0f }; +int i; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +char info[256 ]; +int max_planes = data->display.pipes[data->pipe].n_planes; + +if (opt.iterations ==LOOP_FOREVER ) { + loop_forever = true; +sprintf (info,"forever" ); + }else { + loop_forever = false; + sprintf(info, "for %d %s", + iterations, iterations > 1 ? "iterations": "iteration");
tests/kms_concurrent.c new file +3
-0+ } + + igt_info("Testing connector %s using pipe %s with %dplanes %s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe),max_planes,tests/kms_concurrent.c new file +22
-0+ info, opt.seed); + + i =0 ; +while (i < iterations || loop_forever) { +prepare_planes (data, &blue, max_planes); + +display_commit_mode (data, crc); + + i++; + } +} + +static drmModeConnector * +get_connector_connected (int drm_fd) +{ +drmModeRes *resources =drmModeGetResources (drm_fd); +drmModeConnector *connector; +int i; + +for (i =0 ; i < resources->count_connectors; i++) { + connector = drmModeGetConnector(drm_fd, + resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +36
-0+ +if (connector->connection ==DRM_MODE_CONNECTED ) +break ; + +drmModeFreeConnector (connector); + connector =NULL ; + } + +drmModeFreeResources (resources); + +return connector; +} + +static int get_crtc_for_encoder (drmModeRes *resources, +drmModeEncoder *encoder) +{ +int mask, id; +int i; +bool found; + +for (i =0 ; i < resources->count_crtcs; i++) { + mask =1 << i; + id = resources->crtcs[i]; + + found = encoder->possible_crtcs & mask; +if (found) +break ; + } + +if (!found) +return -EINVAL ; + +return id; +} + +static int get_crtc_for_connector(int drm_fd, drmModeRes*resources,
tests/kms_concurrent.c new file +13
-0+ drmModeConnector *connector) +{ +drmModeEncoder *encoder; +int encoder_id; +int crtc_id; +int i; + +for (i =0 ; i < connector->count_encoders; i++) { + encoder_id = connector->encoders[i]; + encoder =drmModeGetEncoder (drm_fd, encoder_id); + +if (encoder) { + crtc_id = get_crtc_for_encoder(resources,encoder);
tests/kms_concurrent.c new file +26
-0+ +drmModeFreeEncoder (encoder); + +if (crtc_id !=0 ) +break ; + } + } + +if (crtc_id ==0 ) +return -EINVAL ; + +return crtc_id; +} + +static int get_crtc (int drm_fd) +{ +drmModeRes *resources; +drmModeConnector *connector; +drmModeEncoder *encoder; +int i, id; + + resources =drmModeGetResources (drm_fd); + connector =get_connector_connected (drm_fd); + +for (i =0 ; i < resources->count_encoders; i++) { + encoder = drmModeGetEncoder(drm_fd, resources-Quoted 1 line
encoders[i]);
tests/kms_concurrent.c new file +46
-0+ +if (encoder->encoder_id == connector->encoder_id) +break ; + +drmModeFreeEncoder (encoder); + encoder =NULL ; + } + +if (encoder) +return encoder->crtc_id; + + id =get_crtc_for_connector (drm_fd, resources, connector); +igt_assert (id !=0 ); + +return id; +} + +static drmModeModeInfo * +get_lowres_mode (data_t *data,drmModeModeInfo *mode_default) +{ +drmModeRes *resources =drmModeGetResources (data->drm_fd); +drmModeModeInfo std_1024_mode = { + .clock =65000 , + .hdisplay =1024 , + .hsync_start =1048 , + .hsync_end =1184 , + .htotal =1344 , + .hskew =0 , + .vdisplay =768 , + .vsync_start =771 , + .vsync_end =777 , + .vtotal =806 , + .vscan =0 , + .vrefresh =60 , + .flags =0xA , + .type =0x40 , + .name ="Custom 1024x768" , + }; +drmModeModeInfo *mode; +drmModeConnector *connector; +bool found; +int limit = mode_default->vdisplay-SIZE_PLANE ; +int i, j; + +if (!resources) { + igt_warn("drmModeGetResources failed: %s\n",strerror(errno));
tests/kms_concurrent.c new file +7
-0+return mode; + } + + found = false; +for (i =0 ; i < resources->count_connectors; i++) { + + connector = drmModeGetConnectorCurrent(data-Quoted 1 line
drm_fd,(quoted diff) +1
-0+ resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +3
-0+ +if (!connector) { + igt_warn("could not get connector %i:%s\n",
(quoted diff) +1
-0+ resources->connectors[i],strerror(errno));
tests/kms_concurrent.c new file +15
-0+continue ; + } + +if (!connector->count_modes) +continue ; + +for (j =0 ; j < connector->count_modes; j++) { + mode = &connector->modes[j]; + +if (mode->vdisplay < limit) { + found = true; +break ; + } + } +tests/kms_concurrent.c line 469
Quoted 10 lines
tests/kms_concurrent.c new file +10
-0+drmModeFreeConnector (connector); + } + +drmModeFreeResources (resources); + +if (!found) + mode = &std_1024_mode; + +return mode; +}Still not completely happy about this part.
Quoted 4 lines
I would look at
data->output->config.connectorfor modes, and return 1024 mode if nothing's found.Saves a whole lot of drm calls.
True. A lot of lines can be cleaned out.
Quoted 37 lines
Quoted 37 lines
tests/kms_concurrent.c new file +15
-0+static void +test_resolution_with_output (data_t *data) +{ +drmModeModeInfo *mode_hi, *mode_lo; +int ret; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +int i; + +if (opt.iterations ==LOOP_FOREVER ) + loop_forever = true; +else + loop_forever = false; + + igt_info("Testing resolution with connector %s using pipe%s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe), opt.seed);tests/kms_concurrent.c new file +8
-0+ + mode_hi =igt_output_get_mode (data->output); + mode_lo =get_lowres_mode (data, mode_hi); + + i =0 ; +while (i < iterations || loop_forever) { +/* switch to lower resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,
mode_lo);tests/kms_concurrent.c new file +4
-0+igt_assert_eq (ret,0 ); + +/* switch back to higher resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,
Quoted 8 lines
tests/kms_concurrent.c line 505
Quoted 6 lines
mode_hi);tests/kms_concurrent.c new file +5
-0+igt_assert_eq (ret,0 ); + + i++; + } +}Use
igt_output_override_mode+igt_displaycalls? With the thread being a fork now, you can useigt_display. :)
For some reason I keep receiving an error when using igt_output_override_mode + igt_display calls. The error is
igt-kms-CRITICAL: Failed assertion: drmModeDestroyPropertyBlob(display-
Quoted 1 line
drm_fd, *blob) == 0
igt-kms-CRITICAL: Last errno: 1, Operation not permitted
Maybe both threads try to access this and this request is not granted? With drmModeSetCrtc() call I don't see this behavior. Maybe stick with raw calls instead?
Quoted 34 lines
Quoted 18 lines
tests/kms_concurrent.c new file +13
-0+static void +run_test (data_t *data,enum pipe pipe) +{ + color_t blue = { 0.0f, 0.0f, 1.0f }; +test_position_t test = { .data = data }; +int connected_outs; +int max_planes = data->display.pipes[data->pipe].n_planes; + +if (!opt.user_seed) + opt.seed =time (NULL ); + + connected_outs =0 ; + for_each_valid_output_on_pipe(&data->display, pipe, data-Quoted 1 line
output) {
tests/kms_concurrent.c new file +3
-0+ data->pipe = pipe; + + data->connector_id = get_connector_connected(data-Quoted 1 line
Quoted 1 line
drm_fd)->connector_id;
data->output->config.connector->connector_id? Though I don't think we still need it if you use the igt display calls.tests/kms_concurrent.c line 525
Quoted 4 lines
tests/kms_concurrent.c new file +3
-0+igt_assert (data->connector_id != -EINVAL ); + + data->crtc_id =get_crtc (data->drm_fd);
igt_output_set_pipe(output, pipe);Again, shouldn't need
crtc_id, but if you did display-Quoted 1 line
pipes[pipe].crtc_id
With those fixed, I don't think you need raw drm calls in this test at all. :)
~Maarten
Signature · 6 lines
Mika Kahola - Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 10-04-17 om 14:11 schreef Mika Kahola:
Quoted 481 lines · Maarten Lankhorst
Quoted 429 lines
Op 15-03-17 om 09:43 schreef Mika Kahola:
Quoted 416 lines
This test case introduces concurrently running test cases for atomic
modesetting.The first test or thread draws blue backround with black holes on it.
These holes are covered by rectangular, blue planes that are placed randomly like in test case 'kms_plane_multiple'.The second thread changes resolution from higher to lower one and back.
The delay between resolution changes is randomly selected between 20 and
50 milliseconds.The test runs by default 32 iterations to increase the coverage.
v2: use
igt_forkinstead of pthreads to create concurrent test runs (Maarten)Signed-off-by Mika Kahola <[email protected]>--- tests/Makefile.sources | 1 + tests/kms_concurrent.c | 630 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 631 insertions(+) create mode 100644 tests/kms_concurrent.c<snip>
tests/kms_concurrent.c new file +7
-0+static int +display_commit_mode (data_t *data,igt_crc_t *crc) +{ +char buf[256 ]; +struct drm_event *e = (void *)buf; +int n, ret; + int flags = DRM_MODE_PAGE_FLIP_EVENT |
DRM_MODE_ATOMIC_ALLOW_MODESET|DRM_MODE_ATOMIC_NONBLOCK;tests/kms_concurrent.c new file +18
-0+ + ret =igt_display_try_commit_atomic (&data->display, + flags, +NULL ); +igt_skip_on (ret !=0 ); + +igt_set_timeout (1 ,"Stuck on page flip" ); + ret =read (data->display.drm_fd, buf,sizeof (buf)); +igt_assert (ret >=0 ); + +igt_assert_eq (e->type,DRM_EVENT_FLIP_COMPLETE ); +igt_reset_timeout (); + +return n; +} + +static void +test_grab_crc (data_t *data,color_t *color,igt_crc_t *crc/* out */)
tests/kms_concurrent.c new file +8
-0+{ +drmModeModeInfo *mode; +igt_plane_t *primary; +int ret; + +igt_output_set_pipe (data->output, data->pipe); + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +5
-0+ data->plane[primary->index] = primary; + + mode =igt_output_get_mode (data->output); + + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode-Quoted 1 line
vdisplay,
tests/kms_concurrent.c new file +6
-0+DRM_FORMAT_XRGB8888 , +LOCAL_I915_FORMAT_MOD_X_TILED , + color->red, color->green, color->blue, + &data->fb[primary->index]); + + igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
(quoted diff) +2
-0+ + ret = igt_display_try_commit2(&data->display,
COMMIT_ATOMIC);tests/kms_concurrent.c new file +6
-0+igt_skip_on (ret !=0 ); +} + +/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned
+ * out on the primary plane
+ * - Then we scannout number of planes:
+ * * the primary plane uses a blue fb with a black rectangle
hole
+ * * planes, on top of the primary plane, with a blue fb that
is set-up
+ * to cover the black rectangles of the primary plane fb
+ * The resulting CRC should be identical to the reference CRC
+ */tests/kms_concurrent.c new file +4
-0+ +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, + color_t *color, int *rect_x, int
*rect_y,(quoted diff) +1
-0+ int *rect_w, int *rect_h, uint64_ttiling,
tests/kms_concurrent.c new file +7
-0+ int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; +igt_plane_t *primary; + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +9
-0+ + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + tiling, + &data->fb[primary->index]); +igt_assert (fb_id); + + cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[primary-Quoted 1 line
index]);
tests/kms_concurrent.c new file +6
-0+igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =0 ; i < max_planes; i++) { + if (data->plane[i]->type ==
DRM_PLANE_TYPE_PRIMARY)tests/kms_concurrent.c new file +3
-0+continue ; + igt_paint_color(cr, rect_x[i], rect_y[i], + rect_w[i], rect_h[i], 0.0, 0.0,0.0);
tests/kms_concurrent.c new file +19
-0+ } + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + +static void +prepare_planes (data_t *data,color_t *color,int max_planes) +{ +drmModeModeInfo *mode; +igt_pipe_t *pipe; +igt_plane_t *primary; +int *x; +int *y; +int *size; +int i; + +igt_output_set_pipe (data->output, data->pipe); + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +4
-0+ pipe = primary->pipe; + + x =malloc (pipe->n_planes *sizeof (*x)); + igt_assert_f(x, "Failed to allocate %ld bytes for variablex\n", (long int) (
pipe->n_planes*sizeof(*x)));(quoted diff) +2
-0+ y = malloc(pipe->n_planes * sizeof(*y)); + igt_assert_f(y, "Failed to allocate %ld bytes for variabley\n", (long int) (
pipe->n_planes*sizeof(*y)));(quoted diff) +2
-0+ size = malloc(pipe->n_planes * sizeof(*size)); + igt_assert_f(size, "Failed to allocate %ld bytes forvariable size\n", (long int) (
pipe->n_planes*sizeof(*size)));tests/kms_concurrent.c new file +8
-0+ + mode =igt_output_get_mode (data->output); + +/* planes with random positions */ + x[primary->index] =0 ; + y[primary->index] =0 ; +for (i =0 ; i < max_planes; i++) { + igt_plane_t *plane = igt_output_get_plane(data-Quoted 1 line
output, i);
tests/kms_concurrent.c new file +16
-0+ +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; +else if (plane->type ==DRM_PLANE_TYPE_CURSOR ) + size[i] =SIZE_CURSOR ; +else + size[i] =SIZE_PLANE ; + + x[i] =rand () % (mode->hdisplay - size[i]); + y[i] =rand () % (mode->vdisplay - size[i]); + + data->plane[i] = plane; + + igt_create_color_fb(data->drm_fd, + size[i], size[i], + data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?DRM_FORMAT_ARGB8888:DRM_FORMAT_XRGB8888,(quoted diff) +1
-0+ data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?LOCAL_DRM_FORMAT_MOD_NONE:LOCAL_I915_FORMAT_MOD_X_TILED,(quoted diff) +1
-0+ color->red, color->green,
color->blue,tests/kms_concurrent.c new file +3
-0+ &data->fb[i]); + + igt_plane_set_position(data->plane[i], x[i],y[i]);
tests/kms_concurrent.c new file +6
-0+igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[primary->index] = primary; + create_fb_for_mode_position(data, mode, color, x, y, size,size,
tests/kms_concurrent.c new file +1
-0+ LOCAL_I915_FORMAT_MOD_X_TILED,
max_planes);(quoted diff) +1
-0+ igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
tests/kms_concurrent.c new file +20
-0+} + +static void +test_plane_position_with_output (data_t *data) +{ +igt_crc_t *crc; +color_t blue = {0.0f ,0.0f ,1.0f }; +int i; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +char info[256 ]; +int max_planes = data->display.pipes[data->pipe].n_planes; + +if (opt.iterations ==LOOP_FOREVER ) { + loop_forever = true; +sprintf (info,"forever" ); + }else { + loop_forever = false; + sprintf(info, "for %d %s", + iterations, iterations > 1 ? "iterations": "iteration");
tests/kms_concurrent.c new file +3
-0+ } + + igt_info("Testing connector %s using pipe %s with %dplanes %s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe),max_planes,tests/kms_concurrent.c new file +22
-0+ info, opt.seed); + + i =0 ; +while (i < iterations || loop_forever) { +prepare_planes (data, &blue, max_planes); + +display_commit_mode (data, crc); + + i++; + } +} + +static drmModeConnector * +get_connector_connected (int drm_fd) +{ +drmModeRes *resources =drmModeGetResources (drm_fd); +drmModeConnector *connector; +int i; + +for (i =0 ; i < resources->count_connectors; i++) { + connector = drmModeGetConnector(drm_fd, + resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +36
-0+ +if (connector->connection ==DRM_MODE_CONNECTED ) +break ; + +drmModeFreeConnector (connector); + connector =NULL ; + } + +drmModeFreeResources (resources); + +return connector; +} + +static int get_crtc_for_encoder (drmModeRes *resources, +drmModeEncoder *encoder) +{ +int mask, id; +int i; +bool found; + +for (i =0 ; i < resources->count_crtcs; i++) { + mask =1 << i; + id = resources->crtcs[i]; + + found = encoder->possible_crtcs & mask; +if (found) +break ; + } + +if (!found) +return -EINVAL ; + +return id; +} + +static int get_crtc_for_connector(int drm_fd, drmModeRes*resources,
tests/kms_concurrent.c new file +13
-0+ drmModeConnector *connector) +{ +drmModeEncoder *encoder; +int encoder_id; +int crtc_id; +int i; + +for (i =0 ; i < connector->count_encoders; i++) { + encoder_id = connector->encoders[i]; + encoder =drmModeGetEncoder (drm_fd, encoder_id); + +if (encoder) { + crtc_id = get_crtc_for_encoder(resources,encoder);
tests/kms_concurrent.c new file +26
-0+ +drmModeFreeEncoder (encoder); + +if (crtc_id !=0 ) +break ; + } + } + +if (crtc_id ==0 ) +return -EINVAL ; + +return crtc_id; +} + +static int get_crtc (int drm_fd) +{ +drmModeRes *resources; +drmModeConnector *connector; +drmModeEncoder *encoder; +int i, id; + + resources =drmModeGetResources (drm_fd); + connector =get_connector_connected (drm_fd); + +for (i =0 ; i < resources->count_encoders; i++) { + encoder = drmModeGetEncoder(drm_fd, resources-Quoted 1 line
encoders[i]);
tests/kms_concurrent.c new file +46
-0+ +if (encoder->encoder_id == connector->encoder_id) +break ; + +drmModeFreeEncoder (encoder); + encoder =NULL ; + } + +if (encoder) +return encoder->crtc_id; + + id =get_crtc_for_connector (drm_fd, resources, connector); +igt_assert (id !=0 ); + +return id; +} + +static drmModeModeInfo * +get_lowres_mode (data_t *data,drmModeModeInfo *mode_default) +{ +drmModeRes *resources =drmModeGetResources (data->drm_fd); +drmModeModeInfo std_1024_mode = { + .clock =65000 , + .hdisplay =1024 , + .hsync_start =1048 , + .hsync_end =1184 , + .htotal =1344 , + .hskew =0 , + .vdisplay =768 , + .vsync_start =771 , + .vsync_end =777 , + .vtotal =806 , + .vscan =0 , + .vrefresh =60 , + .flags =0xA , + .type =0x40 , + .name ="Custom 1024x768" , + }; +drmModeModeInfo *mode; +drmModeConnector *connector; +bool found; +int limit = mode_default->vdisplay-SIZE_PLANE ; +int i, j; + +if (!resources) { + igt_warn("drmModeGetResources failed: %s\n",strerror(errno));
tests/kms_concurrent.c new file +7
-0+return mode; + } + + found = false; +for (i =0 ; i < resources->count_connectors; i++) { + + connector = drmModeGetConnectorCurrent(data-Quoted 1 line
drm_fd,(quoted diff) +1
-0+ resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +3
-0+ +if (!connector) { + igt_warn("could not get connector %i:%s\n",
(quoted diff) +1
-0+ resources->connectors[i],strerror(errno));
tests/kms_concurrent.c new file +15
-0+continue ; + } + +if (!connector->count_modes) +continue ; + +for (j =0 ; j < connector->count_modes; j++) { + mode = &connector->modes[j]; + +if (mode->vdisplay < limit) { + found = true; +break ; + } + } +tests/kms_concurrent.c line 469
Quoted 10 lines
tests/kms_concurrent.c new file +10
-0+drmModeFreeConnector (connector); + } + +drmModeFreeResources (resources); + +if (!found) + mode = &std_1024_mode; + +return mode; +}Still not completely happy about this part.
Quoted 4 lines
I would look at
data->output->config.connectorfor modes, and return 1024 mode if nothing's found.Saves a whole lot of drm calls.
True. A lot of lines can be cleaned out.
Quoted 35 lines
Quoted 35 lines
tests/kms_concurrent.c new file +15
-0+static void +test_resolution_with_output (data_t *data) +{ +drmModeModeInfo *mode_hi, *mode_lo; +int ret; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +int i; + +if (opt.iterations ==LOOP_FOREVER ) + loop_forever = true; +else + loop_forever = false; + + igt_info("Testing resolution with connector %s using pipe%s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe), opt.seed);tests/kms_concurrent.c new file +8
-0+ + mode_hi =igt_output_get_mode (data->output); + mode_lo =get_lowres_mode (data, mode_hi); + + i =0 ; +while (i < iterations || loop_forever) { +/* switch to lower resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,
mode_lo);tests/kms_concurrent.c new file +4
-0+igt_assert_eq (ret,0 ); + +/* switch back to higher resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,Quoted 8 lines
tests/kms_concurrent.c line 505
Quoted 6 lines
mode_hi);tests/kms_concurrent.c new file +5
-0+igt_assert_eq (ret,0 ); + + i++; + } +}Use
igt_output_override_mode+igt_displaycalls? With the thread being a fork now, you can useigt_display. :)For some reason I keep receiving an error when using
igt_output_override_mode+igt_displaycalls. The error is
Quoted 7 lines
igt-kms-CRITICAL: Failed assertion: drmModeDestroyPropertyBlob(display-
Quoted 1 line
drm_fd, *blob) == 0igt-kms-CRITICAL: Last errno: 1, Operation not permitted
Maybe both threads try to access this and this request is not granted? With
drmModeSetCrtc()call I don't see this behavior. Maybe stick with raw calls instead?
data->display.pipes[pipe].mode_blob = 0; in one of the forks of the test should fix it.
-EPERM means that the blob was already destroyed by this fd, but still used globally.
kms_rmfb does similar, maybe we should ignore failures?
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 489 lines
-----Original Message-----
From: Maarten Lankhorst [mailto:[email protected]]
Sent: Monday, April 10, 2017 3:39 PM
To: Kahola, Mika <[email protected]>; [email protected]
Subject: Re: [PATCH i-g-t v2] tests/kms_concurrent: Concurrent and interruptible subtests for atomicOp 10-04-17 om 14:11 schreef Mika Kahola:
Quoted 29 lines · Maarten Lankhorst
Quoted 28 lines
Op 15-03-17 om 09:43 schreef Mika Kahola:
Quoted 27 lines
This test case introduces concurrently running test cases for atomic modesetting.
The first test or thread draws blue backround with black holes on it.
These holes are covered by rectangular, blue planes that are placed randomly like in test case 'kms_plane_multiple'.The second thread changes resolution from higher to lower one and back.
The delay between resolution changes is randomly selected between 20 and
50 milliseconds.The test runs by default 32 iterations to increase the coverage.
v2: use
igt_forkinstead of pthreads to create concurrent test runs (Maarten)Signed-off-by Mika Kahola <[email protected]>--- tests/Makefile.sources | 1 + tests/kms_concurrent.c | 630 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 631 insertions(+) create mode 100644 tests/kms_concurrent.cQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
<snip>
tests/kms_concurrent.c new file +6
-0+static int +display_commit_mode (data_t *data,igt_crc_t *crc) { +char buf[256 ]; +struct drm_event *e = (void *)buf; +int n, ret; + int flags = DRM_MODE_PAGE_FLIP_EVENT |
DRM_MODE_ATOMIC_ALLOW_MODESET|
DRM_MODE_ATOMIC_NONBLOCK;Quoted 144 lines
Quoted 144 lines
Quoted 144 lines
tests/kms_concurrent.c new file +18
-0+ + ret =igt_display_try_commit_atomic (&data->display, + flags, +NULL ); +igt_skip_on (ret !=0 ); + +igt_set_timeout (1 ,"Stuck on page flip" ); + ret =read (data->display.drm_fd, buf,sizeof (buf)); +igt_assert (ret >=0 ); + +igt_assert_eq (e->type,DRM_EVENT_FLIP_COMPLETE ); +igt_reset_timeout (); + +return n; +} + +static void +test_grab_crc (data_t *data,color_t *color,igt_crc_t *crc/* out */)
tests/kms_concurrent.c new file +8
-0+{ +drmModeModeInfo *mode; +igt_plane_t *primary; +int ret; + +igt_output_set_pipe (data->output, data->pipe); + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +5
-0+ data->plane[primary->index] = primary; + + mode =igt_output_get_mode (data->output); + + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode-Quoted 1 line
vdisplay,
tests/kms_concurrent.c new file +6
-0+DRM_FORMAT_XRGB8888 , +LOCAL_I915_FORMAT_MOD_X_TILED , + color->red, color->green, color->blue, + &data->fb[primary->index]); + + igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
(quoted diff) +2
-0+ + ret = igt_display_try_commit2(&data->display,
COMMIT_ATOMIC);tests/kms_concurrent.c new file +6
-0+igt_skip_on (ret !=0 ); +} + +/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned
+ * out on the primary plane
+ * - Then we scannout number of planes:
+ * * the primary plane uses a blue fb with a black rectangle
hole
+ * * planes, on top of the primary plane, with a blue fb that
is set-up
+ * to cover the black rectangles of the primary plane fb
+ * The resulting CRC should be identical to the reference CRC
+ */tests/kms_concurrent.c new file +4
-0+ +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, + color_t *color, int *rect_x, int
*rect_y,(quoted diff) +1
-0+ int *rect_w, int *rect_h, uint64_ttiling,
tests/kms_concurrent.c new file +7
-0+ int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; +igt_plane_t *primary; + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +9
-0+ + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + tiling, + &data->fb[primary->index]); +igt_assert (fb_id); + + cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[primary-Quoted 1 line
index]);
tests/kms_concurrent.c new file +6
-0+igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =0 ; i < max_planes; i++) { + if (data->plane[i]->type ==
DRM_PLANE_TYPE_PRIMARY)tests/kms_concurrent.c new file +3
-0+continue ; + igt_paint_color(cr, rect_x[i], rect_y[i], + rect_w[i], rect_h[i], 0.0, 0.0,0.0);
tests/kms_concurrent.c new file +18
-0+ } + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + +static void +prepare_planes (data_t *data,color_t *color,int max_planes) { +drmModeModeInfo *mode; +igt_pipe_t *pipe; +igt_plane_t *primary; +int *x; +int *y; +int *size; +int i; + +igt_output_set_pipe (data->output, data->pipe); + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +4
-0+ pipe = primary->pipe; + + x =malloc (pipe->n_planes *sizeof (*x)); + igt_assert_f(x, "Failed to allocate %ld bytes for variablex\n", (long int) (
pipe->n_planes*sizeof(*x)));(quoted diff) +2
-0+ y = malloc(pipe->n_planes * sizeof(*y)); + igt_assert_f(y, "Failed to allocate %ld bytes for variabley\n", (long int) (
pipe->n_planes*sizeof(*y)));(quoted diff) +2
-0+ size = malloc(pipe->n_planes * sizeof(*size)); + igt_assert_f(size, "Failed to allocate %ld bytes forvariable size\n", (long int) (
pipe->n_planes*sizeof(*size)));tests/kms_concurrent.c new file +8
-0+ + mode =igt_output_get_mode (data->output); + +/* planes with random positions */ + x[primary->index] =0 ; + y[primary->index] =0 ; +for (i =0 ; i < max_planes; i++) { + igt_plane_t *plane = igt_output_get_plane(data-Quoted 1 line
output, i);
tests/kms_concurrent.c new file +9
-0+ +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; +else if (plane->type ==DRM_PLANE_TYPE_CURSOR ) + size[i] =SIZE_CURSOR ; +else + size[i] =SIZE_PLANE ; + + x[i] =rand () % (mode->hdisplay - size[i]);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
tests/kms_concurrent.c new file +7
-0+ y[i] =rand () % (mode->vdisplay - size[i]); + + data->plane[i] = plane; + + igt_create_color_fb(data->drm_fd, + size[i], size[i], + data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?DRM_FORMAT_ARGB8888:
DRM_FORMAT_XRGB8888,Quoted 288 lines
Quoted 235 lines
Quoted 223 lines
(quoted diff) +1
-0+ data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?LOCAL_DRM_FORMAT_MOD_NONE:LOCAL_I915_FORMAT_MOD_X_TILED,(quoted diff) +1
-0+ color->red, color->green,
color->blue,tests/kms_concurrent.c new file +3
-0+ &data->fb[i]); + + igt_plane_set_position(data->plane[i], x[i],y[i]);
tests/kms_concurrent.c new file +6
-0+igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[primary->index] = primary; + create_fb_for_mode_position(data, mode, color, x, y, size,size,
tests/kms_concurrent.c new file +1
-0+ LOCAL_I915_FORMAT_MOD_X_TILED,
max_planes);(quoted diff) +1
-0+ igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
tests/kms_concurrent.c new file +19
-0+} + +static void +test_plane_position_with_output (data_t *data) { +igt_crc_t *crc; +color_t blue = {0.0f ,0.0f ,1.0f }; +int i; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +char info[256 ]; +int max_planes = data->display.pipes[data->pipe].n_planes; + +if (opt.iterations ==LOOP_FOREVER ) { + loop_forever = true; +sprintf (info,"forever" ); + }else { + loop_forever = false; + sprintf(info, "for %d %s", + iterations, iterations > 1 ? "iterations": "iteration");
tests/kms_concurrent.c new file +3
-0+ } + + igt_info("Testing connector %s using pipe %s with %dplanes %s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe),max_planes,tests/kms_concurrent.c new file +21
-0+ info, opt.seed); + + i =0 ; +while (i < iterations || loop_forever) { +prepare_planes (data, &blue, max_planes); + +display_commit_mode (data, crc); + + i++; + } +} + +static drmModeConnector * +get_connector_connected (int drm_fd) { +drmModeRes *resources =drmModeGetResources (drm_fd); +drmModeConnector *connector; +int i; + +for (i =0 ; i < resources->count_connectors; i++) { + connector = drmModeGetConnector(drm_fd, + resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +36
-0+ +if (connector->connection ==DRM_MODE_CONNECTED ) +break ; + +drmModeFreeConnector (connector); + connector =NULL ; + } + +drmModeFreeResources (resources); + +return connector; +} + +static int get_crtc_for_encoder (drmModeRes *resources, +drmModeEncoder *encoder) +{ +int mask, id; +int i; +bool found; + +for (i =0 ; i < resources->count_crtcs; i++) { + mask =1 << i; + id = resources->crtcs[i]; + + found = encoder->possible_crtcs & mask; +if (found) +break ; + } + +if (!found) +return -EINVAL ; + +return id; +} + +static int get_crtc_for_connector(int drm_fd, drmModeRes*resources,
tests/kms_concurrent.c new file +13
-0+ drmModeConnector *connector) +{ +drmModeEncoder *encoder; +int encoder_id; +int crtc_id; +int i; + +for (i =0 ; i < connector->count_encoders; i++) { + encoder_id = connector->encoders[i]; + encoder =drmModeGetEncoder (drm_fd, encoder_id); + +if (encoder) { + crtc_id = get_crtc_for_encoder(resources,encoder);
tests/kms_concurrent.c new file +26
-0+ +drmModeFreeEncoder (encoder); + +if (crtc_id !=0 ) +break ; + } + } + +if (crtc_id ==0 ) +return -EINVAL ; + +return crtc_id; +} + +static int get_crtc (int drm_fd) +{ +drmModeRes *resources; +drmModeConnector *connector; +drmModeEncoder *encoder; +int i, id; + + resources =drmModeGetResources (drm_fd); + connector =get_connector_connected (drm_fd); + +for (i =0 ; i < resources->count_encoders; i++) { + encoder = drmModeGetEncoder(drm_fd, resources-Quoted 1 line
encoders[i]);
tests/kms_concurrent.c new file +45
-0+ +if (encoder->encoder_id == connector->encoder_id) +break ; + +drmModeFreeEncoder (encoder); + encoder =NULL ; + } + +if (encoder) +return encoder->crtc_id; + + id =get_crtc_for_connector (drm_fd, resources, connector); +igt_assert (id !=0 ); + +return id; +} + +static drmModeModeInfo * +get_lowres_mode (data_t *data,drmModeModeInfo *mode_default) { +drmModeRes *resources =drmModeGetResources (data->drm_fd); +drmModeModeInfo std_1024_mode = { + .clock =65000 , + .hdisplay =1024 , + .hsync_start =1048 , + .hsync_end =1184 , + .htotal =1344 , + .hskew =0 , + .vdisplay =768 , + .vsync_start =771 , + .vsync_end =777 , + .vtotal =806 , + .vscan =0 , + .vrefresh =60 , + .flags =0xA , + .type =0x40 , + .name ="Custom 1024x768" , + }; +drmModeModeInfo *mode; +drmModeConnector *connector; +bool found; +int limit = mode_default->vdisplay-SIZE_PLANE ; +int i, j; + +if (!resources) { + igt_warn("drmModeGetResources failed: %s\n",strerror(errno));
tests/kms_concurrent.c new file +7
-0+return mode; + } + + found = false; +for (i =0 ; i < resources->count_connectors; i++) { + + connector = drmModeGetConnectorCurrent(data-Quoted 1 line
drm_fd,(quoted diff) +1
-0+ resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +3
-0+ +if (!connector) { + igt_warn("could not get connector %i:%s\n",
(quoted diff) +1
-0+ resources->connectors[i],strerror(errno));
tests/kms_concurrent.c new file +15
-0+continue ; + } + +if (!connector->count_modes) +continue ; + +for (j =0 ; j < connector->count_modes; j++) { + mode = &connector->modes[j]; + +if (mode->vdisplay < limit) { + found = true; +break ; + } + } +tests/kms_concurrent.c line 469
Quoted 10 lines
tests/kms_concurrent.c new file +10
-0+drmModeFreeConnector (connector); + } + +drmModeFreeResources (resources); + +if (!found) + mode = &std_1024_mode; + +return mode; +}Still not completely happy about this part.
Quoted 4 lines
I would look at
data->output->config.connectorfor modes, and return 1024 mode if nothing's found.Saves a whole lot of drm calls.
True. A lot of lines can be cleaned out.
Quoted 34 lines
Quoted 34 lines
tests/kms_concurrent.c new file +14
-0+static void +test_resolution_with_output (data_t *data) { +drmModeModeInfo *mode_hi, *mode_lo; +int ret; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +int i; + +if (opt.iterations ==LOOP_FOREVER ) + loop_forever = true; +else + loop_forever = false; + + igt_info("Testing resolution with connector %s using pipe%s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe), opt.seed);tests/kms_concurrent.c new file +8
-0+ + mode_hi =igt_output_get_mode (data->output); + mode_lo =get_lowres_mode (data, mode_hi); + + i =0 ; +while (i < iterations || loop_forever) { +/* switch to lower resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,
mode_lo);tests/kms_concurrent.c new file +4
-0+igt_assert_eq (ret,0 ); + +/* switch back to higher resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,Quoted 8 lines
tests/kms_concurrent.c line 505
Quoted 6 lines
mode_hi);tests/kms_concurrent.c new file +5
-0+igt_assert_eq (ret,0 ); + + i++; + } +}Use
igt_output_override_mode+igt_displaycalls? With the thread being a fork now, you can useigt_display. :)For some reason I keep receiving an error when using
igt_output_override_mode+igt_displaycalls. The error isigt-kms-CRITICAL: Failed assertion:
drmModeDestroyPropertyBlob(display-Quoted 1 line
drm_fd, *blob) == 0
Quoted 8 lines
Quoted 5 lines
igt-kms-CRITICAL: Last errno: 1, Operation not permitted
Maybe both threads try to access this and this request is not granted? With
drmModeSetCrtc()call I don't see this behavior. Maybe stick with raw calls instead?data->display.pipes[pipe].mode_blob = 0; in one of the forks of the test should fix it.
This seems to fix the issue. I'll throw a revised patch of the test shortly.
Quoted 5 lines
-EPERMmeans that the blob was already destroyed by this fd, but still used globally.
kms_rmfbdoes similar, maybe we should ignore failures?
Maybe we could ignore these failures. Any harm done elsewhere if we do so?
-Mika-
Quoted 2 lines
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 11-04-17 om 09:42 schreef Kahola, Mika:
Quoted 495 lines
Quoted 487 lines
-----Original Message-----
From: Maarten Lankhorst [mailto:[email protected]]
Sent: Monday, April 10, 2017 3:39 PM
To: Kahola, Mika <[email protected]>; [email protected]
Subject: Re: [PATCH i-g-t v2] tests/kms_concurrent: Concurrent and interruptible subtests for atomicOp 10-04-17 om 14:11 schreef Mika Kahola:
Quoted 29 lines · Maarten Lankhorst
Quoted 28 lines
Op 15-03-17 om 09:43 schreef Mika Kahola:
Quoted 27 lines
This test case introduces concurrently running test cases for atomic modesetting.
The first test or thread draws blue backround with black holes on it.
These holes are covered by rectangular, blue planes that are placed randomly like in test case 'kms_plane_multiple'.The second thread changes resolution from higher to lower one and back.
The delay between resolution changes is randomly selected between 20 and
50 milliseconds.The test runs by default 32 iterations to increase the coverage.
v2: use
igt_forkinstead of pthreads to create concurrent test runs (Maarten)Signed-off-by Mika Kahola <[email protected]>--- tests/Makefile.sources | 1 + tests/kms_concurrent.c | 630 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 631 insertions(+) create mode 100644 tests/kms_concurrent.cQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
<snip>
tests/kms_concurrent.c new file +6
-0+static int +display_commit_mode (data_t *data,igt_crc_t *crc) { +char buf[256 ]; +struct drm_event *e = (void *)buf; +int n, ret; + int flags = DRM_MODE_PAGE_FLIP_EVENT |
DRM_MODE_ATOMIC_ALLOW_MODESET|
DRM_MODE_ATOMIC_NONBLOCK;Quoted 144 lines
Quoted 144 lines
Quoted 144 lines
tests/kms_concurrent.c new file +18
-0+ + ret =igt_display_try_commit_atomic (&data->display, + flags, +NULL ); +igt_skip_on (ret !=0 ); + +igt_set_timeout (1 ,"Stuck on page flip" ); + ret =read (data->display.drm_fd, buf,sizeof (buf)); +igt_assert (ret >=0 ); + +igt_assert_eq (e->type,DRM_EVENT_FLIP_COMPLETE ); +igt_reset_timeout (); + +return n; +} + +static void +test_grab_crc (data_t *data,color_t *color,igt_crc_t *crc/* out */)
tests/kms_concurrent.c new file +8
-0+{ +drmModeModeInfo *mode; +igt_plane_t *primary; +int ret; + +igt_output_set_pipe (data->output, data->pipe); + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +5
-0+ data->plane[primary->index] = primary; + + mode =igt_output_get_mode (data->output); + + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode-Quoted 1 line
vdisplay,
tests/kms_concurrent.c new file +6
-0+DRM_FORMAT_XRGB8888 , +LOCAL_I915_FORMAT_MOD_X_TILED , + color->red, color->green, color->blue, + &data->fb[primary->index]); + + igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
(quoted diff) +2
-0+ + ret = igt_display_try_commit2(&data->display,
COMMIT_ATOMIC);tests/kms_concurrent.c new file +6
-0+igt_skip_on (ret !=0 ); +} + +/* +* Multiple plane position test. +* - We start by grabbing a reference CRC of a full blue fb being scanned
+ * out on the primary plane
+ * - Then we scannout number of planes:
+ * * the primary plane uses a blue fb with a black rectangle
hole
+ * * planes, on top of the primary plane, with a blue fb that
is set-up
+ * to cover the black rectangles of the primary plane fb
+ * The resulting CRC should be identical to the reference CRC
+ */tests/kms_concurrent.c new file +4
-0+ +static void +create_fb_for_mode_position (data_t *data,drmModeModeInfo *mode, + color_t *color, int *rect_x, int
*rect_y,(quoted diff) +1
-0+ int *rect_w, int *rect_h, uint64_ttiling,
tests/kms_concurrent.c new file +7
-0+ int max_planes) +{ +unsigned int fb_id; +cairo_t *cr; +igt_plane_t *primary; + + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +9
-0+ + fb_id =igt_create_fb (data->drm_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + tiling, + &data->fb[primary->index]); +igt_assert (fb_id); + + cr = igt_get_cairo_ctx(data->drm_fd, &data->fb[primary-Quoted 1 line
index]);
tests/kms_concurrent.c new file +6
-0+igt_paint_color (cr, rect_x[0 ], rect_y[0 ], + mode->hdisplay, mode->vdisplay, + color->red, color->green, color->blue); + +for (int i =0 ; i < max_planes; i++) { + if (data->plane[i]->type ==
DRM_PLANE_TYPE_PRIMARY)tests/kms_concurrent.c new file +3
-0+continue ; + igt_paint_color(cr, rect_x[i], rect_y[i], + rect_w[i], rect_h[i], 0.0, 0.0,0.0);
tests/kms_concurrent.c new file +18
-0+ } + +igt_assert (cairo_status (cr) ==0 ); +cairo_destroy (cr); +} + +static void +prepare_planes (data_t *data,color_t *color,int max_planes) { +drmModeModeInfo *mode; +igt_pipe_t *pipe; +igt_plane_t *primary; +int *x; +int *y; +int *size; +int i; + +igt_output_set_pipe (data->output, data->pipe); + primary = igt_output_get_plane_type(data->output,
DRM_PLANE_TYPE_PRIMARY);tests/kms_concurrent.c new file +4
-0+ pipe = primary->pipe; + + x =malloc (pipe->n_planes *sizeof (*x)); + igt_assert_f(x, "Failed to allocate %ld bytes for variablex\n", (long int) (
pipe->n_planes*sizeof(*x)));(quoted diff) +2
-0+ y = malloc(pipe->n_planes * sizeof(*y)); + igt_assert_f(y, "Failed to allocate %ld bytes for variabley\n", (long int) (
pipe->n_planes*sizeof(*y)));(quoted diff) +2
-0+ size = malloc(pipe->n_planes * sizeof(*size)); + igt_assert_f(size, "Failed to allocate %ld bytes forvariable size\n", (long int) (
pipe->n_planes*sizeof(*size)));tests/kms_concurrent.c new file +8
-0+ + mode =igt_output_get_mode (data->output); + +/* planes with random positions */ + x[primary->index] =0 ; + y[primary->index] =0 ; +for (i =0 ; i < max_planes; i++) { + igt_plane_t *plane = igt_output_get_plane(data-Quoted 1 line
output, i);
tests/kms_concurrent.c new file +9
-0+ +if (plane->type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; +else if (plane->type ==DRM_PLANE_TYPE_CURSOR ) + size[i] =SIZE_CURSOR ; +else + size[i] =SIZE_PLANE ; + + x[i] =rand () % (mode->hdisplay - size[i]);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
tests/kms_concurrent.c new file +7
-0+ y[i] =rand () % (mode->vdisplay - size[i]); + + data->plane[i] = plane; + + igt_create_color_fb(data->drm_fd, + size[i], size[i], + data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?DRM_FORMAT_ARGB8888:
DRM_FORMAT_XRGB8888,Quoted 287 lines
Quoted 235 lines
Quoted 223 lines
(quoted diff) +1
-0+ data->plane[i]->type ==
DRM_PLANE_TYPE_CURSOR?LOCAL_DRM_FORMAT_MOD_NONE:LOCAL_I915_FORMAT_MOD_X_TILED,(quoted diff) +1
-0+ color->red, color->green,
color->blue,tests/kms_concurrent.c new file +3
-0+ &data->fb[i]); + + igt_plane_set_position(data->plane[i], x[i],y[i]);
tests/kms_concurrent.c new file +6
-0+igt_plane_set_fb (data->plane[i], &data->fb[i]); + } + +/* primary plane */ + data->plane[primary->index] = primary; + create_fb_for_mode_position(data, mode, color, x, y, size,size,
tests/kms_concurrent.c new file +1
-0+ LOCAL_I915_FORMAT_MOD_X_TILED,
max_planes);(quoted diff) +1
-0+ igt_plane_set_fb(data->plane[primary->index], &data-Quoted 1 line
fb[primary->index]);
tests/kms_concurrent.c new file +19
-0+} + +static void +test_plane_position_with_output (data_t *data) { +igt_crc_t *crc; +color_t blue = {0.0f ,0.0f ,1.0f }; +int i; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +char info[256 ]; +int max_planes = data->display.pipes[data->pipe].n_planes; + +if (opt.iterations ==LOOP_FOREVER ) { + loop_forever = true; +sprintf (info,"forever" ); + }else { + loop_forever = false; + sprintf(info, "for %d %s", + iterations, iterations > 1 ? "iterations": "iteration");
tests/kms_concurrent.c new file +3
-0+ } + + igt_info("Testing connector %s using pipe %s with %dplanes %s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe),max_planes,tests/kms_concurrent.c new file +21
-0+ info, opt.seed); + + i =0 ; +while (i < iterations || loop_forever) { +prepare_planes (data, &blue, max_planes); + +display_commit_mode (data, crc); + + i++; + } +} + +static drmModeConnector * +get_connector_connected (int drm_fd) { +drmModeRes *resources =drmModeGetResources (drm_fd); +drmModeConnector *connector; +int i; + +for (i =0 ; i < resources->count_connectors; i++) { + connector = drmModeGetConnector(drm_fd, + resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +36
-0+ +if (connector->connection ==DRM_MODE_CONNECTED ) +break ; + +drmModeFreeConnector (connector); + connector =NULL ; + } + +drmModeFreeResources (resources); + +return connector; +} + +static int get_crtc_for_encoder (drmModeRes *resources, +drmModeEncoder *encoder) +{ +int mask, id; +int i; +bool found; + +for (i =0 ; i < resources->count_crtcs; i++) { + mask =1 << i; + id = resources->crtcs[i]; + + found = encoder->possible_crtcs & mask; +if (found) +break ; + } + +if (!found) +return -EINVAL ; + +return id; +} + +static int get_crtc_for_connector(int drm_fd, drmModeRes*resources,
tests/kms_concurrent.c new file +13
-0+ drmModeConnector *connector) +{ +drmModeEncoder *encoder; +int encoder_id; +int crtc_id; +int i; + +for (i =0 ; i < connector->count_encoders; i++) { + encoder_id = connector->encoders[i]; + encoder =drmModeGetEncoder (drm_fd, encoder_id); + +if (encoder) { + crtc_id = get_crtc_for_encoder(resources,encoder);
tests/kms_concurrent.c new file +26
-0+ +drmModeFreeEncoder (encoder); + +if (crtc_id !=0 ) +break ; + } + } + +if (crtc_id ==0 ) +return -EINVAL ; + +return crtc_id; +} + +static int get_crtc (int drm_fd) +{ +drmModeRes *resources; +drmModeConnector *connector; +drmModeEncoder *encoder; +int i, id; + + resources =drmModeGetResources (drm_fd); + connector =get_connector_connected (drm_fd); + +for (i =0 ; i < resources->count_encoders; i++) { + encoder = drmModeGetEncoder(drm_fd, resources-Quoted 1 line
encoders[i]);
tests/kms_concurrent.c new file +45
-0+ +if (encoder->encoder_id == connector->encoder_id) +break ; + +drmModeFreeEncoder (encoder); + encoder =NULL ; + } + +if (encoder) +return encoder->crtc_id; + + id =get_crtc_for_connector (drm_fd, resources, connector); +igt_assert (id !=0 ); + +return id; +} + +static drmModeModeInfo * +get_lowres_mode (data_t *data,drmModeModeInfo *mode_default) { +drmModeRes *resources =drmModeGetResources (data->drm_fd); +drmModeModeInfo std_1024_mode = { + .clock =65000 , + .hdisplay =1024 , + .hsync_start =1048 , + .hsync_end =1184 , + .htotal =1344 , + .hskew =0 , + .vdisplay =768 , + .vsync_start =771 , + .vsync_end =777 , + .vtotal =806 , + .vscan =0 , + .vrefresh =60 , + .flags =0xA , + .type =0x40 , + .name ="Custom 1024x768" , + }; +drmModeModeInfo *mode; +drmModeConnector *connector; +bool found; +int limit = mode_default->vdisplay-SIZE_PLANE ; +int i, j; + +if (!resources) { + igt_warn("drmModeGetResources failed: %s\n",strerror(errno));
tests/kms_concurrent.c new file +7
-0+return mode; + } + + found = false; +for (i =0 ; i < resources->count_connectors; i++) { + + connector = drmModeGetConnectorCurrent(data-Quoted 1 line
drm_fd,(quoted diff) +1
-0+ resources-Quoted 1 line
connectors[i]);
tests/kms_concurrent.c new file +3
-0+ +if (!connector) { + igt_warn("could not get connector %i:%s\n",
(quoted diff) +1
-0+ resources->connectors[i],strerror(errno));
tests/kms_concurrent.c new file +15
-0+continue ; + } + +if (!connector->count_modes) +continue ; + +for (j =0 ; j < connector->count_modes; j++) { + mode = &connector->modes[j]; + +if (mode->vdisplay < limit) { + found = true; +break ; + } + } +tests/kms_concurrent.c line 469
Quoted 10 lines
tests/kms_concurrent.c new file +10
-0+drmModeFreeConnector (connector); + } + +drmModeFreeResources (resources); + +if (!found) + mode = &std_1024_mode; + +return mode; +}Still not completely happy about this part.
Quoted 4 lines
I would look at
data->output->config.connectorfor modes, and return 1024 mode if nothing's found.Saves a whole lot of drm calls.
True. A lot of lines can be cleaned out.
Quoted 34 lines
Quoted 34 lines
tests/kms_concurrent.c new file +14
-0+static void +test_resolution_with_output (data_t *data) { +drmModeModeInfo *mode_hi, *mode_lo; +int ret; +int iterations = opt.iterations <1 ?1 : opt.iterations; +bool loop_forever; +int i; + +if (opt.iterations ==LOOP_FOREVER ) + loop_forever = true; +else + loop_forever = false; + + igt_info("Testing resolution with connector %s using pipe%s with seed %d\n",
(quoted diff) +1
-0+ igt_output_name(data->output),
kmstest_pipe_name(data->pipe), opt.seed);tests/kms_concurrent.c new file +8
-0+ + mode_hi =igt_output_get_mode (data->output); + mode_lo =get_lowres_mode (data, mode_hi); + + i =0 ; +while (i < iterations || loop_forever) { +/* switch to lower resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,
mode_lo);tests/kms_concurrent.c new file +4
-0+igt_assert_eq (ret,0 ); + +/* switch back to higher resolution */ + ret = drmModeSetCrtc(data->drm_fd, data->crtc_id,
data->fb->fb_id, 0, 0,(quoted diff) +1
-0+ &data->connector_id, 1,Quoted 8 lines
tests/kms_concurrent.c line 505
Quoted 6 lines
mode_hi);tests/kms_concurrent.c new file +5
-0+igt_assert_eq (ret,0 ); + + i++; + } +}Use
igt_output_override_mode+igt_displaycalls? With the thread being a fork now, you can useigt_display. :)For some reason I keep receiving an error when using
igt_output_override_mode+igt_displaycalls. The error isigt-kms-CRITICAL: Failed assertion:
drmModeDestroyPropertyBlob(display-Quoted 8 lines
Quoted 6 lines
Quoted 1 line
drm_fd, *blob) == 0igt-kms-CRITICAL: Last errno: 1, Operation not permitted
Maybe both threads try to access this and this request is not granted? With
drmModeSetCrtc()call I don't see this behavior. Maybe stick with raw calls instead?data->display.pipes[pipe].mode_blob = 0; in one of the forks of the test should fix it.
Quoted 7 lines
This seems to fix the issue. I'll throw a revised patch of the test shortly.
Quoted 4 lines
-EPERMmeans that the blob was already destroyed by this fd, but still used globally.
kms_rmfbdoes similar, maybe we should ignore failures?Maybe we could ignore these failures. Any harm done elsewhere if we do so?
I'm hesitant to ignore them, for the same reason as calling free() twice is a bad idea, we may end up freeing a different unknown blob.
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx