From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 828076EC52 for ; Thu, 11 Mar 2021 21:02:33 +0000 (UTC) Date: Thu, 11 Mar 2021 13:02:19 -0800 Message-ID: <87ft11tndw.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" In-Reply-To: References: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Subject: Re: [igt-dev] [i-g-t] lib/ioctl_wrappers: Keep IGT working without pread/pwrite ioctls List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To: Jason Ekstrand Cc: igt-dev@lists.freedesktop.org List-ID: 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 > > @@ -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. _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev