From patchwork Tue Jan 26 13:40:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 8122291 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 29E909F818 for ; Tue, 26 Jan 2016 13:41:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 499E020254 for ; Tue, 26 Jan 2016 13:41:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2E1DB20270 for ; Tue, 26 Jan 2016 13:41:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF4DC6E5C7; Tue, 26 Jan 2016 05:41:43 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTP id 53C516E5C7 for ; Tue, 26 Jan 2016 05:41:42 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 26 Jan 2016 05:41:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,350,1449561600"; d="scan'208";a="36383967" Received: from svosulli-mobl3.amr.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.252.193.19]) by fmsmga004.fm.intel.com with ESMTP; 26 Jan 2016 05:41:20 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Jan 2016 11:40:15 -0200 Message-Id: <1453815615-29099-1-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.0.rc3 Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH igt] tools/intel_residency: use setitimer instead of {, u}alarm 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 It seems that Android doesn't have ualarm(). Let's use setitimer() instead. The tool still won't compile on Android due to igt_fb requiring Cairo, but we're supposed to solve this in another patch since our igt_fb calls don't actually require Cairo. Reported-by: Derek Morton Signed-off-by: Paulo Zanoni --- tools/intel_residency.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tools/intel_residency.c b/tools/intel_residency.c index 7b820c1..74074c5 100644 --- a/tools/intel_residency.c +++ b/tools/intel_residency.c @@ -23,6 +23,8 @@ * Authors: Paulo Zanoni * */ + +#include #include #include #include @@ -311,6 +313,14 @@ static void setup_alarm(void) sigaction(SIGALRM, &sa, NULL); } +static void set_alarm(time_t sec, suseconds_t usec) +{ + struct itimerval timerval = {{0, 0}, {sec, usec}}; + + alarm_received = false; + igt_assert(setitimer(ITIMER_REAL, &timerval, NULL) == 0); +} + static void unset_mode(void) { int rc; @@ -370,8 +380,7 @@ static void wait_until_idle(void) uint64_t tsc, pc, res; do { - alarm_received = false; - ualarm(500 * 1000, 0); + set_alarm(0, 500 * 1000); tsc = msr_read(IA32_TIME_STAMP_COUNTER); pc = msr_read(deepest_pc_state); @@ -398,12 +407,10 @@ static uint64_t do_measurement(void (*callback)(void *ptr), void *ptr) wait_until_idle(); - alarm_received = false; - alarm(opts.res_warm_time); + set_alarm(opts.res_warm_time, 0); callback(ptr); - alarm_received = false; - alarm(opts.res_calc_time); + set_alarm(opts.res_calc_time, 0); tsc = msr_read(IA32_TIME_STAMP_COUNTER); pc = msr_read(deepest_pc_state); @@ -423,13 +430,11 @@ static void setup_idle(void) for (retries = 0; ; retries++) { - alarm_received = false; - alarm(opts.res_warm_time); + set_alarm(opts.res_warm_time, 0); while (!alarm_received) pause(); - alarm_received = false; - alarm(opts.res_calc_time); + set_alarm(opts.res_calc_time, 0); tsc = msr_read(IA32_TIME_STAMP_COUNTER); for (pc_i = best_pc_i; pc_i < NUM_PC_STATES; pc_i++)