From: Daniel Vetter Subject: Re: [PATCH] lib/igt_aux: make igt_wait_for_pm_status() resist the signal helper Date: Tue, 21 Oct 2014 17:18:22 +0200 Message-ID: <20141021151822.GQ26941@phenom.ffwll.local> References: <1413313942-23351-1-git-send-email-przanoni@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 6872D6E203 for ; Tue, 21 Oct 2014 08:18:20 -0700 (PDT) Received: by mail-wg0-f44.google.com with SMTP id y10so1601799wgg.27 for ; Tue, 21 Oct 2014 08:18:15 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1413313942-23351-1-git-send-email-przanoni@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Paulo Zanoni Cc: intel-gfx@lists.freedesktop.org, Paulo Zanoni List-Id: intel-gfx@lists.freedesktop.org On Tue, Oct 14, 2014 at 04:12:22PM -0300, Paulo Zanoni wrote: > 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); Should we have a generic igt_usleep helper which is signal-robust? Just a quick idea since there's probably more like these. -Daniel > + } while (diff.tv_sec < 10); > > return false; > } > -- > 1.9.1 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch