[Intel-gfx] [PATCH 1/5] lib: move prefault helpers to igt_debugfs.c
Daniel Vetter
daniel.vetter at ffwll.ch
Wed Mar 12 20:59:59 CET 2014
This way all debugfs library code is in one place, ready for some api
documentation care.
---
lib/drmtest.c | 38 ----------------------------------
lib/drmtest.h | 4 ----
lib/igt_debugfs.c | 45 +++++++++++++++++++++++++++++++++++++++++
lib/igt_debugfs.h | 8 ++++++++
tests/gem_exec_faulting_reloc.c | 1 +
tests/gem_mmap_gtt.c | 1 +
6 files changed, 55 insertions(+), 42 deletions(-)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index a5aac4dce126..78b9999d76f6 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -425,44 +425,6 @@ void igt_cleanup_aperture_trashers(void)
free(trash_bos);
}
-#define PREFAULT_DEBUGFS "/sys/module/i915/parameters/prefault_disable"
-static void igt_prefault_control(bool enable)
-{
- const char *name = PREFAULT_DEBUGFS;
- int fd;
- char buf[2] = {'Y', 'N'};
- int index;
-
- fd = open(name, O_RDWR);
- igt_require(fd >= 0);
-
- if (enable)
- index = 1;
- else
- index = 0;
-
- igt_require(write(fd, &buf[index], 1) == 1);
-
- close(fd);
-}
-
-static void enable_prefault_at_exit(int sig)
-{
- igt_enable_prefault();
-}
-
-void igt_disable_prefault(void)
-{
- igt_prefault_control(false);
-
- igt_install_exit_handler(enable_prefault_at_exit);
-}
-
-void igt_enable_prefault(void)
-{
- igt_prefault_control(true);
-}
-
void igt_system_suspend_autoresume(void)
{
int ret;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index f9f21d396c44..593f31b97a11 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -77,10 +77,6 @@ void igt_cleanup_aperture_trashers(void);
/* set vt into graphics mode, required to prevent fbcon from interfering */
void igt_set_vt_graphics_mode(void);
-/* prefault disabling, needs the corresponding debugfs interface */
-void igt_disable_prefault(void);
-void igt_enable_prefault(void);
-
/* suspend and auto-resume system */
void igt_system_suspend_autoresume(void);
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 4a4a4dd4107b..32edc435e4bc 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -34,6 +34,9 @@
#include "igt_display.h"
#include "igt_debugfs.h"
+/*
+ * General debugfs helpers
+ */
int igt_debugfs_init(igt_debugfs_t *debugfs)
{
const char *path = "/sys/kernel/debug";
@@ -376,3 +379,45 @@ void igt_drop_caches_set(uint64_t val)
igt_assert(nbytes == strlen(data) + 1);
close(fd);
}
+
+/*
+ * Prefault control
+ */
+
+#define PREFAULT_DEBUGFS "/sys/module/i915/parameters/prefault_disable"
+static void igt_prefault_control(bool enable)
+{
+ const char *name = PREFAULT_DEBUGFS;
+ int fd;
+ char buf[2] = {'Y', 'N'};
+ int index;
+
+ fd = open(name, O_RDWR);
+ igt_require(fd >= 0);
+
+ if (enable)
+ index = 1;
+ else
+ index = 0;
+
+ igt_require(write(fd, &buf[index], 1) == 1);
+
+ close(fd);
+}
+
+static void enable_prefault_at_exit(int sig)
+{
+ igt_enable_prefault();
+}
+
+void igt_disable_prefault(void)
+{
+ igt_prefault_control(false);
+
+ igt_install_exit_handler(enable_prefault_at_exit);
+}
+
+void igt_enable_prefault(void)
+{
+ igt_prefault_control(true);
+}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 6b7e6239ab04..43fa0fc504bf 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -96,4 +96,12 @@ void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
void igt_drop_caches_set(uint64_t val);
+/*
+ * Prefault control
+ */
+
+void igt_disable_prefault(void);
+void igt_enable_prefault(void);
+
+
#endif /* __IGT_DEBUGFS_H__ */
diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c
index 60de18397241..d5ca18cf6ce2 100644
--- a/tests/gem_exec_faulting_reloc.c
+++ b/tests/gem_exec_faulting_reloc.c
@@ -41,6 +41,7 @@
#include "drmtest.h"
#include "intel_chipset.h"
#include "intel_gpu_tools.h"
+#include "igt_debugfs.h"
/* Testcase: Submit patches with relocations in memory that will fault
*
diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 34ca67895d6f..5f9e6382e8a2 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -38,6 +38,7 @@
#include "drm.h"
#include "i915_drm.h"
#include "drmtest.h"
+#include "igt_debugfs.h"
static int OBJECT_SIZE = 16*1024*1024;
--
1.8.5.2
More information about the Intel-gfx
mailing list