diff options
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r-- | lib/ioctl_wrappers.c | 213 |
1 files changed, 0 insertions, 213 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 404c2fbf..39920f87 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -642,219 +642,6 @@ void gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf) } /** - * __gem_mmap__gtt: - * @fd: open i915 drm file descriptor - * @handle: gem buffer object handle - * @size: size of the gem buffer - * @prot: memory protection bits as used by mmap() - * - * This functions wraps up procedure to establish a memory mapping through the - * GTT. - * - * Returns: A pointer to the created memory mapping, NULL on failure. - */ -void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - memset(&mmap_arg, 0, sizeof(mmap_arg)); - mmap_arg.handle = handle; - if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) - return NULL; - - ptr = mmap64(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) - ptr = NULL; - else - errno = 0; - - VG(VALGRIND_MAKE_MEM_DEFINED(ptr, size)); - - return ptr; -} - -/** - * gem_mmap__gtt: - * @fd: open i915 drm file descriptor - * @handle: gem buffer object handle - * @size: size of the gem buffer - * @prot: memory protection bits as used by mmap() - * - * Like __gem_mmap__gtt() except we assert on failure. - * - * Returns: A pointer to the created memory mapping - */ -void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot) -{ - void *ptr = __gem_mmap__gtt(fd, handle, size, prot); - igt_assert(ptr); - 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; -} - -bool gem_mmap__has_wc(int fd) -{ - static int has_wc = -1; - - if (has_wc == -1) { - struct drm_i915_getparam gp; - int mmap_version = -1; - int gtt_version = -1; - - has_wc = 0; - - memset(&gp, 0, sizeof(gp)); - gp.param = I915_PARAM_MMAP_GTT_VERSION; - gp.value = >t_version; - ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); - - memset(&gp, 0, sizeof(gp)); - gp.param = I915_PARAM_MMAP_VERSION; - gp.value = &mmap_version; - ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); - - /* Do we have the new mmap_ioctl with DOMAIN_WC? */ - if (mmap_version >= 1 && gtt_version >= 2) { - struct drm_i915_gem_mmap arg; - - /* Does this device support wc-mmaps ? */ - memset(&arg, 0, sizeof(arg)); - arg.handle = gem_create(fd, 4096); - arg.offset = 0; - arg.size = 4096; - arg.flags = I915_MMAP_WC; - has_wc = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg) == 0; - gem_close(fd, arg.handle); - } - errno = 0; - } - - return has_wc > 0; -} - -/** - * __gem_mmap: - * @fd: open i915 drm file descriptor - * @handle: gem buffer object handle - * @offset: offset in the gem buffer of the mmap arena - * @size: size of the mmap arena - * @prot: memory protection bits as used by mmap() - * @flags: flags used to determine caching - * - * This functions wraps up procedure to establish a memory mapping through - * direct cpu access, bypassing the gpu (valid for wc == false). For wc == true - * it also bypass cpu caches completely and GTT system agent (i.e. there is no - * automatic tiling of the mmapping through the fence registers). - * - * Returns: A pointer to the created memory mapping, NULL on failure. - */ -static void -*__gem_mmap(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned int prot, uint64_t flags) -{ - struct drm_i915_gem_mmap arg; - - memset(&arg, 0, sizeof(arg)); - arg.handle = handle; - arg.offset = offset; - arg.size = size; - arg.flags = flags; - - if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &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); -} - -/** - * __gem_mmap__wc: - * @fd: open i915 drm file descriptor - * @handle: gem buffer object handle - * @offset: offset in the gem buffer of the mmap arena - * @size: size of the mmap arena - * @prot: memory protection bits as used by mmap() - * - * This functions wraps up procedure to establish a memory mapping through - * direct cpu access, bypassing the gpu and cpu caches completely and also - * bypassing the GTT system agent (i.e. there is no automatic tiling of - * the mmapping through the fence registers). - * - * Returns: A pointer to the created memory mapping, NULL on failure. - */ -void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) -{ - return __gem_mmap(fd, handle, offset, size, prot, I915_MMAP_WC); -} - -/** - * gem_mmap__wc: - * @fd: open i915 drm file descriptor - * @handle: gem buffer object handle - * @offset: offset in the gem buffer of the mmap arena - * @size: size of the mmap arena - * @prot: memory protection bits as used by mmap() - * - * Like __gem_mmap__wc() except we assert on failure. - * - * Returns: A pointer to the created memory mapping - */ -void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) -{ - void *ptr = __gem_mmap__wc(fd, handle, offset, size, prot); - igt_assert(ptr); - return ptr; -} - -/** - * __gem_mmap__cpu: - * @fd: open i915 drm file descriptor - * @handle: gem buffer object handle - * @offset: offset in the gem buffer of the mmap arena - * @size: size of the mmap arena - * @prot: memory protection bits as used by mmap() - * - * This functions wraps up procedure to establish a memory mapping through - * direct cpu access, bypassing the gpu completely. - * - * Returns: A pointer to the created memory mapping, NULL on failure. - */ -void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) -{ - return __gem_mmap(fd, handle, offset, size, prot, 0); -} - -/** - * gem_mmap__cpu: - * @fd: open i915 drm file descriptor - * @handle: gem buffer object handle - * @offset: offset in the gem buffer of the mmap arena - * @size: size of the mmap arena - * @prot: memory protection bits as used by mmap() - * - * Like __gem_mmap__cpu() except we assert on failure. - * - * Returns: A pointer to the created memory mapping - */ -void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) -{ - void *ptr = __gem_mmap__cpu(fd, handle, offset, size, prot); - igt_assert(ptr); - return ptr; -} - -/** * gem_madvise: * @fd: open i915 drm file descriptor * @handle: gem buffer object handle |