Re: [Intel-gfx] [PATCH v3] drm/dp: Add Additional DP2 Headers
Applied to drm-misc-next. Thanks On 09/28, Harry Wentland wrote: > On 2021-09-27 15:23, Fangzhi Zuo wrote: > > Include FEC, DSC, Link Training related headers. > > > > Change since v2 > > - Align with the spec for DP_DSC_SUPPORT_AND_DSC_DECODER_COUNT > > > > Signed-off-by: Fangzhi Zuo > > Reviewed-by: Harry Wentland > > Harry > > > --- > > This patch is based on top of the other DP2.0 work in > > "drm/dp: add LTTPR DP 2.0 DPCD addresses" > > --- > > include/drm/drm_dp_helper.h | 20 > > 1 file changed, 20 insertions(+) > > > > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h > > index 1d5b3dbb6e56..a1df35aa6e68 100644 > > --- a/include/drm/drm_dp_helper.h > > +++ b/include/drm/drm_dp_helper.h > > @@ -453,6 +453,7 @@ struct drm_panel; > > # define DP_FEC_UNCORR_BLK_ERROR_COUNT_CAP (1 << 1) > > # define DP_FEC_CORR_BLK_ERROR_COUNT_CAP(1 << 2) > > # define DP_FEC_BIT_ERROR_COUNT_CAP(1 << 3) > > +#define DP_FEC_CAPABILITY_10x091 /* 2.0 */ > > > > /* DP-HDMI2.1 PCON DSC ENCODER SUPPORT */ > > #define DP_PCON_DSC_ENCODER_CAP_SIZE0xC/* 0x9E - 0x92 */ > > @@ -537,6 +538,9 @@ struct drm_panel; > > #define DP_DSC_BRANCH_OVERALL_THROUGHPUT_1 0x0a1 > > #define DP_DSC_BRANCH_MAX_LINE_WIDTH0x0a2 > > > > +/* DFP Capability Extension */ > > +#define DP_DFP_CAPABILITY_EXTENSION_SUPPORT0x0a3 /* 2.0 */ > > + > > /* Link Configuration */ > > #defineDP_LINK_BW_SET 0x100 > > # define DP_LINK_RATE_TABLE0x00/* eDP 1.4 */ > > @@ -688,6 +692,7 @@ struct drm_panel; > > > > #define DP_DSC_ENABLE 0x160 /* DP 1.4 */ > > # define DP_DECOMPRESSION_EN(1 << 0) > > +#define DP_DSC_CONFIGURATION 0x161 /* DP > > 2.0 */ > > > > #define DP_PSR_EN_CFG 0x170 /* XXX 1.2? */ > > # define DP_PSR_ENABLE BIT(0) > > @@ -743,6 +748,7 @@ struct drm_panel; > > # define DP_RECEIVE_PORT_0_STATUS (1 << 0) > > # define DP_RECEIVE_PORT_1_STATUS (1 << 1) > > # define DP_STREAM_REGENERATION_STATUS (1 << 2) /* 2.0 */ > > +# define DP_INTRA_HOP_AUX_REPLY_INDICATION (1 << 3) /* 2.0 */ > > > > #define DP_ADJUST_REQUEST_LANE0_1 0x206 > > #define DP_ADJUST_REQUEST_LANE2_3 0x207 > > @@ -865,6 +871,8 @@ struct drm_panel; > > # define DP_PHY_TEST_PATTERN_80BIT_CUSTOM 0x4 > > # define DP_PHY_TEST_PATTERN_CP2520 0x5 > > > > +#define DP_PHY_SQUARE_PATTERN 0x249 > > + > > #define DP_TEST_HBR2_SCRAMBLER_RESET0x24A > > #define DP_TEST_80BIT_CUSTOM_PATTERN_7_00x250 > > #defineDP_TEST_80BIT_CUSTOM_PATTERN_15_8 0x251 > > @@ -1109,6 +1117,18 @@ struct drm_panel; > > #define DP_128B132B_TRAINING_AUX_RD_INTERVAL 0x2216 /* 2.0 */ > > # define DP_128B132B_TRAINING_AUX_RD_INTERVAL_MASK 0x7f > > > > +#define DP_TEST_264BIT_CUSTOM_PATTERN_7_0 0x2230 > > +#define DP_TEST_264BIT_CUSTOM_PATTERN_263_256 0x2250 > > + > > +/* DSC Extended Capability Branch Total DSC Resources */ > > +#define DP_DSC_SUPPORT_AND_DSC_DECODER_COUNT 0x2260 /* 2.0 > > */ > > +# define DP_DSC_DECODER_COUNT_MASK (0b111 << 5) > > +# define DP_DSC_DECODER_COUNT_SHIFT5 > > +#define DP_DSC_MAX_SLICE_COUNT_AND_AGGREGATION_0 0x2270 /* 2.0 */ > > +# define DP_DSC_DECODER_0_MAXIMUM_SLICE_COUNT_MASK (1 << 0) > > +# define DP_DSC_DECODER_0_AGGREGATION_SUPPORT_MASK (0b111 << 1) > > +# define DP_DSC_DECODER_0_AGGREGATION_SUPPORT_SHIFT1 > > + > > /* Protocol Converter Extension */ > > /* HDMI CEC tunneling over AUX DP 1.3 section 5.3.3.3.1 DPCD 1.4+ */ > > #define DP_CEC_TUNNELING_CAPABILITY0x3000 > > > -- Rodrigo Siqueira https://siqueira.tech
[Intel-gfx] [PATCH i-g-t] Make force work with multiple drivers available
The force option allows users to specify which driver they want that IGT uses. Nonetheless, if the user has two or more loaded drivers in his system, the force option will not work as expected because IGT will take the first driver found at /dev/dri. This problem can be reproduced in a QEMU VM that using Bochs and VKMS. This patch handles this scenario by ensuring that IGT uses the forced module specified via IGT_FORCE_DRIVER. Signed-off-by: Rodrigo Siqueira --- lib/drmtest.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index 35914c50..7c124ac6 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -250,10 +250,8 @@ static int open_device(const char *name, unsigned int chipset) goto err; forced = forced_driver(); - if (forced && chipset == DRIVER_ANY && !strcmp(forced, dev_name)) { - igt_debug("Force option used: Using driver %s\n", dev_name); - return fd; - } + if (forced && chipset == DRIVER_ANY && strcmp(forced, dev_name)) + goto err; for (int start = 0, end = ARRAY_SIZE(modules) - 1; start < end; ){ int mid = start + (end - start) / 2; @@ -277,6 +275,12 @@ err: static int __search_and_open(const char *base, int offset, unsigned int chipset) { + const char *forced; + + forced = forced_driver(); + if (forced) + igt_info("Force option used: Using driver %s\n", forced); + for (int i = 0; i < 16; i++) { char name[80]; int fd; -- 2.20.1 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t] Make force work with multiple drivers available
On 01/14, Petri Latvala wrote: > On Fri, Jan 11, 2019 at 11:13:37AM -0200, Rodrigo Siqueira wrote: > > The force option allows users to specify which driver they want that IGT > > uses. Nonetheless, if the user has two or more loaded drivers in his > > system, the force option will not work as expected because IGT will take > > the first driver found at /dev/dri. This problem can be reproduced in a > > QEMU VM that using Bochs and VKMS. This patch handles this scenario by > > ensuring that IGT uses the forced module specified via IGT_FORCE_DRIVER. > > > > Signed-off-by: Rodrigo Siqueira > > --- > > lib/drmtest.c | 12 > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/lib/drmtest.c b/lib/drmtest.c > > index 35914c50..7c124ac6 100644 > > --- a/lib/drmtest.c > > +++ b/lib/drmtest.c > > @@ -250,10 +250,8 @@ static int open_device(const char *name, unsigned int > > chipset) > > goto err; > > > > forced = forced_driver(); > > - if (forced && chipset == DRIVER_ANY && !strcmp(forced, dev_name)) { > > - igt_debug("Force option used: Using driver %s\n", dev_name); > > - return fd; > > - } > > + if (forced && chipset == DRIVER_ANY && strcmp(forced, dev_name)) > > + goto err; > > > Yep, an obvious logic error by me. > > Reviewed-by: Petri Latvala > > and merging this momentarily. Thanks for the review and merging :) ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t] tests/kms_flip: Add test to check suspend/resume
Hi, On 01/18, Shayenne Moura wrote: > This patch adds one test to evaluate suspend/resume operations using kms_flip. > > Signed-off-by: Shayenne Moura > --- > tests/kms_flip.c | 1 + > 1 file changed, 1 insertion(+) > mode change 100644 => 100755 tests/kms_flip.c > > diff --git a/tests/kms_flip.c b/tests/kms_flip.c > old mode 100644 > new mode 100755 > index f28272dd..3ca2fdfc > --- a/tests/kms_flip.c > +++ b/tests/kms_flip.c > @@ -1567,6 +1567,7 @@ int main(int argc, char **argv) > { 10, TEST_DPMS_OFF | TEST_DPMS | TEST_VBLANK_RACE, > "dpms-vs-vblank-race" }, > { 10, TEST_MODESET | TEST_VBLANK_RACE, "modeset-vs-vblank-race" > }, > { 0, TEST_BO_TOOBIG | TEST_NO_2X_OUTPUT, "bo-too-big" }, > + { 30, TEST_FLIP | TEST_SUSPEND, "flip-vs-suspend" }, I remember to follow a conversation in the IRC that you said that VKMS pass this test. I tried it here on my VM, and after running the test my system got freeze. My VM uses Arch Linux with Kernel 5.0.0-rc1. Did I miss something? Also, I tested it on my host machine with i915 driver and I noticed that the test took much more than 30 seconds to finish. Is it right? Thanks Best Regards > }; > int i; > > -- > 2.17.1 > -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t v2] tests/kms_flip: Add test to check suspend/resume
On 01/22, Shayenne Moura wrote: > This patch adds one test to evaluate suspend/resume operations using kms_flip. > > Signed-off-by: Shayenne Moura > > v2: Reduce test time to 10 (Daniel) > --- > tests/kms_flip.c | 1 + > 1 file changed, 1 insertion(+) > mode change 100644 => 100755 tests/kms_flip.c > > diff --git a/tests/kms_flip.c b/tests/kms_flip.c > old mode 100644 > new mode 100755 > index f28272dd..3c29f47a > --- a/tests/kms_flip.c > +++ b/tests/kms_flip.c > @@ -1567,6 +1567,7 @@ int main(int argc, char **argv) > { 10, TEST_DPMS_OFF | TEST_DPMS | TEST_VBLANK_RACE, > "dpms-vs-vblank-race" }, > { 10, TEST_MODESET | TEST_VBLANK_RACE, "modeset-vs-vblank-race" > }, > { 0, TEST_BO_TOOBIG | TEST_NO_2X_OUTPUT, "bo-too-big" }, > + { 10, TEST_FLIP | TEST_SUSPEND, "flip-vs-suspend" }, > }; > int i; > > -- > 2.17.1 > Reviewed-by: Rodrigo Siqueira signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V3 i-g-t] Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). Changes since V2: - Add new branch coverage to check if VBlank is enabled or not - Update commit message Changes since V1: Chris Wilson: - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c| 11 +++ lib/igt_kms.h| 2 ++ tests/kms_flip.c | 27 +-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 1a91791c..d720762d 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1652,6 +1652,17 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility) igt_assert_eq(visible, visibility); } +int kms_vblank_status(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_ABSOLUTE; + + drmWaitVBlank(fd, &dummy_vbl); + return errno; +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 4a7c3c97..b6c4e228 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -228,6 +228,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility); +int kms_vblank_status(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 3c29f47a..4cdb23a6 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -73,6 +73,7 @@ #define TEST_TS_CONT (1 << 27) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -125,6 +126,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_TS_CONT | TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -493,11 +506,11 @@ static void check_state(const struct test_output *o, const struct event_state *e /* check only valid if no modeset happens in between, that increments by * (1 << 23) on each step. This bounding matches the one in * DRM_IOCTL_WAIT_VBLANK. */ - if (!(o->flags & (TEST_DPMS | TEST_MODESET))) + if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK))) { igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23, "unexpected %s seq %u, should be >= %u\n", es->name, es->current_seq, es->last_seq + o->seq_step); - + } /* Check that the vblank frame didn't wrap unexpectedly. */ if (o->flags & TEST_TS_CONT) { /* Ignore seq_step here since vblank waits time out immediately @@ -1204,6 +1217,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + int vblank_status = 0; switch (crtc_count) { case 1: @@ -1297,6 +1311,15 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank_status = kms_vblank_status(drm_fd); + if (vblank_status == EOPNOTSUPP) { + if (vblank_dependence(o->flags)) + igt_require_f(!(vblank_status == EOPNOTSUPP), + "Vblank: %s\n", strerror(vblank_status)); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]); -- 2.20.1 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V2 i-g-t] lib: Drop __kms_addfb() wrapper
The function __kms_addfb() and drmModeAddFB2WithModifiers() have a similar code. Due to this similarity, this commit replaces all the occurrences of __kms_addfb() by drmModeAddFB2WithModifiers() and adds the required adaptations. V1: Arkadiusz Hiler - Fix array initialization - Drop __kms_addfb() Signed-off-by: Rodrigo Siqueira --- lib/igt_fb.c| 14 +- lib/ioctl_wrappers.c| 33 - lib/ioctl_wrappers.h| 11 --- tests/kms_available_modes_crc.c | 14 +- tests/kms_draw_crc.c| 10 ++ tests/prime_vgem.c | 14 -- 6 files changed, 32 insertions(+), 64 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index d4929019..bac3b21c 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1235,6 +1235,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, uint64_t bo_size, unsigned bo_stride) { + uint32_t handles[4] = {}; + uint64_t modifiers[4] = {}; + /* FIXME allow the caller to pass these in */ enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709; enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE; @@ -1262,11 +1265,12 @@ igt_create_fb_with_bo_size(int fd, int width, int height, if (fb->modifier || igt_has_fb_modifiers(fd)) flags = LOCAL_DRM_MODE_FB_MODIFIERS; - do_or_die(__kms_addfb(fb->fd, fb->gem_handle, - fb->width, fb->height, - fb->drm_format, fb->modifier, - fb->strides, fb->offsets, fb->num_planes, flags, - &fb->fb_id)); + memset(handles, fb->gem_handle, fb->num_planes); + memset(modifiers, modifier, fb->num_planes); + do_or_die(drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height, +fb->drm_format, handles, +fb->strides, fb->offsets, +modifiers, &fb->fb_id, flags)); return fb->fb_id; } diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 280fdd62..0f00971d 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1453,36 +1453,3 @@ void igt_require_fb_modifiers(int fd) { igt_require(igt_has_fb_modifiers(fd)); } - -int __kms_addfb(int fd, uint32_t handle, - uint32_t width, uint32_t height, - uint32_t pixel_format, uint64_t modifier, - uint32_t strides[4], uint32_t offsets[4], - int num_planes, uint32_t flags, uint32_t *buf_id) -{ - struct drm_mode_fb_cmd2 f; - int ret, i; - - if (flags & DRM_MODE_FB_MODIFIERS) - igt_require_fb_modifiers(fd); - - memset(&f, 0, sizeof(f)); - - f.width = width; - f.height = height; - f.pixel_format = pixel_format; - f.flags = flags; - - for (i = 0; i < num_planes; i++) { - f.handles[i] = handle; - f.modifier[i] = modifier; - f.pitches[i] = strides[i]; - f.offsets[i] = offsets[i]; - } - - ret = igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f); - - *buf_id = f.fb_id; - - return ret < 0 ? -errno : ret; -} diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 03211c97..4afc3e09 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -209,17 +209,6 @@ struct local_drm_mode_fb_cmd2 { bool igt_has_fb_modifiers(int fd); void igt_require_fb_modifiers(int fd); -/** - * __kms_addfb: - * - * Creates a framebuffer object. - */ -int __kms_addfb(int fd, uint32_t handle, - uint32_t width, uint32_t height, - uint32_t pixel_format, uint64_t modifier, - uint32_t strides[4], uint32_t offsets[4], - int num_planes, uint32_t flags, uint32_t *buf_id); - /** * to_user_pointer: * diff --git a/tests/kms_available_modes_crc.c b/tests/kms_available_modes_crc.c index 50b5522a..9e5f1fd5 100644 --- a/tests/kms_available_modes_crc.c +++ b/tests/kms_available_modes_crc.c @@ -172,9 +172,10 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, { drmModeModeInfo *mode; uint64_t w, h; + uint32_t handles[4] = {}; + uint64_t modifiers[4] = {}; signed ret, gemsize = 0; unsigned tile_width, tile_height; - int num_planes = 1; uint64_t tiling; int bpp = 0; int i; @@ -225,10 +226,13 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, igt_assert_eq(ret, 0); - ret = __kms_addfb(data->gfx_fd, data->gem_handle, w, h, - format, tiling, dat
[Intel-gfx] [RESEND PATCH V7 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). V6: Set errno to zero before call drmWaitVBlank() (Chris Wilson) V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson) V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS V3: Add documentation (Daniel Vetter) V2: Add new branch coverage to check if VBlank is enabled or not and update commit message V1: Chris Wilson - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c| 21 + lib/igt_kms.h| 2 ++ tests/kms_flip.c | 22 ++ 3 files changed, 45 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index df9aafd2..ca3073a0 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1656,6 +1656,27 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi igt_assert_eq(visible, visibility); } +/** + * kms_has_vblank: + * @fd: DRM fd + * + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: true if target driver has VBlank support, otherwise return false. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; + + errno = 0; + drmWaitVBlank(fd, &dummy_vbl); + return (errno != EOPNOTSUPP); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 38bdc08f..b0ff79ab 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility); +bool kms_has_vblank(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 8c17c8da..4d1bf69b 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -71,6 +71,7 @@ #define TEST_SUSPEND (1 << 26) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + bool vblank = true; switch (crtc_count) { case RUN_TEST: @@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]); -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH V2 i-g-t] lib: Drop __kms_addfb() wrapper
Hi Simon, Thank you very much for your review. I'll fix the issue in the next version. On Mon, May 20, 2019 at 3:22 AM Ser, Simon wrote: > > Hi Rodrigo, > > On Sun, 2019-05-19 at 20:00 -0300, Rodrigo Siqueira wrote: > > The function __kms_addfb() and drmModeAddFB2WithModifiers() have a > > similar code. Due to this similarity, this commit replaces all the > > occurrences of __kms_addfb() by drmModeAddFB2WithModifiers() and adds > > the required adaptations. > > > > V1: Arkadiusz Hiler > > - Fix array initialization > > - Drop __kms_addfb() > > > > Signed-off-by: Rodrigo Siqueira > > --- > > lib/igt_fb.c| 14 +- > > lib/ioctl_wrappers.c| 33 - > > lib/ioctl_wrappers.h| 11 --- > > tests/kms_available_modes_crc.c | 14 +- > > tests/kms_draw_crc.c| 10 ++ > > tests/prime_vgem.c | 14 -- > > 6 files changed, 32 insertions(+), 64 deletions(-) > > > > diff --git a/lib/igt_fb.c b/lib/igt_fb.c > > index d4929019..bac3b21c 100644 > > --- a/lib/igt_fb.c > > +++ b/lib/igt_fb.c > > @@ -1235,6 +1235,9 @@ igt_create_fb_with_bo_size(int fd, int width, int > > height, > > struct igt_fb *fb, uint64_t bo_size, > > unsigned bo_stride) > > { > > + uint32_t handles[4] = {}; > > + uint64_t modifiers[4] = {}; > > + > > /* FIXME allow the caller to pass these in */ > > enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709; > > enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE; > > @@ -1262,11 +1265,12 @@ igt_create_fb_with_bo_size(int fd, int width, int > > height, > > if (fb->modifier || igt_has_fb_modifiers(fd)) > > flags = LOCAL_DRM_MODE_FB_MODIFIERS; > > > > - do_or_die(__kms_addfb(fb->fd, fb->gem_handle, > > - fb->width, fb->height, > > - fb->drm_format, fb->modifier, > > - fb->strides, fb->offsets, fb->num_planes, flags, > > - &fb->fb_id)); > > + memset(handles, fb->gem_handle, fb->num_planes); > > + memset(modifiers, modifier, fb->num_planes); > > memset is only able to fill bytes. This won't work for larger values. > > > + do_or_die(drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height, > > + fb->drm_format, handles, > > + fb->strides, fb->offsets, > > + modifiers, &fb->fb_id, flags)); > > > > return fb->fb_id; > > } > > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c > > index 280fdd62..0f00971d 100644 > > --- a/lib/ioctl_wrappers.c > > +++ b/lib/ioctl_wrappers.c > > @@ -1453,36 +1453,3 @@ void igt_require_fb_modifiers(int fd) > > { > > igt_require(igt_has_fb_modifiers(fd)); > > } > > - > > -int __kms_addfb(int fd, uint32_t handle, > > - uint32_t width, uint32_t height, > > - uint32_t pixel_format, uint64_t modifier, > > - uint32_t strides[4], uint32_t offsets[4], > > - int num_planes, uint32_t flags, uint32_t *buf_id) > > -{ > > - struct drm_mode_fb_cmd2 f; > > - int ret, i; > > - > > - if (flags & DRM_MODE_FB_MODIFIERS) > > - igt_require_fb_modifiers(fd); > > - > > - memset(&f, 0, sizeof(f)); > > - > > - f.width = width; > > - f.height = height; > > - f.pixel_format = pixel_format; > > - f.flags = flags; > > - > > - for (i = 0; i < num_planes; i++) { > > - f.handles[i] = handle; > > - f.modifier[i] = modifier; > > - f.pitches[i] = strides[i]; > > - f.offsets[i] = offsets[i]; > > - } > > - > > - ret = igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f); > > - > > - *buf_id = f.fb_id; > > - > > - return ret < 0 ? -errno : ret; > > -} > > diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h > > index 03211c97..4afc3e09 100644 > > --- a/lib/ioctl_wrappers.h > > +++ b/lib/ioctl_wrappers.h > > @@ -209,17 +209,6 @@ struct local_drm_mode_fb_cmd2 { > > bool igt_has_fb_modifiers(int fd); > > void igt_requ
[Intel-gfx] [PATCH V3 i-g-t] lib: Drop __kms_addfb() wrapper
The function __kms_addfb() and drmModeAddFB2WithModifiers() have a similar code. Due to this similarity, this commit replaces all the occurrences of __kms_addfb() by drmModeAddFB2WithModifiers() and adds the required adaptations. V2: Simon Sir - Fix array data copy V1: Arkadiusz Hiler - Fix array initialization - Drop __kms_addfb() Signed-off-by: Rodrigo Siqueira --- lib/igt_aux.h | 3 +++ lib/igt_fb.c| 14 +- lib/ioctl_wrappers.c| 33 - lib/ioctl_wrappers.h| 11 --- tests/kms_available_modes_crc.c | 14 +- tests/kms_draw_crc.c| 10 ++ tests/prime_vgem.c | 14 -- 7 files changed, 35 insertions(+), 64 deletions(-) diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 04d22904..2b08a0d4 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -309,4 +309,7 @@ void igt_lsof(const char *dpath); uint64_t vfs_file_max(void); +#define fill_memory(src, value, limit) \ + for (int _i = 0; _i < limit; src[_i] = value, _i++) + #endif /* IGT_AUX_H */ diff --git a/lib/igt_fb.c b/lib/igt_fb.c index d4929019..5f55906b 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1235,6 +1235,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height, struct igt_fb *fb, uint64_t bo_size, unsigned bo_stride) { + uint32_t handles[4] = {}; + uint64_t modifiers[4] = {}; + /* FIXME allow the caller to pass these in */ enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709; enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE; @@ -1262,11 +1265,12 @@ igt_create_fb_with_bo_size(int fd, int width, int height, if (fb->modifier || igt_has_fb_modifiers(fd)) flags = LOCAL_DRM_MODE_FB_MODIFIERS; - do_or_die(__kms_addfb(fb->fd, fb->gem_handle, - fb->width, fb->height, - fb->drm_format, fb->modifier, - fb->strides, fb->offsets, fb->num_planes, flags, - &fb->fb_id)); + fill_memory(handles, fb->gem_handle, fb->num_planes); + fill_memory(modifiers, modifier, fb->num_planes); + do_or_die(drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height, +fb->drm_format, handles, +fb->strides, fb->offsets, +modifiers, &fb->fb_id, flags)); return fb->fb_id; } diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 280fdd62..0f00971d 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1453,36 +1453,3 @@ void igt_require_fb_modifiers(int fd) { igt_require(igt_has_fb_modifiers(fd)); } - -int __kms_addfb(int fd, uint32_t handle, - uint32_t width, uint32_t height, - uint32_t pixel_format, uint64_t modifier, - uint32_t strides[4], uint32_t offsets[4], - int num_planes, uint32_t flags, uint32_t *buf_id) -{ - struct drm_mode_fb_cmd2 f; - int ret, i; - - if (flags & DRM_MODE_FB_MODIFIERS) - igt_require_fb_modifiers(fd); - - memset(&f, 0, sizeof(f)); - - f.width = width; - f.height = height; - f.pixel_format = pixel_format; - f.flags = flags; - - for (i = 0; i < num_planes; i++) { - f.handles[i] = handle; - f.modifier[i] = modifier; - f.pitches[i] = strides[i]; - f.offsets[i] = offsets[i]; - } - - ret = igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f); - - *buf_id = f.fb_id; - - return ret < 0 ? -errno : ret; -} diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 03211c97..4afc3e09 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -209,17 +209,6 @@ struct local_drm_mode_fb_cmd2 { bool igt_has_fb_modifiers(int fd); void igt_require_fb_modifiers(int fd); -/** - * __kms_addfb: - * - * Creates a framebuffer object. - */ -int __kms_addfb(int fd, uint32_t handle, - uint32_t width, uint32_t height, - uint32_t pixel_format, uint64_t modifier, - uint32_t strides[4], uint32_t offsets[4], - int num_planes, uint32_t flags, uint32_t *buf_id); - /** * to_user_pointer: * diff --git a/tests/kms_available_modes_crc.c b/tests/kms_available_modes_crc.c index 50b5522a..275b4b6f 100644 --- a/tests/kms_available_modes_crc.c +++ b/tests/kms_available_modes_crc.c @@ -172,9 +172,10 @@ static bool setup_fb(data_t *data, igt_output_t *output, igt_plane_t *plane, { drmModeModeInfo *mode; uint64_t w, h; + uint32_t handles[4] = {}; + uint64_t modifiers[4] = {};
[Intel-gfx] [PATCH i-g-t] lib: Rework __kms_addfb() function
The function __kms_addfb() and drmModeAddFB2WithModifiers() have a similar code. Due to this similarity, this commit replace part of the code inside __kms_addfb() by using drmModeAddFB2WithModifiers(). Signed-off-by: Rodrigo Siqueira --- lib/ioctl_wrappers.c | 27 ++- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 39920f87..4240d138 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "drmtest.h" #include "i915_drm.h" @@ -1479,29 +1480,13 @@ int __kms_addfb(int fd, uint32_t handle, uint32_t strides[4], uint32_t offsets[4], int num_planes, uint32_t flags, uint32_t *buf_id) { - struct drm_mode_fb_cmd2 f; - int ret, i; + uint32_t handles[4] = {handle}; + uint64_t modifiers[4] = {modifier}; if (flags & DRM_MODE_FB_MODIFIERS) igt_require_fb_modifiers(fd); - memset(&f, 0, sizeof(f)); - - f.width = width; - f.height = height; - f.pixel_format = pixel_format; - f.flags = flags; - - for (i = 0; i < num_planes; i++) { - f.handles[i] = handle; - f.modifier[i] = modifier; - f.pitches[i] = strides[i]; - f.offsets[i] = offsets[i]; - } - - ret = igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f); - - *buf_id = f.fb_id; - - return ret < 0 ? -errno : ret; + return drmModeAddFB2WithModifiers(fd, width, height, pixel_format, + handles, strides, offsets, modifiers, + buf_id, flags); } -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t] lib: Rework __kms_addfb() function
Hi, First of all, thank you for your review. I just have a few questions below. On 04/10, Arkadiusz Hiler wrote: > On Wed, Apr 03, 2019 at 07:24:39PM -0300, Rodrigo Siqueira wrote: > > The function __kms_addfb() and drmModeAddFB2WithModifiers() have a > > similar code. Due to this similarity, this commit replace part of the > > code inside __kms_addfb() by using drmModeAddFB2WithModifiers(). > > igt master % grep '^libdrm_version' meson.build > libdrm_version = '>=2.4.82' > > libdrm master % git log -S drmModeAddFB2WithModifiers > commit abfa680dbdfa4600105d904f4903c047d453cdb5 > Author: Kristian H. Kristensen > Date: Thu Sep 8 13:08:59 2016 -0700 > > Add drmModeAddFB2WithModifiers() which takes format modifiers > > The only other user of this feature open codes the ioctl. Let's add an > entry point for this to libdrm. > > Signed-off-by: Kristian H. Kristensen > Reviewed-by: Rob Clark > > libdrm master % git describe abfa680 > libdrm-2.4.70-15-gabfa680d > > We are good on this front. > > > > > Signed-off-by: Rodrigo Siqueira > > --- > > lib/ioctl_wrappers.c | 27 ++- > > 1 file changed, 6 insertions(+), 21 deletions(-) > > > > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c > > index 39920f87..4240d138 100644 > > --- a/lib/ioctl_wrappers.c > > +++ b/lib/ioctl_wrappers.c > > @@ -46,6 +46,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "drmtest.h" > > #include "i915_drm.h" > > @@ -1479,29 +1480,13 @@ int __kms_addfb(int fd, uint32_t handle, > > uint32_t strides[4], uint32_t offsets[4], > > int num_planes, uint32_t flags, uint32_t *buf_id) > > { > > - struct drm_mode_fb_cmd2 f; > > - int ret, i; > > + uint32_t handles[4] = {handle}; > > + uint64_t modifiers[4] = {modifier}; > > This notation will initialize first element to handle and zero out the > remining ones. Nice catch, I didn’t know about that. I’ll fix it in the V2. > It is not equivalent to what is done below, where handle and modifier > are commpied to each of the num_planes first elements of the arrays. > > > if (flags & DRM_MODE_FB_MODIFIERS) > > igt_require_fb_modifiers(fd); > > > > - memset(&f, 0, sizeof(f)); > > - > > - f.width = width; > > - f.height = height; > > - f.pixel_format = pixel_format; > > - f.flags = flags; > > - > > - for (i = 0; i < num_planes; i++) { > > - f.handles[i] = handle; > > - f.modifier[i] = modifier; > > here ^^^ > > Which may break testing if we ever call it with (num_planes > 1). > > > - f.pitches[i] = strides[i]; > > - f.offsets[i] = offsets[i]; > > - } > > - > > - ret = igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &f); > > - > > - *buf_id = f.fb_id; > > - > > - return ret < 0 ? -errno : ret; > > This also changes behavior, as we log return value of __kms_addfb in few > places, so we lose the information from errno and we would get -1 in > case of any failue now. I’m little bit confused here, because drmModeAddFB2WithModifiers() has the following code: if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f))) return ret; In its turn, DRM_IOCTL(), has the following code: static inline int DRM_IOCTL(int fd, unsigned long cmd, void *arg) { int ret = drmIoctl(fd, cmd, arg); return ret < 0 ? -errno : ret; } Because of this, I thought that “return drmModeAddFB2WithModifiers()” has the same behaviour of the previous code. Could you give me some extra explanation on this issue? > > + return drmModeAddFB2WithModifiers(fd, width, height, pixel_format, > > + handles, strides, offsets, modifiers, > > + buf_id, flags); > > } > > igt master % ff __kms_addfb > tests/kms_draw_crc.c:166:9: ret = __kms_addfb(drm_fd, > gem_handle, 64, 64, > tests/kms_available_modes_crc.c:228:8: ret = __kms_addfb(data->gfx_fd, > data->gem_handle, w, h, > tests/prime_vgem.c:765:15: igt_require(__kms_addfb(i915, > handle[i], > lib/igt_fb.c:1243:12: do_or_die(__kms_addfb(fb->fd, > fb->gem_handle, > lib/ioctl_wrappers.h:217:5: int __kms_addfb(int fd, uint32_t > handle, > lib/ioctl_wrappers.c:1457:5:int __kms_addfb(int fd, uint32_t > handle, > > We call __kms_addfb in 4 places only. It may
[Intel-gfx] [RESEND PATCH v6 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson) V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS V3: Add documentation (Daniel Vetter) V2: Add new branch coverage to check if VBlank is enabled or not and update commit message V1: Chris Wilson - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- Updates: 1. Rebase the code with the last updates from the master. 2. Patch tested on VC4, Bochs, VKMS, and i915. lib/igt_kms.c| 20 lib/igt_kms.h| 2 ++ tests/kms_flip.c | 22 ++ 3 files changed, 44 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index df9aafd2..0bdd1e40 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1656,6 +1656,26 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi igt_assert_eq(visible, visibility); } +/** + * kms_has_vblank: + * @fd: DRM fd + * + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: true if target driver has VBlank support, otherwise return false. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; + + drmWaitVBlank(fd, &dummy_vbl); + return (errno != EOPNOTSUPP); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 38bdc08f..b0ff79ab 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility); +bool kms_has_vblank(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 6287ce14..4e0471a9 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -71,6 +71,7 @@ #define TEST_SUSPEND (1 << 26) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + bool vblank = true; switch (crtc_count) { case RUN_TEST: @@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]); -- 2.21.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [RESEND PATCH v6 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
On 04/18, Chris Wilson wrote: > Quoting Rodrigo Siqueira (2019-04-18 15:01:49) > > +bool kms_has_vblank(int fd) > > +{ > > + drmVBlank dummy_vbl; > > + > > + memset(&dummy_vbl, 0, sizeof(drmVBlank)); > > + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; > > + > > + drmWaitVBlank(fd, &dummy_vbl); > > + return (errno != EOPNOTSUPP); > > errno is only set on error. It is conceivably that drmWaitVBlank() > suceeed but errno is still set to EOPNOTSUPP from an earlier syscall. > -Chris Nice catch! Before I send a V7, how about this fix: bool kms_has_vblank(int fd) { ... errno = 0; drmWaitVBlank(fd, &dummy_vbl); return (errno != EOPNOTSUPP); } -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v7 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). V6: Set errno to zero before call drmWaitVBlank() V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson) V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS V3: Add documentation (Daniel Vetter) V2: Add new branch coverage to check if VBlank is enabled or not and update commit message V1: Chris Wilson - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c| 21 + lib/igt_kms.h| 2 ++ tests/kms_flip.c | 22 ++ 3 files changed, 45 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index df9aafd2..ca3073a0 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1656,6 +1656,27 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi igt_assert_eq(visible, visibility); } +/** + * kms_has_vblank: + * @fd: DRM fd + * + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: true if target driver has VBlank support, otherwise return false. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; + + errno = 0; + drmWaitVBlank(fd, &dummy_vbl); + return (errno != EOPNOTSUPP); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 38bdc08f..b0ff79ab 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility); +bool kms_has_vblank(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 6287ce14..4e0471a9 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -71,6 +71,7 @@ #define TEST_SUSPEND (1 << 26) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + bool vblank = true; switch (crtc_count) { case RUN_TEST: @@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]); -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V4 i-g-t] Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). Changes since V3: Daniel Vetter: - Add documentation for kms_vblank_status() Changes since V2: - Add new branch coverage to check if VBlank is enabled or not - Update commit message - Change function name from kms_has_vblank to kms_vblank_status Changes since V1: Chris Wilson: - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c| 20 lib/igt_kms.h| 2 ++ tests/kms_flip.c | 27 +-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 85a911e1..81fbafe0 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1654,6 +1654,26 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility) igt_assert_eq(visible, visibility); } +/** + * kms_vblank_status: + * @fd: DRM fd + * + * Get the VBlank status after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: The errno code generated by drmWaitVBlank() + */ +int kms_vblank_status(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_ABSOLUTE; + + drmWaitVBlank(fd, &dummy_vbl); + return errno; +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 679d4e84..259eaa75 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility); +int kms_vblank_status(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 798fc4e8..efc59328 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -73,6 +73,7 @@ #define TEST_TS_CONT (1 << 27) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -125,6 +126,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_TS_CONT | TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -493,11 +506,11 @@ static void check_state(const struct test_output *o, const struct event_state *e /* check only valid if no modeset happens in between, that increments by * (1 << 23) on each step. This bounding matches the one in * DRM_IOCTL_WAIT_VBLANK. */ - if (!(o->flags & (TEST_DPMS | TEST_MODESET))) + if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK))) { igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23, "unexpected %s seq %u, should be >= %u\n", es->name, es->current_seq, es->last_seq + o->seq_step); - + } /* Check that the vblank frame didn't wrap unexpectedly. */ if (o->flags & TEST_TS_CONT) { /* Ignore seq_step here since vblank waits time out immediately @@ -1184,6 +1197,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + int vblank_status = 0; switch (crtc_count) { case 1: @@ -1267,6 +1281,15 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank_status = kms_vblank_status(drm_fd); + if (vblank_status == EOPNOTSUPP) { + if (vblank_dependence(o->flags)) + igt_require_f(!(vblank_status == EOPNOTSUPP), + "Vblank: %s\n", strerror(vblank_status)); + else +
[Intel-gfx] [PATCH i-g-t 0/7] kms_flip: cleanups
The last few weeks, I have been dive into the page flip and vblank with the goal to learn how the user space interact with DRM; because of this, I am studying the kms_flip code. As a result, I noticed a bunch of cleanups that could be useful for improving the overall quality of kms_flip. This patchset can be seen in two parts: 1. Eliminates unreachable tests 2. Basic cleanups with the goal to improve the code readability In particular, the patch number three enables kms_flip to work without any issue in any non-intel drivers. Rodrigo Siqueira (7): kms_flip: Removes unreachable code related to TEST_RPM kms_flip: Removes unreachable code related to TEST_TS_CONT kms_flip: Fix warning related to i915 gem dependence kms_flip: Remove unreachable condition in wait_for_events kms_flip: remove magic constant in run_test_on_crtc_set() kms_flip: Rework set_mode() kms_flip: Standardize return value for fb_is_bound tests/kms_flip.c | 88 +--- 1 file changed, 31 insertions(+), 57 deletions(-) -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 1/7] kms_flip: Removes unreachable code related to TEST_RPM
This commit removes the code related to TEST_RPM test because the kms_flip never sets this flags, i.e., TEST_RPM is not used. Take a look at commit 07a3fccf to see why this flag is never set. Signed-off-by: Rodrigo Siqueira --- tests/kms_flip.c | 15 --- 1 file changed, 15 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 798fc4e8..f769d30e 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -68,7 +68,6 @@ #define TEST_ENOENT(1 << 22) #define TEST_FENCE_STRESS (1 << 23) #define TEST_VBLANK_RACE (1 << 24) -#define TEST_RPM (1 << 25) #define TEST_SUSPEND (1 << 26) #define TEST_TS_CONT (1 << 27) #define TEST_BO_TOOBIG (1 << 28) @@ -809,9 +808,6 @@ static unsigned int run_test_step(struct test_output *o) "failed to disable output: %s\n", strerror(errno)); - if (o->flags & TEST_RPM) - igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED)); - if (o->flags & TEST_SUSPEND) igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); @@ -1321,9 +1317,6 @@ static int run_test(int duration, int flags) igt_require((flags & TEST_HANG) == 0 || !is_wedged(drm_fd)); - if (flags & TEST_RPM) - igt_require(igt_setup_runtime_pm()); - resources = drmModeGetResources(drm_fd); igt_require(resources); @@ -1570,10 +1563,6 @@ int main(int argc, char **argv) if (tests[i].flags & TEST_NO_2X_OUTPUT) continue; - /* code doesn't disable all crtcs, so skip rpm tests */ - if (tests[i].flags & TEST_RPM) - continue; - igt_subtest_f( "2x-%s", tests[i].name) run_pair(tests[i].duration, tests[i].flags); } @@ -1592,10 +1581,6 @@ int main(int argc, char **argv) if (tests[i].flags & TEST_NO_2X_OUTPUT) continue; - /* code doesn't disable all crtcs, so skip rpm tests */ - if (tests[i].flags & TEST_RPM) - continue; - igt_subtest_f( "2x-%s-interruptible", tests[i].name) run_pair(tests[i].duration, tests[i].flags); } -- 2.21.0 -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 2/7] kms_flip: Removes unreachable code related to TEST_TS_CONT
This commit removes the code related to TEST_TS_CONT test because the kms_flip never sets this flags, i.e., TEST_TS_CONT is not used. Take a look at commit 07a3fccf to see why this flag is never set. Signed-off-by: Rodrigo Siqueira --- tests/kms_flip.c | 16 1 file changed, 16 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index f769d30e..0d261b77 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -69,7 +69,6 @@ #define TEST_FENCE_STRESS (1 << 23) #define TEST_VBLANK_RACE (1 << 24) #define TEST_SUSPEND (1 << 26) -#define TEST_TS_CONT (1 << 27) #define TEST_BO_TOOBIG (1 << 28) #define TEST_BASIC (1 << 30) @@ -497,21 +496,6 @@ static void check_state(const struct test_output *o, const struct event_state *e "unexpected %s seq %u, should be >= %u\n", es->name, es->current_seq, es->last_seq + o->seq_step); - /* Check that the vblank frame didn't wrap unexpectedly. */ - if (o->flags & TEST_TS_CONT) { - /* Ignore seq_step here since vblank waits time out immediately -* when we kill the crtc. */ - igt_assert_f(es->current_seq - es->last_seq >= 0, -"unexpected %s seq %u, should be >= %u\n", -es->name, es->current_seq, es->last_seq); - igt_assert_f(es->current_seq - es->last_seq <= 150, -"unexpected %s seq %u, should be < %u\n", -es->name, es->current_seq, es->last_seq + 150); - - igt_debug("testing ts continuity: Current frame %u, old frame %u\n", - es->current_seq, es->last_seq); - } - if (o->flags & TEST_CHECK_TS) { double elapsed, expected; -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 3/7] kms_flip: Fix warning related to i915 gem dependence
In the kms_flip tests has an igt_fixture that allocates memory for i915 driver with “drm_intel_bufmgr_gem_init()”, which produces the following warning: IGT-Version: 1.23-g8d81c2c2 (x86_64) (Linux: 5.0.0-rc7-VKMS-RULES+ x86_64) Using monotonic timestamps DRM_IOCTL_I915_GEM_APERTURE failed: Invalid argument Assuming 131072kB available aperture size. May lead to reduced performance or incorrect rendering. get chip id failed: -1 [22] This commit handles this specific dependence with the i915 driver which make the kms_flip logs better. Signed-off-by: Rodrigo Siqueira --- tests/kms_flip.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 0d261b77..57138ec1 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -1528,10 +1528,12 @@ int main(int argc, char **argv) igt_install_exit_handler(kms_flip_exit_handler); get_timestamp_format(); - bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); - if (bufmgr) { - devid = intel_get_drm_devid(drm_fd); - batch = intel_batchbuffer_alloc(bufmgr, devid); + if (is_i915_device(drm_fd)) { + bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); + if (bufmgr) { + devid = intel_get_drm_devid(drm_fd); + batch = intel_batchbuffer_alloc(bufmgr, devid); + } } } -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 4/7] kms_flip: Remove unreachable condition in wait_for_events
In the function wait_for_events() has a double check in the select() function return as described below: igt_assert_f(ret >= 0, "select error (errno %i)\n", errno); igt_assert_f(ret > 0, "select timed out or error (ret %d)\n", ret); Note that the second assert condition will not be reached because of the first assertion. This commit removes the code duplication and update the error message. Signed-off-by: Rodrigo Siqueira --- tests/kms_flip.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 57138ec1..9ef77de9 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -1014,9 +1014,7 @@ static unsigned int wait_for_events(struct test_output *o) } while (ret < 0 && errno == EINTR); igt_assert_f(ret >= 0, -"select error (errno %i)\n", errno); - igt_assert_f(ret > 0, -"select timed out or error (ret %d)\n", ret); +"select error: %s (%d))\n", strerror(errno), ret); igt_assert_f(!FD_ISSET(0, &fds), "no fds active, breaking\n"); -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 5/7] kms_flip: Remove magic constant in run_test_on_crtc_set()
The function run_test_on_crtc_set() expects a parameter named crtc_count which slight changes the behavior of the test. If this crtc_count is ‘1’, the test will run in a single CRTC; otherwise, it will run in two different CRTC. However, this function uses hardcoded literal 1 and 2 for each case. This patch creates two constant with the goal to improve the readability. Signed-off-by: Rodrigo Siqueira --- tests/kms_flip.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 9ef77de9..42ae3ebc 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -76,6 +76,9 @@ #define EVENT_FLIP (1 << 0) #define EVENT_VBLANK (1 << 1) +#define RUN_TEST 1 +#define RUN_PAIR 2 + #ifndef DRM_CAP_TIMESTAMP_MONOTONIC #define DRM_CAP_TIMESTAMP_MONOTONIC 6 #endif @@ -1164,7 +1167,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, int i; switch (crtc_count) { - case 1: + case RUN_TEST: connector_find_preferred_mode(o->_connector[0], crtc_idxs[0], o); if (!o->mode_valid) return; @@ -1175,7 +1178,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, kmstest_connector_type_str(o->kconnector[0]->connector_type), o->kconnector[0]->connector_type_id); break; - case 2: + case RUN_PAIR: connector_find_compatible_mode(crtc_idxs[0], crtc_idxs[1], o); if (!o->mode_valid) return; @@ -1341,7 +1344,7 @@ static int run_test(int duration, int flags) o.depth = 24; crtc_idx = n; - run_test_on_crtc_set(&o, &crtc_idx, 1, duration); + run_test_on_crtc_set(&o, &crtc_idx, RUN_TEST, duration); } } @@ -1410,7 +1413,8 @@ static int run_pair(int duration, int flags) crtc_idxs[0] = n; crtc_idxs[1] = m; - run_test_on_crtc_set(&o, crtc_idxs, 2, + run_test_on_crtc_set(&o, crtc_idxs, +RUN_PAIR, duration); } } -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 6/7] kms_flip: Rework set_mode()
This patch removes the duplicate code inside the function set_mode(). Signed-off-by: Rodrigo Siqueira --- tests/kms_flip.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 42ae3ebc..de3ab600 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -609,22 +609,24 @@ static bool is_wedged(int fd) static int set_mode(struct test_output *o, uint32_t fb, int x, int y) { - int n; + int n, ret; for (n = o->count - 1; n >= 0; n--) { + uint32_t buffer_id = fb, x_crtc = x, y_crtc = y; + uint32_t *conn = &o->_connector[n]; + int count = 1; + drmModeModeInfoPtr mode = &o->kmode[n]; + if (fb == 0) { - int ret = drmModeSetCrtc(drm_fd, o->_crtc[n], -0, 0, 0, -0, 0, 0); - if (ret) - return ret; - } else { - int ret = drmModeSetCrtc(drm_fd, o->_crtc[n], -fb, x, y, -&o->_connector[n], 1, &o->kmode[n]); - if (ret) - return ret; + buffer_id = x_crtc = y_crtc = count = 0; + conn = NULL; mode = NULL; } + + ret = drmModeSetCrtc(drm_fd, o->_crtc[n], +buffer_id, x_crtc, y_crtc, +conn, count, mode); + if (ret) + return ret; } return 0; -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 7/7] kms_flip: Standardize return value for fb_is_bound
The function fb_is_bound() mix integer value with booleans for handling the return value. This commit standardizes the return value of fb_is_bound() for using only booleans. Signed-off-by: Rodrigo Siqueira --- tests/kms_flip.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index de3ab600..abfdd363 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -947,8 +947,7 @@ static void paint_flip_mode(struct igt_fb *fb, bool odd_frame) igt_put_cairo_ctx(drm_fd, fb, cr); } -static int -fb_is_bound(struct test_output *o, int fb) +static bool fb_is_bound(struct test_output *o, int fb) { int n; @@ -958,7 +957,7 @@ fb_is_bound(struct test_output *o, int fb) }; if (drmIoctl(drm_fd, DRM_IOCTL_MODE_GETCRTC, &mode)) - return 0; + return false; if (!mode.mode_valid || mode.fb_id != fb) return false; -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v2] Add support for forcing specific module
On 12/17, Daniel Vetter wrote: > On Wed, Sep 05, 2018 at 05:38:27PM -0300, Rodrigo Siqueira wrote: > > This commit adds a new option for forcing the use of a specific driver > > indicated via an environment variable. > > > > Changes since V1: > > Petri: > > - Use an environment variable instead of command line > > - Refactor the loop in __search_and_open to accept forced module > > - Don't try to load kernel modules > > > > Signed-off-by: Rodrigo Siqueira > > Note: You can't drop the s-o-b line if your patch contains work by other > people, like from Petri here. Proper way to resend a patch by someone else > is to just add a subject prefix of "PATCH RESEND" and otherwise keep > everything unchanged (including author and everything). > > https://patchwork.freedesktop.org/patch/245532/ Hi, Thanks for your feedback. Next time I will take care for not make this mistake again. Best Regards Rodrigo Siqueira > Cheers, Daniel > > > --- > > lib/drmtest.c | 44 ++-- > > lib/drmtest.h | 2 ++ > > lib/igt_core.c | 5 + > > 3 files changed, 49 insertions(+), 2 deletions(-) > > > > diff --git a/lib/drmtest.c b/lib/drmtest.c > > index bfa2e0f0..6e35d1be 100644 > > --- a/lib/drmtest.c > > +++ b/lib/drmtest.c > > @@ -123,6 +123,36 @@ static bool has_known_intel_chipset(int fd) > > return true; > > } > > > > +static char _forced_driver[5] = ""; > > + > > +/** > > + * __set_forced_driver: > > + * @name: name of driver to forcibly use > > + * > > + * Set the name of a driver to use when calling #drm_open_driver with > > + * the #DRIVER_ANY flag. > > + */ > > +void __set_forced_driver(const char *name) > > +{ > > + if (!strcmp(name, "")) { > > + igt_warn("IGT_FORCE_DRIVER flag specified without a value," > > +"ignoring force option\n"); > > + return; > > + } > > + > > + igt_info("Attempt to force module %s\n", name); > > + > > + strncpy(_forced_driver, name, 4); > > +} > > + > > +static const char *forced_driver(void) > > +{ > > + if (_forced_driver[0]) > > + return _forced_driver; > > + > > + return NULL; > > +} > > + > > #define LOCAL_I915_EXEC_VEBOX (4 << 0) > > /** > > * gem_quiescent_gpu: > > @@ -250,8 +280,18 @@ static int __search_and_open(const char *base, int > > offset, unsigned int chipset) > > > > sprintf(name, "%s%u", base, i + offset); > > fd = open_device(name, chipset); > > - if (fd != -1) > > - return fd; > > + if (fd == -1) > > + continue; > > + > > + // Force module > > + if (chipset == DRIVER_ANY && forced_driver()) { > > + if (__is_device(fd, forced_driver())) > > + return fd; > > + close(fd); > > + continue; > > + } > > + > > + return fd; > > } > > > > return -1; > > diff --git a/lib/drmtest.h b/lib/drmtest.h > > index 949865ee..62f53ec3 100644 > > --- a/lib/drmtest.h > > +++ b/lib/drmtest.h > > @@ -51,6 +51,8 @@ > > */ > > #define DRIVER_ANY ~(DRIVER_VGEM) > > > > +void __set_forced_driver(const char *name); > > + > > /** > > * ARRAY_SIZE: > > * @arr: static array > > diff --git a/lib/igt_core.c b/lib/igt_core.c > > index 23bb858f..8e65b5e3 100644 > > --- a/lib/igt_core.c > > +++ b/lib/igt_core.c > > @@ -647,6 +647,11 @@ static void common_init_env(void) > > igt_frame_dump_path = getenv("IGT_FRAME_DUMP_PATH"); > > > > stderr_needs_sentinel = getenv("IGT_SENTINEL_ON_STDERR") != NULL; > > + > > + env = getenv("IGT_FORCE_DRIVER"); > > + if (env) { > > + __set_forced_driver(env); > > + } > > } > > > > static int common_init(int *argc, char **argv, > > -- > > 2.18.0 > > > > > > -- > > Rodrigo Siqueira > > http://siqueira.tech > > Graduate Student > > Department of Computer Science > > University of São Paulo > > ___ > > igt-dev mailing list > > igt-...@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/igt-dev > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH] drm/vblank: Document and fix vblank count barrier semantics
Hi Daniel, All the series look really good for me. I just have some few questions here. On 07/23, Daniel Vetter wrote: > Noticed while reviewing code. I'm not sure whether this might or might > not explain some of the missed vblank hilarity we've been seeing. I I have to admit that I'm a little bit confused about the "missed vblank hilarity we've been seeing". Could you elaborate a little bit more about this problem in the commit message? Additionally, how about break this commit in two? One dedicated to the barriers and the atomic64, and the other related to the documentation? > think those all go through the vblank completion event, which has > unconditional barriers - it always takes the spinlock. Therefore no > cc stable. > > v2: > - Barrriers are hard, put them in in the right order (Chris). > - Improve the comments a bit. > > v3: > > Ville noticed that on 32bit we might be breaking up the load/stores, > now that the vblank counter has been switched over to be 64 bit. Fix > that up by switching to atomic64_t. This this happens so rarely in > practice I figured no need to cc: stable ... > > Cc: Ville Syrjälä > Cc: Keith Packard > References: 570e86963a51 ("drm: Widen vblank count to 64-bits [v3]") > Cc: Rodrigo Siqueira > Cc: Chris Wilson > Signed-off-by: Daniel Vetter > --- > drivers/gpu/drm/drm_vblank.c | 45 > include/drm/drm_vblank.h | 15 ++-- > 2 files changed, 54 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > index 603ab105125d..03e37bceac9c 100644 > --- a/drivers/gpu/drm/drm_vblank.c > +++ b/drivers/gpu/drm/drm_vblank.c > @@ -107,7 +107,7 @@ static void store_vblank(struct drm_device *dev, unsigned > int pipe, > > write_seqlock(&vblank->seqlock); > vblank->time = t_vblank; > - vblank->count += vblank_count_inc; > + atomic64_add(vblank_count_inc, &vblank->count); > write_sequnlock(&vblank->seqlock); > } > > @@ -273,7 +273,8 @@ static void drm_update_vblank_count(struct drm_device > *dev, unsigned int pipe, > > DRM_DEBUG_VBL("updating vblank count on crtc %u:" > " current=%llu, diff=%u, hw=%u hw_last=%u\n", > - pipe, vblank->count, diff, cur_vblank, vblank->last); > + pipe, atomic64_read(&vblank->count), diff, > + cur_vblank, vblank->last); > > if (diff == 0) { > WARN_ON_ONCE(cur_vblank != vblank->last); > @@ -295,11 +296,23 @@ static void drm_update_vblank_count(struct drm_device > *dev, unsigned int pipe, > static u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe) > { > struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; > + u64 count; > > if (WARN_ON(pipe >= dev->num_crtcs)) > return 0; > > - return vblank->count; > + count = atomic64_read(&vblank->count); > + > + /* > + * This read barrier corresponds to the implicit write barrier of the > + * write seqlock in store_vblank(). Note that this is the only place > + * where we need an explicit barrier, since all other access goes > + * through drm_vblank_count_and_time(), which already has the required > + * read barrier curtesy of the read seqlock. > + */ > + smp_rmb(); I think I did not get all the idea behind the smp_rmb() in this function. FWIU, smp_xxx are used for preventing race conditions in a multiprocessor system, right? In this sense, I can presume that this change can bring benefits for VKMS or any other virtual driver; on the other hand, this will not bring any advantage on real drivers like i915 and amdgpu since these devices are not related with smp stuff, right? Thanks > + > + return count; > } > > /** > @@ -764,6 +777,14 @@ drm_get_last_vbltimestamp(struct drm_device *dev, > unsigned int pipe, > * vblank interrupt (since it only reports the software vblank counter), see > * drm_crtc_accurate_vblank_count() for such use-cases. > * > + * Note that for a given vblank counter value drm_crtc_handle_vblank() > + * and drm_crtc_vblank_count() or drm_crtc_vblank_count_and_time() > + * provide a barrier: Any writes done before calling > + * drm_crtc_handle_vblank() will be visible to callers of the later > + * functions, iff the vblank count is the same or a later one. > + * > + * See also &drm_vblank_crtc.count. > + * > * Returns: > * The software vblank counter. > */ > @@ -801,7 +822,7 @@ static u64 drm_vblank_count_and_time(struct drm_de
Re: [Intel-gfx] [PATCH 2/3] drm/vkms: Use wait_for_flip_done
On 07/19, Daniel Vetter wrote: > It's the recommended version, wait_for_vblanks is a bit a hacky > interim thing that predates all the flip_done tracking. It's > unfortunately still the default ... Just one question, is it safe to replace drm_atomic_helper_wait_for_vblanks by drm_atomic_helper_wait_for_flip_done? I noticed that only six drivers use these functions; they are: * atmel-hlcdc * mediatek * msm * tegra * tilcdc * virtio If we change these drivers, can we drop the helper drm_atomic_helper_wait_for_vblanks? Reviewed-by: Rodrigo Siqueira Thanks > Signed-off-by: Daniel Vetter > Cc: Rodrigo Siqueira > Cc: Haneen Mohammed > Cc: Daniel Vetter > --- > drivers/gpu/drm/vkms/vkms_drv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c > index 44ab9f8ef8be..80524a22412a 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.c > +++ b/drivers/gpu/drm/vkms/vkms_drv.c > @@ -83,7 +83,7 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state > *old_state) > > drm_atomic_helper_commit_hw_done(old_state); > > - drm_atomic_helper_wait_for_vblanks(dev, old_state); > + drm_atomic_helper_wait_for_flip_done(dev, old_state); > > for_each_old_crtc_in_state(old_state, crtc, old_crtc_state, i) { > struct vkms_crtc_state *vkms_state = > -- > 2.22.0 > -- Rodrigo Siqueira Software Engineer, Advanced Micro Devices (AMD) https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 3/3] drm/vkms: Reduce critical section in vblank_simulate
Thanks for this patch! It looks good for me. Reviewed-by: Rodrigo Siqueira On 07/19, Daniel Vetter wrote: > We can reduce the critical section in vkms_vblank_simulate under > output->lock quite a lot: > > - hrtimer_forward_now just needs to be ordered correctly wrt > drm_crtc_handle_vblank. We already access the hrtimer timestamp > without locks. While auditing that I noticed that we don't correctly > annotate the read there, so sprinkle a READ_ONCE to make sure the > compiler doesn't do anything foolish. > > - drm_crtc_handle_vblank must stay under the lock to avoid races with > drm_crtc_arm_vblank_event. > > - The access to vkms_ouptut->crc_state also must stay under the lock. > > - next problem is making sure the output->state structure doesn't get > freed too early. First we rely on a given hrtimer being serialized: > If we call drm_crtc_handle_vblank, then we are guaranteed that the > previous call to vkms_vblank_simulate has completed. The other side > of the coin is that the atomic updates waits for the vblank to > happen before it releases the old state. Both taken together means > that by the time the atomic update releases the old state, the > hrtimer won't access it anymore (it might be accessing the new state > at the same time, but that's ok). > > - state is invariant, except the few fields separate protected by > state->crc_lock. So no need to hold the lock for that. > > - finally the queue_work. We need to make sure there's no races with > the flush_work, i.e. when we call flush_work we need to guarantee > that the hrtimer can't requeue the work again. This is guaranteed by > the same vblank/hrtimer ordering guarantees like the reasoning above > why state won't be freed too early: flush_work on the old state is > called after wait_for_flip_done in the atomic commit code. > > Therefore we can also move everything after the output->crc_state out > of the critical section. > > Motivated by suggestions from Rodrigo. > > Signed-off-by: Daniel Vetter > Cc: Rodrigo Siqueira > Cc: Haneen Mohammed > Cc: Daniel Vetter > --- > drivers/gpu/drm/vkms/vkms_crtc.c | 9 - > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c > b/drivers/gpu/drm/vkms/vkms_crtc.c > index 927dafaebc76..74f703b8d22a 100644 > --- a/drivers/gpu/drm/vkms/vkms_crtc.c > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c > @@ -16,17 +16,18 @@ static enum hrtimer_restart vkms_vblank_simulate(struct > hrtimer *timer) > u64 ret_overrun; > bool ret; > > - spin_lock(&output->lock); > - > ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer, > output->period_ns); > WARN_ON(ret_overrun != 1); > > + spin_lock(&output->lock); > ret = drm_crtc_handle_vblank(crtc); > if (!ret) > DRM_ERROR("vkms failure on handling vblank"); > > state = output->composer_state; > + spin_unlock(&output->lock); > + > if (state && output->composer_enabled) { > u64 frame = drm_crtc_accurate_vblank_count(crtc); > > @@ -48,8 +49,6 @@ static enum hrtimer_restart vkms_vblank_simulate(struct > hrtimer *timer) > DRM_DEBUG_DRIVER("Composer worker already queued\n"); > } > > - spin_unlock(&output->lock); > - > return HRTIMER_RESTART; > } > > @@ -85,7 +84,7 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, > unsigned int pipe, > struct vkms_output *output = &vkmsdev->output; > struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; > > - *vblank_time = output->vblank_hrtimer.node.expires; > + *vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires); > > if (WARN_ON(*vblank_time == vblank->time)) > return true; > -- > 2.22.0 > -- Rodrigo Siqueira Software Engineer, Advanced Micro Devices (AMD) https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH] drm/vblank: Document and fix vblank count barrier semantics
Hi, thanks for the explanation. I noticed that I forgot to add my r-b. Reviewed-by: Rodrigo Siqueira On 09/03, Daniel Vetter wrote: > On Tue, Sep 03, 2019 at 08:47:03AM -0400, Rodrigo Siqueira wrote: > > Hi Daniel, > > > > All the series look really good for me. I just have some few questions > > here. > > > > On 07/23, Daniel Vetter wrote: > > > Noticed while reviewing code. I'm not sure whether this might or might > > > not explain some of the missed vblank hilarity we've been seeing. I > > > > I have to admit that I'm a little bit confused about the "missed vblank > > hilarity we've been seeing". Could you elaborate a little bit more about > > this problem in the commit message? > > We've had various reports on various drivers that hw vblanks seem to get > lost and the driver stuck on vblank waits. I think most of those where > just driver bugs, but could be also that there's some issues in the vblank > core. > > > Additionally, how about break this commit in two? One dedicated to the > > barriers > > and the atomic64, and the other related to the documentation? > > > > > think those all go through the vblank completion event, which has > > > unconditional barriers - it always takes the spinlock. Therefore no > > > cc stable. > > > > > > v2: > > > - Barrriers are hard, put them in in the right order (Chris). > > > - Improve the comments a bit. > > > > > > v3: > > > > > > Ville noticed that on 32bit we might be breaking up the load/stores, > > > now that the vblank counter has been switched over to be 64 bit. Fix > > > that up by switching to atomic64_t. This this happens so rarely in > > > practice I figured no need to cc: stable ... > > > > > > Cc: Ville Syrjälä > > > Cc: Keith Packard > > > References: 570e86963a51 ("drm: Widen vblank count to 64-bits [v3]") > > > Cc: Rodrigo Siqueira > > > Cc: Chris Wilson > > > Signed-off-by: Daniel Vetter > > > --- > > > drivers/gpu/drm/drm_vblank.c | 45 > > > include/drm/drm_vblank.h | 15 ++-- > > > 2 files changed, 54 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > > > index 603ab105125d..03e37bceac9c 100644 > > > --- a/drivers/gpu/drm/drm_vblank.c > > > +++ b/drivers/gpu/drm/drm_vblank.c > > > @@ -107,7 +107,7 @@ static void store_vblank(struct drm_device *dev, > > > unsigned int pipe, > > > > > > write_seqlock(&vblank->seqlock); > > > vblank->time = t_vblank; > > > - vblank->count += vblank_count_inc; > > > + atomic64_add(vblank_count_inc, &vblank->count); > > > write_sequnlock(&vblank->seqlock); > > > } > > > > > > @@ -273,7 +273,8 @@ static void drm_update_vblank_count(struct drm_device > > > *dev, unsigned int pipe, > > > > > > DRM_DEBUG_VBL("updating vblank count on crtc %u:" > > > " current=%llu, diff=%u, hw=%u hw_last=%u\n", > > > - pipe, vblank->count, diff, cur_vblank, vblank->last); > > > + pipe, atomic64_read(&vblank->count), diff, > > > + cur_vblank, vblank->last); > > > > > > if (diff == 0) { > > > WARN_ON_ONCE(cur_vblank != vblank->last); > > > @@ -295,11 +296,23 @@ static void drm_update_vblank_count(struct > > > drm_device *dev, unsigned int pipe, > > > static u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe) > > > { > > > struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; > > > + u64 count; > > > > > > if (WARN_ON(pipe >= dev->num_crtcs)) > > > return 0; > > > > > > - return vblank->count; > > > + count = atomic64_read(&vblank->count); > > > + > > > + /* > > > + * This read barrier corresponds to the implicit write barrier of the > > > + * write seqlock in store_vblank(). Note that this is the only place > > > + * where we need an explicit barrier, since all other access goes > > > + * through drm_vblank_count_and_time(), which already has the required > > > + * read barrier curtesy of the read seqlock. > > > + */ > > > + smp_rmb(); > > > > I think I did not get a
Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v5 1/6] lib/igt_kms: Add writeback support
Hi Liviu, I’m using your patchset to guide my implementation of writeback in the VKMS, so, first of all, thanks :) During my work, I noticed that you’re setting the drmSetClientCap() before drmModeGetResources() which make the writeback capability ‘invisible’ for drmModeGetResources(). I made the following change, and I could pass the igt_display_require(): diff --git a/lib/igt_kms.c b/lib/igt_kms.c index f4ff3a96..bb2d8e06 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1912,6 +1912,12 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->drm_fd = drm_fd; + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); + if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0) + display->is_atomic = 1; + + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); + resources = drmModeGetResources(display->drm_fd); if (!resources) goto out; @@ -1924,12 +1930,6 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes); igt_assert_f(display->pipes, "Failed to allocate memory for %d pipes\n", display->n_pipes); - drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); - if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0) - display->is_atomic = 1; - - drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); - plane_resources = drmModeGetPlaneResources(display->drm_fd); igt_assert(plane_resources); I'm not 100% confident about this issue, because of this I will send an RFC and see if I can get more details about this issue. Additionally, if you need any help with this patchset I will be glad to help since I’m using it \o/ Best Regards Rodrigo Siqueira On 02/04, Brian Starkey wrote: > Hi Liviu, > > On Tue, Jan 15, 2019 at 05:47:42PM +, Liviu Dudau wrote: > > From: Brian Starkey > > [snip] > > > > > +/** > > + * igt_output_set_writeback_fb: > > + * @output: Target output > > + * @fb: Target framebuffer > > + * > > + * This function sets the given @fb to be used as the target framebuffer > > for the > > + * writeback engine at the next atomic commit. It will also request a > > writeback > > + * out fence that will contain the fd number of the out fence created by > > KMS if > > + * the given @fb is valid. > > + */ > > +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb) > > +{ > > + igt_display_t *display = output->display; > > + > > + LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, fb ? > > fb->fb_id : 0); > > + > > + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb ? > > fb->fb_id : 0); > > + /* only request a writeback out fence if the framebuffer is valid */ > > + if (fb) > > + igt_output_set_prop_value(output, > > IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, > > + > > (ptrdiff_t)&output->writeback_out_fence_fd); > > I'm still not sure (ptrdiff_t) is the right type here, (uintptr_t) > seems better. > > Thanks, > -Brian > ___ > igt-dev mailing list > igt-...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/igt-dev -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH i-g-t 7/7] kms_flip: Standardize return value for fb_is_bound
On 03/06, Maarten Lankhorst wrote: > Op 04-03-2019 om 16:32 schreef Rodrigo Siqueira: > > The function fb_is_bound() mix integer value with booleans for handling > > the return value. This commit standardizes the return value of > > fb_is_bound() for using only booleans. > > > > Signed-off-by: Rodrigo Siqueira > > --- > > tests/kms_flip.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/tests/kms_flip.c b/tests/kms_flip.c > > index de3ab600..abfdd363 100755 > > --- a/tests/kms_flip.c > > +++ b/tests/kms_flip.c > > @@ -947,8 +947,7 @@ static void paint_flip_mode(struct igt_fb *fb, bool > > odd_frame) > > igt_put_cairo_ctx(drm_fd, fb, cr); > > } > > > > -static int > > -fb_is_bound(struct test_output *o, int fb) > > +static bool fb_is_bound(struct test_output *o, int fb) > > { > > int n; > > > > @@ -958,7 +957,7 @@ fb_is_bound(struct test_output *o, int fb) > > }; > > > > if (drmIoctl(drm_fd, DRM_IOCTL_MODE_GETCRTC, &mode)) > > - return 0; > > + return false; > > > > if (!mode.mode_valid || mode.fb_id != fb) > > return false; > > > > ___ > > igt-dev mailing list > > igt-...@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/igt-dev > > Nice cleanup. Hope we can eventually convert kms_flip to igt_display at some > point for readability. Hi Petri and Maarten, First of all, thanks for your review and the clarification in the patch 4 (I really missed the ret = 0, thanks for highlight this case :) Maarten, could you give some extra details about the idea of converting kms_flip to igt_display? Could you point out some links or code reference? I'm just curious to know a little more about this subject. Best Regards Rodrigo Siqueira > For all except patch 4: > > Reviewed-by: Maarten Lankhorst > > :) > -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 16/17] drm/vkms: Convert to using __drm_atomic_helper_crtc_reset() for reset.
On 03/01, Maarten Lankhorst wrote: > Convert vkms to using __drm_atomic_helper_crtc_reset(), instead of > writing its own version. Instead of open coding destroy_state(), > call it directly for freeing the old state. > > Signed-off-by: Maarten Lankhorst > Cc: Rodrigo Siqueira > Cc: Haneen Mohammed > Cc: Daniel Vetter > --- > drivers/gpu/drm/vkms/vkms_crtc.c | 33 +--- > 1 file changed, 13 insertions(+), 20 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c > b/drivers/gpu/drm/vkms/vkms_crtc.c > index 8a9aeb0a9ea8..550888e72c96 100644 > --- a/drivers/gpu/drm/vkms/vkms_crtc.c > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c > @@ -83,26 +83,6 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, > unsigned int pipe, > return true; > } > > -static void vkms_atomic_crtc_reset(struct drm_crtc *crtc) > -{ > - struct vkms_crtc_state *vkms_state = NULL; > - > - if (crtc->state) { > - vkms_state = to_vkms_crtc_state(crtc->state); > - __drm_atomic_helper_crtc_destroy_state(crtc->state); > - kfree(vkms_state); > - crtc->state = NULL; > - } > - > - vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL); > - if (!vkms_state) > - return; > - INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle); > - > - crtc->state = &vkms_state->base; > - crtc->state->crtc = crtc; > -} > - > static struct drm_crtc_state * > vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc) > { > @@ -135,6 +115,19 @@ static void vkms_atomic_crtc_destroy_state(struct > drm_crtc *crtc, > } > } > > +static void vkms_atomic_crtc_reset(struct drm_crtc *crtc) > +{ > + struct vkms_crtc_state *vkms_state = > + kzalloc(sizeof(*vkms_state), GFP_KERNEL); > + > + if (crtc->state) > + vkms_atomic_crtc_destroy_state(crtc, crtc->state); > + > + __drm_atomic_helper_crtc_reset(crtc, &vkms_state->base); > + if (vkms_state) > + INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle); > +} > + > static const struct drm_crtc_funcs vkms_crtc_funcs = { > .set_config = drm_atomic_helper_set_config, > .destroy= drm_crtc_cleanup, > -- > 2.20.1 > Hi Maarten, First of all, thanks for the patch :) I tested it on my VM with the IGT test, and everything looks fine. Reviewed-by: Rodrigo Siqueira -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [RFC i-g-t] lib/igt_kms: Set capabilities before get resource
Hi, I was working on adding the writeback support to VKMS; as a result, I was using the Liviu’s patchset to validate my implementation [1]. However, I consistently failed to pass the requirements in igt_display_require(); more specifically, I couldn't pass this test: igt_skip("No KMS driver or no outputs, pipes: %d, outputs: %d\n", display->n_pipes, display->n_outputs); Next, I made a simple code that does the following three steps: 1. Open the device 2. Collect the resource information with drmModeGetResources() 3. Set writeback capability via drmSetClientCap() 4. Print the total of connectors I noticed that I could not get any connector as well; after some time debugging the issue and thanks to Anholt’s help in the dri-channel I learned that I had to use drmSetClientCap() before drmModeGetResources(). After move all drmSetClientCap() above drmModeGetResources(), my simple coded displayed the connector information. I did the same thing within igt_display_require(), and this test started to pass for me (I did it, in the Liviu’s patch). In this sense, I checked the igt_display_require() code in the master branch; and again, I noticed that capabilities are set after getting the resource information. Is that correct? Is it ok to call drmModeGetResources() before drmSetClientCap() in this case? P.s.: I sent it as a RFC because I’m not 100% sure about the change and the impacts on the tests. If it make sense, I can make a real patch. 1. https://patchwork.freedesktop.org/series/39229/ Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 7ebab4ca..2de9ac41 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1886,6 +1886,10 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->drm_fd = drm_fd; + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); + if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0) + display->is_atomic = 1; + resources = drmModeGetResources(display->drm_fd); if (!resources) goto out; @@ -1898,10 +1902,6 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes); igt_assert_f(display->pipes, "Failed to allocate memory for %d pipes\n", display->n_pipes); - drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); - if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0) - display->is_atomic = 1; - plane_resources = drmModeGetPlaneResources(display->drm_fd); igt_assert(plane_resources); -- 2.21.0 -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V5 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS V3: Add documentation (Daniel Vetter) V2: Add new branch coverage to check if VBlank is enabled or not and update commit message V1: Chris Wilson - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c| 20 lib/igt_kms.h| 2 ++ tests/kms_flip.c | 22 ++ 3 files changed, 44 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index e1eacc1e..1d2d7188 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1655,6 +1655,26 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility) igt_assert_eq(visible, visibility); } +/** + * kms_has_vblank: + * @fd: DRM fd + * + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: true if target driver has VBlank support, otherwise return false. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_NEXTONMISS; + + drmWaitVBlank(fd, &dummy_vbl); + return (errno != EOPNOTSUPP); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 407f3d64..1cc15eea 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility); +bool kms_has_vblank(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index dfa5a69e..614efc5b 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -71,6 +71,7 @@ #define TEST_SUSPEND (1 << 26) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -1177,6 +1190,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + int vblank = true; switch (crtc_count) { case RUN_TEST: @@ -1260,6 +1274,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]); -- 2.21.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH V5 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
On 03/18, Ville Syrjälä wrote: > On Sat, Mar 16, 2019 at 11:00:23AM -0300, Rodrigo Siqueira wrote: > > The kms_flip test relies on VBlank support, and this situation may > > exclude some virtual drivers to take advantage of this set of tests. > > This commit adds a mechanism that checks if a module has VBlank. If the > > target module has VBlank support, kms_flip will run all the VBlank > > tests; otherwise, the VBlank tests will be skipped. Additionally, this > > commit improves the test coverage by checks if the function > > drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). > > > > V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and > > DRM_VBLANK_NEXTONMISS > > > > V3: Add documentation (Daniel Vetter) > > > > V2: Add new branch coverage to check if VBlank is enabled or not and > > update commit message > > > > V1: Chris Wilson > > - Change function name from igt_there_is_vblank to kms_has_vblank > > - Move vblank function check from igt_aux to igt_kms > > - Utilizes memset in dummy_vbl variable > > - Directly return the result of drmWaitVBlank() > > > > Signed-off-by: Rodrigo Siqueira > > --- > > lib/igt_kms.c| 20 > > lib/igt_kms.h| 2 ++ > > tests/kms_flip.c | 22 ++ > > 3 files changed, 44 insertions(+) > > > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > > index e1eacc1e..1d2d7188 100644 > > --- a/lib/igt_kms.c > > +++ b/lib/igt_kms.c > > @@ -1655,6 +1655,26 @@ void igt_assert_plane_visible(int fd, enum pipe > > pipe, bool visibility) > > igt_assert_eq(visible, visibility); > > } > > > > +/** > > + * kms_has_vblank: > > + * @fd: DRM fd > > + * > > + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This > > + * function is useful for checking if a driver has support or not for > > VBlank. > > + * > > + * Returns: true if target driver has VBlank support, otherwise return > > false. > > + */ > > +bool kms_has_vblank(int fd) > > +{ > > + drmVBlank dummy_vbl; > > + > > + memset(&dummy_vbl, 0, sizeof(drmVBlank)); > > + dummy_vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_NEXTONMISS; > > Why the NEXTONMISS? I added this flag because I was suspecting that in case of any problem during the kms_has_vblank() execution the flag NEXTONMISS will wait for the next VBlank and avoid to generate problems in the subsequent tests. However, I was not 100% sure about this decision since this code will only test the first if condition inside drm_wait_vblank_ioctl(). Additionally, I could not find a good way to test the drmWaitVBlank() with and without this flag. Please, correct if I'm wrong. I'm fighting to understand the vblank API. Thanks for you review :) > > + > > + drmWaitVBlank(fd, &dummy_vbl); > > + return (errno != EOPNOTSUPP); > > +} > > + > > /* > > * A small modeset API > > */ > > diff --git a/lib/igt_kms.h b/lib/igt_kms.h > > index 407f3d64..1cc15eea 100644 > > --- a/lib/igt_kms.h > > +++ b/lib/igt_kms.h > > @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); > > unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); > > void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility); > > > > +bool kms_has_vblank(int fd); > > + > > /* > > * A small modeset API > > */ > > diff --git a/tests/kms_flip.c b/tests/kms_flip.c > > index dfa5a69e..614efc5b 100755 > > --- a/tests/kms_flip.c > > +++ b/tests/kms_flip.c > > @@ -71,6 +71,7 @@ > > #define TEST_SUSPEND (1 << 26) > > #define TEST_BO_TOOBIG (1 << 28) > > > > +#define TEST_NO_VBLANK (1 << 29) > > #define TEST_BASIC (1 << 30) > > > > #define EVENT_FLIP (1 << 0) > > @@ -126,6 +127,18 @@ struct event_state { > > int seq_step; > > }; > > > > +static bool vblank_dependence(int flags) > > +{ > > + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | > > + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | > > + TEST_CHECK_TS | TEST_VBLANK_RACE; > > + > > + if (flags & vblank_flags) > > + return true; > > + > > + return false; > > +} > > + > > static float timeval_float(const struct timeval *tv) > > { > > return tv->tv_sec + tv->tv_usec / 100.0f; > > @@ -117
Re: [Intel-gfx] [igt-dev] [PATCH V5 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
On 03/18, Chris Wilson wrote: > Quoting Rodrigo Siqueira (2019-03-18 21:35:44) > > On 03/18, Ville Syrjälä wrote: > > > On Sat, Mar 16, 2019 at 11:00:23AM -0300, Rodrigo Siqueira wrote: > > > > The kms_flip test relies on VBlank support, and this situation may > > > > exclude some virtual drivers to take advantage of this set of tests. > > > > This commit adds a mechanism that checks if a module has VBlank. If the > > > > target module has VBlank support, kms_flip will run all the VBlank > > > > tests; otherwise, the VBlank tests will be skipped. Additionally, this > > > > commit improves the test coverage by checks if the function > > > > drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). > > > > > > > > V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and > > > > DRM_VBLANK_NEXTONMISS > > > > > > > > V3: Add documentation (Daniel Vetter) > > > > > > > > V2: Add new branch coverage to check if VBlank is enabled or not and > > > > update commit message > > > > > > > > V1: Chris Wilson > > > > - Change function name from igt_there_is_vblank to kms_has_vblank > > > > - Move vblank function check from igt_aux to igt_kms > > > > - Utilizes memset in dummy_vbl variable > > > > - Directly return the result of drmWaitVBlank() > > > > > > > > Signed-off-by: Rodrigo Siqueira > > > > --- > > > > lib/igt_kms.c| 20 > > > > lib/igt_kms.h| 2 ++ > > > > tests/kms_flip.c | 22 ++ > > > > 3 files changed, 44 insertions(+) > > > > > > > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > > > > index e1eacc1e..1d2d7188 100644 > > > > --- a/lib/igt_kms.c > > > > +++ b/lib/igt_kms.c > > > > @@ -1655,6 +1655,26 @@ void igt_assert_plane_visible(int fd, enum pipe > > > > pipe, bool visibility) > > > > igt_assert_eq(visible, visibility); > > > > } > > > > > > > > +/** > > > > + * kms_has_vblank: > > > > + * @fd: DRM fd > > > > + * > > > > + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This > > > > + * function is useful for checking if a driver has support or not for > > > > VBlank. > > > > + * > > > > + * Returns: true if target driver has VBlank support, otherwise return > > > > false. > > > > + */ > > > > +bool kms_has_vblank(int fd) > > > > +{ > > > > + drmVBlank dummy_vbl; > > > > + > > > > + memset(&dummy_vbl, 0, sizeof(drmVBlank)); > > > > + dummy_vbl.request.type = DRM_VBLANK_RELATIVE | > > > > DRM_VBLANK_NEXTONMISS; > > > > > > Why the NEXTONMISS? > > > > I added this flag because I was suspecting that in case of any problem > > during the kms_has_vblank() execution the flag NEXTONMISS will wait for > > the next VBlank and avoid to generate problems in the subsequent tests. > > That is true, and a valid use for using NEXTONMISS if you want to align > your code to the start of a vblank to avoid overrunning into the next > vblank. > > However, that is not the purpose of kms_has_vblank()! Whose only purpose > is answer the question of whether the device has vblank support, and so > should be as quick and simple as possible, so the trivial query of the > current vblank counter. Nice! Thanks for your answer. So, I suppose that use DRM_VBLANK_RELATIVE is enough for this case, right? > -Chris -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v5 1/6] lib/igt_kms: Add writeback support
On 03/18, Liviu Dudau wrote: > On Wed, Mar 06, 2019 at 06:30:05PM -0300, Rodrigo Siqueira wrote: > > Hi Liviu, > > > > I’m using your patchset to guide my implementation of writeback in the > > VKMS, so, first of all, thanks :) > > > > During my work, I noticed that you’re setting the drmSetClientCap() > > before drmModeGetResources() which make the writeback capability > > before? I believe your patchset moves it to be before, which makes > sense, as the writeback applies to connectors, not planes (sorry for the > confusion, I think I wrote the code when we were toying with the idea > that writeback was going to be a plane property). > > > ‘invisible’ for drmModeGetResources(). I made the following change, and > > I could pass the igt_display_require(): > > > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > > index f4ff3a96..bb2d8e06 100644 > > --- a/lib/igt_kms.c > > +++ b/lib/igt_kms.c > > @@ -1912,6 +1912,12 @@ void igt_display_require(igt_display_t *display, int > > drm_fd) > > > > display->drm_fd = drm_fd; > > > > + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); > > + if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0) > > + display->is_atomic = 1; > > + > > + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); > > + > > resources = drmModeGetResources(display->drm_fd); > > if (!resources) > > goto out; > > @@ -1924,12 +1930,6 @@ void igt_display_require(igt_display_t *display, int > > drm_fd) > > display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes); > > igt_assert_f(display->pipes, "Failed to allocate memory for %d > > pipes\n", display->n_pipes); > > > > - drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); > > - if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0) > > - display->is_atomic = 1; > > - > > - drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); > > - > > plane_resources = drmModeGetPlaneResources(display->drm_fd); > > igt_assert(plane_resources); > > > > I'm not 100% confident about this issue, because of this I will send an > > RFC and see if I can get more details about this issue. > > It actually looks correct to me, so > > Acked-by: Liviu Dudau > > > > > Additionally, if you need any help with this patchset I will be glad to > > help since I’m using it \o/ > > Well, I need to send an updated version and if you could review that > then I can merge it into igt. Sure! I will be glad to take some time to review your code :) I can also try to test it on my current implementation of VKMS. One question, I have a NanoPc-T1 device [1] which has a Mali GPU, can I test the writeback feature in this device? All kind of Mali GPU has support for the writeback feature? 1. http://wiki.friendlyarm.com/wiki/index.php/NanoPC-T1 Thanks! Best Regards > Best regards, > Liviu > > > > > Best Regards > > Rodrigo Siqueira > > > > On 02/04, Brian Starkey wrote: > > > Hi Liviu, > > > > > > On Tue, Jan 15, 2019 at 05:47:42PM +, Liviu Dudau wrote: > > > > From: Brian Starkey > > > > > > [snip] > > > > > > > > > > > +/** > > > > + * igt_output_set_writeback_fb: > > > > + * @output: Target output > > > > + * @fb: Target framebuffer > > > > + * > > > > + * This function sets the given @fb to be used as the target > > > > framebuffer for the > > > > + * writeback engine at the next atomic commit. It will also request a > > > > writeback > > > > + * out fence that will contain the fd number of the out fence created > > > > by KMS if > > > > + * the given @fb is valid. > > > > + */ > > > > +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb > > > > *fb) > > > > +{ > > > > + igt_display_t *display = output->display; > > > > + > > > > + LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, > > > > fb ? fb->fb_id : 0); > > > > + > > > > + igt_output_set_prop_value(output, > > > > IGT_CONNECTOR_WRITEBACK_FB_ID, fb ? fb->fb_id : 0); > > > > + /* only request a writeback out fence if the framebuffer is > > > > valid
Re: [Intel-gfx] [igt-dev] [PATCH V5 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
On 03/18, Chris Wilson wrote: > Quoting Rodrigo Siqueira (2019-03-18 21:53:42) > > On 03/18, Chris Wilson wrote: > > > Quoting Rodrigo Siqueira (2019-03-18 21:35:44) > > > > On 03/18, Ville Syrjälä wrote: > > > > > On Sat, Mar 16, 2019 at 11:00:23AM -0300, Rodrigo Siqueira wrote: > > > > > > The kms_flip test relies on VBlank support, and this situation may > > > > > > exclude some virtual drivers to take advantage of this set of tests. > > > > > > This commit adds a mechanism that checks if a module has VBlank. If > > > > > > the > > > > > > target module has VBlank support, kms_flip will run all the VBlank > > > > > > tests; otherwise, the VBlank tests will be skipped. Additionally, > > > > > > this > > > > > > commit improves the test coverage by checks if the function > > > > > > drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). > > > > > > > > > > > > V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and > > > > > > DRM_VBLANK_NEXTONMISS > > > > > > > > > > > > V3: Add documentation (Daniel Vetter) > > > > > > > > > > > > V2: Add new branch coverage to check if VBlank is enabled or not and > > > > > > update commit message > > > > > > > > > > > > V1: Chris Wilson > > > > > > - Change function name from igt_there_is_vblank to kms_has_vblank > > > > > > - Move vblank function check from igt_aux to igt_kms > > > > > > - Utilizes memset in dummy_vbl variable > > > > > > - Directly return the result of drmWaitVBlank() > > > > > > > > > > > > Signed-off-by: Rodrigo Siqueira > > > > > > --- > > > > > > lib/igt_kms.c| 20 > > > > > > lib/igt_kms.h| 2 ++ > > > > > > tests/kms_flip.c | 22 ++ > > > > > > 3 files changed, 44 insertions(+) > > > > > > > > > > > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > > > > > > index e1eacc1e..1d2d7188 100644 > > > > > > --- a/lib/igt_kms.c > > > > > > +++ b/lib/igt_kms.c > > > > > > @@ -1655,6 +1655,26 @@ void igt_assert_plane_visible(int fd, enum > > > > > > pipe pipe, bool visibility) > > > > > > igt_assert_eq(visible, visibility); > > > > > > } > > > > > > > > > > > > +/** > > > > > > + * kms_has_vblank: > > > > > > + * @fd: DRM fd > > > > > > + * > > > > > > + * Get the VBlank errno after an attempt to call drmWaitVBlank(). > > > > > > This > > > > > > + * function is useful for checking if a driver has support or not > > > > > > for VBlank. > > > > > > + * > > > > > > + * Returns: true if target driver has VBlank support, otherwise > > > > > > return false. > > > > > > + */ > > > > > > +bool kms_has_vblank(int fd) > > > > > > +{ > > > > > > + drmVBlank dummy_vbl; > > > > > > + > > > > > > + memset(&dummy_vbl, 0, sizeof(drmVBlank)); > > > > > > + dummy_vbl.request.type = DRM_VBLANK_RELATIVE | > > > > > > DRM_VBLANK_NEXTONMISS; > > > > > > > > > > Why the NEXTONMISS? > > > > > > > > I added this flag because I was suspecting that in case of any problem > > > > during the kms_has_vblank() execution the flag NEXTONMISS will wait for > > > > the next VBlank and avoid to generate problems in the subsequent tests. > > > > > > That is true, and a valid use for using NEXTONMISS if you want to align > > > your code to the start of a vblank to avoid overrunning into the next > > > vblank. > > > > > > However, that is not the purpose of kms_has_vblank()! Whose only purpose > > > is answer the question of whether the device has vblank support, and so > > > should be as quick and simple as possible, so the trivial query of the > > > current vblank counter. > > > > Nice! Thanks for your answer. > > > > So, I suppose that use DRM_VBLANK_RELATIVE is enough for this case, > > right? > > Yes, that should return immediately both on success and on failure. > -Chris Thanks! I will prepare a v6 tomorrow -- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V6 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson) V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS V3: Add documentation (Daniel Vetter) V2: Add new branch coverage to check if VBlank is enabled or not and update commit message V1: Chris Wilson - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c| 20 lib/igt_kms.h| 2 ++ tests/kms_flip.c | 22 ++ 3 files changed, 44 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 43f45997..d3ab3684 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1660,6 +1660,26 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility) igt_assert_eq(visible, visibility); } +/** + * kms_has_vblank: + * @fd: DRM fd + * + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: true if target driver has VBlank support, otherwise return false. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; + + drmWaitVBlank(fd, &dummy_vbl); + return (errno != EOPNOTSUPP); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 407f3d64..1cc15eea 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -230,6 +230,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility); +bool kms_has_vblank(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 6ece1e53..ebd5c3a6 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -71,6 +71,7 @@ #define TEST_SUSPEND (1 << 26) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -1177,6 +1190,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + bool vblank = true; switch (crtc_count) { case RUN_TEST: @@ -1260,6 +1274,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]); -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V3 i-g-t] lib: Drop __kms_addfb() wrapper
Hi Chris, Thank you for your feedback and the explanation about igt_ioctl, now I've got it. On Mon, May 27, 2019 at 7:13 AM Chris Wilson wrote: > > Quoting Rodrigo Siqueira (2019-05-27 02:19:51) > > The function __kms_addfb() and drmModeAddFB2WithModifiers() have a > > similar code. Due to this similarity, this commit replaces all the > > occurrences of __kms_addfb() by drmModeAddFB2WithModifiers() and adds > > the required adaptations. > > No. There is a critical difference between the two: igt_ioctl. That > allows us to control the ioctl for error injection into the kernel. > > If you want to test libdrm API and not the kernel, please add tests > to libdrm. > -Chris -- Rodrigo Siqueira https://siqueira.tech ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V8 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
The kms_flip test relies on VBlank support, and this situation may exclude some virtual drivers to take advantage of this set of tests. This commit adds a mechanism that checks if a module has VBlank. If the target module has VBlank support, kms_flip will run all the VBlank tests; otherwise, the VBlank tests will be skipped. Additionally, this commit improves the test coverage by checks if the function drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). V7: Changes since V6 - Skip TEST_DPMS with TEST_MODESET and TEST_EBUSY if the device does not support vblank V6: Set errno to zero before call drmWaitVBlank() (Chris Wilson) V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson) V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and DRM_VBLANK_NEXTONMISS V3: Add documentation (Daniel Vetter) V2: Add new branch coverage to check if VBlank is enabled or not and update commit message V1: Chris Wilson - Change function name from igt_there_is_vblank to kms_has_vblank - Move vblank function check from igt_aux to igt_kms - Utilizes memset in dummy_vbl variable - Directly return the result of drmWaitVBlank() Signed-off-by: Rodrigo Siqueira --- lib/igt_kms.c| 21 + lib/igt_kms.h| 2 ++ tests/kms_flip.c | 24 +++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index d7d711a7..8a465f67 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1673,6 +1673,27 @@ void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visi igt_assert_eq(visible, visibility); } +/** + * kms_has_vblank: + * @fd: DRM fd + * + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This + * function is useful for checking if a driver has support or not for VBlank. + * + * Returns: true if target driver has VBlank support, otherwise return false. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; + + errno = 0; + drmWaitVBlank(fd, &dummy_vbl); + return (errno != EOPNOTSUPP); +} + /* * A small modeset API */ diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 4ac28131..5b5cf274 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -229,6 +229,8 @@ void kmstest_wait_for_pageflip(int fd); unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, bool visibility); +bool kms_has_vblank(int fd); + /* * A small modeset API */ diff --git a/tests/kms_flip.c b/tests/kms_flip.c index d7c1f9cf..2a158d97 100755 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -71,6 +71,7 @@ #define TEST_SUSPEND (1 << 26) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_CHECK_TS | TEST_VBLANK_RACE | TEST_EBUSY; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -494,7 +507,7 @@ static void check_state(const struct test_output *o, const struct event_state *e /* check only valid if no modeset happens in between, that increments by * (1 << 23) on each step. This bounding matches the one in * DRM_IOCTL_WAIT_VBLANK. */ - if (!(o->flags & (TEST_DPMS | TEST_MODESET))) + if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK))) igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23, "unexpected %s seq %u, should be >= %u\n", es->name, es->current_seq, es->last_seq + o->seq_step); @@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + bool vblank = true; switch (crtc_count) { case RUN_TEST: @@ -1259,6 +1273,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw
Re: [Intel-gfx] [PATCH V8 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank
On 06/06, Ser, Simon wrote: > On Tue, 2019-06-04 at 23:30 -0300, Rodrigo Siqueira wrote: > > The kms_flip test relies on VBlank support, and this situation may > > exclude some virtual drivers to take advantage of this set of tests. > > This commit adds a mechanism that checks if a module has VBlank. If the > > target module has VBlank support, kms_flip will run all the VBlank > > tests; otherwise, the VBlank tests will be skipped. Additionally, this > > commit improves the test coverage by checks if the function > > drmWaitVBlank() returns EOPNOTSUPP (i.e., no VBlank support). > > > > V7: Changes since V6 > > - Skip TEST_DPMS with TEST_MODESET and TEST_EBUSY if the device does > >not support vblank > > Hmm, I'm not sure I understand this line. If I'm reading this correctly > it refers to this line: > > if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK))) > > So the check was previously skipped on TEST_DPMS and TEST_MODESET. It's > now skipped on TEST_NO_VBLANK too. So I'm a little confused with the > changelog line: should it say "skip seq number checking it the device > doesn't support vblank"? > > Am I missing something? > > Apart from this, the patch itself looks good to me. Hi Simon, Thank you for your review. About the changelog message, I'll update it to: Skip seq number checking and busy flip if the device doesn't support vblank Can I add your Reviewed-by before applying this patch? > > V6: Set errno to zero before call drmWaitVBlank() (Chris Wilson) > > > > V5: Drop the DRM_VBLANK_NEXTONMISS (Chris Wilson) > > > > V4: Replace DRM_VBLANK_ABSOLUTE by DRM_VBLANK_RELATIVE and > > DRM_VBLANK_NEXTONMISS > > > > V3: Add documentation (Daniel Vetter) > > > > V2: Add new branch coverage to check if VBlank is enabled or not and > > update commit message > > > > V1: Chris Wilson > > - Change function name from igt_there_is_vblank to kms_has_vblank > > - Move vblank function check from igt_aux to igt_kms > > - Utilizes memset in dummy_vbl variable > > - Directly return the result of drmWaitVBlank() > > > > Signed-off-by: Rodrigo Siqueira > > --- > > lib/igt_kms.c| 21 + > > lib/igt_kms.h| 2 ++ > > tests/kms_flip.c | 24 +++- > > 3 files changed, 46 insertions(+), 1 deletion(-) > > > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > > index d7d711a7..8a465f67 100644 > > --- a/lib/igt_kms.c > > +++ b/lib/igt_kms.c > > @@ -1673,6 +1673,27 @@ void igt_assert_plane_visible(int fd, enum pipe > > pipe, int plane_index, bool visi > > igt_assert_eq(visible, visibility); > > } > > > > +/** > > + * kms_has_vblank: > > + * @fd: DRM fd > > + * > > + * Get the VBlank errno after an attempt to call drmWaitVBlank(). This > > + * function is useful for checking if a driver has support or not for > > VBlank. > > + * > > + * Returns: true if target driver has VBlank support, otherwise return > > false. > > + */ > > +bool kms_has_vblank(int fd) > > +{ > > + drmVBlank dummy_vbl; > > + > > + memset(&dummy_vbl, 0, sizeof(drmVBlank)); > > + dummy_vbl.request.type = DRM_VBLANK_RELATIVE; > > + > > + errno = 0; > > + drmWaitVBlank(fd, &dummy_vbl); > > + return (errno != EOPNOTSUPP); > > +} > > + > > /* > > * A small modeset API > > */ > > diff --git a/lib/igt_kms.h b/lib/igt_kms.h > > index 4ac28131..5b5cf274 100644 > > --- a/lib/igt_kms.h > > +++ b/lib/igt_kms.h > > @@ -229,6 +229,8 @@ void kmstest_wait_for_pageflip(int fd); > > unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags); > > void igt_assert_plane_visible(int fd, enum pipe pipe, int plane_index, > > bool visibility); > > > > +bool kms_has_vblank(int fd); > > + > > /* > > * A small modeset API > > */ > > diff --git a/tests/kms_flip.c b/tests/kms_flip.c > > index d7c1f9cf..2a158d97 100755 > > --- a/tests/kms_flip.c > > +++ b/tests/kms_flip.c > > @@ -71,6 +71,7 @@ > > #define TEST_SUSPEND (1 << 26) > > #define TEST_BO_TOOBIG (1 << 28) > > > > +#define TEST_NO_VBLANK (1 << 29) > > #define TEST_BASIC (1 << 30) > > > > #define EVENT_FLIP (1 << 0) > > @@ -126,6 +127,18 @@ struct event_state { > > int seq_step; > > }; > > > >
[Intel-gfx] [RESEND PATCH V3] drm/drm_vblank: Change EINVAL by the correct errno
For historical reason, the function drm_wait_vblank_ioctl always return -EINVAL if something gets wrong. This scenario limits the flexibility for the userspace make detailed verification of the problem and take some action. In particular, the validation of “if (!dev->irq_enabled)” in the drm_wait_vblank_ioctl is responsible for checking if the driver support vblank or not. If the driver does not support VBlank, the function drm_wait_vblank_ioctl returns EINVAL which does not represent the real issue; this patch changes this behavior by return EOPNOTSUPP. Additionally, some operations are unsupported by this function, and returns EINVAL; this patch also changes the return value to EOPNOTSUPP in this case. Lastly, the function drm_wait_vblank_ioctl is invoked by libdrm, which is used by many compositors; because of this, it is important to check if this change breaks any compositor. In this sense, the following projects were examined: * Drm-hwcomposer * Kwin * Sway * Wlroots * Wayland-core * Weston * Xorg (67 different drivers) For each repository the verification happened in three steps: * Update the main branch * Look for any occurrence "drmWaitVBlank" with the command: git grep -n "drmWaitVBlank" * Look in the git history of the project with the command: git log -SdrmWaitVBlank Finally, none of the above projects validate the use of EINVAL which make safe, at least for these projects, to change the return values. Change since V2: Daniel Vetter and Chris Wilson - Replace ENOTTY by EOPNOTSUPP - Return EINVAL if the parameters are wrong Signed-off-by: Rodrigo Siqueira --- Update: Now IGT has a way to validate if a driver has vblank support or not. See: https://gitlab.freedesktop.org/drm/igt-gpu-tools/commit/2d244aed69165753f3adbbd6468db073dc1acf9A drivers/gpu/drm/drm_vblank.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 0d704bddb1a6..d76a783a7d4b 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -1578,10 +1578,10 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, unsigned int flags, pipe, high_pipe; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & _DRM_VBLANK_SIGNAL) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK | -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V6 i-g-t 0/6] igt: Add support for testing writeback connectors
DRM already have writeback connectors support, which is a way to expose in DRM the hardware functionality from display engines that allows writing back into memory the result of the DE's composition of supported planes. These days, I'm working to add the writeback support into the vkms[1], and I used the kms_writeback to validate my implementation. As a result, I had to rebase the v5 version of Liviu's series, and I also fixed a small issue in the first path (lib/igt_kms: Add writeback support). Patches have been originally implemented by Brian, Liviu has done the v3 and v4 updates to them. I’m just sending a v6. 1. https://patchwork.freedesktop.org/series/61738/ Brian Starkey (6): lib/igt_kms: Add writeback support kms_writeback: Add initial writeback tests lib: Add function to hash a framebuffer kms_writeback: Add writeback-check-output lib/igt_kms: Add igt_output_clone_pipe for cloning kms_writeback: Add tests using a cloned output lib/igt_fb.c | 66 ++ lib/igt_fb.h | 3 + lib/igt_kms.c | 157 + lib/igt_kms.h | 10 + tests/Makefile.sources | 1 + tests/kms_writeback.c | 492 + tests/meson.build | 1 + 7 files changed, 692 insertions(+), 38 deletions(-) create mode 100644 tests/kms_writeback.c -- 2.21.0 -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] Drop use of DRM_WAIT_ON() [Was: drm/drm_vblank: Change EINVAL by the correct errno]
Hi Sam, I tested it by using VKMS and kms_flip, and tests related to “vblank” fails (e.g., basic-flip-vs-wf_vblank, blocking-absolute-wf_vblank, flip-vs-absolute-wf_vblank, etc). I tried to dig into this issue, and you can see my comments inline: On Thu, Jun 13, 2019 at 2:04 AM Sam Ravnborg wrote: > > Hi Rodrigo. > > On Wed, Jun 12, 2019 at 11:10:54PM -0300, Rodrigo Siqueira wrote: > > For historical reason, the function drm_wait_vblank_ioctl always return > > -EINVAL if something gets wrong. This scenario limits the flexibility > > for the userspace make detailed verification of the problem and take > > some action. In particular, the validation of “if (!dev->irq_enabled)” > > in the drm_wait_vblank_ioctl is responsible for checking if the driver > > support vblank or not. If the driver does not support VBlank, the > > function drm_wait_vblank_ioctl returns EINVAL which does not represent > > the real issue; this patch changes this behavior by return EOPNOTSUPP. > > Additionally, some operations are unsupported by this function, and > > returns EINVAL; this patch also changes the return value to EOPNOTSUPP > > in this case. Lastly, the function drm_wait_vblank_ioctl is invoked by > > libdrm, which is used by many compositors; because of this, it is > > important to check if this change breaks any compositor. In this sense, > > the following projects were examined: > > > > * Drm-hwcomposer > > * Kwin > > * Sway > > * Wlroots > > * Wayland-core > > * Weston > > * Xorg (67 different drivers) > > > > For each repository the verification happened in three steps: > > > > * Update the main branch > > * Look for any occurrence "drmWaitVBlank" with the command: > > git grep -n "drmWaitVBlank" > > * Look in the git history of the project with the command: > > git log -SdrmWaitVBlank > > > > Finally, none of the above projects validate the use of EINVAL which > > make safe, at least for these projects, to change the return values. > > > > Change since V2: > > Daniel Vetter and Chris Wilson > > - Replace ENOTTY by EOPNOTSUPP > > - Return EINVAL if the parameters are wrong > > > > Signed-off-by: Rodrigo Siqueira > > --- > > Update: > > Now IGT has a way to validate if a driver has vblank support or not. > > See: > > https://gitlab.freedesktop.org/drm/igt-gpu-tools/commit/2d244aed69165753f3adbbd6468db073dc1acf9A > > > > drivers/gpu/drm/drm_vblank.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > > index 0d704bddb1a6..d76a783a7d4b 100644 > > --- a/drivers/gpu/drm/drm_vblank.c > > +++ b/drivers/gpu/drm/drm_vblank.c > > @@ -1578,10 +1578,10 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, > > void *data, > > unsigned int flags, pipe, high_pipe; > > > > if (!dev->irq_enabled) > > - return -EINVAL; > > + return -EOPNOTSUPP; > > > > if (vblwait->request.type & _DRM_VBLANK_SIGNAL) > > - return -EINVAL; > > + return -EOPNOTSUPP; > > > > if (vblwait->request.type & > > ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK | > > When touching this function, could I ask you to take a look at > eliminating the use of DRM_WAIT_ON()? > It comes from the deprecated drm_os_linux.h header, and it is only of > the few remaining users of DRM_WAIT_ON(). > > Below you can find my untested first try - where I did an attempt not to > change behaviour. > > Sam > > commit 17b119b02467356198b57bca9949b146082bcaa1 > Author: Sam Ravnborg > Date: Thu May 30 09:38:47 2019 +0200 > > drm/vblank: drop use of DRM_WAIT_ON() > > DRM_WAIT_ON() is from the deprecated drm_os_linux header and > the modern replacement is the wait_event_*. > > The return values differ, so a conversion is needed to > keep the original interface towards userspace. > Introduced a switch/case to make code obvious and to allow > different debug prints depending on the result. > > The timeout value of 3 * HZ was translated to 30 msec > > Signed-off-by: Sam Ravnborg > Cc: Maarten Lankhorst > Cc: Maxime Ripard > Cc: Sean Paul > Cc: David Airlie > Cc: Daniel Vetter > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > index 0d704bddb1a6..51fc6b106333 100644 > --- a/drivers/gpu/drm/drm_vblank.c > +++
Re: [Intel-gfx] [PATCH V6 i-g-t 1/6] lib/igt_kms: Add writeback support
-1; > > + } > > } > > > > /* > > @@ -3447,6 +3471,16 @@ display_commit_changed(igt_display_t *display, enum > > igt_commit_style s) > > else > > /* no modeset in universal commit, no change to crtc. > > */ > > output->changed &= 1 << IGT_CONNECTOR_CRTC_ID; > > + > > + if (s == COMMIT_ATOMIC) { > > + if (igt_output_is_prop_changed(output, > > IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) > > + igt_assert(output->writeback_out_fence_fd >= > > 0); > > + > > + output->values[IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] > > = 0; > > + output->values[IGT_CONNECTOR_WRITEBACK_FB_ID] = 0; > > + igt_output_clear_prop_changed(output, > > IGT_CONNECTOR_WRITEBACK_FB_ID); > > + igt_output_clear_prop_changed(output, > > IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); > > + } > > } > > > > if (display->first_commit) { > > @@ -4119,6 +4153,29 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe) > > igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, > > (ptrdiff_t)&pipe->out_fence_fd); > > } > > > > +/** > > + * igt_output_set_writeback_fb: > > + * @output: Target output > > + * @fb: Target framebuffer > > + * > > + * This function sets the given @fb to be used as the target framebuffer > > for the > > + * writeback engine at the next atomic commit. It will also request a > > writeback > > + * out fence that will contain the fd number of the out fence created by > > KMS if > > + * the given @fb is valid. > > + */ > > +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb) > > +{ > > + igt_display_t *display = output->display; > > + > > + LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, fb ? > > fb->fb_id : 0); > > + > > + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb ? > > fb->fb_id : 0); > > + /* only request a writeback out fence if the framebuffer is valid */ > > + if (fb) > > + igt_output_set_prop_value(output, > > IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, > > + > > (ptrdiff_t)&output->writeback_out_fence_fd); > > +} > > + > > /** > > * igt_wait_for_vblank_count: > > * @drm_fd: A drm file descriptor > > diff --git a/lib/igt_kms.h b/lib/igt_kms.h > > index a448a003..cacc6b90 100644 > > --- a/lib/igt_kms.h > > +++ b/lib/igt_kms.h > > @@ -123,6 +123,9 @@ enum igt_atomic_connector_properties { > > IGT_CONNECTOR_BROADCAST_RGB, > > IGT_CONNECTOR_CONTENT_PROTECTION, > > IGT_CONNECTOR_VRR_CAPABLE, > > + IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS, > > + IGT_CONNECTOR_WRITEBACK_FB_ID, > > + IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, > > IGT_NUM_CONNECTOR_PROPS > > }; > > > > @@ -364,6 +367,8 @@ typedef struct { > > bool use_override_mode; > > drmModeModeInfo override_mode; > > > > + int32_t writeback_out_fence_fd; > > + > > /* bitmask of changed properties */ > > uint64_t changed; > > > > @@ -414,6 +419,7 @@ igt_plane_t > > *igt_output_get_plane_type_index(igt_output_t *output, > > igt_output_t *igt_output_from_connector(igt_display_t *display, > > drmModeConnector *connector); > > const drmModeModeInfo *igt_std_1024_mode_get(void); > > +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb); > > > > igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type); > > int igt_pipe_count_plane_type(igt_pipe_t *pipe, int plane_type); > > -- > > 2.21.0 > > > > > > -- > > Rodrigo Siqueira > > https://siqueira.tech > > > > -- > > | I would like to | > | fix the world, | > | but they're not | > | giving me the | > \ source code! / > --- > ¯\_(ツ)_/¯ -- Rodrigo Siqueira https://siqueira.tech ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V4] drm/drm_vblank: Change EINVAL by the correct errno
For historical reason, the function drm_wait_vblank_ioctl always return -EINVAL if something gets wrong. This scenario limits the flexibility for the userspace make detailed verification of the problem and take some action. In particular, the validation of “if (!dev->irq_enabled)” in the drm_wait_vblank_ioctl is responsible for checking if the driver support vblank or not. If the driver does not support VBlank, the function drm_wait_vblank_ioctl returns EINVAL which does not represent the real issue; this patch changes this behavior by return EOPNOTSUPP. Additionally, some operations are unsupported by this function, and returns EINVAL; this patch also changes the return value to EOPNOTSUPP in this case. Lastly, the function drm_wait_vblank_ioctl is invoked by libdrm, which is used by many compositors; because of this, it is important to check if this change breaks any compositor. In this sense, the following projects were examined: * Drm-hwcomposer * Kwin * Sway * Wlroots * Wayland-core * Weston * Xorg (67 different drivers) For each repository the verification happened in three steps: * Update the main branch * Look for any occurrence "drmWaitVBlank" with the command: git grep -n "drmWaitVBlank" * Look in the git history of the project with the command: git log -SdrmWaitVBlank Finally, none of the above projects validate the use of EINVAL which make safe, at least for these projects, to change the return values. Change since V3: - Return EINVAL for _DRM_VBLANK_SIGNAL (Daniel) Change since V2: Daniel Vetter and Chris Wilson - Replace ENOTTY by EOPNOTSUPP - Return EINVAL if the parameters are wrong Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 603ab105125d..bed233361614 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -1582,7 +1582,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, unsigned int flags, pipe, high_pipe; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & _DRM_VBLANK_SIGNAL) return -EINVAL; -- 2.21.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V4] drm/drm_vblank: Change EINVAL by the correct errno
On 06/19, Daniel Vetter wrote: > On Wed, Jun 19, 2019 at 09:48:56AM +0200, Daniel Vetter wrote: > > On Tue, Jun 18, 2019 at 11:07:50PM -0300, Rodrigo Siqueira wrote: > > > For historical reason, the function drm_wait_vblank_ioctl always return > > > -EINVAL if something gets wrong. This scenario limits the flexibility > > > for the userspace make detailed verification of the problem and take > > > some action. In particular, the validation of “if (!dev->irq_enabled)” > > > in the drm_wait_vblank_ioctl is responsible for checking if the driver > > > support vblank or not. If the driver does not support VBlank, the > > > function drm_wait_vblank_ioctl returns EINVAL which does not represent > > > the real issue; this patch changes this behavior by return EOPNOTSUPP. > > > Additionally, some operations are unsupported by this function, and > > > returns EINVAL; this patch also changes the return value to EOPNOTSUPP > > > in this case. Lastly, the function drm_wait_vblank_ioctl is invoked by > > > libdrm, which is used by many compositors; because of this, it is > > > important to check if this change breaks any compositor. In this sense, > > > the following projects were examined: > > > > > > * Drm-hwcomposer > > > * Kwin > > > * Sway > > > * Wlroots > > > * Wayland-core > > > * Weston > > > * Xorg (67 different drivers) > > > > > > For each repository the verification happened in three steps: > > > > > > * Update the main branch > > > * Look for any occurrence "drmWaitVBlank" with the command: > > > git grep -n "drmWaitVBlank" > > > * Look in the git history of the project with the command: > > > git log -SdrmWaitVBlank > > > > > > Finally, none of the above projects validate the use of EINVAL which > > > make safe, at least for these projects, to change the return values. > > > > > > Change since V3: > > > - Return EINVAL for _DRM_VBLANK_SIGNAL (Daniel) > > > > > > Change since V2: > > > Daniel Vetter and Chris Wilson > > > - Replace ENOTTY by EOPNOTSUPP > > > - Return EINVAL if the parameters are wrong > > > > > > > Reviewed-by: Daniel Vetter > > > > Apologies for the confusion on the last time around. btw if someone tells > > you "r-b (or a-b) with these changes", then just apply the r-b/a-b tag > > next time around. Otherwise people will re-review the same thing over and > > over again. > > btw when resending patches it's good practice to add anyone who commented > on it (or who commented on the igt test for the same patch and other way > round) onto the explicit Cc: list of the patch. That way it's easier for > them to follow the patch evolution and do a quick r-b once they're happy. Thanks for these valuable tips. Do you think that is a good idea to resend this patch CC's everybody? Or is it ok if I just apply it? > If you don't do that then much bigger chances your patch gets ignored. > -Daniel > > > > > Signed-off-by: Rodrigo Siqueira > > > --- > > > drivers/gpu/drm/drm_vblank.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > > > index 603ab105125d..bed233361614 100644 > > > --- a/drivers/gpu/drm/drm_vblank.c > > > +++ b/drivers/gpu/drm/drm_vblank.c > > > @@ -1582,7 +1582,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, > > > void *data, > > > unsigned int flags, pipe, high_pipe; > > > > > > if (!dev->irq_enabled) > > > - return -EINVAL; > > > + return -EOPNOTSUPP; > > > > > > if (vblwait->request.type & _DRM_VBLANK_SIGNAL) > > > return -EINVAL; > > > -- > > > 2.21.0 > > > > -- > > Daniel Vetter > > Software Engineer, Intel Corporation > > http://blog.ffwll.ch > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V4] drm/drm_vblank: Change EINVAL by the correct errno
On Wed, Jun 26, 2019 at 4:53 AM Daniel Vetter wrote: > > On Wed, Jun 26, 2019 at 4:00 AM Rodrigo Siqueira > wrote: > > > > On 06/19, Daniel Vetter wrote: > > > On Wed, Jun 19, 2019 at 09:48:56AM +0200, Daniel Vetter wrote: > > > > On Tue, Jun 18, 2019 at 11:07:50PM -0300, Rodrigo Siqueira wrote: > > > > > For historical reason, the function drm_wait_vblank_ioctl always > > > > > return > > > > > -EINVAL if something gets wrong. This scenario limits the flexibility > > > > > for the userspace make detailed verification of the problem and take > > > > > some action. In particular, the validation of “if (!dev->irq_enabled)” > > > > > in the drm_wait_vblank_ioctl is responsible for checking if the driver > > > > > support vblank or not. If the driver does not support VBlank, the > > > > > function drm_wait_vblank_ioctl returns EINVAL which does not represent > > > > > the real issue; this patch changes this behavior by return EOPNOTSUPP. > > > > > Additionally, some operations are unsupported by this function, and > > > > > returns EINVAL; this patch also changes the return value to EOPNOTSUPP > > > > > in this case. Lastly, the function drm_wait_vblank_ioctl is invoked by > > > > > libdrm, which is used by many compositors; because of this, it is > > > > > important to check if this change breaks any compositor. In this > > > > > sense, > > > > > the following projects were examined: > > > > > > > > > > * Drm-hwcomposer > > > > > * Kwin > > > > > * Sway > > > > > * Wlroots > > > > > * Wayland-core > > > > > * Weston > > > > > * Xorg (67 different drivers) > > > > > > > > > > For each repository the verification happened in three steps: > > > > > > > > > > * Update the main branch > > > > > * Look for any occurrence "drmWaitVBlank" with the command: > > > > > git grep -n "drmWaitVBlank" > > > > > * Look in the git history of the project with the command: > > > > > git log -SdrmWaitVBlank > > > > > > > > > > Finally, none of the above projects validate the use of EINVAL which > > > > > make safe, at least for these projects, to change the return values. > > > > > > > > > > Change since V3: > > > > > - Return EINVAL for _DRM_VBLANK_SIGNAL (Daniel) > > > > > > > > > > Change since V2: > > > > > Daniel Vetter and Chris Wilson > > > > > - Replace ENOTTY by EOPNOTSUPP > > > > > - Return EINVAL if the parameters are wrong > > > > > > > > > > > > > Reviewed-by: Daniel Vetter > > > > > > > > Apologies for the confusion on the last time around. btw if someone > > > > tells > > > > you "r-b (or a-b) with these changes", then just apply the r-b/a-b tag > > > > next time around. Otherwise people will re-review the same thing over > > > > and > > > > over again. > > > > > > btw when resending patches it's good practice to add anyone who commented > > > on it (or who commented on the igt test for the same patch and other way > > > round) onto the explicit Cc: list of the patch. That way it's easier for > > > them to follow the patch evolution and do a quick r-b once they're happy. > > > > Thanks for these valuable tips. > > Do you think that is a good idea to resend this patch CC's everybody? Or > > is it ok if I just apply it? > > Hm I thought I answered that on irc ... but just today I realized that > we missed 2 ioctls. There's also drm_crtc_get_sequence_ioctl and > drm_crtc_queue_sequence_ioctl which have the same dev->irq_enabled > check and I think should be treated the same. Hi, I reexamined all the composers described in the commit message (latest versions) to check if any project use and validate the return value from drm_crtc_get_sequence_ioctl and drm_crtc_queue_sequence_ioctl. I noticed that mesa and xserver use them. FWIU replace EINVAL by EOPNOTSUPP is harmless for mesa project, however it is not the same for xserver. Take a look at line 189 and 238 of hw/xfree86/drivers/modesetting/vblank.c * https://gitlab.freedesktop.org/xorg/xserver/blob/master/hw/xfree86/drivers/modesetting/vblank.c#L238 * https://gitlab.freedesktop.org/xorg/xserver/blob/master/h
[Intel-gfx] [PATCH V5] drm/drm_vblank: Change EINVAL by the correct errno
For historical reasons, the function drm_wait_vblank_ioctl always return -EINVAL if something gets wrong. This scenario limits the flexibility for the userspace to make detailed verification of any problem and take some action. In particular, the validation of “if (!dev->irq_enabled)” in the drm_wait_vblank_ioctl is responsible for checking if the driver support vblank or not. If the driver does not support VBlank, the function drm_wait_vblank_ioctl returns EINVAL, which does not represent the real issue; this patch changes this behavior by return EOPNOTSUPP. Additionally, drm_crtc_get_sequence_ioctl and drm_crtc_queue_sequence_ioctl, also returns EINVAL if vblank is not supported; this patch also changes the return value to EOPNOTSUPP in these functions. Lastly, these functions are invoked by libdrm, which is used by many compositors; because of this, it is important to check if this change breaks any compositor. In this sense, the following projects were examined: * Drm-hwcomposer * Kwin * Sway * Wlroots * Wayland-core * Weston * Xorg (67 different drivers) For each repository the verification happened in three steps: * Update the main branch * Look for any occurrence of "drmCrtcQueueSequence", "drmCrtcGetSequence", and "drmWaitVBlank" with the command git grep -n "STRING". * Look in the git history of the project with the command git log -S None of the above projects validate the use of EINVAL when using drmWaitVBlank(), which make safe, at least for these projects, to change the return values. On the other hand, mesa and xserver project uses drmCrtcQueueSequence() and drmCrtcGetSequence(); this change is harmless for both projects. Change since V4 (Daniel): - Also return EOPNOTSUPP in drm_crtc_[get|queue]_sequence_ioctl Change since V3: - Return EINVAL for _DRM_VBLANK_SIGNAL (Daniel) Change since V2: Daniel Vetter and Chris Wilson - Replace ENOTTY by EOPNOTSUPP - Return EINVAL if the parameters are wrong Cc: Keith Packard Cc: Maarten Lankhorst Cc: Ville Syrjälä Cc: Chris Wilson Cc: Daniel Vetter Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/drm_vblank.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 603ab105125d..bd4ac834d3ef 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -1582,7 +1582,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, unsigned int flags, pipe, high_pipe; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & _DRM_VBLANK_SIGNAL) return -EINVAL; @@ -1823,7 +1823,7 @@ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data, return -EOPNOTSUPP; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; crtc = drm_crtc_find(dev, file_priv, get_seq->crtc_id); if (!crtc) @@ -1881,7 +1881,7 @@ int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data, return -EOPNOTSUPP; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; crtc = drm_crtc_find(dev, file_priv, queue_seq->crtc_id); if (!crtc) -- 2.21.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH] drm/vkms: prime import support
Hi Oleg, First of all, thank you for your patch and for working in this issue. A few comments inline. On Thu, Jul 4, 2019 at 5:54 AM Oleg Vasilev wrote: > > Bring dmabuf sharing through implementing prime_import_sg_table callback. > This will help to validate userspace conformance in prime configurations > without using any actual hardware (e.g. in the cloud). > > Cc: Rodrigo Siqueira > Cc: Haneen Mohammed > Cc: Daniel Vetter > Signed-off-by: Oleg Vasilev > --- > drivers/gpu/drm/vkms/vkms_drv.c | 6 + > drivers/gpu/drm/vkms/vkms_drv.h | 9 +++ > drivers/gpu/drm/vkms/vkms_gem.c | 46 + > 3 files changed, 61 insertions(+) > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c > index cc53ef88a331..b71c16d9ca09 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.c > +++ b/drivers/gpu/drm/vkms/vkms_drv.c > @@ -10,6 +10,7 @@ > */ > > #include > +#include Maybe I missed something, but I think you don't need to add this include here since you already included it on vkms_gem. > #include > #include > #include > @@ -96,6 +97,8 @@ static struct drm_driver vkms_driver = { > .gem_vm_ops = &vkms_gem_vm_ops, > .gem_free_object_unlocked = vkms_gem_free_object, > .get_vblank_timestamp = vkms_get_vblank_timestamp, > + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, > + .gem_prime_import_sg_table = vkms_prime_import_sg_table, > > .name = DRIVER_NAME, > .desc = DRIVER_DESC, > @@ -147,6 +150,9 @@ static int __init vkms_init(void) > > ret = drm_dev_init(&vkms_device->drm, &vkms_driver, >&vkms_device->platform->dev); > + > + dma_coerce_mask_and_coherent(vkms_device->drm.dev, > +DMA_BIT_MASK(64)); How about capture the return value from dma_coerce_mask_and_coherent() and warn the user if something wrong happened? Something like: ret = dma_coerce_mask_and_coherent(..); if (ret) DRM_WARN("Failed to set dma mask"); Additionally, I would like to suggest you move this code above drm_dev_init() since there's a return validation of ret in the below if. > if (ret) > goto out_unregister; > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h > index 12b4db7ac641..fb15101c8f3e 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.h > +++ b/drivers/gpu/drm/vkms/vkms_drv.h > @@ -126,6 +126,9 @@ struct drm_gem_object *vkms_gem_create(struct drm_device > *dev, >u32 *handle, >u64 size); > > +struct vkms_gem_object *vkms_gem_create_private(struct drm_device *dev, > + u64 size); > + > vm_fault_t vkms_gem_fault(struct vm_fault *vmf); > > int vkms_dumb_create(struct drm_file *file, struct drm_device *dev, > @@ -137,6 +140,12 @@ int vkms_gem_vmap(struct drm_gem_object *obj); > > void vkms_gem_vunmap(struct drm_gem_object *obj); > > +/* Prime */ > +struct drm_gem_object * > +vkms_prime_import_sg_table(struct drm_device *dev, > + struct dma_buf_attachment *attach, > + struct sg_table *sg); > + > /* CRC Support */ > const char *const *vkms_get_crc_sources(struct drm_crtc *crtc, > size_t *count); > diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c > index 69048e73377d..a1b837460f63 100644 > --- a/drivers/gpu/drm/vkms/vkms_gem.c > +++ b/drivers/gpu/drm/vkms/vkms_gem.c > @@ -1,5 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0+ > > +#include > #include > > #include "vkms_drv.h" > @@ -117,6 +118,25 @@ struct drm_gem_object *vkms_gem_create(struct drm_device > *dev, > return &obj->gem; > } > > +struct vkms_gem_object *vkms_gem_create_private(struct drm_device *dev, > + u64 size) > +{ I did not fully get the idea behind this function in this patch, and it looks like this function is never invoked. Am I right or I missed something? > + struct vkms_gem_object *obj; > + > + obj = kzalloc(sizeof(*obj), GFP_KERNEL); > + > + if (!obj) > + return ERR_PTR(-ENOMEM); > + > + size = roundup(size, PAGE_SIZE); > + > + drm_gem_private_object_init(dev, &obj->gem, size); Please, correct if I'm wrong, I'm trying to understand where this function should be placed and when it is invoked. If I correctly understoo
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 1/6] lib/igt_kms: Add writeback support
On Wed, Jul 3, 2019 at 9:15 AM Ser, Simon wrote: > > On Tue, 2019-06-18 at 18:56 -0300, Rodrigo Siqueira wrote: > > On Thu, Jun 13, 2019 at 11:54 AM Liviu Dudau wrote: > > > On Wed, Jun 12, 2019 at 11:16:02PM -0300, Brian Starkey wrote: > > > > Add support in igt_kms for writeback connectors, with the ability > > > > to attach framebuffers. > > > > > > > > v5: Rebase and add DRM_CLIENT_CAP_WRITEBACK_CONNECTORS before > > > > drmModeGetResources() > > > > > > Reviewed-by: Liviu Dudau > > > > > > Thanks for updating this! Given that I have done the last changes and > > > this is > > > mostly a refresh, not sure if I should add more Reviewed-by's to the other > > > patches. > > > > Thanks Liviu! > > > > I just forgot to add my SoB, and for some reason, gmail does not allow > > me to send an email on someone behalf. > > FWIW, that's a good thing, and it's required to pass DMARC checks. > > Instead, git-send-email should add a From line at the beginning of the > message when sending a patch on behalf of someone else. I wonder what > happened here. Thank you for your help. I’m using neomutt for sending patches, and I’ll take a look at git-send-email. Additionally, it looks like Gmail requires that I add a new account in order to allow me to send patches on someone behalf. I’ll take some time to read about this issue, and I will try to resend the patchset again. Btw, if you have time, could you take a look in this series? Best regards > > Btw, I can fix it after > > everybody agrees that the kms_writeback is ready for landing. > > > > > > > Best regards, > > > Liviu > > > > > > > Signed-off-by: Brian Starkey > > > > [rebased and updated to the latest igt style] > > > > Signed-off-by: Liviu Dudau > > > > --- > > > > lib/igt_kms.c | 57 +++ > > > > lib/igt_kms.h | 6 ++ > > > > 2 files changed, 63 insertions(+) > > > > > > > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > > > > index da188a39..140db346 100644 > > > > --- a/lib/igt_kms.c > > > > +++ b/lib/igt_kms.c > > > > @@ -325,6 +325,9 @@ const char * const > > > > igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { > > > > [IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB", > > > > [IGT_CONNECTOR_CONTENT_PROTECTION] = "Content Protection", > > > > [IGT_CONNECTOR_VRR_CAPABLE] = "vrr_capable", > > > > + [IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS] = > > > > "WRITEBACK_PIXEL_FORMATS", > > > > + [IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID", > > > > + [IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = > > > > "WRITEBACK_OUT_FENCE_PTR", > > > > }; > > > > > > > > /* > > > > @@ -557,6 +560,7 @@ static const struct type_name > > > > connector_type_names[] = { > > > > { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, > > > > { DRM_MODE_CONNECTOR_DSI, "DSI" }, > > > > { DRM_MODE_CONNECTOR_DPI, "DPI" }, > > > > + { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" }, > > > > {} > > > > }; > > > > > > > > @@ -1889,6 +1893,12 @@ static void igt_output_reset(igt_output_t > > > > *output) > > > > if (igt_output_has_prop(output, IGT_CONNECTOR_BROADCAST_RGB)) > > > > igt_output_set_prop_value(output, > > > > IGT_CONNECTOR_BROADCAST_RGB, > > > > BROADCAST_RGB_FULL); > > > > + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID)) > > > > + igt_output_set_prop_value(output, > > > > IGT_CONNECTOR_WRITEBACK_FB_ID, 0); > > > > + if (igt_output_has_prop(output, > > > > IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) { > > > > + igt_output_clear_prop_changed(output, > > > > IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); > > > > + output->writeback_out_fence_fd = -1; > > > > + } > > > > } > > > > > > > > /** > > > > @@ -1901,6 +1911,8 @@ static void igt_output_reset(igt_output_t *output) > > > > * For outputs: > > > > * - %IGT_CONNECTOR_C
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 1/6] lib/igt_kms: Add writeback support
On Tue, Jul 9, 2019 at 11:42 AM Ser, Simon wrote: > > On Tue, 2019-07-09 at 11:32 -0300, Rodrigo Siqueira wrote: > > On Wed, Jul 3, 2019 at 9:15 AM Ser, Simon wrote: > > > On Tue, 2019-06-18 at 18:56 -0300, Rodrigo Siqueira wrote: > > > > On Thu, Jun 13, 2019 at 11:54 AM Liviu Dudau > > > > wrote: > > > > > On Wed, Jun 12, 2019 at 11:16:02PM -0300, Brian Starkey wrote: > > > > > > Add support in igt_kms for writeback connectors, with the ability > > > > > > to attach framebuffers. > > > > > > > > > > > > v5: Rebase and add DRM_CLIENT_CAP_WRITEBACK_CONNECTORS before > > > > > > drmModeGetResources() > > > > > > > > > > Reviewed-by: Liviu Dudau > > > > > > > > > > Thanks for updating this! Given that I have done the last changes and > > > > > this is > > > > > mostly a refresh, not sure if I should add more Reviewed-by's to the > > > > > other > > > > > patches. > > > > > > > > Thanks Liviu! > > > > > > > > I just forgot to add my SoB, and for some reason, gmail does not allow > > > > me to send an email on someone behalf. > > > > > > FWIW, that's a good thing, and it's required to pass DMARC checks. > > > > > > Instead, git-send-email should add a From line at the beginning of the > > > message when sending a patch on behalf of someone else. I wonder what > > > happened here. > > > > Thank you for your help. > > > > I’m using neomutt for sending patches, and I’ll take a look at > > git-send-email. Additionally, it looks like Gmail requires that I add > > a new account in order to allow me to send patches on someone behalf. > > I’ll take some time to read about this issue, and I will try to resend > > the patchset again. > > When sending a patch on someone else's behalf, you shouldn't send the > e-mail with the sender (From header) set to someone else. You should > use your normal address. The From line in the body of the message will > make Git understand the author is someone else. > > So no new account setup required. > > I really recommend using git-send-email for patches. There are too many > ways to make a mistake if you try sending emails manually. Here is a > tutorial: > https://git-send-email.io/ Thank you very much for the tutorial! I'll read it and prepare to migrate from 'neomutt -H' to git-send-mail. > > Btw, if you have time, could you take a look in this series? > > Sure, I've already began looking at the series. I'll continue soon. Thank you again for your help. > Thanks for your work! > > > Best regards > > > > > > Btw, I can fix it after > > > > everybody agrees that the kms_writeback is ready for landing. > > > > > > > > > > > > > Best regards, > > > > > Liviu > > > > > > > > > > > Signed-off-by: Brian Starkey > > > > > > [rebased and updated to the latest igt style] > > > > > > Signed-off-by: Liviu Dudau > > > > > > --- > > > > > > lib/igt_kms.c | 57 > > > > > > +++ > > > > > > lib/igt_kms.h | 6 ++ > > > > > > 2 files changed, 63 insertions(+) > > > > > > > > > > > > diff --git a/lib/igt_kms.c b/lib/igt_kms.c > > > > > > index da188a39..140db346 100644 > > > > > > --- a/lib/igt_kms.c > > > > > > +++ b/lib/igt_kms.c > > > > > > @@ -325,6 +325,9 @@ const char * const > > > > > > igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { > > > > > > [IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB", > > > > > > [IGT_CONNECTOR_CONTENT_PROTECTION] = "Content Protection", > > > > > > [IGT_CONNECTOR_VRR_CAPABLE] = "vrr_capable", > > > > > > + [IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS] = > > > > > > "WRITEBACK_PIXEL_FORMATS", > > > > > > + [IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID", > > > > > > + [IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = > > > > > > "WRITEBACK_OUT_FENCE_PTR", > > > > > > }; > > > > > > > > > > > > /* > > > > >
[Intel-gfx] [PATCH V6] drm/drm_vblank: Change EINVAL by the correct errno
For historical reasons, the function drm_wait_vblank_ioctl always return -EINVAL if something gets wrong. This scenario limits the flexibility for the userspace to make detailed verification of any problem and take some action. In particular, the validation of “if (!dev->irq_enabled)” in the drm_wait_vblank_ioctl is responsible for checking if the driver support vblank or not. If the driver does not support VBlank, the function drm_wait_vblank_ioctl returns EINVAL, which does not represent the real issue; this patch changes this behavior by return EOPNOTSUPP. Additionally, drm_crtc_get_sequence_ioctl and drm_crtc_queue_sequence_ioctl, also returns EINVAL if vblank is not supported; this patch also changes the return value to EOPNOTSUPP in these functions. Lastly, these functions are invoked by libdrm, which is used by many compositors; because of this, it is important to check if this change breaks any compositor. In this sense, the following projects were examined: * Drm-hwcomposer * Kwin * Sway * Wlroots * Wayland * Weston * Mutter * Xorg (67 different drivers) For each repository the verification happened in three steps: * Update the main branch * Look for any occurrence of "drmCrtcQueueSequence", "drmCrtcGetSequence", and "drmWaitVBlank" with the command git grep -n "STRING". * Look in the git history of the project with the command git log -S None of the above projects validate the use of EINVAL when using drmWaitVBlank(), which make safe, at least for these projects, to change the return values. On the other hand, mesa and xserver project uses drmCrtcQueueSequence() and drmCrtcGetSequence(); this change is harmless for both projects. Change since V5 (Pekka Paalanen): - Check if the change also affects Mutter Change since V4 (Daniel): - Also return EOPNOTSUPP in drm_crtc_[get|queue]_sequence_ioctl Change since V3: - Return EINVAL for _DRM_VBLANK_SIGNAL (Daniel) Change since V2: Daniel Vetter and Chris Wilson - Replace ENOTTY by EOPNOTSUPP - Return EINVAL if the parameters are wrong Cc: Keith Packard Cc: Maarten Lankhorst Cc: Ville Syrjälä Cc: Chris Wilson Cc: Daniel Vetter Cc: Pekka Paalanen Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/drm_vblank.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 9c6899758bc9..71cf2633ac58 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -1610,7 +1610,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, unsigned int flags, pipe, high_pipe; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & _DRM_VBLANK_SIGNAL) return -EINVAL; @@ -1876,7 +1876,7 @@ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data, return -EOPNOTSUPP; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; crtc = drm_crtc_find(dev, file_priv, get_seq->crtc_id); if (!crtc) @@ -1934,7 +1934,7 @@ int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data, return -EOPNOTSUPP; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; crtc = drm_crtc_find(dev, file_priv, queue_seq->crtc_id); if (!crtc) -- 2.23.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v7 i-g-t 0/4] Add support for testing writeback connectors
Hi, A couple of months ago, I updated and re-submitted a patchset made by Brian Starkey and Liviu Dudau for adding a writeback connectors test to IGT. It is important to highlight that DRM already have writeback connectors support, which is a way to expose in DRM the hardware functionality from display engines that allows writing back into memory the result of the DE's composition of supported planes. After I resubmitted the patchset, Simon Ser provides a long and detailed review for all of the patches (thanks Simon). As a result, I finally had time to go through all the details and prepare this new version. Follows some notes: 1. Patchset author Brian Starkey is the original author of this patchset, and I'm just trying to upstream his changes. Note that during this patch submission, the mail server from google going to overwrite Brian's mail by mine; this happens on the mail server side for avoiding malicious users to send emails as someone else. Note that I could spend time figuring out how to fix it, but I think this is not worth since I can fix it during the merge process (if it got accepted). 2. Drop the clone commits from the series After Simon's review, we decided to drop the last two patches of the original series since it was related to cloning output, and VKMS does not support it yet. However, after we finish with this series, I can try to take a look at this feature or maybe propose it as a GSoC/Outreachy project. 3. Changes Most of the changes happened in the second patch. Thanks Brian Starkey (4): lib/igt_kms: Add writeback support kms_writeback: Add initial writeback tests lib: Add function to hash a framebuffer kms_writeback: Add writeback-check-output lib/igt_fb.c | 68 +++ lib/igt_fb.h | 2 + lib/igt_kms.c | 59 ++ lib/igt_kms.h | 6 + tests/Makefile.sources | 1 + tests/kms_writeback.c | 413 + tests/meson.build | 1 + 7 files changed, 550 insertions(+) create mode 100644 tests/kms_writeback.c -- 2.23.0 signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 19/21] drm/vkms: Convert to CRTC VBLANK callbacks
Hi, Thanks for the patch, I reviewed and tested it. Everything looks fine for VKMS. Reviewed-by: Rodrigo Siqueira Tested-by: Rodrigo Siqueira On 01/15, Thomas Zimmermann wrote: > VBLANK callbacks in struct drm_driver are deprecated in favor of > their equivalents in struct drm_crtc_funcs. Convert vkms over. > > Signed-off-by: Thomas Zimmermann > --- > drivers/gpu/drm/vkms/vkms_crtc.c | 9 ++--- > drivers/gpu/drm/vkms/vkms_drv.c | 1 - > drivers/gpu/drm/vkms/vkms_drv.h | 4 > 3 files changed, 6 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c > b/drivers/gpu/drm/vkms/vkms_crtc.c > index 74f703b8d22a..ac85e17428f8 100644 > --- a/drivers/gpu/drm/vkms/vkms_crtc.c > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c > @@ -76,10 +76,12 @@ static void vkms_disable_vblank(struct drm_crtc *crtc) > hrtimer_cancel(&out->vblank_hrtimer); > } > > -bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, > -int *max_error, ktime_t *vblank_time, > -bool in_vblank_irq) > +static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, > + int *max_error, ktime_t *vblank_time, > + bool in_vblank_irq) > { > + struct drm_device *dev = crtc->dev; > + unsigned int pipe = crtc->index; > struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); > struct vkms_output *output = &vkmsdev->output; > struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; > @@ -154,6 +156,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = { > .atomic_destroy_state = vkms_atomic_crtc_destroy_state, > .enable_vblank = vkms_enable_vblank, > .disable_vblank = vkms_disable_vblank, > + .get_vblank_timestamp = vkms_get_vblank_timestamp, > .get_crc_sources= vkms_get_crc_sources, > .set_crc_source = vkms_set_crc_source, > .verify_crc_source = vkms_verify_crc_source, > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c > index 25bd7519295f..860de052e820 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.c > +++ b/drivers/gpu/drm/vkms/vkms_drv.c > @@ -103,7 +103,6 @@ static struct drm_driver vkms_driver = { > .dumb_create= vkms_dumb_create, > .gem_vm_ops = &vkms_gem_vm_ops, > .gem_free_object_unlocked = vkms_gem_free_object, > - .get_vblank_timestamp = vkms_get_vblank_timestamp, > .prime_fd_to_handle = drm_gem_prime_fd_to_handle, > .gem_prime_import_sg_table = vkms_prime_import_sg_table, > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h > index 7d52e24564db..eda04ffba7b1 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.h > +++ b/drivers/gpu/drm/vkms/vkms_drv.h > @@ -111,10 +111,6 @@ struct vkms_gem_object { > int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, > struct drm_plane *primary, struct drm_plane *cursor); > > -bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, > -int *max_error, ktime_t *vblank_time, > - bool in_vblank_irq); > - > int vkms_output_init(struct vkms_device *vkmsdev, int index); > > struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, > -- > 2.24.1 > -- Rodrigo Siqueira Software Engineer, Advanced Micro Devices (AMD) https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v7 i-g-t 3/4] lib: Add function to hash a framebuffer
Hi Maxime, First of all, thank you a lot for your review and for testing this patchset. I'm going to prepare a new version trying to address all issues highlight by you, Petri, and Simon (I'm already working in a new version). Just a note, I run this test on top of VKMS in a virtual machine (x86). Best Regards On 04/15, Maxime Ripard wrote: > Hi Rodrigo, > > I gave your (and Brian's) patches on a RPi, and there's a couple of > things that need to be fixed. > > On Mon, Oct 21, 2019 at 10:00:00PM -0300, Brian Starkey wrote: > > To use writeback buffers as a CRC source, we need to be able to hash > > them. Implement a simple FVA-1a hashing routine for this purpose. > > > > Doing a bytewise hash on the framebuffer directly can be very slow if > > the memory is noncached. By making a copy of each line in the FB first > > (which can take advantage of word-access speedup), we can do the hash > > on a cached copy, which is much faster (10x speedup on my platform). > > > > V6: Simon Sir > > - Replace #define by plain uint32_t variables > > - Return -EINVAL in case fb->num_planes != 1 > > - Directly assign the mmap result to ptr > > - No need to copy the whole stride, just copy fb->width * cpp since > > we're only going to read that > > > > v5: use igt_memcpy_from_wc() instead of plain memcpy, as suggested by > > Chris Wilson > > > > Signed-off-by: Brian Starkey > > [rebased and updated to the most recent API] > > Signed-off-by: Liviu Dudau > > [rebased and updated the patch to address feedback] > > Signed-off-by: Rodrigo Siqueira > > Reviewed-by: Simon Ser > > --- > > lib/igt_fb.c | 68 > > lib/igt_fb.h | 2 ++ > > 2 files changed, 70 insertions(+) > > > > diff --git a/lib/igt_fb.c b/lib/igt_fb.c > > index 6b674c1b..64d52634 100644 > > --- a/lib/igt_fb.c > > +++ b/lib/igt_fb.c > > @@ -3491,6 +3491,74 @@ bool igt_fb_supported_format(uint32_t drm_format) > > return false; > > } > > > > +/* > > + * This implements the FNV-1a hashing algorithm instead of CRC, for > > + * simplicity > > + * http://www.isthe.com/chongo/tech/comp/fnv/index.html > > + * > > + * hash = offset_basis > > + * for each octet_of_data to be hashed > > + * hash = hash xor octet_of_data > > + * hash = hash * FNV_prime > > + * return hash > > + * > > + * 32 bit offset_basis = 2166136261 > > + * 32 bit FNV_prime = 224 + 28 + 0x93 = 16777619 > > + */ > > +int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc) > > +{ > > + uint32_t FNV1a_OFFSET_BIAS = 2166136261; > > + uint32_t FNV1a_PRIME = 16777619; > > + uint32_t hash; > > + void *map; > > + char *ptr, *line = NULL; > > + int x, y, cpp = igt_drm_format_to_bpp(fb->drm_format) / 8; > > + uint32_t stride = calc_plane_stride(fb, 0); > > + > > + 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); > > You should be using igt_fb_map_buffer here > > > + /* > > +* Framebuffers are often uncached, which can make byte-wise accesses > > +* very slow. We copy each line of the FB into a local buffer to speed > > +* up the hashing. > > +*/ > > + line = malloc(stride); > > + if (!line) { > > + munmap(map, fb->size); > > + return -ENOMEM; > > + } > > + > > + hash = FNV1a_OFFSET_BIAS; > > + > > + for (y = 0; y < fb->height; y++, ptr += stride) { > > + > > + igt_memcpy_from_wc(line, ptr, fb->width * cpp); > > + > > + for (x = 0; x < fb->width * cpp; x++) { > > + hash ^= line[x]; > > + hash *= FNV1a_PRIME; > > + } > > + } > > + > > + crc->n_words = 1; > > + crc->crc[0] = hash; > > + > > + free(line); > > + munmap(map, fb->size); > > And this will lead to a segfault here, since map has not been > initialized. I'm assuming the intention is to have map be the returned > value of mmap, and ptr to be initialized to that same value, and use > that as your current line pointer later on (the error path from the > malloc has the same issue). > > Maxime -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v7 i-g-t 4/4] kms_writeback: Add writeback-check-output
On 04/15, Maxime Ripard wrote: > Hi! > > On Mon, Oct 21, 2019 at 10:00:39PM -0300, Brian Starkey wrote: > > 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 > > > > Signed-off-by: Brian Starkey > > [rebased and updated the patch to address feedback] > > Signed-off-by: Rodrigo Siqueira > > --- > > tests/kms_writeback.c | 123 ++ > > 1 file changed, 123 insertions(+) > > > > diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c > > index a373ec4d..068595b9 100644 > > --- a/tests/kms_writeback.c > > +++ b/tests/kms_writeback.c > > @@ -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_t > > igt_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]); > > +} > > + > > 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. 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 > Maxime -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v7 i-g-t 4/4] kms_writeback: Add writeback-check-output
On 04/22, Maxime Ripard wrote: > Hi! > > On Tue, Apr 21, 2020 at 05:07:05PM -0400, Rodrigo Siqueira wrote: > > On 04/15, Maxime Ripard wrote: > > > On Mon, Oct 21, 2019 at 10:00:39PM -0300, Brian Starkey wrote: > > > > 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 > > > > > > > > Signed-off-by: Brian Starkey > > > > [rebased and updated the patch to address feedback] > > > > Signed-off-by: Rodrigo Siqueira > > > > --- > > > > tests/kms_writeback.c | 123 ++ > > > > 1 file changed, 123 insertions(+) > > > > > > > > diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c > > > > index a373ec4d..068595b9 100644 > > > > --- a/tests/kms_writeback.c > > > > +++ b/tests/kms_writeback.c > > > > @@ -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_t > > > > igt_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]); > > > > +} > > > > + > > > > > > 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. > > > > 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 > Maxime > diff --git a/lib/igt_fb.c b/lib/igt_fb.c > index 97a656c8..be825220 100644 > --- a/lib/igt_fb.c > +++ b/lib/igt_fb.c > @@ -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 > diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c > index 068595b9..c2ee05dd 100644 > --- a/tests/kms_writeback.c > +++ b/tests/kms_writeback.c > @@ -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_fen
[Intel-gfx] [PATCH i-g-t v8 0/4] Add support for testing writeback connectors
Hi, A couple of months ago, I updated and re-submitted a patchset made by Brian Starkey and Liviu Dudau for adding a writeback connectors test to IGT. It is important to highlight that DRM already have writeback connectors support, which is a way to expose in DRM the hardware functionality from display engines that allows writing back into memory the result of the DE's composition of supported planes. After I resubmitted the patchset, Simon Ser provides a long and detailed review for all of the patches (thanks Simon). Additionally, Maxime Ripard tested the previous series in an ARM32 architecture and provided his feedback for making this patchset portable (thanks Maxime). I finally had time to go through all the details and prepare this new version. Follows some notes: 1. Patchset author Brian Starkey is the original author of this patchset, and I'm just trying to upstream his changes. Note that during this patch submission, the mail server from google going to overwrite Brian's mail by mine; this happens on the mail server side for avoiding malicious users to send emails as someone else. Note that I could spend time figuring out how to fix it, but I think this is not worth since I can fix it during the merge process (if it got accepted). 2. Drop the clone commits from the series After Simon's review, we decided to drop the last two patches of the original series since it was related to cloning output, and VKMS does not support it yet. However, after we finish with this series, I can try to take a look at this feature or maybe propose it as a GSoC/Outreachy project. Most of the changes happened in the second patch. 3. Cross-platform improvements Thanks Brian Starkey (4): lib/igt_kms: Add writeback support kms_writeback: Add initial writeback tests lib: Add function to hash a framebuffer kms_writeback: Add writeback-check-output lib/igt_fb.c | 63 ++ lib/igt_fb.h | 2 + lib/igt_kms.c | 57 ++ lib/igt_kms.h | 6 + tests/Makefile.sources | 1 + tests/kms_writeback.c | 443 + tests/meson.build | 1 + 7 files changed, 573 insertions(+) create mode 100644 tests/kms_writeback.c -- 2.26.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t v8 1/4] lib/igt_kms: Add writeback support
From: Brian Starkey Add support in igt_kms for writeback connectors, with the ability to attach framebuffers. v5: Rebase and add DRM_CLIENT_CAP_WRITEBACK_CONNECTORS before drmModeGetResources() Signed-off-by: Brian Starkey [rebased and updated to the latest igt style] Signed-off-by: Liviu Dudau [rebased and updated to the latest igt style] Signed-off-by: Rodrigo Siqueira Reviewed-by: Liviu Dudau Reviewed-by: Simon Ser --- lib/igt_kms.c | 57 +++ lib/igt_kms.h | 6 ++ 2 files changed, 63 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index e9621e7e..67053d8b 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -421,6 +421,9 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { [IGT_CONNECTOR_LINK_STATUS] = "link-status", [IGT_CONNECTOR_MAX_BPC] = "max bpc", [IGT_CONNECTOR_HDR_OUTPUT_METADATA] = "HDR_OUTPUT_METADATA", + [IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS] = "WRITEBACK_PIXEL_FORMATS", + [IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID", + [IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = "WRITEBACK_OUT_FENCE_PTR", }; /* @@ -653,6 +656,7 @@ static const struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, { DRM_MODE_CONNECTOR_DPI, "DPI" }, + { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" }, {} }; @@ -1802,6 +1806,14 @@ static void igt_output_reset(igt_output_t *output) if (igt_output_has_prop(output, IGT_CONNECTOR_HDR_OUTPUT_METADATA)) igt_output_set_prop_value(output, IGT_CONNECTOR_HDR_OUTPUT_METADATA, 0); + + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID)) + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, 0); + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) { + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + output->writeback_out_fence_fd = -1; + } + } /** @@ -1885,6 +1897,8 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->drm_fd = drm_fd; + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); + resources = drmModeGetResources(display->drm_fd); if (!resources) goto out; @@ -2193,6 +2207,11 @@ static void igt_output_fini(igt_output_t *output) kmstest_free_connector_config(&output->config); free(output->name); output->name = NULL; + + if (output->writeback_out_fence_fd != -1) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } } /** @@ -3255,6 +3274,11 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto output->props[i], output->values[i])); } + + if (output->writeback_out_fence_fd != -1) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } } /* @@ -3377,6 +3401,16 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s) else /* no modeset in universal commit, no change to crtc. */ output->changed &= 1 << IGT_CONNECTOR_CRTC_ID; + + if (s == COMMIT_ATOMIC) { + if (igt_output_is_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) + igt_assert(output->writeback_out_fence_fd >= 0); + + output->values[IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = 0; + output->values[IGT_CONNECTOR_WRITEBACK_FB_ID] = 0; + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_FB_ID); + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + } } if (display->first_commit) { @@ -4049,6 +4083,29 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe) igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)&pipe->out_fence_fd); } +/** + * igt_output_set_writeback_fb: + * @output: Target output + * @fb: Target framebuffer + * + * This function sets the given @fb to be used as the target framebuffer for the + * writeback engine at the next atomic commit. It will also request a writeback + * out fence that will contain the fd number of the out fence created by KMS if + * the given @fb is valid. + */ +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb) +{ +
[Intel-gfx] [PATCH i-g-t v8 4/4] kms_writeback: Add writeback-check-output
From: 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. Changes since V7 (Maxime Ripard): * Make fb_fill cross-platform Changes since v6 (Simon Ser): * Add a descriptive error message if sync_fence_wait fail * Drop color_idx variable * Compute expected CRC based on input framebuffer in writeback_sequence * Remove unnecessary parentheses * Replace int variable for unsigned int Signed-off-by: Brian Starkey [rebased and updated] Signed-off-by: Rodrigo Siqueira Reviewed-by: Liviu Dudau --- tests/kms_writeback.c | 127 ++ 1 file changed, 127 insertions(+) diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c index e08eb611..bba1fb01 100644 --- a/tests/kms_writeback.c +++ b/tests/kms_writeback.c @@ -30,6 +30,7 @@ #include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output) { @@ -217,6 +218,118 @@ static void writeback_fb_id(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t * igt_assert(ret == 0); } +static void fill_fb(igt_fb_t *fb, uint32_t pixel) +{ + void *ptr; + + igt_assert(fb->drm_format == DRM_FORMAT_XRGB); + + 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) +{ + 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 = 0; + uint32_t in_fb_colors[2] = { 0x, 0xff00ff00 }; + uint32_t clear_color = 0x; + + 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_fnv1a_crc(in_fb, &out_expected); + fill_fb(out_fbs[i], clear_color); + + if (i == 0) + igt_fb_get_fnv1a_crc(out_fbs[i], &cleared_crc); + igt_fb_get_fnv1a_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_fnv1a_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_fnv1a_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(o
[Intel-gfx] [PATCH i-g-t v8 2/4] kms_writeback: Add initial writeback tests
From: Brian Starkey Add tests for the WRITEBACK_PIXEL_FORMATS, WRITEBACK_OUT_FENCE_PTR and WRITEBACK_FB_ID properties on writeback connectors, ensuring their behaviour is correct. Changes since V7 (Maxime Ripard and Petri Latvala): * Utilizes `to_user_pointer` to avoid cast compilation error on ARM 32 bits. Changes since V6 (Simon Ser): * Add igt_describe per sub-test * Remove kmstest_force_connector from kms_writeback_get_output, since userspace will not do this sort of operation * Add an igt_debug statement in case we don't use a specific writeback connector * Drop flag parameter from do_writeback_test * Rename invalid_out_fence to test_invalid_parameters * Drop invalid_fb from writeback_fb_id * Assert if plane is null on igt_fixture * Replace all occurrences of igt_fb_mod_to_tiling(0) by DRM_FORMAT_MOD_LINEAR * Rename invalid_fb to invalid_output_fb in the sub-test related to "writeback-invalid-out-fence" * Replace ret by fb_id in igt_main Reviewed-by: Liviu Dudau Signed-off-by: Brian Starkey [rebased and updated do_writeback_test() function to address feedback] Signed-off-by: Liviu Dudau Signed-off-by: Rodrigo Siqueira --- tests/Makefile.sources | 1 + tests/kms_writeback.c | 316 + tests/meson.build | 1 + 3 files changed, 318 insertions(+) create mode 100644 tests/kms_writeback.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 32cbbf4f..3e7afa4d 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -86,6 +86,7 @@ TESTS_progs = \ kms_universal_plane \ kms_vblank \ kms_vrr \ + kms_writeback \ meta_test \ perf \ perf_pmu \ diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c new file mode 100644 index ..e08eb611 --- /dev/null +++ b/tests/kms_writeback.c @@ -0,0 +1,316 @@ +/* + * (C) COPYRIGHT 2017 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include +#include +#include +#include + +#include "igt.h" +#include "igt_core.h" +#include "igt_fb.h" + +static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output) +{ + drmModePropertyBlobRes *blob = NULL; + uint64_t blob_id; + int ret; + + ret = kmstest_get_property(output->display->drm_fd, + output->config.connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, + igt_connector_prop_names[IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS], + NULL, &blob_id, NULL); + if (ret) + blob = drmModeGetPropertyBlob(output->display->drm_fd, blob_id); + + igt_assert(blob); + + return blob; +} + +static bool check_writeback_config(igt_display_t *display, igt_output_t *output) +{ + igt_fb_t input_fb, output_fb; + igt_plane_t *plane; + uint32_t writeback_format = DRM_FORMAT_XRGB; + uint64_t tiling = DRM_FORMAT_MOD_LINEAR; + int width, height, ret; + drmModeModeInfo override_mode = { + .clock = 25175, + .hdisplay = 640, + .hsync_start = 656, + .hsync_end = 752, + .htotal = 800, + .hskew = 0, + .vdisplay = 480, + .vsync_start = 490, + .vsync_end = 492, + .vtotal = 525, + .vscan = 0, + .vrefresh = 60, + .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, + .name = {"640x480-60"}, + }; + igt_output_override_mode(output, &override_mode); + + width = override_mode.hdisplay; + height = override_mode.vdisplay; + + ret = igt_create_fb(
[Intel-gfx] [PATCH i-g-t v8 3/4] lib: Add function to hash a framebuffer
From: Brian Starkey To use writeback buffers as a CRC source, we need to be able to hash them. Implement a simple FVA-1a hashing routine for this purpose. Doing a bytewise hash on the framebuffer directly can be very slow if the memory is noncached. By making a copy of each line in the FB first (which can take advantage of word-access speedup), we can do the hash on a cached copy, which is much faster (10x speedup on my platform). Changes since V7 (Maxime Ripard): * Maxime Ripard: - Replace `gem_mmap__gtt` by `igt_fb_map_buffer` on `igt_fb_get_crc()` * Rodrigo Siqueira: - Rename igt_fb_get_crc to igt_fb_get_fnv1a_crc Changes since V6 (Simon Ser): * Use plain uint32_t for FNV1a_OFFSET_BIAS and FNV1a_PRIME * Return -EINVAL in case fb->num_planes != 1 * Just copy fb->width * cpp instead of copy the whole stride v5: use igt_memcpy_from_wc() instead of plain memcpy, as suggested by Chris Wilson Signed-off-by: Brian Starkey [rebased and updated to the most recent API] Signed-off-by: Liviu Dudau [rebased and updated] Signed-off-by: Rodrigo Siqueira Reviewed-by: Simon Ser Reviewed-by: Liviu Dudau --- lib/igt_fb.c | 63 lib/igt_fb.h | 2 ++ 2 files changed, 65 insertions(+) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 5ed586e7..562206b1 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -3785,6 +3785,69 @@ bool igt_fb_supported_format(uint32_t drm_format) return true; } +/* + * This implements the FNV-1a hashing algorithm instead of CRC, for + * simplicity + * http://www.isthe.com/chongo/tech/comp/fnv/index.html + * + * hash = offset_basis + * for each octet_of_data to be hashed + * hash = hash xor octet_of_data + * hash = hash * FNV_prime + * return hash + * + * 32 bit offset_basis = 2166136261 + * 32 bit FNV_prime = 224 + 28 + 0x93 = 16777619 + */ +int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc) +{ + const uint32_t FNV1a_OFFSET_BIAS = 2166136261; + const uint32_t FNV1a_PRIME = 16777619; + uint32_t hash; + void *map; + char *ptr, *line = NULL; + int x, y, cpp = igt_drm_format_to_bpp(fb->drm_format) / 8; + uint32_t stride = calc_plane_stride(fb, 0); + + if (fb->num_planes != 1) + return -EINVAL; + + ptr = igt_fb_map_buffer(fb->fd, fb); + igt_assert(ptr); + map = ptr; + + /* +* Framebuffers are often uncached, which can make byte-wise accesses +* very slow. We copy each line of the FB into a local buffer to speed +* up the hashing. +*/ + line = malloc(stride); + if (!line) { + munmap(map, fb->size); + return -ENOMEM; + } + + hash = FNV1a_OFFSET_BIAS; + + for (y = 0; y < fb->height; y++, ptr += stride) { + + igt_memcpy_from_wc(line, ptr, fb->width * cpp); + + for (x = 0; x < fb->width * cpp; x++) { + hash ^= line[x]; + hash *= FNV1a_PRIME; + } + } + + crc->n_words = 1; + crc->crc[0] = hash; + + free(line); + igt_fb_unmap_buffer(fb, map); + + return 0; +} + /** * igt_format_is_yuv: * @drm_format: drm fourcc diff --git a/lib/igt_fb.h b/lib/igt_fb.h index 587f7a44..4221d8b9 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -207,5 +207,7 @@ int igt_format_plane_bpp(uint32_t drm_format, int plane); void igt_format_array_fill(uint32_t **formats_array, unsigned int *count, bool allow_yuv); +int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc); + #endif /* __IGT_FB_H__ */ -- 2.26.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 2/6] kms_writeback: Add initial writeback tests
output = kms_writeback_get_output(&display); > > + igt_require(output); > > + > > + if (output->use_override_mode) > > + memcpy(&mode, &output->override_mode, sizeof(mode)); > > + else > > + memcpy(&mode, &output->config.default_mode, > > sizeof(mode)); > > + > > + plane = igt_output_get_plane_type(output, > > DRM_PLANE_TYPE_PRIMARY); > > + igt_require(plane); > > Maybe we can assert on this? > > > + ret = igt_create_fb(display.drm_fd, mode.hdisplay, > > + mode.vdisplay, > > + DRM_FORMAT_XRGB, > > + igt_fb_mod_to_tiling(0), > > This is supposed to take a modifier. DRM_FORMAT_MOD_LINEAR would be > better to make this clear. > > (Applies to other lines of this patch) > > > + &input_fb); > > + igt_assert(ret >= 0); > > + igt_plane_set_fb(plane, &input_fb); > > + } > > + > > + igt_subtest("writeback-pixel-formats") { > > + drmModePropertyBlobRes *formats_blob = > > get_writeback_formats_blob(output); > > Need to drmModeFreePropertyBlob this. > > > + const char *valid_chars = "0123456 ABCGNRUVXY"; > > + unsigned int i; > > + char *c; > > + > > + /* > > +* We don't have a comprehensive list of formats, so just check > > +* that the blob length is sensible and that it doesn't contain > > +* any outlandish characters > > +*/ > > + igt_assert(!(formats_blob->length % 4)); > > + c = formats_blob->data; > > + for (i = 0; i < formats_blob->length; i++) > > + igt_assert_f(strchr(valid_chars, c[i]), > > +"Unexpected character %c\n", c[i]); > > Honestly, I'm not a fan of this check. There's no guarantee that fourcc > codes will be made from ASCII characters, in fact some formats already > have non-printable chars in them. I don't want to have to update this > test when a new fourcc format is added. > > We currently don't have a test for IN_FORMATS. If we really want to > check formats, we could have a big array of known formats and add a > bool is_valid_format(uint32_t fmt) function. Agree with you. How about remove this test? Thanks Best Regards > > + } > > + > > + igt_subtest("writeback-invalid-out-fence") { > > + igt_fb_t invalid_fb; > > invalid_output_fb would be a better name IMHO. > > > + ret = igt_create_fb(display.drm_fd, mode.hdisplay / 2, > > + mode.vdisplay / 2, > > + DRM_FORMAT_XRGB, > > + igt_fb_mod_to_tiling(0), > > + &invalid_fb); > > + igt_require(ret > 0); > > We should probably use a different variable: ret is signed, > igt_create_fb isn't. Also ret doesn't make it clear that the return > value is the KMS framebuffer ID. > > (Applies to other subtests) > > > + invalid_out_fence(output, &input_fb, &invalid_fb); > > (Still not sure why we provide the input FB to this function.) > > > + igt_remove_fb(display.drm_fd, &invalid_fb); > > + } > > + > > + igt_subtest("writeback-fb-id") { > > + igt_fb_t output_fb; > > + ret = igt_create_fb(display.drm_fd, mode.hdisplay, > > mode.vdisplay, > > + DRM_FORMAT_XRGB, > > + igt_fb_mod_to_tiling(0), > > + &output_fb); > > + igt_require(ret > 0); > > + > > + writeback_fb_id(output, &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); > > + } > > +} > > diff --git a/tests/meson.build b/tests/meson.build > > index f168fbba..9c77cfcd 100644 > > --- a/tests/meson.build > > +++ b/tests/meson.build > > @@ -63,6 +63,7 @@ test_progs = [ > > 'kms_universal_plane', > > 'kms_vblank', > > 'kms_vrr', > > + 'kms_writeback', > > 'meta_test', > > 'panfrost_get_param', > > 'panfrost_gem_new', > > ___ > > igt-dev mailing list > > igt-...@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/igt-dev -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 3/6] lib: Add function to hash a framebuffer
SET_BIAS > > > +#undef FNV1a_PRIME > > > +} > > > + > > > /** > > > * igt_format_is_yuv: > > > * @drm_format: drm fourcc > > > diff --git a/lib/igt_fb.h b/lib/igt_fb.h > > > index adefebe1..a2741c05 100644 > > > --- a/lib/igt_fb.h > > > +++ b/lib/igt_fb.h > > > @@ -37,6 +37,7 @@ > > > #include > > > > > > #include "igt_color_encoding.h" > > > +#include "igt_debugfs.h" > > > > > > /* > > > * Internal format to denote a buffer compatible with pixman's > > > @@ -194,5 +195,7 @@ int igt_format_plane_bpp(uint32_t drm_format, int > > > plane); > > > void igt_format_array_fill(uint32_t **formats_array, unsigned int *count, > > > bool allow_yuv); > > > > > > +int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc); > > > + > > > #endif /* __IGT_FB_H__ */ > > > > > > ___ > > > igt-dev mailing list > > > igt-...@lists.freedesktop.org > > > https://lists.freedesktop.org/mailman/listinfo/igt-dev > > ___ > > igt-dev mailing list > > igt-...@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/igt-dev -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 2/6] kms_writeback: Add initial writeback tests
On 07/12, Ser, Simon wrote: > On Thu, 2019-07-11 at 23:44 -0300, Rodrigo Siqueira wrote: > > On 07/10, Ser, Simon wrote: > > > Hi, > > > > > > Thanks for the patch! Here are a few comments. > > > > > > For bonus points, it would be nice to add igt_describe descriptions of > > > each sub-test. > > > > Hi Simon, > > > > First of all, thanks for your feedback; I already applied most of your > > suggestions. I just have some inline comments/questions. > > > > > On Wed, 2019-06-12 at 23:16 -0300, Brian Starkey wrote: > > > > Add tests for the WRITEBACK_PIXEL_FORMATS, WRITEBACK_OUT_FENCE_PTR and > > > > WRITEBACK_FB_ID properties on writeback connectors, ensuring their > > > > behaviour is correct. > > > > > > > > Signed-off-by: Brian Starkey > > > > [rebased and updated do_writeback_test() function to address feedback] > > > > Signed-off-by: Liviu Dudau > > > > --- > > > > tests/Makefile.sources | 1 + > > > > tests/kms_writeback.c | 314 + > > > > tests/meson.build | 1 + > > > > 3 files changed, 316 insertions(+) > > > > create mode 100644 tests/kms_writeback.c > > > > > > > > diff --git a/tests/Makefile.sources b/tests/Makefile.sources > > > > index 027ed82f..03cc8efa 100644 > > > > --- a/tests/Makefile.sources > > > > +++ b/tests/Makefile.sources > > > > @@ -77,6 +77,7 @@ TESTS_progs = \ > > > > kms_universal_plane \ > > > > kms_vblank \ > > > > kms_vrr \ > > > > + kms_writeback \ > > > > meta_test \ > > > > perf \ > > > > perf_pmu \ > > > > diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c > > > > new file mode 100644 > > > > index ..66ef48a6 > > > > --- /dev/null > > > > +++ b/tests/kms_writeback.c > > > > @@ -0,0 +1,314 @@ > > > > +/* > > > > + * (C) COPYRIGHT 2017 ARM Limited. All rights reserved. > > > > + * > > > > + * Permission is hereby granted, free of charge, to any person > > > > obtaining a > > > > + * copy of this software and associated documentation files (the > > > > "Software"), > > > > + * to deal in the Software without restriction, including without > > > > limitation > > > > + * the rights to use, copy, modify, merge, publish, distribute, > > > > sublicense, > > > > + * and/or sell copies of the Software, and to permit persons to whom > > > > the > > > > + * Software is furnished to do so, subject to the following conditions: > > > > + * > > > > + * The above copyright notice and this permission notice (including > > > > the next > > > > + * paragraph) shall be included in all copies or substantial portions > > > > of the > > > > + * Software. > > > > + * > > > > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > > > > EXPRESS OR > > > > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > > > > MERCHANTABILITY, > > > > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT > > > > SHALL > > > > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES > > > > OR OTHER > > > > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > > > > ARISING > > > > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > > > > DEALINGS > > > > + * IN THE SOFTWARE. > > > > + * > > > > + */ > > > > + > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > + > > > > +#include "igt.h" > > > > +#include "igt_core.h" > > > > +#include "igt_fb.h" > > > > + > > > > +static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t > > > > *output) > > > > +{ > > > > + drmModePropertyBlobRes *blob = NULL; > > > > + uint64_t blob_id; > > > > + int ret; > > > > + > > > > + ret = kmstest_get_property(output->display->drm_fd, > > > > +
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 3/6] lib: Add function to hash a framebuffer
On 07/12, Ser, Simon wrote: > On Thu, 2019-07-11 at 23:49 -0300, Rodrigo Siqueira wrote: > > On 07/10, Ser, Simon wrote: > > > On Wed, 2019-07-10 at 15:30 +, Ser, Simon wrote: > > > > Mostly LGTM, here are a few nits. > > > > > > > > On Wed, 2019-06-12 at 23:17 -0300, Brian Starkey wrote: > > > > > To use writeback buffers as a CRC source, we need to be able to hash > > > > > them. Implement a simple FVA-1a hashing routine for this purpose. > > > > > > > > > > Doing a bytewise hash on the framebuffer directly can be very slow if > > > > > the memory is noncached. By making a copy of each line in the FB first > > > > > (which can take advantage of word-access speedup), we can do the hash > > > > > on a cached copy, which is much faster (10x speedup on my platform). > > > > > > > > > > v6: use igt_memcpy_from_wc() instead of plain memcpy, as suggested by > > > > > Chris Wilson > > > > > > > > > > Signed-off-by: Brian Starkey > > > > > [rebased and updated to the most recent API] > > > > > Signed-off-by: Liviu Dudau > > > > > --- > > > > > lib/igt_fb.c | 66 > > > > > > > > > > lib/igt_fb.h | 3 +++ > > > > > 2 files changed, 69 insertions(+) > > > > > > > > > > diff --git a/lib/igt_fb.c b/lib/igt_fb.c > > > > > index 9d4f905e..d07dae39 100644 > > > > > --- a/lib/igt_fb.c > > > > > +++ b/lib/igt_fb.c > > > > > @@ -3256,6 +3256,72 @@ bool igt_fb_supported_format(uint32_t > > > > > drm_format) > > > > > return false; > > > > > } > > > > > > > > > > +/* > > > > > + * This implements the FNV-1a hashing algorithm instead of CRC, for > > > > > + * simplicity > > > > > + * http://www.isthe.com/chongo/tech/comp/fnv/index.html > > > > > + * > > > > > + * hash = offset_basis > > > > > + * for each octet_of_data to be hashed > > > > > + * hash = hash xor octet_of_data > > > > > + * hash = hash * FNV_prime > > > > > + * return hash > > > > > + * > > > > > + * 32 bit offset_basis = 2166136261 > > > > > + * 32 bit FNV_prime = 224 + 28 + 0x93 = 16777619 > > > > > + */ > > > > > +int igt_fb_get_crc(struct igt_fb *fb, igt_crc_t *crc) > > > > > +{ > > > > > +#define FNV1a_OFFSET_BIAS 2166136261 > > > > > +#define FNV1a_PRIME 16777619 > > > > > > > > I'd just use plain uint32_t variables for those, but no big deal. > > > > > > > > > + uint32_t hash; > > > > > + void *map; > > > > > + char *ptr, *line = NULL; > > > > > + int x, y, cpp = igt_drm_format_to_bpp(fb->drm_format) / 8; > > > > > + uint32_t stride = calc_plane_stride(fb, 0); > > > > > > > > We could return -EINVAL in case fb->num_planes != 1. > > > > > > Let's not waste cycles. With this ^ fixed, this patch is: > > > > > > Reviewed-by: Simon Ser > > > > > > Other nits are optional. > > > > I agreed with all your suggestions, and I already applied all of them. > > Should I wait for the other patches review, or should I resend the new > > version? > > I'm fine with waiting for the full review before a new version of the > whole patchset, but you can also send an updated version of a single > patch with: > > git send-email > --in-reply-to="" -1 > > > where In-Reply-To is the Message-Id of the patch you want to update. I > agree it's a little tedious since you need to extract the Message-Id > from the message header. Thanks for the tip with git-send-mail. Since I already applied most of your suggestions, I'll send a full version soon. > > Thanks for all the feedback > > :) > > > Best Regards > > > > > > > + if (fb->is_dumb) > > > > > + map = kmstest_dumb_map_buffer(fb->fd, fb->gem_handle, > > > > > fb->size, > > > > > + PROT_READ); > > > > > + else > > > > > + map = gem_mmap__gtt(fb->fd, fb->gem_ha
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 5/6] lib/igt_kms: Add igt_output_clone_pipe for cloning
> + igt_assert_f(pipe->outputs & (1 << > > igt_output_idx(output)), > > +"Output %s not expected to be using pipe > > %s\n", > > +igt_output_name(output), > > +kmstest_pipe_name(pipe->pipe)); > > + > > + if (pipes_in_use & pending_crtc_idx_mask) > > + LOG(display, "Output %s clones pipe %s\n", > > + igt_output_name(output), > > + kmstest_pipe_name(pipe->pipe)); > > + } > > + > > + pipes_in_use |= pending_crtc_idx_mask; > > + > > + if (output->force_reprobe) > > + igt_output_refresh(output); > > + } > > +} > > + > > static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, int plane_idx) > > { > > igt_require_f(plane_idx >= 0 && plane_idx < pipe->n_planes, > > @@ -3766,6 +3775,7 @@ void igt_output_override_mode(igt_output_t *output, > > const drmModeModeInfo *mode) > > output->use_override_mode = !!mode; > > > > if (pipe) { > > + igt_debug("overriding pipe mode in %s way\n", > > output->display->is_atomic ? "atomic" : "legacy"); > > if (output->display->is_atomic) > > igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_MODE_ID, > > igt_output_get_mode(output), sizeof(*mode)); > > else > > @@ -3773,6 +3783,16 @@ void igt_output_override_mode(igt_output_t *output, > > const drmModeModeInfo *mode) > > } > > } > > > > +void igt_output_clone_pipe(igt_output_t *output, enum pipe pipe) > > +{ > > + igt_display_t *display = output->display; > > + uint32_t current_clones = display->pipes[pipe].outputs; > > + > > + igt_output_set_pipe(output, pipe); > > + > > + display->pipes[pipe].outputs |= current_clones; > > +} > > + > > /* > > * igt_output_set_pipe: > > * @output: Target output for which the pipe is being set to > > @@ -3789,11 +3809,15 @@ void igt_output_set_pipe(igt_output_t *output, enum > > pipe pipe) > > > > igt_assert(output->name); > > > > - if (output->pending_pipe != PIPE_NONE) > > + if (output->pending_pipe != PIPE_NONE) { > > old_pipe = igt_output_get_driving_pipe(output); > > + old_pipe->outputs &= ~(1 << igt_output_idx(output)); > > + } > > > > - if (pipe != PIPE_NONE) > > + if (pipe != PIPE_NONE) { > > pipe_obj = &display->pipes[pipe]; > > + pipe_obj->outputs = (1 << igt_output_idx(output)); > > + } > > > > LOG(display, "%s: set_pipe(%s)\n", igt_output_name(output), > > kmstest_pipe_name(pipe)); > > diff --git a/lib/igt_kms.h b/lib/igt_kms.h > > index cacc6b90..676839bb 100644 > > --- a/lib/igt_kms.h > > +++ b/lib/igt_kms.h > > @@ -354,6 +354,8 @@ struct igt_pipe { > > uint32_t crtc_id; > > > > int32_t out_fence_fd; > > + > > + uint32_t outputs; > > }; > > > > typedef struct { > > @@ -411,6 +413,8 @@ const char *igt_output_name(igt_output_t *output); > > drmModeModeInfo *igt_output_get_mode(igt_output_t *output); > > void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo > > *mode); > > void igt_output_set_pipe(igt_output_t *output, enum pipe pipe); > > +void igt_output_clone_pipe(igt_output_t *output, enum pipe pipe); > > + > > igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx); > > igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int > > plane_type); > > int igt_output_count_plane_type(igt_output_t *output, int plane_type); > > ___ > > igt-dev mailing list > > igt-...@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/igt-dev -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [igt-dev] [PATCH V6 i-g-t 2/6] kms_writeback: Add initial writeback tests
> > > > > > + igt_display_require(&display, display.drm_fd); > > > > > > > > + > > > > > > > > + igt_require(display.is_atomic); > > > > > > > > + > > > > > > > > + output = kms_writeback_get_output(&display); > > > > > > > > + igt_require(output); > > > > > > > > + > > > > > > > > + if (output->use_override_mode) > > > > > > > > + memcpy(&mode, &output->override_mode, > > > > > > > > sizeof(mode)); > > > > > > > > + else > > > > > > > > + memcpy(&mode, &output->config.default_mode, > > > > > > > > sizeof(mode)); > > > > > > > > + > > > > > > > > + plane = igt_output_get_plane_type(output, > > > > > > > > DRM_PLANE_TYPE_PRIMARY); > > > > > > > > + igt_require(plane); > > > > > > > > > > > > > > Maybe we can assert on this? > > > > > > > > > > > > > > > + ret = igt_create_fb(display.drm_fd, mode.hdisplay, > > > > > > > > + mode.vdisplay, > > > > > > > > + DRM_FORMAT_XRGB, > > > > > > > > + igt_fb_mod_to_tiling(0), > > > > > > > > > > > > > > This is supposed to take a modifier. DRM_FORMAT_MOD_LINEAR would > > > > > > > be > > > > > > > better to make this clear. > > > > > > > > > > Agree. The patchset pre-dates the modifiers support (or has the same > > > > > age, I > > > > > forgot) > > > > > > > > > > > > (Applies to other lines of this patch) > > > > > > > > > > > > > > > + &input_fb); > > > > > > > > + igt_assert(ret >= 0); > > > > > > > > + igt_plane_set_fb(plane, &input_fb); > > > > > > > > + } > > > > > > > > + > > > > > > > > + igt_subtest("writeback-pixel-formats") { > > > > > > > > + drmModePropertyBlobRes *formats_blob = > > > > > > > > get_writeback_formats_blob(output); > > > > > > > > > > > > > > Need to drmModeFreePropertyBlob this. > > > > > > > > > > > > > > > + const char *valid_chars = "0123456 ABCGNRUVXY"; > > > > > > > > + unsigned int i; > > > > > > > > + char *c; > > > > > > > > + > > > > > > > > + /* > > > > > > > > + * We don't have a comprehensive list of formats, so > > > > > > > > just check > > > > > > > > + * that the blob length is sensible and that it > > > > > > > > doesn't contain > > > > > > > > + * any outlandish characters > > > > > > > > + */ > > > > > > > > + igt_assert(!(formats_blob->length % 4)); > > > > > > > > + c = formats_blob->data; > > > > > > > > + for (i = 0; i < formats_blob->length; i++) > > > > > > > > + igt_assert_f(strchr(valid_chars, c[i]), > > > > > > > > + "Unexpected character %c\n", > > > > > > > > c[i]); > > > > > > > > > > > > > > Honestly, I'm not a fan of this check. There's no guarantee that > > > > > > > fourcc > > > > > > > codes will be made from ASCII characters, in fact some formats > > > > > > > already > > > > > > > have non-printable chars in them. I don't want to have to update > > > > > > > this > > > > > > > test when a new fourcc format is added. > > > > > > > > > > Like the comments says, we don't have a full list of formats to check > > > > > against. > > > > > Suggestions on how to improve are welcome, but I don't think we > > > > > should delay > > > > > (any longer) the patchset due to this. > > > > > > > > Agreed. > > > > > > > > > Best regards, > > > > > Liviu > > -- > > | I would like to | > | fix the world, | > | but they're not | > | giving me the | > \ source code! / > --- > ¯\_(ツ)_/¯ -- Rodrigo Siqueira https://siqueira.tech ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V5] drm: Add support for DP 1.4 Compliance edid corruption test
print_bad_edid, > } > > csum = drm_edid_block_checksum(raw_edid); > - if (csum) { > + if (drm_edid_block_checksum_diff(raw_edid, csum)) { > if (edid_corrupt) > *edid_corrupt = true; > > @@ -1793,6 +1804,10 @@ static void connector_bad_edid(struct drm_connector > *connector, > u8 *edid, int num_blocks) > { > int i; > + u8 num_of_ext = edid[0x7e]; > + > + /* Calculate real checksum for the last edid extension block data */ > + connector->real_edid_checksum = drm_edid_block_checksum(edid + > num_of_ext * EDID_LENGTH); > > if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS)) > return; > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h > index 2113500b4075..b3815371c271 100644 > --- a/include/drm/drm_connector.h > +++ b/include/drm/drm_connector.h > @@ -1357,6 +1357,12 @@ struct drm_connector { >* rev1.1 4.2.2.6 >*/ > bool edid_corrupt; > + /** > + * @real_edid_checksum: real edid checksum for corrupted edid block. > + * Required in Displayport 1.4 compliance testing > + * rev1.1 4.2.2.6 > + */ > + u8 real_edid_checksum; > > /** @debugfs_entry: debugfs directory for this connector */ > struct dentry *debugfs_entry; > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h > index 127d6e1d3338..957a3d00ee05 100644 > --- a/include/drm/drm_dp_helper.h > +++ b/include/drm/drm_dp_helper.h > @@ -1459,6 +1459,9 @@ static inline ssize_t drm_dp_dpcd_writeb(struct > drm_dp_aux *aux, > int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, >u8 status[DP_LINK_STATUS_SIZE]); > > +bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, > + u8 real_edid_checksum); > + > int drm_dp_downstream_max_clock(const u8 dpcd[DP_RECEIVER_CAP_SIZE], > const u8 port_cap[4]); > int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE], > -- > 2.17.1 > > ___ > dri-devel mailing list > dri-de...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Rodrigo Siqueira Software Engineer, Advanced Micro Devices (AMD) https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V6] drm: Add support for DP 1.4 Compliance edid corruption test
true; > + else > + return false; > } > > static bool drm_edid_is_zero(const u8 *in_edid, int length) > @@ -1652,7 +1663,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool > print_bad_edid, > } > > csum = drm_edid_block_checksum(raw_edid); > - if (csum) { > + if (drm_edid_block_checksum_diff(raw_edid, csum)) { > if (edid_corrupt) > *edid_corrupt = true; > > @@ -1793,6 +1804,10 @@ static void connector_bad_edid(struct drm_connector > *connector, > u8 *edid, int num_blocks) > { > int i; > + u8 num_of_ext = edid[0x7e]; > + > + /* Calculate real checksum for the last edid extension block data */ > + connector->real_edid_checksum = drm_edid_block_checksum(edid + > num_of_ext * EDID_LENGTH); > > if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS)) > return; > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h > index 2113500b4075..b3815371c271 100644 > --- a/include/drm/drm_connector.h > +++ b/include/drm/drm_connector.h > @@ -1357,6 +1357,12 @@ struct drm_connector { >* rev1.1 4.2.2.6 >*/ > bool edid_corrupt; > + /** > + * @real_edid_checksum: real edid checksum for corrupted edid block. > + * Required in Displayport 1.4 compliance testing > + * rev1.1 4.2.2.6 > + */ > + u8 real_edid_checksum; > > /** @debugfs_entry: debugfs directory for this connector */ > struct dentry *debugfs_entry; > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h > index 127d6e1d3338..957a3d00ee05 100644 > --- a/include/drm/drm_dp_helper.h > +++ b/include/drm/drm_dp_helper.h > @@ -1459,6 +1459,9 @@ static inline ssize_t drm_dp_dpcd_writeb(struct > drm_dp_aux *aux, > int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, >u8 status[DP_LINK_STATUS_SIZE]); > > +bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, > + u8 real_edid_checksum); > + > int drm_dp_downstream_max_clock(const u8 dpcd[DP_RECEIVER_CAP_SIZE], > const u8 port_cap[4]); > int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE], > -- > 2.17.1 > Reviewed-by: Rodrigo Siqueira -- Rodrigo Siqueira Software Engineer, Advanced Micro Devices (AMD) https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 04/25] drm/vkms: Annotate vblank timer
Hi, Everything looks fine to me, I just noticed that the amdgpu patches did not apply smoothly, however it was trivial to fix the issues. Reviewed-by: Rodrigo Siqueira Melissa, Since you are using vkms regularly, could you test this patch and review it? Remember to add your Tested-by when you finish. Thanks On 07/07, Daniel Vetter wrote: > This is needed to signal the fences from page flips, annotate it > accordingly. We need to annotate entire timer callback since if we get > stuck anywhere in there, then the timer stops, and hence fences stop. > Just annotating the top part that does the vblank handling isn't > enough. > > Cc: linux-me...@vger.kernel.org > Cc: linaro-mm-...@lists.linaro.org > Cc: linux-r...@vger.kernel.org > Cc: amd-...@lists.freedesktop.org > Cc: intel-gfx@lists.freedesktop.org > Cc: Chris Wilson > Cc: Maarten Lankhorst > Cc: Christian König > Signed-off-by: Daniel Vetter > Cc: Rodrigo Siqueira > Cc: Haneen Mohammed > Cc: Daniel Vetter > --- > drivers/gpu/drm/vkms/vkms_crtc.c | 8 +++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c > b/drivers/gpu/drm/vkms/vkms_crtc.c > index ac85e17428f8..a53a40848a72 100644 > --- a/drivers/gpu/drm/vkms/vkms_crtc.c > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c > @@ -1,5 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0+ > > +#include > + > #include > #include > #include > @@ -14,7 +16,9 @@ static enum hrtimer_restart vkms_vblank_simulate(struct > hrtimer *timer) > struct drm_crtc *crtc = &output->crtc; > struct vkms_crtc_state *state; > u64 ret_overrun; > - bool ret; > + bool ret, fence_cookie; > + > + fence_cookie = dma_fence_begin_signalling(); > > ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer, > output->period_ns); > @@ -49,6 +53,8 @@ static enum hrtimer_restart vkms_vblank_simulate(struct > hrtimer *timer) > DRM_DEBUG_DRIVER("Composer worker already queued\n"); > } > > + dma_fence_end_signalling(fence_cookie); > + > return HRTIMER_RESTART; > } > > -- > 2.27.0 > -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t v9 4/4] kms_writeback: Add writeback-check-output
From: 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. Changes since V8 (Arkadiusz Hiler): * Add short description Changes since V7 (Maxime Ripard): * Make fb_fill cross-platform Changes since v6 (Simon Ser): * Add a descriptive error message if sync_fence_wait fail * Drop color_idx variable * Compute expected CRC based on input framebuffer in writeback_sequence * Remove unnecessary parentheses * Replace int variable for unsigned int Signed-off-by: Brian Starkey [rebased and updated] Signed-off-by: Rodrigo Siqueira Reviewed-by: Liviu Dudau --- tests/kms_writeback.c | 134 ++ 1 file changed, 134 insertions(+) diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c index f8025538..60dbda2a 100644 --- a/tests/kms_writeback.c +++ b/tests/kms_writeback.c @@ -30,6 +30,14 @@ #include "igt.h" #include "igt_core.h" #include "igt_fb.h" +#include "sw_sync.h" + +IGT_TEST_DESCRIPTION( + "This test validates the expected behavior of the writeback connectors " + "feature by checking if the target device support writeback; it validates " + "bad and good combination, check color format, and check the output result " + "by using CRC." +); static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output) { @@ -217,6 +225,118 @@ static void writeback_fb_id(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t * igt_assert(ret == 0); } +static void fill_fb(igt_fb_t *fb, uint32_t pixel) +{ + void *ptr; + + igt_assert(fb->drm_format == DRM_FORMAT_XRGB); + + 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) +{ + 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 = 0; + uint32_t in_fb_colors[2] = { 0x, 0xff00ff00 }; + uint32_t clear_color = 0x; + + 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_fnv1a_crc(in_fb, &out_expected); + fill_fb(out_fbs[i], clear_color); + + if (i == 0) + igt_fb_get_fnv1a_crc(out_fbs[i], &cleared_crc); + igt_fb_get_fnv1a_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_fnv1a_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_fnv1a_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(ou
[Intel-gfx] [PATCH i-g-t v9 0/4] Add support for testing writeback connectors
Hi, A couple of months ago I updated and re-submitted a patchset made by Brian Starkey and Liviu Dudau for adding a writeback connectors test to IGT. It is important to highlight that DRM already have writeback connectors support, which is a way to expose in DRM the hardware functionality from display engines that allows writing back into memory the result of DE's composition of supported planes. After I resubmitted the patchset, Simon Ser provides a long and detailed review for all of the patches (thanks Simon). Additionally, Maxime Ripard tested the previous series in an ARM32 architecture and provided his feedback for making this patchset portable (thanks Maxime). I finally had time to go through all the details and prepare this new version. Follows some notes: 1. Patchset author Brian Starkey is the original author of this patchset, and I'm just trying to upstream his changes. Note that during this patch submission, the mail server from google going to overwrite Brian's mail by mine; this happens on the mail server side for avoiding malicious users to send emails as someone else. Note that I could spend time figuring out how to fix it, but I think this is not worth it since I can fix it during the merge process (if it got accepted). 2. Drop the clone commits from the series After Simon's review, we decided to drop the last two patches of the original series since it was related to cloning output and VKMS does not support it yet. However, after we finish this series, I can try to take a look at this feature or maybe propose it as a GSoC/Outreachy project. Most of the changes happened in the second patch. 3. Cross-platform improvements 4. Add test description and remove some unnecessary code Thanks Brian Starkey (4): lib/igt_kms: Add writeback support kms_writeback: Add initial writeback tests lib: Add function to hash a framebuffer kms_writeback: Add writeback-check-output lib/igt_fb.c | 63 ++ lib/igt_fb.h | 2 + lib/igt_kms.c | 52 + lib/igt_kms.h | 6 + tests/Makefile.sources | 1 + tests/kms_writeback.c | 450 + tests/meson.build | 1 + 7 files changed, 575 insertions(+) create mode 100644 tests/kms_writeback.c -- 2.28.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t v9 3/4] lib: Add function to hash a framebuffer
From: Brian Starkey To use writeback buffers as a CRC source, we need to be able to hash them. Implement a simple FVA-1a hashing routine for this purpose. Doing a bytewise hash on the framebuffer directly can be very slow if the memory is noncached. By making a copy of each line in the FB first (which can take advantage of word-access speedup), we can do the hash on a cached copy, which is much faster (10x speedup on my platform). Changes since V7 (Maxime Ripard): * Maxime Ripard: - Replace `gem_mmap__gtt` by `igt_fb_map_buffer` on `igt_fb_get_crc()` * Rodrigo Siqueira: - Rename igt_fb_get_crc to igt_fb_get_fnv1a_crc Changes since V6 (Simon Ser): * Use plain uint32_t for FNV1a_OFFSET_BIAS and FNV1a_PRIME * Return -EINVAL in case fb->num_planes != 1 * Just copy fb->width * cpp instead of copy the whole stride v5: use igt_memcpy_from_wc() instead of plain memcpy, as suggested by Chris Wilson Signed-off-by: Brian Starkey [rebased and updated to the most recent API] Signed-off-by: Liviu Dudau [rebased and updated] Signed-off-by: Rodrigo Siqueira Reviewed-by: Simon Ser Reviewed-by: Liviu Dudau --- lib/igt_fb.c | 63 lib/igt_fb.h | 2 ++ 2 files changed, 65 insertions(+) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 3864b7a1..5e3706e9 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -3783,6 +3783,69 @@ bool igt_fb_supported_format(uint32_t drm_format) return true; } +/* + * This implements the FNV-1a hashing algorithm instead of CRC, for + * simplicity + * http://www.isthe.com/chongo/tech/comp/fnv/index.html + * + * hash = offset_basis + * for each octet_of_data to be hashed + * hash = hash xor octet_of_data + * hash = hash * FNV_prime + * return hash + * + * 32 bit offset_basis = 2166136261 + * 32 bit FNV_prime = 224 + 28 + 0x93 = 16777619 + */ +int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc) +{ + const uint32_t FNV1a_OFFSET_BIAS = 2166136261; + const uint32_t FNV1a_PRIME = 16777619; + uint32_t hash; + void *map; + char *ptr, *line = NULL; + int x, y, cpp = igt_drm_format_to_bpp(fb->drm_format) / 8; + uint32_t stride = calc_plane_stride(fb, 0); + + if (fb->num_planes != 1) + return -EINVAL; + + ptr = igt_fb_map_buffer(fb->fd, fb); + igt_assert(ptr); + map = ptr; + + /* +* Framebuffers are often uncached, which can make byte-wise accesses +* very slow. We copy each line of the FB into a local buffer to speed +* up the hashing. +*/ + line = malloc(stride); + if (!line) { + munmap(map, fb->size); + return -ENOMEM; + } + + hash = FNV1a_OFFSET_BIAS; + + for (y = 0; y < fb->height; y++, ptr += stride) { + + igt_memcpy_from_wc(line, ptr, fb->width * cpp); + + for (x = 0; x < fb->width * cpp; x++) { + hash ^= line[x]; + hash *= FNV1a_PRIME; + } + } + + crc->n_words = 1; + crc->crc[0] = hash; + + free(line); + igt_fb_unmap_buffer(fb, map); + + return 0; +} + /** * igt_format_is_yuv: * @drm_format: drm fourcc diff --git a/lib/igt_fb.h b/lib/igt_fb.h index 5ec906b7..debfb5ad 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -207,5 +207,7 @@ int igt_format_plane_bpp(uint32_t drm_format, int plane); void igt_format_array_fill(uint32_t **formats_array, unsigned int *count, bool allow_yuv); +int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc); + #endif /* __IGT_FB_H__ */ -- 2.28.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t v9 2/4] kms_writeback: Add initial writeback tests
From: Brian Starkey Add tests for the WRITEBACK_PIXEL_FORMATS, WRITEBACK_OUT_FENCE_PTR and WRITEBACK_FB_ID properties on writeback connectors, ensuring their behaviour is correct. Changes since V8: * Remove unnecessary fence cleanup on prepare commit. Changes since V7 (Maxime Ripard and Petri Latvala): * Utilizes `to_user_pointer` to avoid cast compilation error on ARM 32 bits. Changes since V6 (Simon Ser): * Add igt_describe per sub-test * Remove kmstest_force_connector from kms_writeback_get_output, since userspace will not do this sort of operation * Add an igt_debug statement in case we don't use a specific writeback connector * Drop flag parameter from do_writeback_test * Rename invalid_out_fence to test_invalid_parameters * Drop invalid_fb from writeback_fb_id * Assert if plane is null on igt_fixture * Replace all occurrences of igt_fb_mod_to_tiling(0) by DRM_FORMAT_MOD_LINEAR * Rename invalid_fb to invalid_output_fb in the sub-test related to "writeback-invalid-out-fence" * Replace ret by fb_id in igt_main Reviewed-by: Liviu Dudau Signed-off-by: Brian Starkey [rebased and updated do_writeback_test() function to address feedback] Signed-off-by: Liviu Dudau Signed-off-by: Rodrigo Siqueira --- tests/Makefile.sources | 1 + tests/kms_writeback.c | 316 + tests/meson.build | 1 + 3 files changed, 318 insertions(+) create mode 100644 tests/kms_writeback.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 269b506d..6ae95155 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -89,6 +89,7 @@ TESTS_progs = \ kms_universal_plane \ kms_vblank \ kms_vrr \ + kms_writeback \ meta_test \ prime_busy \ prime_mmap \ diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c new file mode 100644 index ..f8025538 --- /dev/null +++ b/tests/kms_writeback.c @@ -0,0 +1,316 @@ +/* + * (C) COPYRIGHT 2017 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include +#include +#include +#include + +#include "igt.h" +#include "igt_core.h" +#include "igt_fb.h" + +static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output) +{ + drmModePropertyBlobRes *blob = NULL; + uint64_t blob_id; + int ret; + + ret = kmstest_get_property(output->display->drm_fd, + output->config.connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, + igt_connector_prop_names[IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS], + NULL, &blob_id, NULL); + if (ret) + blob = drmModeGetPropertyBlob(output->display->drm_fd, blob_id); + + igt_assert(blob); + + return blob; +} + +static bool check_writeback_config(igt_display_t *display, igt_output_t *output) +{ + igt_fb_t input_fb, output_fb; + igt_plane_t *plane; + uint32_t writeback_format = DRM_FORMAT_XRGB; + uint64_t tiling = DRM_FORMAT_MOD_LINEAR; + int width, height, ret; + drmModeModeInfo override_mode = { + .clock = 25175, + .hdisplay = 640, + .hsync_start = 656, + .hsync_end = 752, + .htotal = 800, + .hskew = 0, + .vdisplay = 480, + .vsync_start = 490, + .vsync_end = 492, + .vtotal = 525, + .vscan = 0, + .vrefresh = 60, + .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, + .name = {"640x480-60"}, + }; + igt_output_override_mode(output, &override_mode); + + width = override_mode.hdisplay;
[Intel-gfx] [PATCH i-g-t v9 1/4] lib/igt_kms: Add writeback support
From: Brian Starkey Add support in igt_kms for writeback connectors, with the ability to attach framebuffers. v8: Remove unnecessary fence cleanup on prepare commit. v5: Rebase and add DRM_CLIENT_CAP_WRITEBACK_CONNECTORS before drmModeGetResources() Signed-off-by: Brian Starkey [rebased and updated to the latest igt style] Signed-off-by: Liviu Dudau [rebased and updated to the latest igt style] Signed-off-by: Rodrigo Siqueira Reviewed-by: Liviu Dudau Reviewed-by: Simon Ser --- lib/igt_kms.c | 52 +++ lib/igt_kms.h | 6 ++ 2 files changed, 58 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index f57972f1..7cf2008e 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -421,6 +421,9 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { [IGT_CONNECTOR_LINK_STATUS] = "link-status", [IGT_CONNECTOR_MAX_BPC] = "max bpc", [IGT_CONNECTOR_HDR_OUTPUT_METADATA] = "HDR_OUTPUT_METADATA", + [IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS] = "WRITEBACK_PIXEL_FORMATS", + [IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID", + [IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = "WRITEBACK_OUT_FENCE_PTR", }; /* @@ -653,6 +656,7 @@ static const struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, { DRM_MODE_CONNECTOR_DPI, "DPI" }, + { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" }, {} }; @@ -1813,6 +1817,14 @@ static void igt_output_reset(igt_output_t *output) if (igt_output_has_prop(output, IGT_CONNECTOR_HDR_OUTPUT_METADATA)) igt_output_set_prop_value(output, IGT_CONNECTOR_HDR_OUTPUT_METADATA, 0); + + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID)) + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, 0); + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) { + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + output->writeback_out_fence_fd = -1; + } + } /** @@ -1930,6 +1942,8 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->drm_fd = drm_fd; is_i915_dev = is_i915_device(drm_fd); + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); + resources = drmModeGetResources(display->drm_fd); if (!resources) goto out; @@ -2268,6 +2282,11 @@ static void igt_output_fini(igt_output_t *output) kmstest_free_connector_config(&output->config); free(output->name); output->name = NULL; + + if (output->writeback_out_fence_fd != -1) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } } /** @@ -3458,6 +3477,16 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s) else /* no modeset in universal commit, no change to crtc. */ output->changed &= 1 << IGT_CONNECTOR_CRTC_ID; + + if (s == COMMIT_ATOMIC) { + if (igt_output_is_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) + igt_assert(output->writeback_out_fence_fd >= 0); + + output->values[IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = 0; + output->values[IGT_CONNECTOR_WRITEBACK_FB_ID] = 0; + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_FB_ID); + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + } } if (display->first_commit) { @@ -4130,6 +4159,29 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe) igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)&pipe->out_fence_fd); } +/** + * igt_output_set_writeback_fb: + * @output: Target output + * @fb: Target framebuffer + * + * This function sets the given @fb to be used as the target framebuffer for the + * writeback engine at the next atomic commit. It will also request a writeback + * out fence that will contain the fd number of the out fence created by KMS if + * the given @fb is valid. + */ +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb) +{ + igt_display_t *display = output->display; + + LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, fb ? fb->fb_id : 0); + + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb ? fb->fb_id : 0); + /* only request a writeback out fence if the framebuffer is valid */ +
Re: [Intel-gfx] [PATCH 14/51] drm/vkms: Use drmm_add_final_kfree
Hi, Thanks for the patch. I reviewed and tested this patch, and everything looks fine. Reviewed-by: Rodrigo Siqueira Tested-by: Rodrigo Siqueira On 02/27, Daniel Vetter wrote: > With this we can drop the final kfree from the release function. > > v2: After drm_dev_init/drmm_add_final_kfree we need to clean up > everything through a drm_dev_put. Rework the unwind code to match > that. > > Signed-off-by: Daniel Vetter > Cc: Rodrigo Siqueira > Cc: Haneen Mohammed > Cc: Daniel Vetter > --- > drivers/gpu/drm/vkms/vkms_drv.c | 18 +- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c > index 860de052e820..2f35fe789343 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.c > +++ b/drivers/gpu/drm/vkms/vkms_drv.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -158,13 +159,14 @@ static int __init vkms_init(void) > &vkms_device->platform->dev); > if (ret) > goto out_unregister; > + drmm_add_final_kfree(&vkms_device->drm, vkms_device); > > ret = dma_coerce_mask_and_coherent(vkms_device->drm.dev, > DMA_BIT_MASK(64)); > > if (ret) { > DRM_ERROR("Could not initialize DMA support\n"); > - goto out_fini; > + goto out_put; > } > > vkms_device->drm.irq_enabled = true; > @@ -172,25 +174,25 @@ static int __init vkms_init(void) > ret = drm_vblank_init(&vkms_device->drm, 1); > if (ret) { > DRM_ERROR("Failed to vblank\n"); > - goto out_fini; > + goto out_put; > } > > ret = vkms_modeset_init(vkms_device); > if (ret) > - goto out_fini; > + goto out_put; > > ret = drm_dev_register(&vkms_device->drm, 0); > if (ret) > - goto out_fini; > + goto out_put; > > return 0; > > -out_fini: > - drm_dev_fini(&vkms_device->drm); > +out_put: > + drm_dev_put(&vkms_device->drm); > + return ret; > > out_unregister: > platform_device_unregister(vkms_device->platform); > - > out_free: > kfree(vkms_device); > return ret; > @@ -205,8 +207,6 @@ static void __exit vkms_exit(void) > > drm_dev_unregister(&vkms_device->drm); > drm_dev_put(&vkms_device->drm); > - > - kfree(vkms_device); > } > > module_init(vkms_init); > -- > 2.24.1 > -- Rodrigo Siqueira https://siqueira.tech signature.asc Description: PGP signature ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On 11/12, Maarten Lankhorst wrote: > We already have __drm_atomic_helper_connector_reset() and > __drm_atomic_helper_plane_reset(), extend this to crtc as well. > > Most drivers already have a gpu reset hook, correct it. > Nouveau already implemented its own __drm_atomic_helper_crtc_reset(), > convert it to the common one. > > Signed-off-by: Maarten Lankhorst > Cc: Harry Wentland > Cc: Leo Li > Cc: Alex Deucher > Cc: "Christian König" > Cc: "David (ChunMing) Zhou" > Cc: David Airlie > Cc: Liviu Dudau > Cc: Brian Starkey > Cc: Mali DP Maintainers > Cc: Boris Brezillon > Cc: Nicolas Ferre > Cc: Alexandre Belloni > Cc: Ludovic Desroches > Cc: Maarten Lankhorst > Cc: Maxime Ripard > Cc: Sean Paul > Cc: Jani Nikula > Cc: Joonas Lahtinen > Cc: Rodrigo Vivi > Cc: Philipp Zabel > Cc: CK Hu > Cc: Matthias Brugger > Cc: Rob Clark > Cc: Ben Skeggs > Cc: Tomi Valkeinen > Cc: Laurent Pinchart > Cc: Kieran Bingham > Cc: Sandy Huang > Cc: "Heiko Stübner" > Cc: Thierry Reding > Cc: Jonathan Hunter > Cc: Eric Anholt > Cc: VMware Graphics > Cc: Sinclair Yeh > Cc: Thomas Hellstrom > Cc: Tony Cheng > Cc: Shirish S > Cc: Mikita Lipski > Cc: Bhawanpreet Lakha > Cc: David Francis > Cc: Anthony Koo > Cc: Jeykumar Sankaran > Cc: Jordan Crouse > Cc: Bruce Wang > Cc: Sravanthi Kollukuduru > Cc: Archit Taneja > Cc: Steve Kowalik > Cc: Carsten Behling > Cc: Haneen Mohammed > Cc: Daniel Vetter > Cc: Rodrigo Siqueira > Cc: Mahesh Kumar > Cc: amd-...@lists.freedesktop.org > Cc: dri-de...@lists.freedesktop.org > Cc: linux-ker...@vger.kernel.org > Cc: linux-arm-ker...@lists.infradead.org > Cc: intel-gfx@lists.freedesktop.org > Cc: linux-media...@lists.infradead.org > Cc: linux-arm-...@vger.kernel.org > Cc: freedr...@lists.freedesktop.org > Cc: nouv...@lists.freedesktop.org > Cc: linux-renesas-...@vger.kernel.org > Cc: linux-rockc...@lists.infradead.org > Cc: linux-te...@vger.kernel.org > --- > .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 +-- > drivers/gpu/drm/arm/malidp_crtc.c | 5 +-- > .../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c| 5 +-- > drivers/gpu/drm/drm_atomic_state_helper.c | 31 --- > drivers/gpu/drm/i915/intel_display.c | 2 +- > drivers/gpu/drm/imx/ipuv3-crtc.c | 5 +-- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +-- > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 12 ++- > drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 6 +--- > drivers/gpu/drm/nouveau/dispnv50/head.c | 13 ++-- > drivers/gpu/drm/omapdrm/omap_crtc.c | 7 ++--- > drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 4 +-- > drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 7 +++-- > drivers/gpu/drm/tegra/dc.c| 5 +-- > drivers/gpu/drm/vc4/vc4_crtc.c| 8 ++--- > drivers/gpu/drm/vkms/vkms_crtc.c | 7 + > drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 9 +- > include/drm/drm_atomic_state_helper.h | 2 ++ > 18 files changed, 56 insertions(+), 81 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > index 5064768642f3..770a71726cd1 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -2802,9 +2802,7 @@ static void dm_crtc_reset_state(struct drm_crtc *crtc) > if (WARN_ON(!state)) > return; > > - crtc->state = &state->base; > - crtc->state->crtc = crtc; > - > + __drm_atomic_helper_crtc_reset(crtc, &state->base); > } > > static struct drm_crtc_state * > diff --git a/drivers/gpu/drm/arm/malidp_crtc.c > b/drivers/gpu/drm/arm/malidp_crtc.c > index e1b72782848c..9a924ff27148 100644 > --- a/drivers/gpu/drm/arm/malidp_crtc.c > +++ b/drivers/gpu/drm/arm/malidp_crtc.c > @@ -474,10 +474,7 @@ static void malidp_crtc_reset(struct drm_crtc *crtc) > > kfree(state); > state = kzalloc(sizeof(*state), GFP_KERNEL); > - if (state) { > - crtc->state = &state->base; > - crtc->state->crtc = crtc; > - } > + __drm_atomic_helper_crtc_reset(crtc, &state->base); > } > > static void malidp_crtc_destroy_state(struct drm_crtc *crtc, > diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c > b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c > index 96f4082671fe..8084d549c7d1 100644 > --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c > +++ b/drivers/gpu/drm
[Intel-gfx] [FOR CI] drm/drm_vblank: Change EINVAL by the correct errno
For historical reason, the function drm_wait_vblank_ioctl always return -EINVAL if something gets wrong. This scenario limits the flexibility for the userspace make detailed verification of the problem and take some action. In particular, the validation of “if (!dev->irq_enabled)” in the drm_wait_vblank_ioctl is responsible for checking if the driver support vblank or not. If the driver does not support VBlank, the function drm_wait_vblank_ioctl returns EINVAL which does not represent the real issue; this patch changes this behavior by return EOPNOTSUPP. Additionally, some operations are unsupported by this function, and returns EINVAL; this patch also changes the return value to EOPNOTSUPP in this case. Lastly, the function drm_wait_vblank_ioctl is invoked by libdrm, which is used by many compositors; because of this, it is important to check if this change breaks any compositor. In this sense, the following projects were examined: * Drm-hwcomposer * Kwin * Sway * Wlroots * Wayland-core * Weston * Xorg (67 different drivers) For each repository the verification happened in three steps: * Update the main branch * Look for any occurrence "drmWaitVBlank" with the command: git grep -n "drmWaitVBlank" * Look in the git history of the project with the command: git log -SdrmWaitVBlank Finally, none of the above projects validate the use of EINVAL which make safe, at least for these projects, to change the return values. Change since V2: Daniel Vetter and Chris Wilson - Replace ENOTTY by EOPNOTSUPP - Return EINVAL if the parameters are wrong Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/drm_vblank.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 98e091175921..80f5a3bb427e 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -1533,10 +1533,10 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, unsigned int flags, pipe, high_pipe; if (!dev->irq_enabled) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & _DRM_VBLANK_SIGNAL) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK | -- 2.19.1 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 0/7] GCC warning cleanup
This patchset fixes all the current GCC 8.1.1 warnings found in the IGT. Rodrigo Siqueira (7): Remove parameter aliases with another argument Cast void * pointer used in arithmetic to uint32_t* Fix comparison that always evaluates to false Fix truncate string in the snprintf Make string commands dynamic allocate Fix truncate string in the strncpy Avoid truncate string in __igt_lsof_fds lib/igt_aux.c| 2 +- lib/igt_core.c | 6 +++--- lib/igt_fb.c | 6 -- tests/perf.c | 10 +- tools/intel_gvtg_test.c | 27 ++- tools/intel_reg.c| 2 +- tools/intel_reg_decode.c | 2 +- 7 files changed, 33 insertions(+), 22 deletions(-) -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 1/7] Remove parameter aliases with another argument
This commit fixes the following GCC warning: warning: passing argument 2 to restrict-qualified parameter aliases with argument 1 [-Wrestrict] return (readlink (buf, buf, sizeof (buf)) != -1 && This commit fixes the GCC warning by creating a second buffer only to keep the path. Signed-off-by: Rodrigo Siqueira --- lib/igt_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 3313050c..fa22f12d 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1169,10 +1169,10 @@ bool igt_can_fail(void) static bool run_under_gdb(void) { - char buf[1024]; + char pathname[1024], buf[1024]; - sprintf(buf, "/proc/%d/exe", getppid()); - return (readlink (buf, buf, sizeof (buf)) != -1 && + sprintf(pathname, "/proc/%d/exe", getppid()); + return (readlink (pathname, buf, sizeof (buf)) != -1 && strncmp(basename(buf), "gdb", 3) == 0); } -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 2/7] Cast void * pointer used in arithmetic to uint32_t*
This commit fixes the GCC warning: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] memset(ptr + offsets[0], full_range ? 0x00 : 0x10, ^ warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] memset(ptr + offsets[1], 0x80, This commit cast the ptr pointer, which is a void *, to uint32_t * in the pointer arithmetic operation. Signed-off-by: Rodrigo Siqueira --- lib/igt_fb.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index ae71d967..ca905038 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -410,9 +410,11 @@ static int create_bo_for_fb(int fd, int width, int height, switch (format->drm_id) { case DRM_FORMAT_NV12: - memset(ptr + offsets[0], full_range ? 0x00 : 0x10, + memset(((uint32_t *)ptr) + offsets[0], + full_range ? 0x00 : 0x10, calculated_stride * height); - memset(ptr + offsets[1], 0x80, + memset(((uint32_t *)ptr) + offsets[1], + 0x80, calculated_stride * height/2); break; case DRM_FORMAT_YUYV: -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 4/7] Fix truncate string in the snprintf
This patch fix the following GCC warning: intel_reg.c: In function ‘dump_decode’: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(decode, sizeof(decode), "\n%s", bin); intel_reg.c:203:3: note: ‘snprintf’ output between 2 and 1025 bytes into a destination of size 1024 [..] Signed-off-by: Rodrigo Siqueira --- tools/intel_reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/intel_reg.c b/tools/intel_reg.c index ddff2794..15ebb86a 100644 --- a/tools/intel_reg.c +++ b/tools/intel_reg.c @@ -180,7 +180,7 @@ static void to_binary(char *buf, size_t buflen, uint32_t val) static void dump_decode(struct config *config, struct reg *reg, uint32_t val) { - char decode[1024]; + char decode[2060]; char tmp[1024]; char bin[1024]; -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 3/7] Fix comparison that always evaluates to false
This commit fix the GCC warning: warning: bitwise comparison always evaluates to false [-Wtautological-compare] } else if ((val & DPLLB_MODE_LVDS) == DPLLB_MODE_DAC_SERIAL) { The first comparison already checks DPLLB_MODE_LVDS, in this sense, the second 'if' condition always will be false. This commit changes the comparison to DPLLB_MODE_DAC_SERIAL. Signed-off-by: Rodrigo Siqueira --- tools/intel_reg_decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/intel_reg_decode.c b/tools/intel_reg_decode.c index f3c7d74a..5a632e09 100644 --- a/tools/intel_reg_decode.c +++ b/tools/intel_reg_decode.c @@ -1277,7 +1277,7 @@ DEBUGSTRING(ironlake_debug_pch_dpll) p2 = "Div 7"; else p2 = "Div 14"; - } else if ((val & DPLLB_MODE_LVDS) == DPLLB_MODE_DAC_SERIAL) { + } else if ((val & DPLLB_MODE_DAC_SERIAL) == DPLLB_MODE_DAC_SERIAL) { mode = "Non-LVDS"; if (val & DPLL_DAC_SERIAL_P2_CLOCK_DIV_5) p2 = "Div 5"; -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 5/7] Make string commands dynamic allocate
This patch fix the following GCC warning: intel_gvtg_test.c: In function ‘create_guest’: intel_gvtg_test.c:127:50: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 4077 [-Wformat-overflow=] [..] intel_gvtg_test.c:127:5: note: ‘sprintf’ output between 36 and 8226 bytes into a destination of size 4096 [..] This patch changes the approach for allocating memory to handle QEMU commands by dynamically allocate space to save the whole command. Signed-off-by: Rodrigo Siqueira --- tools/intel_gvtg_test.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c index 659b7956..93c05e37 100644 --- a/tools/intel_gvtg_test.c +++ b/tools/intel_gvtg_test.c @@ -120,16 +120,25 @@ static int check_tools(void) static void create_guest(void) { -char create_qcow_cmd[PATH_MAX] = {0}; -char create_vgpu_cmd[PATH_MAX] = {0}; -char create_instance_cmd[PATH_MAX] = {0}; +unsigned int max_size_cmd = sysconf(_SC_ARG_MAX); +char *command; -sprintf(create_qcow_cmd, "qemu-img create -b %s -f qcow2 %s.qcow2", +command = malloc(max_size_cmd); +if (!command) +return; + +sprintf(command, "qemu-img create -b %s -f qcow2 %s.qcow2", hda_path, hda_path); -sprintf(create_vgpu_cmd, "echo \"%s\" > /sys/bus/pci/devices/:00:02.0/" +igt_assert_eq(system(command), 0); +memset(command, 0, max_size_cmd); + +sprintf(command, "echo \"%s\" > /sys/bus/pci/devices/:00:02.0/" "mdev_supported_types/$(ls /sys/bus/pci/devices/:00:02.0/" "mdev_supported_types |awk {'print $1'}|tail -1)/create", uuid); -sprintf(create_instance_cmd, "%s -m 2048 -smp 2 -M pc -name gvtg_guest" +igt_assert_eq(system(command), 0); +memset(command, 0, max_size_cmd); + +sprintf(command, "%s -m 2048 -smp 2 -M pc -name gvtg_guest" " -hda %s.qcow2 -bios %s -enable-kvm --net nic,macaddr=%s -net" " tap,script=/etc/qemu-ifup -vga cirrus -k en-us" " -serial stdio -vnc :1 -machine kernel_irqchip=on -global" @@ -137,9 +146,9 @@ static void create_guest(void) " -usb -usbdevice tablet -device vfio-pci,sysfsdev=" "/sys/bus/pci/devices/:00:02.0/%s &", qemu_path, hda_path, bios_path, mac_addr, uuid); -igt_assert_eq(system(create_qcow_cmd), 0); -igt_assert_eq(system(create_vgpu_cmd), 0); -igt_assert_eq(system(create_instance_cmd), 0); +igt_assert_eq(system(command), 0); + +free(command); } static void destroy_all_guest(void) -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 6/7] Fix truncate string in the strncpy
This patch fix the following GCC Warnings: warning: ‘strncpy’ output truncated before terminating nul copying 36 bytes from a string of the same length [-Wstringop-truncation] [..] Signed-off-by: Rodrigo Siqueira --- tests/perf.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/perf.c b/tests/perf.c index 95048bfa..031bcee8 100644 --- a/tests/perf.c +++ b/tests/perf.c @@ -3693,7 +3693,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* invalid mux_regs */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 1; config.mux_regs_ptr = to_user_pointer(invalid_mux_regs); config.n_boolean_regs = 0; @@ -3702,7 +3702,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* empty config */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 0; config.mux_regs_ptr = to_user_pointer(mux_regs); config.n_boolean_regs = 0; @@ -3711,7 +3711,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* empty config with null pointers */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 1; config.mux_regs_ptr = to_user_pointer(NULL); config.n_boolean_regs = 2; @@ -3722,7 +3722,7 @@ test_invalid_create_userspace_config(void) igt_assert_eq(__i915_perf_add_config(drm_fd, &config), -EINVAL); /* invalid pointers */ - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 42; config.mux_regs_ptr = to_user_pointer((void *) 0xDEADBEEF); config.n_boolean_regs = 0; @@ -3809,7 +3809,7 @@ test_create_destroy_userspace_config(void) i915_perf_remove_config(drm_fd, config_id); memset(&config, 0, sizeof(config)); - strncpy(config.uuid, uuid, sizeof(config.uuid)); + strncpy(config.uuid, uuid, strlen(config.uuid)); config.n_mux_regs = 1; config.mux_regs_ptr = to_user_pointer(mux_regs); -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 7/7] Avoid truncate string in __igt_lsof_fds
Note that 'proc_path' parameter in __igt_lsof_fds receives a string which was initialized with the size of PATH_MAX and the local variable 'path' has the same size, but it also have to append: '/', '\0', and the directory name. This situation caused the warning described below. warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Wformat-truncation=] snprintf(path, sizeof(path), "%s/%s", proc_path, d->d_name); note: ‘snprintf’ output between 2 and 4352 bytes into a destination of size 4096 [..] This commit fixes this problem by changing the string size passed by __igt_lsoft to __igt_lsof_fds. The max size for the string is strlen("/proc/%d/cwd")+1 where "%d" can be estimated with CEILING(LOG_10(INT_MAX)), in this sense, it is safe to define a path size of 30 characters. Signed-off-by: Rodrigo Siqueira --- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index ca8ccfbd..d9dbf7ce 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1485,7 +1485,7 @@ __igt_lsof(const char *dir) PROCTAB *proc; proc_t *proc_info; - char path[PATH_MAX]; + char path[30]; char *name_lnk; struct stat st; int state = 0; -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 0/2] Add support to force specific module load
This patchset adds support for forcing a specific module to be loaded via command line. This feature can bring benefits for developers that need to create a new module since they can use IGT as a base test to guide their development (Test-driven development - TDD ). The first patch, expand the size of the module name accepted by IGT to make possible that modules with larger names can be loaded. The second patch has the force option implementation. The discussion about this feature started with an RFC named "[PATCH i-g-t] [RFC] Add support to force specific module load", link: https://www.spinics.net/lists/intel-gfx/msg166764.html Rodrigo Siqueira (2): Increase the string size for a module name Add support for forcing specific module lib/drmtest.c| 39 +++ lib/igt_core.c | 23 +++ lib/igt_core.h | 4 scripts/run-tests.sh | 4 +++- 4 files changed, 61 insertions(+), 9 deletions(-) -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 1/2] Increase the string size for a module name
Some modules name are larger than 5 characters, this can be a problem to add support for other modules. This patch, increase the maximum size in order to enable other modules to use IGT. Signed-off-by: Rodrigo Siqueira --- lib/drmtest.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index fae6f86f..eee733eb 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -60,6 +60,8 @@ #include "ioctl_wrappers.h" #include "igt_dummyload.h" +#define NAME_LEN 32 + /** * SECTION:drmtest * @short_description: Base library for drm tests and tools @@ -82,7 +84,7 @@ static int __get_drm_device_name(int fd, char *name) drm_version_t version; memset(&version, 0, sizeof(version)); - version.name_len = 4; + version.name_len = NAME_LEN; version.name = name; if (!drmIoctl(fd, DRM_IOCTL_VERSION, &version)){ @@ -94,7 +96,7 @@ static int __get_drm_device_name(int fd, char *name) static bool __is_device(int fd, const char *expect) { - char name[5] = ""; + char name[NAME_LEN] = ""; if (__get_drm_device_name(fd, name)) return false; -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t 2/2] Add support for forcing specific module
This commit adds a new option for forcing the use of a specific module indicated via command line. The force command expects a module name which will be used on the target test (changing the standard behavior). Signed-off-by: Rodrigo Siqueira --- lib/drmtest.c| 33 +++-- lib/igt_core.c | 23 +++ lib/igt_core.h | 4 scripts/run-tests.sh | 4 +++- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index eee733eb..a77e2231 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -247,6 +247,20 @@ static int __open_device(const char *base, int offset, unsigned int chipset) if (chipset & DRIVER_AMDGPU && is_amd_device(fd)) return fd; + // Force options + if (get_target_module() && chipset == DRIVER_ANY) { + if (__is_device(fd, get_target_module())) { + return fd; + } + else { + memset(name, 0, sizeof(name)); + __get_drm_device_name(fd, name); + close(fd); + igt_kmod_unload(name, 0); + return -1; + } + } + /* Only VGEM-specific tests should be run on VGEM */ if (chipset == DRIVER_ANY && !is_vgem_device(fd)) return fd; @@ -260,6 +274,7 @@ static int __open_device(const char *base, int offset, unsigned int chipset) static int __open_driver(const char *base, int offset, unsigned int chipset) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + const char* target; static const struct module { unsigned int bit; const char *module; @@ -278,13 +293,19 @@ static int __open_driver(const char *base, int offset, unsigned int chipset) if (fd != -1) return fd; + target = get_target_module(); + pthread_mutex_lock(&mutex); - for (const struct module *m = modules; m->module; m++) { - if (chipset & m->bit) { - if (m->modprobe) - m->modprobe(m->module); - else - modprobe(m->module); + if (target) { + modprobe(target); + } else { + for (const struct module *m = modules; m->module; m++) { + if (chipset & m->bit) { + if (m->modprobe) + m->modprobe(m->module); + else + modprobe(m->module); + } } } pthread_mutex_unlock(&mutex); diff --git a/lib/igt_core.c b/lib/igt_core.c index 5092a3f0..ee085e2a 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -286,6 +286,7 @@ enum { OPT_DESCRIPTION, OPT_DEBUG, OPT_INTERACTIVE_DEBUG, + OPT_FORCE_MODULE, OPT_HELP = 'h' }; @@ -303,6 +304,23 @@ static pthread_mutex_t log_buffer_mutex = PTHREAD_MUTEX_INITIALIZER; GKeyFile *igt_key_file; #endif +char *target_module = NULL; + +void set_target_module(char *target) +{ + if (!target) + igt_warn("No module specified, keep default behaviour"); + + target_module = target; +} + +const char *get_target_module(void) +{ + if (target_module) + return target_module; + return NULL; +} + char *igt_frame_dump_path; const char *igt_test_name(void) @@ -555,6 +573,7 @@ static void print_usage(const char *help_str, bool output_on_stderr) " --debug[=log-domain]\n" " --interactive-debug[=domain]\n" " --help-description\n" + " --force-module \n" " --help\n"); if (help_str) fprintf(f, "%s\n", help_str); @@ -666,6 +685,7 @@ static int common_init(int *argc, char **argv, {"debug", optional_argument, 0, OPT_DEBUG}, {"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG}, {"help", 0, 0, OPT_HELP}, + {"force-module", required_argument, 0, OPT_FORCE_MODULE}, {0, 0, 0, 0} }; char *short_opts; @@ -763,6 +783,9 @@ static int common_init(int *argc, char **argv, print_test_description(); ret = -1; goto out; + case OPT_FORCE_MODULE: + set_target_module(strdup(optarg)); + break;
Re: [Intel-gfx] [igt-dev] [PATCH i-g-t 2/7] Cast void * pointer used in arithmetic to uint32_t*
Hi, Thanks for the feedback, I'm just a little bit confused about the next step here. Is it worth to fix this patch and the others? I got confused since you said that IGT will remove autotools and some of the warnings here does not appear on meson. Best Regards Rodrigo Siqueira On 07/10, Arkadiusz Hiler wrote: > On Tue, Jul 10, 2018 at 03:09:25PM +0100, Chris Wilson wrote: > > Quoting Arkadiusz Hiler (2018-07-10 14:58:49) > > > On Sat, Jul 07, 2018 at 08:22:38PM -0300, Rodrigo Siqueira wrote: > > > > This commit fixes the GCC warning: > > > > > > > > warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] > > > > memset(ptr + offsets[0], full_range ? 0x00 : 0x10, > > > > ^ > > > > warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] > > > > memset(ptr + offsets[1], 0x80, > > > > > > > > This commit cast the ptr pointer, which is a void *, to uint32_t * in > > > > the pointer arithmetic operation. > > > > > > This will change semantics, as according to GNU C standard[1], void > > > pointers have a size of 1 for all arithmetical purposes. > > > > > > So you should be using uint8_t (or char) pointer instead. > > > > Please just fix the compiler flags, we want close compatibility with the > > kernel coding standards which explicitly allow void arithmetic for the > > simplicity it lends to writing code. > > -Chris > > Fair point. > > We don't rise the error with meson, so it is not a change in the gcc > defaults. Somehow autotools manage to end up adding -Wpointer-arith to > BASE_CFLAGS. > > I don't think we should invest time into making autotools behave, since > it's going to be dropped completely. Hopefully this will happen sooner > than later. > > -- > Cheers, > Arek ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v2 i-g-t 1/2] Make string commands dynamic allocate
This patch fix the following GCC warning: intel_gvtg_test.c: In function ‘create_guest’: intel_gvtg_test.c:127:50: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 4077 [-Wformat-overflow=] [..] intel_gvtg_test.c:127:5: note: ‘sprintf’ output between 36 and 8226 bytes into a destination of size 4096 [..] This patch changes the approach for allocating memory to handle QEMU commands by dynamically allocate space to save the whole command. Changes since v1: Arkadiusz Hiler: - Remove overkill allocation for handling commands - Remove unnecessary use of memset Signed-off-by: Rodrigo Siqueira --- tools/intel_gvtg_test.c | 25 - 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c index 659b7956..ad5ee6a6 100644 --- a/tools/intel_gvtg_test.c +++ b/tools/intel_gvtg_test.c @@ -120,16 +120,23 @@ static int check_tools(void) static void create_guest(void) { -char create_qcow_cmd[PATH_MAX] = {0}; -char create_vgpu_cmd[PATH_MAX] = {0}; -char create_instance_cmd[PATH_MAX] = {0}; +unsigned int max_size_cmd = 4 * PATH_MAX; +char *command; -sprintf(create_qcow_cmd, "qemu-img create -b %s -f qcow2 %s.qcow2", +command = malloc(max_size_cmd); +if (!command) +return; + +sprintf(command, "qemu-img create -b %s -f qcow2 %s.qcow2", hda_path, hda_path); -sprintf(create_vgpu_cmd, "echo \"%s\" > /sys/bus/pci/devices/:00:02.0/" +igt_assert_eq(system(command), 0); + +sprintf(command, "echo \"%s\" > /sys/bus/pci/devices/:00:02.0/" "mdev_supported_types/$(ls /sys/bus/pci/devices/:00:02.0/" "mdev_supported_types |awk {'print $1'}|tail -1)/create", uuid); -sprintf(create_instance_cmd, "%s -m 2048 -smp 2 -M pc -name gvtg_guest" +igt_assert_eq(system(command), 0); + +sprintf(command, "%s -m 2048 -smp 2 -M pc -name gvtg_guest" " -hda %s.qcow2 -bios %s -enable-kvm --net nic,macaddr=%s -net" " tap,script=/etc/qemu-ifup -vga cirrus -k en-us" " -serial stdio -vnc :1 -machine kernel_irqchip=on -global" @@ -137,9 +144,9 @@ static void create_guest(void) " -usb -usbdevice tablet -device vfio-pci,sysfsdev=" "/sys/bus/pci/devices/:00:02.0/%s &", qemu_path, hda_path, bios_path, mac_addr, uuid); -igt_assert_eq(system(create_qcow_cmd), 0); -igt_assert_eq(system(create_vgpu_cmd), 0); -igt_assert_eq(system(create_instance_cmd), 0); +igt_assert_eq(system(command), 0); + +free(command); } static void destroy_all_guest(void) -- 2.17.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v2 i-g-t 0/2] Fix some GCC warnings
During the compilation, some GCC (8.1) warnings are shown. This patchset address some of the warnings problems. Changes since v2: - Reduce the total amount of bytes allocated during command handling operation - Remove unnecessary memset operation - Improved commit message Rodrigo Siqueira (2): Make string commands dynamic allocate Fix truncate string in the snprintf tools/intel_gvtg_test.c | 25 - tools/intel_reg.c | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) -- 2.17.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v2 i-g-t 2/2] Fix truncate string in the snprintf
This patch fix the following GCC warning: ../tools/intel_reg.c: In function ‘dump_decode’: ../tools/intel_reg.c:203:41: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(decode, sizeof(decode), "\n%s", bin); [..] ../tools/intel_reg.c:200:40: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 1022 [-Wformat-truncation=] snprintf(decode, sizeof(decode), " (%s)\n%s", tmp, bin); [..] ../tools/intel_reg.c:200:4: note: ‘snprintf’ output between 5 and 2051 bytes into a destination of size 1024 snprintf(decode, sizeof(decode), " (%s)\n%s", tmp, bin); [..] Notice that snprintf writes in the decode variable the values from tmp and bin. These two variables together have 2048 bytes and some extra characters added by snprintf, this commit changed the size of decode to support the combination. Changes since V1: - Improve commit message Signed-off-by: Rodrigo Siqueira --- tools/intel_reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/intel_reg.c b/tools/intel_reg.c index ddff2794..15ebb86a 100644 --- a/tools/intel_reg.c +++ b/tools/intel_reg.c @@ -180,7 +180,7 @@ static void to_binary(char *buf, size_t buflen, uint32_t val) static void dump_decode(struct config *config, struct reg *reg, uint32_t val) { - char decode[1024]; + char decode[2060]; char tmp[1024]; char bin[1024]; -- 2.17.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t 0/2] Add support to force specific module load
Hi, I would like to know if there is any improvement that I can do for this patchset. Thanks On 07/07, Rodrigo Siqueira wrote: > This patchset adds support for forcing a specific module to be loaded > via command line. This feature can bring benefits for developers that > need to create a new module since they can use IGT as a base test to > guide their development (Test-driven development - TDD ). The first > patch, expand the size of the module name accepted by IGT to make > possible that modules with larger names can be loaded. The second patch > has the force option implementation. > > The discussion about this feature started with an RFC named "[PATCH > i-g-t] [RFC] Add support to force specific module load", link: > https://www.spinics.net/lists/intel-gfx/msg166764.html > > Rodrigo Siqueira (2): > Increase the string size for a module name > Add support for forcing specific module > > lib/drmtest.c| 39 +++ > lib/igt_core.c | 23 +++ > lib/igt_core.h | 4 > scripts/run-tests.sh | 4 +++- > 4 files changed, 61 insertions(+), 9 deletions(-) > > -- > 2.18.0 > -- Rodrigo Siqueira http://siqueira.tech Graduate Student Department of Computer Science University of São Paulo ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 i-g-t 0/2] Fix some GCC warnings
Hi, I would like to know if there is any improvement that I can do for this patchset. Thanks On 07/29, Rodrigo Siqueira wrote: > During the compilation, some GCC (8.1) warnings are shown. This patchset > address some of the warnings problems. > > Changes since v2: > - Reduce the total amount of bytes allocated during command handling >operation > - Remove unnecessary memset operation > - Improved commit message > > Rodrigo Siqueira (2): > Make string commands dynamic allocate > Fix truncate string in the snprintf > > tools/intel_gvtg_test.c | 25 - > tools/intel_reg.c | 2 +- > 2 files changed, 17 insertions(+), 10 deletions(-) > > -- > 2.17.0 > -- Rodrigo Siqueira http://siqueira.tech Graduate Student Department of Computer Science University of São Paulo ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH i-g-t] Skip VBlank tests in modules without VBlank
The kms_flip test does not support drivers without VBlank which exclude some virtual drivers. This patch adds a function that checks if a module has a VBlank or not; if a module has VBlank than kms_flip will execute all the VBlank tests, otherwise, VBlank tests will be skipped. Signed-off-by: Rodrigo Siqueira --- lib/igt_aux.c| 14 ++ lib/igt_aux.h| 2 ++ tests/kms_flip.c | 26 -- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 1250d5c5..da5be4bb 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -564,6 +564,20 @@ bool igt_aub_dump_enabled(void) return dump_aub; } +bool igt_there_is_vblank(int drm_fd) +{ + drmVBlank dummy_vbl; + int ret; + + dummy_vbl.request.type = DRM_VBLANK_ABSOLUTE; + ret = drmWaitVBlank(drm_fd, &dummy_vbl); + + if (ret < 0) + return false; + + return true; +} + /* other helpers */ /** * igt_exchange_int: diff --git a/lib/igt_aux.h b/lib/igt_aux.h index ef89faa9..933055e8 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -119,6 +119,8 @@ bool igt_check_boolean_env_var(const char *env_var, bool default_value); bool igt_aub_dump_enabled(void); +bool igt_there_is_vblank(int fd); + /* suspend/hibernate and auto-resume system */ /** diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 393d690a..770fa5f7 100644 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -73,6 +73,7 @@ #define TEST_TS_CONT (1 << 27) #define TEST_BO_TOOBIG (1 << 28) +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) #define EVENT_FLIP (1 << 0) @@ -125,6 +126,18 @@ struct event_state { int seq_step; }; +static bool vblank_dependence(int flags) +{ + int vblank_flags = TEST_VBLANK | TEST_VBLANK_BLOCK | + TEST_VBLANK_ABSOLUTE | TEST_VBLANK_EXPIRED_SEQ | + TEST_TS_CONT | TEST_CHECK_TS | TEST_VBLANK_RACE; + + if (flags & vblank_flags) + return true; + + return false; +} + static float timeval_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec / 100.0f; @@ -493,11 +506,11 @@ static void check_state(const struct test_output *o, const struct event_state *e /* check only valid if no modeset happens in between, that increments by * (1 << 23) on each step. This bounding matches the one in * DRM_IOCTL_WAIT_VBLANK. */ - if (!(o->flags & (TEST_DPMS | TEST_MODESET))) + if (!(o->flags & (TEST_DPMS | TEST_MODESET | TEST_NO_VBLANK))) { igt_assert_f(es->current_seq - (es->last_seq + o->seq_step) <= 1UL << 23, "unexpected %s seq %u, should be >= %u\n", es->name, es->current_seq, es->last_seq + o->seq_step); - + } /* Check that the vblank frame didn't wrap unexpectedly. */ if (o->flags & TEST_TS_CONT) { /* Ignore seq_step here since vblank waits time out immediately @@ -1204,6 +1217,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, unsigned bo_size = 0; uint64_t tiling; int i; + bool vblank = true; switch (crtc_count) { case 1: @@ -1297,6 +1311,14 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, } igt_assert(fb_is_bound(o, o->fb_ids[0])); + vblank = igt_there_is_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no Vblank\n"); + else + o->flags |= TEST_NO_VBLANK; + } + /* quiescent the hw a bit so ensure we don't miss a single frame */ if (o->flags & TEST_CHECK_TS) calibrate_ts(o, crtc_idxs[0]); -- 2.18.0 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH i-g-t 1/2] Increase the string size for a module name
On 08/21, Petri Latvala wrote: > On Sat, Jul 07, 2018 at 08:24:39PM -0300, Rodrigo Siqueira wrote: > > Some modules name are larger than 5 characters, this can be a problem to > > add support for other modules. This patch, increase the maximum size in > > order to enable other modules to use IGT. > > > > Signed-off-by: Rodrigo Siqueira > > --- > > lib/drmtest.c | 6 -- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/lib/drmtest.c b/lib/drmtest.c > > index fae6f86f..eee733eb 100644 > > --- a/lib/drmtest.c > > +++ b/lib/drmtest.c > > @@ -60,6 +60,8 @@ > > #include "ioctl_wrappers.h" > > #include "igt_dummyload.h" > > > > +#define NAME_LEN 32 > > + > > /** > > * SECTION:drmtest > > * @short_description: Base library for drm tests and tools > > @@ -82,7 +84,7 @@ static int __get_drm_device_name(int fd, char *name) > > drm_version_t version; > > > > memset(&version, 0, sizeof(version)); > > - version.name_len = 4; > > + version.name_len = NAME_LEN; > > version.name = name; > > > > if (!drmIoctl(fd, DRM_IOCTL_VERSION, &version)){ > > @@ -94,7 +96,7 @@ static int __get_drm_device_name(int fd, char *name) > > > > static bool __is_device(int fd, const char *expect) > > { > > - char name[5] = ""; > > + char name[NAME_LEN] = ""; > > This would need to be NAME_LEN + 1 to have room for the > null-termination. > > But, is this patch really necessary? Are there false matches from > using a substring of 4 to match driver names? Hi, To test the force option, I used two drivers: Bochs and VKMS. I noticed that Bochs failed to load because the module name is "bochs-drm". Additionally, if we want to add a force option, I assume that someone can have a module name larger than four characters. Make sense? Or Did I missed something? Thanks for your feedback > > -- > Petri Latvala -- Rodrigo Siqueira http://siqueira.tech Graduate Student Department of Computer Science University of São Paulo ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx