diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/igt_debugfs.c | 28 | ||||
-rw-r--r-- | lib/igt_debugfs.h | 15 |
2 files changed, 43 insertions, 0 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 0319effc..fc274fd8 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -316,3 +316,31 @@ igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs, *out_crcs = crcs; } + +/* + * Drop caches + */ + +int igt_drop_caches_set(uint64_t val) +{ + igt_debugfs_t debugfs; + int fd; + char data[19]; + size_t nbytes; + int ret = -1; + + sprintf(data, "0x%" PRIx64, val); + + igt_debugfs_init(&debugfs); + fd = igt_debugfs_open(&debugfs, "i915_gem_drop_caches", O_WRONLY); + + if (fd >= 0) + { + nbytes = write(fd, data, strlen(data) + 1); + if (nbytes == strlen(data) + 1) + ret = 0; + close(fd); + } + + return ret; +} diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h index c2810ee3..02f4afa2 100644 --- a/lib/igt_debugfs.h +++ b/lib/igt_debugfs.h @@ -79,4 +79,19 @@ void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc); void igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs, igt_crc_t **out_crcs); +/* + * Drop caches + */ + +#define DROP_UNBOUND 0x1 +#define DROP_BOUND 0x2 +#define DROP_RETIRE 0x4 +#define DROP_ACTIVE 0x8 +#define DROP_ALL (DROP_UNBOUND | \ + DROP_BOUND | \ + DROP_RETIRE | \ + DROP_ACTIVE) + +int igt_drop_caches_set(uint64_t val); + #endif /* __IGT_DEBUGFS_H__ */ |