[igt-dev] [PATCH i-g-t 2/6] lib/ioctl_wrapper: Implement __gem_mmap
Chris Wilson
chris at chris-wilson.co.uk
Wed Jan 9 20:40:39 UTC 2019
Quoting Lukasz Kalamarz (2019-01-09 17:40:53)
> +void *__gem_mmap(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot, bool wc)
> +{
> + struct drm_i915_gem_mmap arg;
> +
> + if (wc & !gem_mmap__has_wc(fd)) {
Let's just pass it to the kernel once rather than twice. It only really
made sense if there was an assert later on and we wanted to
differentiate between expected failure and user error.
> + errno = ENOSYS;
> + return NULL;
> + }
> +
> + memset(&arg, 0, sizeof(arg));
> + arg.handle = handle;
> + arg.offset = offset;
> + arg.size = size;
> + arg.flags = wc ? I915_MMAP_WC : 0;
Then take _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);
> +}
More information about the igt-dev
mailing list