<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 4, 2014 at 2:04 AM, Daniel Vetter <span dir="ltr"><<a href="mailto:daniel@ffwll.ch" target="_blank">daniel@ffwll.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Wed, Sep 03, 2014 at 09:30:03PM -0400, Rodrigo Vivi wrote:<br>
> In order to get all test cases fixed and the matrix planes-operations working<br>
> it was needed to use the common new igt kms functions for all cases.<br>
> Previously only sprite testcase was using it.<br>
><br>
> Fixed the fb colors in a way to make tests more clear and be impossible to see<br>
> black screen during the tests.<br>
><br>
> Signed-off-by: Rodrigo Vivi <<a href="mailto:rodrigo.vivi@intel.com">rodrigo.vivi@intel.com</a>><br>
<br>
</div>Ok, everything changed ;-) So a bit hard to review just as a patch and so<br>
just a few comments on top:<br></blockquote><div><br></div><div>I'm sorry about that.... I got surprised I could split all in 9 patches, but I know this one staid ugly.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- Looks good overall, but the gold standard is whether it'll catch bugs.<br>
So if you remove some of the frontbuffer tracking (as little as possible<br>
in each test) and the new testcase catches it all, then I think we're<br>
good.<br></blockquote><div><br></div><div>It is already catching something, what is good! :)</div><div>and not broken anymore!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- I think we should have a residency check before we grab a new crc, to<br>
make sure that we're really again (or if the kernel is buggy, still) in<br>
psr mode.<br></blockquote><div><br></div><div>yeah, but residency check is bad for vlv/chv.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- Checking for mismatching crc is risky, see the comment in a different<br>
reply in this thread.<br>
<br>
But overall looks good so probably best to just push these patches and<br>
then fixup anything missing afterwards. I'll read through the entire test<br>
again once it all landed to double-check we haven't missed anything really<br>
important.<br></blockquote><div><br></div><div>cool. Thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Aside: A suspend/resume testcase might be useful, if it can reliably<br>
reproduce the issue you're working on. But again, follow-up.<br></blockquote><div><br></div><div>For sure. I just saw we have igt_system_suspend_autoresume. I'll definetely add another test using it.</div><div><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-Daniel<br>
<div class="HOEnZb"><div class="h5"><br>
> ---<br>
> tests/kms_psr_sink_crc.c | 269 ++++++++++++++++++-----------------------------<br>
> 1 file changed, 101 insertions(+), 168 deletions(-)<br>
><br>
> diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c<br>
> index 4358889..27f3df9 100644<br>
> --- a/tests/kms_psr_sink_crc.c<br>
> +++ b/tests/kms_psr_sink_crc.c<br>
> @@ -27,8 +27,6 @@<br>
> #include <stdio.h><br>
> #include <string.h><br>
><br>
> -#include "drm_fourcc.h"<br>
> -<br>
> #include "ioctl_wrappers.h"<br>
> #include "drmtest.h"<br>
> #include "intel_bufmgr.h"<br>
> @@ -79,88 +77,37 @@ typedef struct {<br>
> int drm_fd;<br>
> enum planes test_plane;<br>
> enum operations op;<br>
> - drmModeRes *resources;<br>
> - drm_intel_bufmgr *bufmgr;<br>
> uint32_t devid;<br>
> - uint32_t handle[2];<br>
> uint32_t crtc_id;<br>
> - uint32_t crtc_idx;<br>
> - uint32_t fb_id[3];<br>
> - struct kmstest_connector_config config;<br>
> igt_display_t display;<br>
> - struct igt_fb fb[2];<br>
> - igt_plane_t *plane[2];<br>
> + drm_intel_bufmgr *bufmgr;<br>
> + struct igt_fb fb_green, fb_white;<br>
> + igt_plane_t *primary, *sprite, *cursor;<br>
> } data_t;<br>
><br>
> -static uint32_t create_fb(data_t *data,<br>
> - int w, int h,<br>
> - double r, double g, double b,<br>
> - struct igt_fb *fb)<br>
> +static void create_cursor_fb(data_t *data)<br>
> {<br>
> - uint32_t fb_id;<br>
> cairo_t *cr;<br>
> + uint32_t fb_id;<br>
><br>
> - fb_id = igt_create_fb(data->drm_fd, w, h,<br>
> - DRM_FORMAT_XRGB8888, I915_TILING_X, fb);<br>
> + fb_id = igt_create_fb(data->drm_fd, 64, 64,<br>
> + DRM_FORMAT_ARGB8888, I915_TILING_NONE,<br>
> + &data->fb_white);<br>
> igt_assert(fb_id);<br>
><br>
> - cr = igt_get_cairo_ctx(data->drm_fd, fb);<br>
> - igt_paint_color(cr, 0, 0, w, h, r, g, b);<br>
> - igt_assert(cairo_status(cr) == 0);<br>
> - cairo_destroy(cr);<br>
> -<br>
> - return fb_id;<br>
> -}<br>
> -<br>
> -static void create_cursor_fb(data_t *data, struct igt_fb *fb)<br>
> -{<br>
> - cairo_t *cr;<br>
> -<br>
> - data->fb_id[2] = igt_create_fb(data->drm_fd, 64, 64,<br>
> - DRM_FORMAT_ARGB8888, I915_TILING_NONE,<br>
> - fb);<br>
> - igt_assert(data->fb_id[2]);<br>
> -<br>
> - cr = igt_get_cairo_ctx(data->drm_fd, fb);<br>
> + cr = igt_get_cairo_ctx(data->drm_fd, &data->fb_white);<br>
> igt_paint_color_alpha(cr, 0, 0, 64, 64, 1.0, 1.0, 1.0, 1.0);<br>
> igt_assert(cairo_status(cr) == 0);<br>
> }<br>
><br>
> -static bool<br>
> -connector_set_mode(data_t *data, drmModeModeInfo *mode, uint32_t fb_id)<br>
> -{<br>
> - struct kmstest_connector_config *config = &data->config;<br>
> - int ret;<br>
> -<br>
> -#if 0<br>
> - fprintf(stdout, "Using pipe %s, %dx%d\n", kmstest_pipe_name(config->pipe),<br>
> - mode->hdisplay, mode->vdisplay);<br>
> -#endif<br>
> -<br>
> - ret = drmModeSetCrtc(data->drm_fd,<br>
> - config->crtc->crtc_id,<br>
> - fb_id,<br>
> - 0, 0, /* x, y */<br>
> - &config->connector->connector_id,<br>
> - 1,<br>
> - mode);<br>
> - igt_assert(ret == 0);<br>
> -<br>
> - return 0;<br>
> -}<br>
> -<br>
> static void display_init(data_t *data)<br>
> {<br>
> igt_display_init(&data->display, data->drm_fd);<br>
> - data->resources = drmModeGetResources(data->drm_fd);<br>
> - igt_assert(data->resources);<br>
> }<br>
><br>
> static void display_fini(data_t *data)<br>
> {<br>
> igt_display_fini(&data->display);<br>
> - drmModeSetCursor(data->drm_fd, data->crtc_id, 0, 0, 0);<br>
> - drmModeFreeResources(data->resources);<br>
> }<br>
><br>
> static void fill_blt(data_t *data, uint32_t handle, unsigned char color)<br>
> @@ -316,112 +263,105 @@ static void get_sink_crc(data_t *data, char *crc) {<br>
><br>
> static void test_crc(data_t *data)<br>
> {<br>
> - uint32_t handle = data->handle[0];<br>
> + uint32_t handle = data->fb_white.gem_handle;<br>
> + igt_plane_t *test_plane;<br>
> + void *ptr;<br>
> char ref_crc[12];<br>
> char crc[12];<br>
><br>
> - if (data->op == PLANE_MOVE) {<br>
> - igt_assert(drmModeSetCursor(data->drm_fd, data->crtc_id,<br>
> - handle, 64, 64) == 0);<br>
> - igt_assert(drmModeMoveCursor(data->drm_fd, data->crtc_id,<br>
> - 1, 1) == 0);<br>
> + igt_plane_set_fb(data->primary, &data->fb_green);<br>
> + igt_display_commit(&data->display);<br>
> +<br>
> + /* Setting a secondary fb/plane */<br>
> + switch (data->test_plane) {<br>
> + case PRIMARY: default: test_plane = data->primary; break;<br>
> + case SPRITE: test_plane = data->sprite; break;<br>
> + case CURSOR: test_plane = data->cursor; break;<br>
> }<br>
> + igt_plane_set_fb(test_plane, &data->fb_white);<br>
> + igt_display_commit(&data->display);<br>
><br>
> igt_assert(wait_psr_entry(data, 10));<br>
> get_sink_crc(data, ref_crc);<br>
><br>
> switch (data->op) {<br>
> - void *ptr;<br>
> case PAGE_FLIP:<br>
> + /* Only in use when testing primary plane */<br>
> igt_assert(drmModePageFlip(data->drm_fd, data->crtc_id,<br>
> - data->fb_id[1], 0, NULL) == 0);<br>
> + data->fb_green.fb_id, 0, NULL) == 0);<br>
> break;<br>
> - case MMAP_CPU:<br>
> - ptr = gem_mmap__cpu(data->drm_fd, handle, 4096, PROT_WRITE);<br>
> + case MMAP_GTT:<br>
> + ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);<br>
> gem_set_domain(data->drm_fd, handle,<br>
> - I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);<br>
> - sleep(1);<br>
> + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);<br>
> memset(ptr, 0, 4);<br>
> munmap(ptr, 4096);<br>
> - sleep(1);<br>
> - gem_sw_finish(data->drm_fd, handle);<br>
> break;<br>
> - case MMAP_GTT:<br>
> case MMAP_GTT_WAITING:<br>
> ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE);<br>
> gem_set_domain(data->drm_fd, handle,<br>
> I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);<br>
> +<br>
> + /* Printing white on white so the screen shouldn't change */<br>
> memset(ptr, 0xff, 4);<br>
> + get_sink_crc(data, crc);<br>
> + igt_assert(strcmp(ref_crc, crc) == 0);<br>
> +<br>
> + fprintf(stdout, "Waiting 10s...\n");<br>
> + sleep(10);<br>
> +<br>
> + /* Now lets print black to change the screen */<br>
> + memset(ptr, 0, 4);<br>
> munmap(ptr, 4096);<br>
> - gem_bo_busy(data->drm_fd, handle);<br>
> + break;<br>
> + case MMAP_CPU:<br>
> + ptr = gem_mmap__cpu(data->drm_fd, handle, 4096, PROT_WRITE);<br>
> + gem_set_domain(data->drm_fd, handle,<br>
> + I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);<br>
> + memset(ptr, 0, 4);<br>
> + munmap(ptr, 4096);<br>
> + gem_sw_finish(data->drm_fd, handle);<br>
> break;<br>
> case BLT:<br>
> - fill_blt(data, handle, 0xff);<br>
> + fill_blt(data, handle, 0);<br>
> break;<br>
> case RENDER:<br>
> - fill_render(data, handle, 0xff);<br>
> + fill_render(data, handle, 0);<br>
> break;<br>
> case PLANE_MOVE:<br>
> - igt_assert(drmModeMoveCursor(data->drm_fd, data->crtc_id, 1, 2) == 0);<br>
> + /* Only in use when testing Sprite and Cursor */<br>
> + igt_plane_set_position(test_plane, 1, 1);<br>
> + igt_display_commit(&data->display);<br>
> break;<br>
> case PLANE_ONOFF:<br>
> - igt_plane_set_fb(data->plane[0], &data->fb[0]);<br>
> - igt_display_commit(&data->display);<br>
> - igt_plane_set_fb(data->plane[1], &data->fb[1]);<br>
> + /* Only in use when testing Sprite and Cursor */<br>
> + igt_plane_set_fb(test_plane, NULL);<br>
> igt_display_commit(&data->display);<br>
> break;<br>
> }<br>
> -<br>
> - igt_wait_for_vblank(data->drm_fd, data->crtc_idx);<br>
> -<br>
> get_sink_crc(data, crc);<br>
> igt_assert(strcmp(ref_crc, crc) != 0);<br>
> }<br>
><br>
> -static bool prepare_crtc(data_t *data, uint32_t connector_id)<br>
> -{<br>
> - if (!kmstest_get_connector_config(data->drm_fd,<br>
> - connector_id,<br>
> - 1 << data->crtc_idx,<br>
> - &data->config))<br>
> - return false;<br>
> -<br>
> - data->fb_id[0] = create_fb(data,<br>
> - data->config.default_mode.hdisplay,<br>
> - data->config.default_mode.vdisplay,<br>
> - 0.0, 1.0, 0.0, &data->fb[0]);<br>
> - igt_assert(data->fb_id[0]);<br>
> -<br>
> - if (data->op == PLANE_MOVE)<br>
> - create_cursor_fb(data, &data->fb[0]);<br>
> -<br>
> - data->fb_id[1] = create_fb(data,<br>
> - data->config.default_mode.hdisplay,<br>
> - data->config.default_mode.vdisplay,<br>
> - 1.0, 0.0, 0.0, &data->fb[1]);<br>
> - igt_assert(data->fb_id[1]);<br>
> -<br>
> - data->handle[0] = data->fb[0].gem_handle;<br>
> - data->handle[1] = data->fb[1].gem_handle;<br>
> -<br>
> - /* scanout = fb[1] */<br>
> - connector_set_mode(data, &data->config.default_mode,<br>
> - data->fb_id[1]);<br>
> +static void test_cleanup(data_t *data) {<br>
> + igt_plane_set_fb(data->primary, NULL);<br>
> + if (data->test_plane == SPRITE)<br>
> + igt_plane_set_fb(data->sprite, NULL);<br>
> + if (data->test_plane == CURSOR)<br>
> + igt_plane_set_fb(data->cursor, NULL);<br>
><br>
> - /* scanout = fb[0] */<br>
> - connector_set_mode(data, &data->config.default_mode,<br>
> - data->fb_id[0]);<br>
> + igt_display_commit(&data->display);<br>
><br>
> - kmstest_free_connector_config(&data->config);<br>
> -<br>
> - return true;<br>
> + igt_remove_fb(data->drm_fd, &data->fb_green);<br>
> + igt_remove_fb(data->drm_fd, &data->fb_white);<br>
> }<br>
><br>
> -static void test_sprite(data_t *data)<br>
> +static void run_test(data_t *data)<br>
> {<br>
> igt_display_t *display = &data->display;<br>
> igt_output_t *output;<br>
> drmModeModeInfo *mode;<br>
> + uint32_t white_h, white_v;<br>
><br>
> for_each_connected_output(display, output) {<br>
> drmModeConnectorPtr c = output->config.connector;<br>
> @@ -431,6 +371,7 @@ static void test_sprite(data_t *data)<br>
> continue;<br>
><br>
> igt_output_set_pipe(output, PIPE_ANY);<br>
> + data->crtc_id = output->config.crtc->crtc_id;<br>
><br>
> mode = igt_output_get_mode(output);<br>
><br>
> @@ -438,51 +379,45 @@ static void test_sprite(data_t *data)<br>
> mode->hdisplay, mode->vdisplay,<br>
> DRM_FORMAT_XRGB8888, I915_TILING_X,<br>
> 0.0, 1.0, 0.0,<br>
> - &data->fb[0]);<br>
> -<br>
> - igt_create_color_fb(data->drm_fd,<br>
> - mode->hdisplay/2, mode->vdisplay/2,<br>
> - DRM_FORMAT_XRGB8888, I915_TILING_X,<br>
> - 1.0, 0.0, 0.0,<br>
> - &data->fb[1]);<br>
> + &data->fb_green);<br>
> +<br>
> + data->primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);<br>
> + igt_plane_set_fb(data->primary, NULL);<br>
> +<br>
> + white_h = mode->hdisplay;<br>
> + white_v = mode->vdisplay;<br>
> +<br>
> + switch (data->test_plane) {<br>
> + case SPRITE:<br>
> + data->sprite = igt_output_get_plane(output,<br>
> + IGT_PLANE_2);<br>
> + igt_plane_set_fb(data->sprite, NULL);<br>
> + /* To make it different for human eyes let's make<br>
> + * sprite visible in only one quarter of the primary<br>
> + */<br>
> + white_h = white_h/2;<br>
> + white_v = white_v/2;<br>
> + case PRIMARY:<br>
> + igt_create_color_fb(data->drm_fd,<br>
> + white_h, white_v,<br>
> + DRM_FORMAT_XRGB8888, I915_TILING_X,<br>
> + 1.0, 1.0, 1.0,<br>
> + &data->fb_white);<br>
> + break;<br>
> + case CURSOR:<br>
> + data->cursor = igt_output_get_plane(output,<br>
> + IGT_PLANE_CURSOR);<br>
> + igt_plane_set_fb(data->cursor, NULL);<br>
> + create_cursor_fb(data);<br>
> + igt_plane_set_position(data->cursor, 0, 0);<br>
> + break;<br>
> + }<br>
><br>
> - data->plane[0] = igt_output_get_plane(output, 0);<br>
> - data->plane[1] = igt_output_get_plane(output, 1);<br>
> + igt_display_commit(&data->display);<br>
><br>
> test_crc(data);<br>
> - }<br>
> -}<br>
> -<br>
> -static void run_test(data_t *data)<br>
> -{<br>
> - int i, n;<br>
> - drmModeConnectorPtr c;<br>
> - /* Baytrail supports per-pipe PSR configuration, however PSR on<br>
> - * PIPE_B isn't working properly. So let's keep it disabled for now.<br>
> - * crtcs = IS_VALLEYVIEW(data->devid)? 2 : 1; */<br>
> - int crtcs = 1;<br>
> -<br>
> - if (data->op == PLANE_ONOFF) {<br>
> - test_sprite(data);<br>
> - return;<br>
> - }<br>
><br>
> - for (i = 0; i < data->resources->count_connectors; i++) {<br>
> - uint32_t connector_id = data->resources->connectors[i];<br>
> - c = drmModeGetConnector(data->drm_fd, connector_id);<br>
> -<br>
> - if (c->connector_type != DRM_MODE_CONNECTOR_eDP ||<br>
> - c->connection != DRM_MODE_CONNECTED)<br>
> - continue;<br>
> - for (n = 0; n < crtcs; n++) {<br>
> - data->crtc_idx = n;<br>
> - data->crtc_id = data->resources->crtcs[n];<br>
> -<br>
> - if (!prepare_crtc(data, connector_id))<br>
> - continue;<br>
> -<br>
> - test_crc(data);<br>
> - }<br>
> + test_cleanup(data);<br>
> }<br>
> }<br>
><br>
> @@ -496,7 +431,6 @@ igt_main<br>
> igt_fixture {<br>
> data.drm_fd = drm_open_any();<br>
> kmstest_set_vt_graphics_mode();<br>
> -<br>
> data.devid = intel_get_drm_devid(data.drm_fd);<br>
><br>
> igt_skip_on(!psr_enabled(&data));<br>
> @@ -508,7 +442,6 @@ igt_main<br>
> display_init(&data);<br>
> }<br>
><br>
> -<br>
> for (op = PAGE_FLIP; op <= RENDER; op++) {<br>
> igt_subtest_f("primary_%s", op_str(op)) {<br>
> data.test_plane = PRIMARY;<br>
> @@ -517,7 +450,7 @@ igt_main<br>
> }<br>
> }<br>
><br>
> - for (op = PLANE_ONOFF; op <= PLANE_ONOFF; op++) {<br>
> + for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) {<br>
> igt_subtest_f("sprite_%s", op_str(op)) {<br>
> data.test_plane = SPRITE;<br>
> data.op = op;<br>
> @@ -525,7 +458,7 @@ igt_main<br>
> }<br>
> }<br>
><br>
> - for (op = PLANE_MOVE; op <= PLANE_MOVE; op++) {<br>
> + for (op = MMAP_GTT; op <= PLANE_ONOFF; op++) {<br>
> igt_subtest_f("cursor_%s", op_str(op)) {<br>
> data.test_plane = CURSOR;<br>
> data.op = op;<br>
> --<br>
> 1.9.3<br>
><br>
> _______________________________________________<br>
> Intel-gfx mailing list<br>
> <a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Daniel Vetter<br>
Software Engineer, Intel Corporation<br>
<a href="tel:%2B41%20%280%29%2079%20365%2057%2048" value="+41793655748">+41 (0) 79 365 57 48</a> - <a href="http://blog.ffwll.ch" target="_blank">http://blog.ffwll.ch</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Intel-gfx mailing list<br>
<a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Rodrigo Vivi</div><div>Blog: <a href="http://blog.vivi.eng.br" target="_blank">http://blog.vivi.eng.br</a></div><div> </div>
</div></div>