From patchwork Wed Aug 30 13:56:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowki X-Patchwork-Id: 9929653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3513B60380 for ; Wed, 30 Aug 2017 13:56:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 271BE28643 for ; Wed, 30 Aug 2017 13:56:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BFC128650; Wed, 30 Aug 2017 13:56:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B240E28643 for ; Wed, 30 Aug 2017 13:56:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCCA76E190; Wed, 30 Aug 2017 13:56:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 252246E190 for ; Wed, 30 Aug 2017 13:56:12 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2017 06:56:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,448,1498546800"; d="scan'208";a="124032369" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 30 Aug 2017 06:56:12 -0700 Received: from workstation.fi.intel.com (workstation.fi.intel.com [10.237.68.33]) by linux.intel.com (Postfix) with ESMTP id 4C46D58035C; Wed, 30 Aug 2017 06:56:11 -0700 (PDT) From: Paul Kocialkowski To: intel-gfx@lists.freedesktop.org Date: Wed, 30 Aug 2017 16:56:09 +0300 Message-Id: <20170830135609.9010-1-paul.kocialkowski@linux.intel.com> X-Mailer: git-send-email 2.14.0 Subject: [Intel-gfx] [PATCH i-g-t] lib/igt_aux: Allow sysfs open to fail when setting suspend/resume delay 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-Virus-Scanned: ClamAV using ClamSMTP This removes the igt_require condition on the sysfs open call used to write the suspend/resume delay so that it is allowed to fail. Intsead, the code that depends on it is put in a conditional block. This allows running test binaries as a non-privileged user for e.g. listing the available tests with the SuspendResumeDelay parameter set in igtrc configuration. Sysfs access would otherwise cause it to fail. Signed-off-by: Paul Kocialkowski Reviewed-by: Arkadiusz Hiler --- lib/igt_aux.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index f428f159..d808fe3e 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -883,19 +883,21 @@ void igt_set_autoresume_delay(int delay_secs) igt_skip_on_simulation(); - igt_require((delay_fd = open("/sys/module/suspend/parameters/pm_test_delay", - O_RDWR)) >= 0); + delay_fd = open("/sys/module/suspend/parameters/pm_test_delay", O_RDWR); + + if (delay_fd >= 0) { + if (!original_autoresume_delay) { + igt_require(read(delay_fd, delay_str, + sizeof(delay_str))); + original_autoresume_delay = atoi(delay_str); + igt_install_exit_handler(igt_restore_autoresume_delay); + } - if (!original_autoresume_delay) { - igt_require(read(delay_fd, delay_str, sizeof(delay_str))); - original_autoresume_delay = atoi(delay_str); - igt_install_exit_handler(igt_restore_autoresume_delay); - } + snprintf(delay_str, sizeof(delay_str), "%d", delay_secs); + igt_require(write(delay_fd, delay_str, strlen(delay_str))); - snprintf(delay_str, sizeof(delay_str), "%d", delay_secs); - igt_require(write(delay_fd, delay_str, strlen(delay_str))); - - close(delay_fd); + close(delay_fd); + } autoresume_delay = delay_secs; }