kms_writeback: Add writeback-check-output
PATCH v7 4/4 kms_writeback: Add writeback-check-output
Add a test which makes commits using the writeback connector, and checks the output buffer hash to make sure it is/isn't written as appropriate.
V6: Simon Ser
- Add igt documentation with igt_describe
- Replace int ret by unsigned int fd_id when calling igt_create_fb
- Add a descriptive error message if sync_fence_wait fail
- Replace color_idx variable by i
- Use in_fb instead of out_fb for getting the expected CRC
- Drop unnecessary parentheses
- Replace igt_fb_mod_to_tiling to DRM_FORMAT_MOD_LINEAR
--- tests/kms_writeback.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+)
tests/kms_writeback.c +123 -0
@@ -30,6 +30,7 @@#include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" IGT_TEST_DESCRIPTION ("Exercise writeback feature." );
@@ -196,6 +197,115 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_tigt_assert (ret == -EINVAL ); } +static void fill_fb (igt_fb_t *fb,double color[3 ]) +{ +cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); +igt_assert (cr); + +igt_paint_color (cr,0 ,0 , fb->width, fb->height, + color[0 ], color[1 ], color[2 ]); +} + +static void get_and_wait_out_fence (igt_output_t *output) +{ +int ret; + +igt_assert (output->writeback_out_fence_fd >=0 ); + + ret =sync_fence_wait (output->writeback_out_fence_fd,1000 ); +igt_assert_f (ret ==0 ,"sync_fence_wait failed: %s\n" ,strerror (-ret)); +close (output->writeback_out_fence_fd); + output->writeback_out_fence_fd =-1 ; +} + +static void writeback_sequence (igt_output_t *output,igt_plane_t *plane, +igt_fb_t *in_fb,igt_fb_t *out_fbs[],int n_commits) +{ +int i; +double in_fb_colors[2 ][3 ] = { + {1.0 ,0.0 ,0.0 }, + {0.0 ,1.0 ,0.0 }, + }; +double clear_color[3 ] = {1.0 ,1.0 ,1.0 }; +igt_crc_t cleared_crc, out_expected; + +for (i =0 ; i < n_commits; i++) { +/* Change the input color each time */ +fill_fb (in_fb, in_fb_colors[i %2 ]); + +if (out_fbs[i]) { +igt_crc_t out_before; + +/* Get the expected CRC */ +igt_fb_get_crc (in_fb, &out_expected); + +fill_fb (out_fbs[i], clear_color); +if (i ==0 ) +igt_fb_get_crc (out_fbs[i], &cleared_crc); +igt_fb_get_crc (out_fbs[i], &out_before); +igt_assert_crc_equal (&cleared_crc, &out_before); + } + +/* Commit */ +igt_plane_set_fb (plane, in_fb); +igt_output_set_writeback_fb (output, out_fbs[i]); + +igt_display_commit_atomic (output->display, +DRM_MODE_ATOMIC_ALLOW_MODESET , +NULL ); +if (out_fbs[i]) +get_and_wait_out_fence (output); + +/* Make sure the old output buffer is untouched */ +if (i >0 && out_fbs[i -1 ] && out_fbs[i] != out_fbs[i -1 ]) { +igt_crc_t out_prev; +igt_fb_get_crc (out_fbs[i -1 ], &out_prev); +igt_assert_crc_equal (&cleared_crc, &out_prev); + } + +/* Make sure this output buffer is written */ +if (out_fbs[i]) { +igt_crc_t out_after; +igt_fb_get_crc (out_fbs[i], &out_after); +igt_assert_crc_equal (&out_expected, &out_after); + +/* And clear it, for the next time */ +fill_fb (out_fbs[i], clear_color); + } + } +} + +static void writeback_check_output (igt_output_t *output,igt_plane_t *plane, +igt_fb_t *input_fb,igt_fb_t *output_fb) +{ +igt_fb_t *out_fbs[2 ] = {0 }; +igt_fb_t second_out_fb; +unsigned int fb_id; + +/* One commit, with a writeback. */ +writeback_sequence (output, plane, input_fb, &output_fb,1 ); + +/* Two commits, the second with no writeback */ + out_fbs[0 ] = output_fb; +writeback_sequence (output, plane, input_fb, out_fbs,2 ); + +/* Two commits, both with writeback */ + out_fbs[1 ] = output_fb; +writeback_sequence (output, plane, input_fb, out_fbs,2 ); + + fb_id =igt_create_fb (output_fb->fd, + output_fb->width, output_fb->height, +DRM_FORMAT_XRGB8888 , +DRM_FORMAT_MOD_LINEAR , &second_out_fb); +igt_require (fb_id >0 ); + +/* Two commits, with different writeback buffers */ + out_fbs[1 ] = &second_out_fb; +writeback_sequence (output, plane, input_fb, out_fbs,2 ); + +igt_remove_fb (output_fb->fd, &second_out_fb); +} + igt_main {igt_display_t display;
@@ -283,6 +393,19 @@ igt_mainigt_remove_fb (display.drm_fd, &invalid_fb); } +igt_describe ("Check writeback output with CRC validation" ); + igt_subtest("writeback-check-output") { +igt_fb_t output_fb; + fb_id =igt_create_fb (display.drm_fd, mode.hdisplay, + mode.vdisplay,DRM_FORMAT_XRGB8888 , +DRM_FORMAT_MOD_LINEAR , &output_fb); +igt_require (fb_id >0 ); + +writeback_check_output (output, plane, &input_fb, &output_fb); + +igt_remove_fb (display.drm_fd, &output_fb); + } + igt_fixture {igt_remove_fb (display.drm_fd, &input_fb);igt_display_fini (&display);
Signature · 1 line
2.23.0
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Hi!
Quoted 35 lines · Brian Starkey
Add a test which makes commits using the writeback connector, and checks the output buffer hash to make sure it is/isn't written as appropriate.
V6: Simon Ser
- Add igt documentation withigt_describe
- Replace int ret by unsigned intfd_idwhen callingigt_create_fb
- Add a descriptive error message ifsync_fence_waitfail
- Replacecolor_idxvariable by i
- Usein_fbinstead ofout_fbfor getting the expected CRC
- Drop unnecessary parentheses
- Replaceigt_fb_mod_to_tilingtoDRM_FORMAT_MOD_LINEARSigned-off-by Brian Starkey <[email protected]>[rebased and updated the patch to address feedback]Signed-off-by Rodrigo Siqueira <[email protected]>--- tests/kms_writeback.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+)tests/kms_writeback.c +1
-0@@ -30,6 +30,7 @@#include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" IGT_TEST_DESCRIPTION ("Exercise writeback feature." );@@ -196,6 +197,115 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_tigt_assert (ret == -EINVAL ); }
tests/kms_writeback.c static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t · line 208
Quoted 10 lines
tests/kms_writeback.c +9
-0+static void fill_fb (igt_fb_t *fb,double color[3 ]) +{ +cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); +igt_assert (cr); + +igt_paint_color (cr,0 ,0 , fb->width, fb->height, + color[0 ], color[1 ], color[2 ]); +} +
On which platform did you test this? On Arm (but I would assume anything !i915), this will fire up an assert.
I've replaced this with a igt_fb_map_buffer/memset, and it works as expected.
Maxime
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 52 lines · Maxime Ripard
Hi!
Quoted 35 lines · Brian Starkey
Add a test which makes commits using the writeback connector, and checks the output buffer hash to make sure it is/isn't written as appropriate.
V6: Simon Ser
- Add igt documentation withigt_describe
- Replace int ret by unsigned intfd_idwhen callingigt_create_fb
- Add a descriptive error message ifsync_fence_waitfail
- Replacecolor_idxvariable by i
- Usein_fbinstead ofout_fbfor getting the expected CRC
- Drop unnecessary parentheses
- Replaceigt_fb_mod_to_tilingtoDRM_FORMAT_MOD_LINEARSigned-off-by Brian Starkey <[email protected]>[rebased and updated the patch to address feedback]Signed-off-by Rodrigo Siqueira <[email protected]>--- tests/kms_writeback.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+)tests/kms_writeback.c +1
-0@@ -30,6 +30,7 @@#include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" IGT_TEST_DESCRIPTION ("Exercise writeback feature." );@@ -196,6 +197,115 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_tigt_assert (ret == -EINVAL ); }tests/kms_writeback.c static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t · line 208
Quoted 10 lines
tests/kms_writeback.c +9
-0+static void fill_fb (igt_fb_t *fb,double color[3 ]) +{ +cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); +igt_assert (cr); + +igt_paint_color (cr,0 ,0 , fb->width, fb->height, + color[0 ], color[1 ], color[2 ]); +} +On which platform did you test this? On Arm (but I would assume anything !i915), this will fire up an assert.
Quoted 2 lines
I've replaced this with a igt_fb_map_buffer/memset, and it works as expected.
Hi,
Could you share your fix for this issue? Since you already have a solution that you know that works on ARM, I can just use it for avoiding an unnecessary round of review in the next version.
Thanks
Quoted 1 line
Maxime
Signature · 2 lines
Rodrigo Siqueira https://siqueira.tech
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Hi!
Quoted 51 lines · Rodrigo Siqueira
Quoted 50 lines · Maxime Ripard
Quoted 35 lines · Brian Starkey
Add a test which makes commits using the writeback connector, and checks the output buffer hash to make sure it is/isn't written as appropriate.
V6: Simon Ser
- Add igt documentation withigt_describe
- Replace int ret by unsigned intfd_idwhen callingigt_create_fb
- Add a descriptive error message ifsync_fence_waitfail
- Replacecolor_idxvariable by i
- Usein_fbinstead ofout_fbfor getting the expected CRC
- Drop unnecessary parentheses
- Replaceigt_fb_mod_to_tilingtoDRM_FORMAT_MOD_LINEARSigned-off-by Brian Starkey <[email protected]>[rebased and updated the patch to address feedback]Signed-off-by Rodrigo Siqueira <[email protected]>--- tests/kms_writeback.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+)tests/kms_writeback.c +1
-0@@ -30,6 +30,7 @@#include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" IGT_TEST_DESCRIPTION ("Exercise writeback feature." );@@ -196,6 +197,115 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_tigt_assert (ret == -EINVAL ); }tests/kms_writeback.c static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t · line 208
Quoted 10 lines
tests/kms_writeback.c +9
-0+static void fill_fb (igt_fb_t *fb,double color[3 ]) +{ +cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); +igt_assert (cr); + +igt_paint_color (cr,0 ,0 , fb->width, fb->height, + color[0 ], color[1 ], color[2 ]); +} +On which platform did you test this? On Arm (but I would assume anything !i915), this will fire up an assert.
Quoted 6 lines
Quoted 2 lines
I've replaced this with a igt_fb_map_buffer/memset, and it works as expected.
Could you share your fix for this issue? Since you already have a solution that you know that works on ARM, I can just use it for avoiding an unnecessary round of review in the next version.
Sure, you'll find it attached
Maxime
lib/igt_fb.c +4 -7
@@ -3812,12 +3812,9 @@ int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc)if (fb->num_planes !=1 )return -EINVAL ; -if (fb->is_dumb) - ptr =kmstest_dumb_map_buffer (fb->fd, fb->gem_handle, fb->size, -PROT_READ ); -else - ptr =gem_mmap__gtt (fb->fd, fb->gem_handle, fb->size, -PROT_READ ); + ptr =igt_fb_map_buffer (fb->fd, fb); +igt_assert (ptr); + map = ptr;/* * Framebuffers are often uncached, which can make byte-wise accesses
@@ -3846,7 +3843,7 @@ int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc) crc->crc[0 ] = hash;free (line); -munmap (map, fb->size); +igt_fb_unmap_buffer (fb, map);return 0 ;#undef FNV1a_OFFSET_BIAS
tests/kms_writeback.c +13 -11
@@ -149,7 +149,7 @@ static int do_writeback_test(igt_output_t *output, uint32_t fb_id,igt_output_set_prop_value (output,IGT_CONNECTOR_CRTC_ID , config->crtc->crtc_id);igt_output_set_prop_value (output,IGT_CONNECTOR_WRITEBACK_FB_ID , fb_id); -igt_output_set_prop_value (output,IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR , (uint64_t )out_fence_ptr); +igt_output_set_prop_value (output,IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR , (uint64_t )(uintptr_t )out_fence_ptr);if (ptr_valid) *out_fence_ptr =0 ;
@@ -197,13 +197,18 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_tigt_assert (ret == -EINVAL ); } -static void fill_fb (igt_fb_t *fb,double color[3 ]) +static void fill_fb (igt_fb_t *fb,uint32_t pixel) { -cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); -igt_assert (cr); +void *ptr; -igt_paint_color (cr,0 ,0 , fb->width, fb->height, - color[0 ], color[1 ], color[2 ]); +igt_assert (fb->drm_format ==DRM_FORMAT_XRGB8888 ); + + ptr =igt_fb_map_buffer (fb->fd, fb); +igt_assert (ptr); + +memset (ptr, pixel, fb->strides[0 ] * fb->height); + +igt_fb_unmap_buffer (fb, ptr); }static void get_and_wait_out_fence (igt_output_t *output)
@@ -222,11 +227,8 @@ static void writeback_sequence(igt_output_t *output, igt_plane_t *plane, igt_fb_t *in_fb, igt_fb_t *out_fbs[], int n_commits) {int i; -double in_fb_colors[2 ][3 ] = { - {1.0 ,0.0 ,0.0 }, - {0.0 ,1.0 ,0.0 }, - }; -double clear_color[3 ] = {1.0 ,1.0 ,1.0 }; +uint32_t in_fb_colors[2 ] = {0xffff0000 ,0xff00ff00 }; +uint32_t clear_color =0xffffffff ;igt_crc_t cleared_crc, out_expected;for (i =0 ; i < n_commits; i++) {
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 54 lines · Maxime Ripard
Hi!
Quoted 51 lines · Rodrigo Siqueira
Quoted 50 lines · Maxime Ripard
Quoted 35 lines · Brian Starkey
Add a test which makes commits using the writeback connector, and checks the output buffer hash to make sure it is/isn't written as appropriate.
V6: Simon Ser
- Add igt documentation withigt_describe
- Replace int ret by unsigned intfd_idwhen callingigt_create_fb
- Add a descriptive error message ifsync_fence_waitfail
- Replacecolor_idxvariable by i
- Usein_fbinstead ofout_fbfor getting the expected CRC
- Drop unnecessary parentheses
- Replaceigt_fb_mod_to_tilingtoDRM_FORMAT_MOD_LINEARSigned-off-by Brian Starkey <[email protected]>[rebased and updated the patch to address feedback]Signed-off-by Rodrigo Siqueira <[email protected]>--- tests/kms_writeback.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+)tests/kms_writeback.c +1
-0@@ -30,6 +30,7 @@#include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" IGT_TEST_DESCRIPTION ("Exercise writeback feature." );@@ -196,6 +197,115 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_tigt_assert (ret == -EINVAL ); }tests/kms_writeback.c static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t · line 208
Quoted 10 lines
tests/kms_writeback.c +9
-0+static void fill_fb (igt_fb_t *fb,double color[3 ]) +{ +cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); +igt_assert (cr); + +igt_paint_color (cr,0 ,0 , fb->width, fb->height, + color[0 ], color[1 ], color[2 ]); +} +On which platform did you test this? On Arm (but I would assume anything !i915), this will fire up an assert.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I've replaced this with a igt_fb_map_buffer/memset, and it works as expected.
Could you share your fix for this issue? Since you already have a solution that you know that works on ARM, I can just use it for avoiding an unnecessary round of review in the next version.
Sure, you'll find it attached
Thanks!
I'm going to submit a new version today.
Best Regards
Quoted 82 lines
Maxime
lib/igt_fb.c +4
-7@@ -3812,12 +3812,9 @@ int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc)if (fb->num_planes !=1 )return -EINVAL ; -if (fb->is_dumb) - ptr =kmstest_dumb_map_buffer (fb->fd, fb->gem_handle, fb->size, -PROT_READ ); -else - ptr =gem_mmap__gtt (fb->fd, fb->gem_handle, fb->size, -PROT_READ ); + ptr =igt_fb_map_buffer (fb->fd, fb); +igt_assert (ptr); + map = ptr;/* * Framebuffers are often uncached, which can make byte-wise accesses @@ -3846,7 +3843,7 @@ int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc) crc->crc[0 ] = hash;free (line); -munmap (map, fb->size); +igt_fb_unmap_buffer (fb, map);return 0 ;#undef FNV1a_OFFSET_BIAStests/kms_writeback.c +13
-11@@ -149,7 +149,7 @@ static int do_writeback_test(igt_output_t *output, uint32_t fb_id,igt_output_set_prop_value (output,IGT_CONNECTOR_CRTC_ID , config->crtc->crtc_id);igt_output_set_prop_value (output,IGT_CONNECTOR_WRITEBACK_FB_ID , fb_id); -igt_output_set_prop_value (output,IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR , (uint64_t )out_fence_ptr); +igt_output_set_prop_value (output,IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR , (uint64_t )(uintptr_t )out_fence_ptr);if (ptr_valid) *out_fence_ptr =0 ;@@ -197,13 +197,18 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_tigt_assert (ret == -EINVAL ); } -static void fill_fb (igt_fb_t *fb,double color[3 ]) +static void fill_fb (igt_fb_t *fb,uint32_t pixel) { -cairo_t *cr =igt_get_cairo_ctx (fb->fd, fb); -igt_assert (cr); +void *ptr; -igt_paint_color (cr,0 ,0 , fb->width, fb->height, - color[0 ], color[1 ], color[2 ]); +igt_assert (fb->drm_format ==DRM_FORMAT_XRGB8888 ); + + ptr =igt_fb_map_buffer (fb->fd, fb); +igt_assert (ptr); + +memset (ptr, pixel, fb->strides[0 ] * fb->height); + +igt_fb_unmap_buffer (fb, ptr); }static void get_and_wait_out_fence (igt_output_t *output)@@ -222,11 +227,8 @@ static void writeback_sequence(igt_output_t *output, igt_plane_t *plane, igt_fb_t *in_fb, igt_fb_t *out_fbs[], int n_commits) {int i; -double in_fb_colors[2 ][3 ] = { - {1.0 ,0.0 ,0.0 }, - {0.0 ,1.0 ,0.0 }, - }; -double clear_color[3 ] = {1.0 ,1.0 ,1.0 }; +uint32_t in_fb_colors[2 ] = {0xffff0000 ,0xff00ff00 }; +uint32_t clear_color =0xffffffff ;igt_crc_t cleared_crc, out_expected;for (i =0 ; i < n_commits; i++) {
Signature · 2 lines
Rodrigo Siqueira https://siqueira.tech
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev