From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 23 Apr 2019 11:18:02 -0300 From: Rodrigo Siqueira Message-ID: <20190423141802.ceddj3qbt7hqla2w@smtp.gmail.com> MIME-Version: 1.0 Subject: [igt-dev] [PATCH v7 i-g-t] tests/kms_flip: Skip VBlank tests in modules without VBlank List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1040962573==" Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To: Petri Latvala , Arkadiusz Hiler , Daniel Vetter , Chris Wilson , Ville =?utf-8?B?U3lyasOkbMOk?= Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org List-ID: --===============1040962573== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7atr2mwv5336ftmx" Content-Disposition: inline --7atr2mwv5336ftmx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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); } =20 +/** + * 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 VBla= nk. + * + * Returns: true if target driver has VBlank support, otherwise return fal= se. + */ +bool kms_has_vblank(int fd) +{ + drmVBlank dummy_vbl; + + memset(&dummy_vbl, 0, sizeof(drmVBlank)); + dummy_vbl.request.type =3D DRM_VBLANK_RELATIVE; + + errno =3D 0; + drmWaitVBlank(fd, &dummy_vbl); + return (errno !=3D 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, boo= l visibility); =20 +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) =20 +#define TEST_NO_VBLANK (1 << 29) #define TEST_BASIC (1 << 30) =20 #define EVENT_FLIP (1 << 0) @@ -126,6 +127,18 @@ struct event_state { int seq_step; }; =20 +static bool vblank_dependence(int flags) +{ + int vblank_flags =3D 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 / 1000000.0f; @@ -1176,6 +1189,7 @@ static void run_test_on_crtc_set(struct test_output *= o, int *crtc_idxs, unsigned bo_size =3D 0; uint64_t tiling; int i; + bool vblank =3D true; =20 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])); =20 + vblank =3D kms_has_vblank(drm_fd); + if (!vblank) { + if (vblank_dependence(o->flags)) + igt_require_f(vblank, "There is no VBlank\n"); + else + o->flags |=3D 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]); --=20 2.21.0 --7atr2mwv5336ftmx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE4tZ+ii1mjMCMQbfkWJzP/comvP8FAly/HpoACgkQWJzP/com vP/IHw/+P3WZhANv2DPOHL6vawp1zwW+8Ub6/XP5lHsigzB2Fbt0fLu2tHLf1g0C qrOpU9ZkcPicLfaL6GU1vNnN5j7bd2iVK3zXF7ByiMSTLdvB+7rK+w9l2LSWGPFe qxsbP1gHwDPnUdq+Ihk7bPYPdVdkguvSuQpvt9DKs1zGH5cGYLrg3vGWSdmri7e5 ak4msJ5/nkOFZOG/w9nLz/j9UpXWXIYacNiGrVtp2Cgj5ZcFRdHf2QFqXNIvneN2 i993GJe+Xxw0jxtPSr5g5RnRL7fCS2uF39hNtCub8aUGP1klyJ0YdmJN09Jz3gcT cXbKcTdpDRwjOz/YE73BR4L8WmyEM9Tjo6RFRGWB/tHfA0WtF1EpzIMwj8qyXBYv MSkRSpvY9cLjIglgIboU4Fs5b/rA4se2syNE9Hn8HK/3GcfbW0rgqShWqIcztenn bTvEoUtSY+Jht2Ky0gr4FeisOWQW3VoYZCBVTPGTEhmAmP2ZQQKXqMyeI4ckBYGM mflhCkX+hDLCXnRC9SsDex+WltvgwUwPpVo3hhYILZTzRDibPcvH+a8a3pFQiWFd HOURDQJwEIVOIreN3eaGfzEeNeyvCToxOZ4XQlWebVKXHs5Ch7WXeVN0SqpmMCoB gFo5IW9rnNZy/EUpjqN7/ZcampgJ/VId61PbF1bv4XZV0HHGO24= =IuIr -----END PGP SIGNATURE----- --7atr2mwv5336ftmx-- --===============1040962573== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KaWd0LWRldiBt YWlsaW5nIGxpc3QKaWd0LWRldkBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0cHM6Ly9saXN0cy5m cmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9pZ3QtZGV2 --===============1040962573==--