From patchwork Tue Oct 23 09:07:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 1629521 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 3CED23FD4E for ; Tue, 23 Oct 2012 09:37:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 319EE9F38E for ; Tue, 23 Oct 2012 02:37:49 -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 0A3349F363 for ; Tue, 23 Oct 2012 02:07:54 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 23 Oct 2012 02:07:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,634,1344236400"; d="scan'208";a="207871930" Received: from ideak-desk.fi.intel.com (HELO localhost) ([10.237.72.98]) by azsmga001.ch.intel.com with ESMTP; 23 Oct 2012 02:07:53 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Tue, 23 Oct 2012 12:07:52 +0300 Message-Id: <1350983272-26906-1-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350927609-14649-5-git-send-email-imre.deak@intel.com> References: <1350927609-14649-5-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [PATCH v2] flip_test: add wf-vblank test for expired sequence 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 | 58 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 10 deletions(-) In v2: - Wait for the seq that just completed (current_seq) not last_seq - 1. - Do an equality check for ts and seq instead of >=. The previous issue didn't let us do this before. - Simplify the condition when we do an "expired sequence" check by only using the last flip event as a reference. diff --git a/tests/flip_test.c b/tests/flip_test.c index 7fed2f1..3dfce8e 100644 --- a/tests/flip_test.c +++ b/tests/flip_test.c @@ -52,6 +52,7 @@ #define TEST_VBLANK (1 << 8) #define TEST_VBLANK_BLOCK (1 << 9) #define TEST_VBLANK_ABSOLUTE (1 << 10) +#define TEST_VBLANK_EXPIRED_SEQ (1 << 11) #define EVENT_FLIP (1 << 0) #define EVENT_VBLANK (1 << 1) @@ -116,6 +117,16 @@ struct test_output { unsigned int pending_events; }; + +static unsigned long gettime_us(void) +{ + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts); + + return ts.tv_sec * 1000000 + ts.tv_nsec / 1000; +} + static void emit_dummy_load(struct test_output *o) { int i, limit; @@ -221,13 +232,14 @@ struct vblank_reply { struct timeval ts; }; -static int do_wait_for_vblank(struct test_output *o, int crtc_idx, - int target_seq, struct vblank_reply *reply) +static int __wait_for_vblank(unsigned int flags, int crtc_idx, + int target_seq, unsigned long ret_data, + struct vblank_reply *reply) { drmVBlank wait_vbl; int ret; unsigned crtc_idx_mask; - bool event = !(o->flags & TEST_VBLANK_BLOCK); + bool event = !(flags & TEST_VBLANK_BLOCK); memset(&wait_vbl, 0, sizeof(wait_vbl)); @@ -235,13 +247,13 @@ static int do_wait_for_vblank(struct test_output *o, int crtc_idx, assert(!(crtc_idx_mask & ~DRM_VBLANK_HIGH_CRTC_MASK)); wait_vbl.request.type = crtc_idx_mask; - if (o->flags & TEST_VBLANK_ABSOLUTE) + if (flags & TEST_VBLANK_ABSOLUTE) wait_vbl.request.type |= DRM_VBLANK_ABSOLUTE; else wait_vbl.request.type |= DRM_VBLANK_RELATIVE; if (event) { wait_vbl.request.type |= DRM_VBLANK_EVENT; - wait_vbl.request.signal = (unsigned long)o; + wait_vbl.request.signal = ret_data; } wait_vbl.request.sequence = target_seq; @@ -251,17 +263,25 @@ static int do_wait_for_vblank(struct test_output *o, int crtc_idx, reply->ts.tv_sec = wait_vbl.reply.tval_sec; reply->ts.tv_usec = wait_vbl.reply.tval_usec; reply->sequence = wait_vbl.reply.sequence; - - if (event) { - assert(!(o->pending_events & EVENT_VBLANK)); - o->pending_events |= EVENT_VBLANK; - } } else ret = -errno; return ret; } +static int do_wait_for_vblank(struct test_output *o, int pipe_id, + int target_seq, struct vblank_reply *reply) +{ + int ret; + + ret = __wait_for_vblank(o->flags, pipe_id, target_seq, (unsigned long)o, + reply); + if (ret == 0 && !(o->flags & TEST_VBLANK_BLOCK)) + set_flag(&o->pending_events, EVENT_VBLANK); + + return ret; +} + static bool analog_tv_connector(struct test_output *o) { @@ -460,6 +480,22 @@ static unsigned int run_test_step(struct test_output *o) o->current_fb_id = !o->current_fb_id; new_fb_id = o->fb_ids[o->current_fb_id]; + if ((o->flags & TEST_VBLANK_EXPIRED_SEQ) && + !(o->pending_events & EVENT_VBLANK) && o->flip_state.count > 0) { + struct vblank_reply reply; + unsigned int exp_seq; + unsigned long start; + + exp_seq = o->flip_state.current_seq; + start = gettime_us(); + do_or_die(__wait_for_vblank(TEST_VBLANK_ABSOLUTE | + TEST_VBLANK_BLOCK, o->pipe, exp_seq, + 0, &reply)); + assert(gettime_us() - start < 500); + assert(reply.sequence == exp_seq); + assert(timercmp(&reply.ts, &o->flip_state.last_ts, ==)); + } + if (do_flip && (o->flags & TEST_EINVAL) && o->flip_state.count > 0) assert(do_page_flip(o, new_fb_id) == expected_einval); @@ -934,6 +970,8 @@ int main(int argc, char **argv) { 30, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_LOAD, "delayed flip vs panning" }, { 30, TEST_FLIP | TEST_MODESET | TEST_EINVAL, "flip vs modeset" }, { 30, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_LOAD, "delayed flip vs modeset" }, + { 5, TEST_FLIP | TEST_VBLANK_EXPIRED_SEQ, + "flip vs. expired vblank" }, { 15, TEST_FLIP | TEST_VBLANK | TEST_VBLANK_ABSOLUTE | TEST_CHECK_TS, "flip vs absolute wf-vblank" },