From patchwork Tue Oct 16 14:34:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 1601111 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 3545F40ABA for ; Tue, 16 Oct 2012 14:50:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E1C9A0891 for ; Tue, 16 Oct 2012 07:50:55 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id DD0ED9F3BA for ; Tue, 16 Oct 2012 07:35:42 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 16 Oct 2012 07:35:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,593,1344236400"; d="scan'208";a="205092424" Received: from ideak-desk.fi.intel.com (HELO localhost) ([10.237.72.98]) by azsmga001.ch.intel.com with ESMTP; 16 Oct 2012 07:35:41 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Tue, 16 Oct 2012 17:34:54 +0300 Message-Id: <1350398096-3649-21-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350398096-3649-1-git-send-email-imre.deak@intel.com> References: <1350398096-3649-1-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [PATCH 20/22] flip_test: add event sequence number tracking 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 | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/flip_test.c b/tests/flip_test.c index 9772599..82ab347 100644 --- a/tests/flip_test.c +++ b/tests/flip_test.c @@ -75,6 +75,7 @@ struct event_state { */ struct timeval last_ts; /* kernel reported timestamp */ struct timeval last_received_ts; /* the moment we received it */ + unsigned int last_seq; /* kernel reported seq. num */ /* * Event data for for the current event that we just received and @@ -82,8 +83,12 @@ struct event_state { */ struct timeval current_ts; /* kernel reported timestamp */ struct timeval current_received_ts; /* the moment we received it */ + unsigned int current_seq; /* kernel reported seq. num */ int count; /* # of events of this type */ + + /* Step between the current and next 'target' sequence number. */ + int seq_step; }; struct test_output { @@ -223,6 +228,7 @@ static void event_handler(struct event_state *es, unsigned int frame, gettimeofday(&es->current_received_ts, NULL); es->current_ts.tv_sec = sec; es->current_ts.tv_usec = usec; + es->current_seq = frame; } static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, @@ -256,10 +262,20 @@ static void check_state(struct test_output *o, struct event_state *es) exit(6); } + if (es->count == 0) + return; - if (es->count > 0 && (o->flags & TEST_CHECK_TS) && (!analog_tv_connector(o))) { + /* This bounding matches the one in DRM_IOCTL_WAIT_VBLANK. */ + if (es->current_seq - (es->last_seq + es->seq_step) > 1UL << 23) { + fprintf(stderr, "unexpected %s seq %u, should be >= %u\n", + es->name, es->current_seq, es->last_seq + es->seq_step); + exit(10); + } + + if ((o->flags & TEST_CHECK_TS) && (!analog_tv_connector(o))) { timersub(&es->current_ts, &es->last_ts, &diff); - usec_interflip = 1.0 / ((double)o->mode.vrefresh) * 1000.0 * 1000.0; + usec_interflip = (double)es->seq_step / + ((double)o->mode.vrefresh) * 1000.0 * 1000.0; if (fabs((((double) diff.tv_usec) - usec_interflip) / usec_interflip) > 0.005) { fprintf(stderr, "inter-%s ts jitter: %is, %ius\n", @@ -269,6 +285,12 @@ static void check_state(struct test_output *o, struct event_state *es) * poll helper :( hence make it non-fatal for now */ //exit(9); } + + if (es->current_seq != es->last_seq + es->seq_step) + fprintf(stderr, "unexpected %s seq %u, expected %u\n", + es->name, es->current_seq, + es->last_seq + es->seq_step); + /* no exit, due to the same reason as above */ } } @@ -361,6 +383,7 @@ static void update_state(struct event_state *es) { es->last_received_ts = es->current_received_ts; es->last_ts = es->current_ts; + es->last_seq = es->current_seq; es->count++; } @@ -499,6 +522,7 @@ static void check_final_state(struct test_output *o, struct event_state *es, int expected; int count = es->count; + count *= es->seq_step; expected = ellapsed * o->mode.vrefresh / (1000 * 1000); if (count < expected * 99/100) { fprintf(stderr, "dropped frames, expected %d, counted %d, encoder type %d\n", @@ -640,6 +664,7 @@ static void flip_mode(struct test_output *o, int duration) wait_for_events(o); o->current_fb_id = 1; + o->flip_state.seq_step = 1; ellapsed = event_loop(o, duration);