From: Marius Vlad Subject: Re: [PATCH i-g-t v4 4/5] kms_vblank: Switch from using crtc0 statically to explicitly setting mode. Date: Mon, 9 May 2016 18:38:35 +0300 Message-ID: <20160509153823.GA29124@mcvlad-wk.rb.intel.com> References: <1461686062-24630-1-git-send-email-robert.foss@collabora.com> <1461686062-24630-5-git-send-email-robert.foss@collabora.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0541527197==" Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EB306E320 for ; Mon, 9 May 2016 15:35:53 +0000 (UTC) In-Reply-To: <1461686062-24630-5-git-send-email-robert.foss@collabora.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: robert.foss@collabora.com Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org, daniel.stone@collabora.com, tomeu.vizoso@collabora.com List-Id: intel-gfx@lists.freedesktop.org --===============0541527197== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="E39vaYmALEf/7YXx" Content-Disposition: inline --E39vaYmALEf/7YXx Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 26, 2016 at 11:54:21AM -0400, robert.foss@collabora.com wrote: > From: Robert Foss >=20 > Previously crtc0 was statically used for VBLANK tests, but > that assumption is not valid for the VC4 platform. > Instead we're now explicitly setting the mode. >=20 > Also add support for testing all connected connectors during > the same test. >=20 > Signed-off-by: Robert Foss > --- > tests/kms_vblank.c | 162 ++++++++++++++++++++++++++++++++++++++++++++---= ------ > 1 file changed, 137 insertions(+), 25 deletions(-) >=20 > diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c > index 40ab6fd..6c32c57 100644 > --- a/tests/kms_vblank.c > +++ b/tests/kms_vblank.c > @@ -44,6 +44,14 @@ > =20 > IGT_TEST_DESCRIPTION("Test speed of WaitVblank."); > =20 > +typedef struct { > + igt_display_t display; > + struct igt_fb primary_fb; > + igt_output_t *output; > + enum pipe pipe; > + uint8_t mode_busy:1; > +} data_t; > + > static double elapsed(const struct timespec *start, > const struct timespec *end, > int loop) > @@ -51,38 +59,119 @@ static double elapsed(const struct timespec *start, > return (1e6*(end->tv_sec - start->tv_sec) + (end->tv_nsec - start->tv_n= sec)/1000)/loop; > } > =20 > -static bool crtc0_active(int fd) > +static bool prepare_crtc(data_t *data, int fd, igt_output_t *output) > { > - union drm_wait_vblank vbl; > + drmModeModeInfo *mode; > + igt_display_t *display =3D &data->display; > + igt_plane_t *primary; > + > + /* select the pipe we want to use */ > + igt_output_set_pipe(output, data->pipe); > + igt_display_commit(display); > + > + if (!output->valid) { > + igt_output_set_pipe(output, PIPE_ANY); > + igt_display_commit(display); > + return false; > + } > =20 > - memset(&vbl, 0, sizeof(vbl)); > - vbl.request.type =3D DRM_VBLANK_RELATIVE; > - return drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl) =3D=3D 0; > + /* create and set the primary plane fb */ > + mode =3D igt_output_get_mode(output); > + igt_create_color_fb(fd, mode->hdisplay, mode->vdisplay, > + DRM_FORMAT_XRGB8888, > + LOCAL_DRM_FORMAT_MOD_NONE, > + 0.0, 0.0, 0.0, > + &data->primary_fb); > + > + primary =3D igt_output_get_plane(output, IGT_PLANE_PRIMARY); > + igt_plane_set_fb(primary, &data->primary_fb); > + > + igt_display_commit(display); > + > + igt_wait_for_vblank(fd, data->pipe); > + > + return true; > } > =20 > -static void accuracy(int fd) > +static void cleanup_crtc(data_t *data, int fd, igt_output_t *output) > +{ > + igt_display_t *display =3D &data->display; > + igt_plane_t *primary; > + > + igt_remove_fb(fd, &data->primary_fb); > + > + primary =3D igt_output_get_plane(output, IGT_PLANE_PRIMARY); > + igt_plane_set_fb(primary, NULL); > + > + igt_output_set_pipe(output, PIPE_ANY); > + igt_display_commit(display); > +} > + > +static void run_test(data_t *data, int fd, void (*testfunc)(data_t *, in= t)) > +{ > + igt_display_t *display =3D &data->display; > + igt_output_t *output; > + enum pipe p; > + unsigned int valid_tests =3D 0; > + > + for_each_connected_output(display, output) { > + for_each_pipe(display, p) { > + data->pipe =3D p; > + > + if (!prepare_crtc(data, fd, output)) > + continue; > + > + valid_tests++; > + > + igt_info("Beginning %s on pipe %s, connector %s\n", > + igt_subtest_name(), > + kmstest_pipe_name(data->pipe), > + igt_output_name(output)); > + > + testfunc(data, fd); > + > + igt_info("\n%s on pipe %s, connector %s: PASSED\n\n", > + igt_subtest_name(), > + kmstest_pipe_name(data->pipe), > + igt_output_name(output)); > + > + /* cleanup what prepare_crtc() has done */ > + cleanup_crtc(data, fd, output); > + } > + } > + > + igt_require_f(valid_tests, "no valid crtc/connector combinations found\= n"); > +} > + > +static void accuracy(data_t *data, int fd) > { > union drm_wait_vblank vbl; > unsigned long target; > + uint32_t pipe_id_flag; > int n; > =20 > memset(&vbl, 0, sizeof(vbl)); > + pipe_id_flag =3D pipe_id_to_vbl_flag(data->pipe); > =20 > vbl.request.type =3D DRM_VBLANK_RELATIVE; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 1; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > =20 > target =3D vbl.reply.sequence + 60; > for (n =3D 0; n < 60; n++) { > vbl.request.type =3D DRM_VBLANK_RELATIVE; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 1; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > =20 > vbl.request.type =3D DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D target; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > } > vbl.request.type =3D DRM_VBLANK_RELATIVE; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 0; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > igt_assert_eq(vbl.reply.sequence, target); > @@ -94,22 +183,26 @@ static void accuracy(int fd) > } > } The accuracy test fails always on pipe B, with Failed assertion: ev.sequence =3D=3D target. Not sure if this a bug in kernel but it seems to happen on a couple of machines I've tested this (and previously we weren't enabling all pipes) > =20 > -static void vblank_query(int fd, bool busy) > +static void vblank_query(data_t *data, int fd) > { > union drm_wait_vblank vbl; > struct timespec start, end; > unsigned long sq, count =3D 0; > struct drm_event_vblank buf; > + uint32_t pipe_id_flag; > =20 > memset(&vbl, 0, sizeof(vbl)); > + pipe_id_flag =3D pipe_id_to_vbl_flag(data->pipe); > =20 > - if (busy) { > + if (data->mode_busy) { > vbl.request.type =3D DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 72; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > } > =20 > vbl.request.type =3D DRM_VBLANK_RELATIVE; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 0; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > =20 > @@ -118,6 +211,7 @@ static void vblank_query(int fd, bool busy) > clock_gettime(CLOCK_MONOTONIC, &start); > do { > vbl.request.type =3D DRM_VBLANK_RELATIVE; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 0; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > count++; > @@ -125,28 +219,32 @@ static void vblank_query(int fd, bool busy) > clock_gettime(CLOCK_MONOTONIC, &end); > =20 > igt_info("Time to query current counter (%s): %7.3f=B5s\n", > - busy ? "busy" : "idle", elapsed(&start, &end, count)); > + data->mode_busy ? "busy" : "idle", elapsed(&start, &end, count)); > =20 > - if (busy) > + if (data->mode_busy) > igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf)); > } > =20 > -static void vblank_wait(int fd, bool busy) > +static void vblank_wait(data_t *data, int fd) > { > union drm_wait_vblank vbl; > struct timespec start, end; > unsigned long sq, count =3D 0; > struct drm_event_vblank buf; > + uint32_t pipe_id_flag; > =20 > memset(&vbl, 0, sizeof(vbl)); > + pipe_id_flag =3D pipe_id_to_vbl_flag(data->pipe); > =20 > - if (busy) { > + if (data->mode_busy) { > vbl.request.type =3D DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 72; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > } > =20 > vbl.request.type =3D DRM_VBLANK_RELATIVE; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 0; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > =20 > @@ -155,6 +253,7 @@ static void vblank_wait(int fd, bool busy) > clock_gettime(CLOCK_MONOTONIC, &start); > do { > vbl.request.type =3D DRM_VBLANK_RELATIVE; > + vbl.request.type |=3D pipe_id_flag; > vbl.request.sequence =3D 1; > do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl); > count++; > @@ -163,36 +262,49 @@ static void vblank_wait(int fd, bool busy) > =20 > igt_info("Time to wait for %ld/%d vblanks (%s): %7.3f=B5s\n", > count, (int)(vbl.reply.sequence - sq), > - busy ? "busy" : "idle", > + data->mode_busy ? "busy" : "idle", > elapsed(&start, &end, count)); > =20 > - if (busy) > + if (data->mode_busy) > igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf)); > } > =20 > igt_main > { > int fd; > + data_t data; > =20 > igt_skip_on_simulation(); > =20 > igt_fixture { > fd =3D drm_open_driver(DRIVER_ANY); > - igt_require(crtc0_active(fd)); > + kmstest_set_vt_graphics_mode(); > + igt_display_init(&data.display, fd); > } > =20 > - igt_subtest("accuracy") > - accuracy(fd); > + igt_subtest("accuracy") { > + data.mode_busy =3D 0; > + run_test(&data, fd, accuracy); > + } > =20 > - igt_subtest("query-idle") > - vblank_query(fd, false); > + igt_subtest("query-idle") { > + data.mode_busy =3D 0; > + run_test(&data, fd, vblank_query); > + } > =20 > - igt_subtest("query-busy") > - vblank_query(fd, true); > + igt_subtest("query-busy") { > + data.mode_busy =3D 1; > + run_test(&data, fd, vblank_query); > + } > =20 > - igt_subtest("wait-idle") > - vblank_wait(fd, false); > + igt_subtest("wait-idle") { > + data.mode_busy =3D 0; > + run_test(&data, fd, vblank_wait); > + } > =20 > - igt_subtest("wait-busy") > - vblank_wait(fd, true); > + igt_subtest("wait-busy") { > + data.mode_busy =3D 1; > + run_test(&data, fd, vblank_wait); > + } > } > + white-space. > --=20 > 2.5.0 >=20 --E39vaYmALEf/7YXx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJXMK74AAoJELmLWIAQzyE+nOYH+waSEVrKjk3EfKGZR02mcezo 0gGbGWJFJ8tmmwK/v97p1dWFdZ3rybR/9RPY8ucdyqhVIAGxwPfl1aMRFLiCFNw6 6Ak3yjz86R1zX2G4q3PVwXzYVPmRu/o0ZlmrZ9EundB5n4JwEknF/BW6ewYpZBf0 EB3qC6dkERabh8LLqO4ZQqWXJGYHBPEQa8AnM4JALTOEZzN9OYrXs6YCW2rPNBds a1rCdZr3DvKiZ9hchsAgE1NnSM3lvnVY70+G+IchENUSEhsxMojxKLcFKwDULQL7 kSp893fSwE4uz1KSv194s7KYA9gy+MeDVU7Ao7xLSsnQRcUd+nZGKE7jpDjVRXY= =W1vZ -----END PGP SIGNATURE----- --E39vaYmALEf/7YXx-- --===============0541527197== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============0541527197==--