From patchwork Wed Mar 25 21:50:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 6095301 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 73CEB9F399 for ; Wed, 25 Mar 2015 21:51:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98BAE2035B for ; Wed, 25 Mar 2015 21:51:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B3EFF202F2 for ; Wed, 25 Mar 2015 21:51:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 425D76E93A; Wed, 25 Mar 2015 14:51:47 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qg0-f45.google.com (mail-qg0-f45.google.com [209.85.192.45]) by gabe.freedesktop.org (Postfix) with ESMTP id B7F406E93E for ; Wed, 25 Mar 2015 14:51:44 -0700 (PDT) Received: by qgep97 with SMTP id p97so66963471qge.1 for ; Wed, 25 Mar 2015 14:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q9n90Xw4g9BH4IvIKD0dYkd7uyluWpCPdFt2hOGoXXU=; b=OYmRN5fTJ1LGYgX8wyDpqhlZK41NOsk2KD781i7OY4GBdNHHathRAGtHSxch95qEBY +5Wa2Asqvj5Y5MYKl6Uf5G//gGU+YCfTd91itrPgzeoU4xHdHEf5druoitpmmV/r+GqO vpSYzlt5TP1xAAU0LPXfCfz8PKztnCi0pBFOzBWSdjpEyc7MeQ7BehlC9q8hvAbmufvL wEoFaHbrFRtElGAXWGTwjMl6A3/JjBlhD45vRGy3EFyDbKB34dHVFomhwaO+qfRibABE 083qiH/FhnibbxmurJSH4Rn1Y/9DBYJLyOwHLavYNadSjEAV2+8hrhvrGYPiWRAyXq5z zQuw== X-Received: by 10.140.130.71 with SMTP id 68mr14911051qhc.12.1427320304258; Wed, 25 Mar 2015 14:51:44 -0700 (PDT) Received: from localhost.localdomain ([187.121.139.226]) by mx.google.com with ESMTPSA id b52sm2308334qgb.16.2015.03.25.14.51.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Mar 2015 14:51:43 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Wed, 25 Mar 2015 18:50:35 -0300 Message-Id: <1427320239-25667-3-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427320239-25667-1-git-send-email-przanoni@gmail.com> References: <1427320239-25667-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 3/7] tests/kms_fbc_crc: add wait_for_fbc_enabled() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni The code has a common pattern of "wait 300ms, then check if FBC is enabled". Most of the time FBC is enabled in either 50ms or 0ms, so introduce wait_for_fbc_enabled(), which can return much earlier if FBC is actually enabled before the 300ms timeout. Signed-off-by: Paulo Zanoni --- tests/kms_fbc_crc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c index b3e6109..11078e0 100644 --- a/tests/kms_fbc_crc.c +++ b/tests/kms_fbc_crc.c @@ -28,6 +28,7 @@ #include #include "drmtest.h" +#include "igt_aux.h" #include "igt_debugfs.h" #include "igt_kms.h" #include "intel_chipset.h" @@ -203,6 +204,11 @@ static bool fbc_enabled(data_t *data) return strstr(str, "FBC enabled") != NULL; } +static bool wait_for_fbc_enabled(data_t *data) +{ + return igt_wait(fbc_enabled(data), 300, 30); +} + static void test_crc(data_t *data, enum test_mode mode) { uint32_t crtc_id = data->output->config.crtc->crtc_id; @@ -216,9 +222,8 @@ static void test_crc(data_t *data, enum test_mode mode) handle = data->handle[1]; igt_assert(drmModePageFlip(data->drm_fd, crtc_id, data->fb_id[1], 0, NULL) == 0); - usleep(300000); - igt_assert(fbc_enabled(data)); + igt_assert(wait_for_fbc_enabled(data)); } switch (mode) { @@ -277,9 +282,7 @@ static void test_crc(data_t *data, enum test_mode mode) * Allow time for FBC to kick in again if it * got disabled during dirtyfb or page flip. */ - usleep(300000); - - igt_assert(fbc_enabled(data)); + igt_assert(wait_for_fbc_enabled(data)); igt_pipe_crc_start(pipe_crc); igt_pipe_crc_get_crcs(pipe_crc, 1, &crcs); @@ -338,9 +341,8 @@ static bool prepare_test(data_t *data, enum test_mode test_mode) /* scanout = fb[1] */ igt_plane_set_fb(data->primary, &data->fb[1]); igt_display_commit(display); - usleep(300000); - if (!fbc_enabled(data)) { + if (!wait_for_fbc_enabled(data)) { igt_info("FBC not enabled\n"); igt_plane_set_fb(data->primary, NULL); @@ -388,9 +390,8 @@ static bool prepare_test(data_t *data, enum test_mode test_mode) /* scanout = fb[0] */ igt_plane_set_fb(data->primary, &data->fb[0]); igt_display_commit(display); - usleep(300000); - igt_assert(fbc_enabled(data)); + igt_assert(wait_for_fbc_enabled(data)); if (test_mode == TEST_CONTEXT || test_mode == TEST_PAGE_FLIP_AND_CONTEXT) { /*