summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2017-02-09 10:42:01 +0100
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2017-02-27 11:17:25 +0100
commitd930b6493d93a6e6c2ca9a5ed468d360a9183586 (patch)
tree353049a57f2544c68f3e771f8bf84fbeedc3e39b /lib/ioctl_wrappers.c
parent8f3164ff51b7ceef87ebc285c5ba9874ceee767e (diff)
lib: Add basic support for valgrind annotations.
SIGRTMAX appears to be used by valgrind now for its internal tracking, so avoid it in the helpers. Also add some valgrind annotations in gem_mmap, to make sure that its accesses are tracked correctly. I've also added gem_munmap, but there are a lot of places that don't use it yet in tests/. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 2d1be49b..7370543f 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -56,6 +56,15 @@
#include "igt_debugfs.h"
#include "config.h"
+#ifdef HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define VG(x) x
+#else
+#define VG(x)
+#endif
+
#include "ioctl_wrappers.h"
/**
@@ -636,6 +645,8 @@ void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
else
errno = 0;
+ VG(VALGRIND_MAKE_MEM_DEFINED(ptr, size));
+
return ptr;
}
@@ -657,6 +668,16 @@ void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
return ptr;
}
+int gem_munmap(void *ptr, uint64_t size)
+{
+ int ret = munmap(ptr, size);
+
+ if (ret == 0)
+ VG(VALGRIND_MAKE_MEM_NOACCESS(ptr, size));
+
+ return ret;
+}
+
struct local_i915_gem_mmap_v2 {
uint32_t handle;
uint32_t pad;
@@ -734,6 +755,8 @@ void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, un
if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_MMAP_v2, &arg))
return NULL;
+ VG(VALGRIND_MAKE_MEM_DEFINED(from_user_pointer(arg.addr_ptr), arg.size));
+
errno = 0;
return from_user_pointer(arg.addr_ptr);
}
@@ -781,6 +804,8 @@ void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, u
if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg))
return NULL;
+ VG(VALGRIND_MAKE_MEM_DEFINED(from_user_pointer(mmap_arg.addr_ptr), mmap_arg.size));
+
errno = 0;
return from_user_pointer(mmap_arg.addr_ptr);
}