From patchwork Tue Oct 14 19:12:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 5082051 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 164B5C11AC for ; Tue, 14 Oct 2014 19:12:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 33C1120204 for ; Tue, 14 Oct 2014 19:12:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 04DF8201F7 for ; Tue, 14 Oct 2014 19:12:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55F8F89B33; Tue, 14 Oct 2014 12:12:47 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qc0-f169.google.com (mail-qc0-f169.google.com [209.85.216.169]) by gabe.freedesktop.org (Postfix) with ESMTP id 26A4889B33 for ; Tue, 14 Oct 2014 12:12:46 -0700 (PDT) Received: by mail-qc0-f169.google.com with SMTP id o8so7394232qcw.14 for ; Tue, 14 Oct 2014 12:12:45 -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; bh=+0Vhf83+h+BJ3KdTvu9uCH9XwDEl0zB0/VQmM5k41F4=; b=whXQAFwJxFC9BikK+6KgHL+vKTK83+3yAeTxggW/nizdRSkiLYvPQlBN4fbrMqIOT9 2x5+SD15qqFbi8KnedCDkdDdK2SOJB4WW0AWp5itjr9qyK8JsFK4XxyI1eAVbErpfuAt IA5qIRUg2OKFTNJk+OZ0xijvvhQ9S4luo77b1HKDA272kKbbgpH+HgJvSvtgCUR1cvEW WKFoIOKbnnt0y66bylGHfyFI7o/Lnw2ZNVi+rsEncpai9Uh6lgZhhRa/c843mfH7DJa4 JuzOUu+oLZ0S5YRyDVxZA+ZfG9Ld0uCP1C3lKgG4gyavfdutEcBqjmyhJf7ja+zcvzBW oXqQ== X-Received: by 10.140.42.39 with SMTP id b36mr11184444qga.102.1413313965425; Tue, 14 Oct 2014 12:12:45 -0700 (PDT) Received: from localhost.localdomain (177.204.135.17.dynamic.adsl.gvt.net.br. [177.204.135.17]) by mx.google.com with ESMTPSA id q90sm16149617qgd.4.2014.10.14.12.12.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Oct 2014 12:12:45 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 14 Oct 2014 16:12:22 -0300 Message-Id: <1413313942-23351-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH] lib/igt_aux: make igt_wait_for_pm_status() resist the signal helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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=ham 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 If the signal helper is active, the usleep() calls return earlier, and we may end up returning false way before the 10s timeout, failing the subtests. This currently happens on the kms_flip RPM interruptible subtests. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78893 Signed-off-by: Paulo Zanoni --- lib/igt_aux.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index b32297e..01654f0 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -502,21 +503,27 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void) * Waits until for the driver to switch to into the desired runtime PM status, * with a 10 second timeout. * + * Some subtests call this function while the signal helper is active, so we + * can't assume each usleep() call will sleep for 100ms. + * * Returns: * True if the desired runtime PM status was attained, false if the operation * timed out. */ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status) { - int i; - int hundred_ms = 100 * 1000, ten_s = 10 * 1000 * 1000; + struct timeval start, end, diff; - for (i = 0; i < ten_s; i += hundred_ms) { + igt_assert(gettimeofday(&start, NULL) == 0); + do { if (igt_get_runtime_pm_status() == status) return true; - usleep(hundred_ms); - } + usleep(100 * 1000); + + igt_assert(gettimeofday(&end, NULL) == 0); + timersub(&end, &start, &diff); + } while (diff.tv_sec < 10); return false; }