diff mbox

[i-g-t,v2,1/3] igt: Add a helper function to mark BOs purgeable

Message ID 20171004102221.23085-2-boris.brezillon@free-electrons.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boris BREZILLON Oct. 4, 2017, 10:22 a.m. UTC
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Changes in v2:
- none
---
 lib/igt_vc4.c | 12 ++++++++++++
 lib/igt_vc4.h |  1 +
 2 files changed, 13 insertions(+)
diff mbox

Patch

diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index c4682f5688f1..b75c063204ec 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -128,3 +128,15 @@  igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot)
 	else
 		return ptr;
 }
+
+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 e9252461c951..9f0fc59910f6 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -27,5 +27,6 @@ 
 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);
 
 #endif /* IGT_VC4_H */