summaryrefslogtreecommitdiff
path: root/lib/drmtest.c
diff options
context:
space:
mode:
authorXiong Zhang <xiong.y.zhang@intel.com>2013-07-19 18:42:51 +0800
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-07-19 18:12:36 +0200
commit7ea2983b119a13f535a9a01fbfd28a05eb3014f2 (patch)
treee08c22f009fffe1b9ba44bcdece78d21fcd98bea /lib/drmtest.c
parent161e610765b0b590a93c5a69468bc75f726c3f1b (diff)
lib/drmtest: add drmtest_disable/enable_prefault() function
V2: add exit handler to enable prefault (Daniel) Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
Diffstat (limited to 'lib/drmtest.c')
-rw-r--r--lib/drmtest.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index a9a7498a..49742b7a 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -1605,3 +1605,53 @@ 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;
+}
+
+static void enable_prefault_at_exit(int sig)
+{
+ drmtest_enable_prefault();
+}
+
+int drmtest_disable_prefault(void)
+{
+ drmtest_install_exit_handler(enable_prefault_at_exit);
+
+ return drmtest_prefault_control(false);
+}
+
+int drmtest_enable_prefault(void)
+{
+ return drmtest_prefault_control(true);
+}
+