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. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx> --- diff --git a/configure.ac b/configure.ac index 5bdd744a0750..562d5525e894 100644 --- a/configure.ac +++ b/configure.ac @@ -124,6 +124,11 @@ PKG_CHECK_MODULES(DRM, [libdrm]) PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10]) PKG_CHECK_MODULES(KMOD, [libkmod]) PKG_CHECK_MODULES(PROCPS, [libprocps]) +PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no]) + +if test x$have_valgrind = xyes; then + AC_DEFINE(HAVE_VALGRIND, 1, [Enable valgrind annotation support.]) +fi case "$target_cpu" in x86*|i?86) diff --git a/lib/Makefile.am b/lib/Makefile.am index 7030ea27dc27..c0ddf2986849 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -34,6 +34,7 @@ AM_CFLAGS = \ $(XMLRPC_CFLAGS) \ $(LIBUDEV_CFLAGS) \ $(PIXMAN_CFLAGS) \ + $(VALGRIND_CFLAGS) \ -DIGT_SRCDIR=\""$(abs_top_srcdir)/tests"\" \ -DIGT_DATADIR=\""$(pkgdatadir)"\" \ -DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \ diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 763e997c5b83..eb4ca640128a 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -402,7 +402,7 @@ void igt_fork_hang_detector(int fd) igt_assert(fstat(fd, &st) == 0); - signal(SIGRTMAX, sig_abort); + signal(SIGRTMAX - 1, sig_abort); igt_fork_helper(&hang_detector) hang_detector_process(getppid(), st.st_rdev); } diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index 7ceb370b6fcb..bff67433b21d 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -220,7 +220,8 @@ void igt_spin_batch_set_timeout(igt_spin_t *spin, int64_t ns) igt_assert(!spin->timer); - if (spin_signo == SIGRTMAX) + /* SIGRTMAX is used by valgrind, SIGRTMAX - 1 by igt_fork_hang_detector */ + if (spin_signo >= SIGRTMAX - 2) spin_signo = SIGRTMIN; spin->signo = ++spin_signo; diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index cd0c24ba871a..8b45967d3b76 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" /** @@ -734,6 +743,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 +792,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); } _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx