From patchwork Mon Dec 8 16:12:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 5457481 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 391A19F1C5 for ; Mon, 8 Dec 2014 16:13:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E01F20155 for ; Mon, 8 Dec 2014 16:13:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4014320160 for ; Mon, 8 Dec 2014 16:13:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CB1E6E7CB; Mon, 8 Dec 2014 08:13:35 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qc0-f172.google.com (mail-qc0-f172.google.com [209.85.216.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B70C6E7D1 for ; Mon, 8 Dec 2014 08:13:34 -0800 (PST) Received: by mail-qc0-f172.google.com with SMTP id m20so3774469qcx.3 for ; Mon, 08 Dec 2014 08:13:34 -0800 (PST) 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=66Xh3rG3JIF+z0pPOH7WpFQPhjmRx3wiE4MeQzimBt0=; b=s9Mezigs01EOxVZU9mIVM/rIHIQ4RMhnZ3dITrk+wLO15H9hNCuIRf9KElmPBk3S1A 94lA6itlyWwRt5ei9gcUJGPMZE1JlCnejZCMyqqsHRdHucRuqKzNm+O5sActDXX8TPsc ADuIZS/c2pxXXAsIpO/NvJB1K0CvTihXIx+sBdDXhyvEH0RwVCfS9HdR/nc1MUE3VvU7 ifS6wUy9Mx+5y7vdYNb59i+u5G140x0Xw0MsbEItQhhycSNGZ0ykWaj4brUOQhePpv51 76TGIMpDjoikXuRY+MhVi2JWRmGKNqxRisnhc015Z6XGqtzc1taKcPgsebcwRYUWWZzN 83Xg== X-Received: by 10.224.127.74 with SMTP id f10mr53111376qas.16.1418055214054; Mon, 08 Dec 2014 08:13:34 -0800 (PST) Received: from localhost.localdomain ([187.95.104.42]) by mx.google.com with ESMTPSA id l10sm30480245qas.25.2014.12.08.08.13.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 08:13:33 -0800 (PST) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Mon, 8 Dec 2014 14:12:43 -0200 Message-Id: <1418055164-1536-3-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418055164-1536-1-git-send-email-przanoni@gmail.com> References: <1418054960-1403-1-git-send-email-przanoni@gmail.com> <1418055164-1536-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH igt 3/4] 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 7c3a412..354a2b7 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) { @@ -278,9 +283,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); @@ -340,9 +343,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); @@ -390,9 +392,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) { /*