[igt-dev] [PATCH i-g-t v5 2/4] lib/i915/gem_mman: add mmap_offset support
Zbigniew KempczyĆski
zbigniew.kempczynski at intel.com
Fri Nov 22 09:12:43 UTC 2019
On Fri, Nov 22, 2019 at 08:59:10AM +0000, Chris Wilson wrote:
> > +#define LOCAL_I915_PARAM_MMAP_OFFSET_VERSION 54
>
> Leftover.
You're right.
> > +/**
> > + * __gem_mmap_offset:
> > + * @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
> > + *
> > + * Mmap the gem buffer memory on offset returned in GEM_MMAP_OFFSET ioctl.
> > + * Offset argument passed in function call must be 0. In the future
> > + * when driver will allow slice mapping of buffer object this restriction
> > + * will be removed.
> > + *
> > + * Returns: A pointer to the created memory mapping, NULL on failure.
> > + */
> > +void *__gem_mmap_offset(int fd, uint32_t handle, uint64_t offset, uint64_t size,
> > + unsigned int prot, uint64_t flags)
> > +{
> > + struct local_i915_gem_mmap_offset arg;
> > + void *ptr;
> > +
> > + igt_assert(offset == 0);
> > +
> > + memset(&arg, 0, sizeof(arg));
> > + arg.handle = handle;
> > + arg.flags = flags;
> > +
> > + if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_MMAP_OFFSET, &arg))
> > + return NULL;
> > +
> > + ptr = mmap64(0, size, prot, MAP_SHARED, fd, arg.offset);
>
> I am tempted to say arg.offset + offset, but that is premature until an
> actual slice API is decided upon.
As I'm going to remove LOCAL_* define above so I will add this to the call.
>
> This looks to be a reasonable step forward that should at least cover us
> for the transition period.
>
> local_* notwithstanding,
> Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
> -Chris
Thanks. I'm fixing above and add R-B.
Zbigniew
More information about the igt-dev
mailing list