From patchwork Mon Oct 22 17:40:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 1627411 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 2FAD6DFB79 for ; Mon, 22 Oct 2012 17:41:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2317B9E75D for ; Mon, 22 Oct 2012 10:41:40 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 2EFC69E75D for ; Mon, 22 Oct 2012 10:40:35 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 22 Oct 2012 10:40:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,631,1344236400"; d="scan'208";a="207580018" Received: from ideak-desk.fi.intel.com (HELO localhost) ([10.237.72.98]) by azsmga001.ch.intel.com with ESMTP; 22 Oct 2012 10:40:14 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Mon, 22 Oct 2012 20:40:06 +0300 Message-Id: <1350927609-14649-3-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350927609-14649-1-git-send-email-imre.deak@intel.com> References: <1350927609-14649-1-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [PATCH 3/5] flip_test: check if the vblank and flip states correlate X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Signed-off-by: Imre Deak --- tests/flip_test.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/tests/flip_test.c b/tests/flip_test.c index 00f98ce..b387bf5 100644 --- a/tests/flip_test.c +++ b/tests/flip_test.c @@ -291,6 +291,11 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, event_handler(&o->flip_state, frame, sec, usec); } +static double frame_time(struct test_output *o) +{ + return 1000.0 * 1000.0 / o->mode.vrefresh; +} + static void fixup_premature_vblank_ts(struct test_output *o, struct event_state *es) { @@ -359,8 +364,7 @@ static void check_state(struct test_output *o, struct event_state *es) if ((o->flags & TEST_CHECK_TS) && (!analog_tv_connector(o))) { timersub(&es->current_ts, &es->last_ts, &diff); - usec_interflip = (double)es->seq_step / - ((double)o->mode.vrefresh) * 1000.0 * 1000.0; + usec_interflip = (double)es->seq_step * frame_time(o); if (fabs((((double) diff.tv_usec) - usec_interflip) / usec_interflip) > 0.005) { fprintf(stderr, "inter-%s ts jitter: %is, %ius\n", @@ -380,13 +384,48 @@ static void check_state(struct test_output *o, struct event_state *es) } } +static void check_state_correlation(struct test_output *o, + struct event_state *es1, + struct event_state *es2) +{ + struct timeval tv_diff; + double ftime; + double usec_diff; + int seq_diff; + + if (es1->count == 0 || es2->count == 0) + return; + + timersub(&es2->current_ts, &es1->current_ts, &tv_diff); + usec_diff = tv_diff.tv_sec * 1000 * 1000 + tv_diff.tv_usec; + + seq_diff = es2->current_seq - es1->current_seq; + ftime = frame_time(o); + usec_diff -= seq_diff * ftime; + + if (fabs(usec_diff) / ftime > 0.005) { + fprintf(stderr, + "timestamp mismatch between %s and %s (diff %.4f sec)\n", + es1->name, es2->name, usec_diff / 1000 / 1000); + exit(14); + } +} + static void check_all_state(struct test_output *o, unsigned int completed_events) { - if (completed_events & EVENT_FLIP) + bool flip, vblank; + + flip = completed_events & EVENT_FLIP; + vblank = completed_events & EVENT_VBLANK; + + if (flip) check_state(o, &o->flip_state); - if (completed_events & EVENT_VBLANK) + if (vblank) check_state(o, &o->vblank_state); + + if (flip && vblank) + check_state_correlation(o, &o->flip_state, &o->vblank_state); } /* Return mask of completed events. */