[igt-dev] [i-g-t] lib/ioctl_wrappers: Keep IGT working without pread/pwrite ioctls

Jason Ekstrand jason at jlekstrand.net
Thu Mar 11 21:06:36 UTC 2021


On Thu, Mar 11, 2021 at 3:02 PM Dixit, Ashutosh
<ashutosh.dixit at intel.com> wrote:
>
> On Thu, 11 Mar 2021 12:47:41 -0800, Jason Ekstrand wrote:
> > > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> > > index 45415621b7..4440004c42 100644
> > > --- a/lib/ioctl_wrappers.c
> > > +++ b/lib/ioctl_wrappers.c
> > > @@ -56,6 +56,7 @@
> > >  #include "igt_debugfs.h"
> > >  #include "igt_sysfs.h"
> > >  #include "config.h"
> > > +#include "i915/gem_mman.h"
> > >
> > >  #ifdef HAVE_VALGRIND
> > >  #include <valgrind/valgrind.h>
> > > @@ -324,6 +325,70 @@ void gem_close(int fd, uint32_t handle)
> > >      do_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close_bo);
> > >  }
> > >
> > > +static bool is_cache_coherent(int fd, uint32_t handle)
> > > +{
> > > +    return gem_get_caching(fd, handle) != I915_CACHING_NONE;
> > > +}
> > > +
> > > +static void mmap_write(int fd, uint32_t handle, uint64_t offset,
> > > +               const void *buf, uint64_t length)
> > > +{
> > > +    void *map = NULL;
> > > +
> > > +    if (!length)
> > > +        return;
> > > +
> > > +    if (is_cache_coherent(fd, handle)) {
> > > +        /* offset arg for mmap functions must be 0 */
> > > +        map = __gem_mmap__cpu_coherent(fd, handle, 0, offset + length,
> > > +                           PROT_READ | PROT_WRITE);
> > > +        if (map)
> > > +            gem_set_domain(fd, handle,
> > > +                       I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
> >
> > Not sure how much it matters for IGT but the pread/pwrite ioctls
> > appear to always leave the BO in the GTT domain.
>
> It probably doesn't matter. This code here is actually copied from lib/intel_bufops.c:
>
> https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/blob/master/lib/intel_bufops.c#L423
>
> Because it has been tested and verified to work and because it is already
> used elsewhere my preference would be to leave as is unless you think
> otherwise? Thanks.

Fine with me.  I'm mostly asking questions here, not really having opinions. :-)

--Jason


More information about the igt-dev mailing list