From patchwork Fri Jul 19 05:53:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Xiong Y" X-Patchwork-Id: 2830239 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 BF452C0319 for ; Fri, 19 Jul 2013 05:52:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EEFE9203E6 for ; Fri, 19 Jul 2013 05:52:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F3CB4203E3 for ; Fri, 19 Jul 2013 05:52:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C5D0E6925 for ; Thu, 18 Jul 2013 22:52:23 -0700 (PDT) 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 ESMTP id B00FDE683D for ; Thu, 18 Jul 2013 22:50:19 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 18 Jul 2013 22:50:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,699,1367996400"; d="scan'208";a="372978889" Received: from panda-dev.bj.intel.com ([10.238.154.175]) by orsmga002.jf.intel.com with ESMTP; 18 Jul 2013 22:49:48 -0700 From: Xiong Zhang To: intel-gfx@lists.freedesktop.org Date: Fri, 19 Jul 2013 13:53:08 +0800 Message-Id: <1374213192-2456-1-git-send-email-xiong.y.zhang@intel.com> X-Mailer: git-send-email 1.7.9.5 Subject: [Intel-gfx] [PATCH 1/5] lib/drmtest: add drmtest_disable/enable_prefault() function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.6 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 Signed-off-by: Xiong Zhang --- lib/drmtest.c | 43 +++++++++++++++++++++++++++++++++++++++++++ lib/drmtest.h | 3 +++ 2 files changed, 46 insertions(+) diff --git a/lib/drmtest.c b/lib/drmtest.c index 011d8c1..713c5ff 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -1593,3 +1593,46 @@ void kmstest_free_connector_config(struct kmstest_connector_config *config) drmModeFreeEncoder(config->encoder); drmModeFreeConnector(config->connector); } + +#define PREFAULT_DEBUGFS "/sys/module/i915/parameters/prefault_disable" +static int drmtest_prefault_control(bool enable) +{ + char *name = PREFAULT_DEBUGFS; + int fd; + char buf[2] = {'Y', 'N'}; + int index; + int result = 0; + + fd = open(name, O_RDWR); + if (fd == -1) { + fprintf(stderr, "Couldn't open prefault_debugfs.%s\n", + strerror(errno)); + return -1; + } + + if (enable) + index = 1; + else + index = 0; + + if (write(fd, &buf[index], 1) != 1) { + fprintf(stderr, "write prefault_debugfs error.%s\n", + strerror(errno)); + result = -1; + } + + close(fd); + + return result; +} + +int drmtest_disable_prefault(void) +{ + return drmtest_prefault_control(false); +} + +int drmtest_enable_prefault(void) +{ + return drmtest_prefault_control(true); +} + diff --git a/lib/drmtest.h b/lib/drmtest.h index e3a9275..80b344c 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -179,3 +179,6 @@ void drmtest_enable_exit_handler(void); void drmtest_disable_exit_handler(void); int drmtest_set_vt_graphics_mode(void); + +int drmtest_disable_prefault(void); +int drmtest_enable_prefault(void);