summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2017-09-26 14:33:37 +0200
committerEric Anholt <eric@anholt.net>2017-11-21 10:05:36 -0800
commit39a24cd314a190db2d5cc6b1809518e18ecd2e14 (patch)
tree3e51ff1642002ae1185cf1e8d35a336d01b1385e
parent4251f2fffa63b82a2715ad83eedba00c65f71f95 (diff)
igt/vc4: Add a helper function to mark BOs purgeable
v2: Rebase on get/set_tiling helpers (by anholt). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--lib/igt_vc4.c12
-rw-r--r--lib/igt_vc4.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index 5347af8d..238bf26b 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -149,3 +149,15 @@ uint64_t igt_vc4_get_tiling(int fd, uint32_t handle)
return get.modifier;
}
+
+bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable)
+{
+ struct drm_vc4_gem_madvise arg = {
+ .handle = handle,
+ .madv = purgeable ? VC4_MADV_DONTNEED : VC4_MADV_WILLNEED,
+ };
+
+ do_ioctl(fd, DRM_IOCTL_VC4_GEM_MADVISE, &arg);
+
+ return arg.retained;
+}
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index d1740b93..2c016b16 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -27,6 +27,7 @@
uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
int igt_vc4_create_bo(int fd, size_t size);
void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
+bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable);
void igt_vc4_set_tiling(int fd, uint32_t handle, uint64_t modifier);
uint64_t igt_vc4_get_tiling(int fd, uint32_t handle);