[igt-dev] [PATCH i-g-t 2/3] lib/i915/gem_mman: add mmap_offset support

Chris Wilson chris at chris-wilson.co.uk
Tue Nov 26 15:33:54 UTC 2019


Quoting Chris Wilson (2019-11-26 15:29:39)
> Quoting Zbigniew KempczyƄski (2019-11-26 10:05:55)
> 
> Due to how we have had to extend the ioctl, we cannot use a simple
> trial-and-error approach, but need the API parameter:
> 
> > +bool __gem_mmap_offset__has_wc(int fd)
> > +{
> > +       int has_wc = 0;
> > +       struct drm_i915_gem_mmap_offset arg;
> 
>        if (!gem_has_mmap_offset(fd))
>                return false;

Maybe even:

uint32_t handle;
void *map;

handle = gem_create(fd, 4096);
map = __gem_mmap_offset(fd, handle, 0, 4096,
	PROT_READ, I915_MMAP_OFFSET_WC);
if (map)
	munumap(map, 4096);
gem_close(fd, handle);

return map;

> > +
> > +       /* Does this device support wc-mmaps ? */
> > +       memset(&arg, 0, sizeof(arg));
> > +       arg.handle = gem_create(fd, 4096);
> > +       arg.offset = 0;
> > +       arg.flags = I915_MMAP_OFFSET_WC;
> > +       has_wc = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET,
> > +                          &arg) == 0;
> > +       gem_close(fd, arg.handle);

Bah, missed the munmap
-Chris


More information about the igt-dev mailing list