From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13AD26E17F for ; Sat, 29 Aug 2020 03:32:48 +0000 (UTC) From: Ashutosh Dixit Date: Fri, 28 Aug 2020 20:32:47 -0700 Message-Id: <20200829033247.21518-1-ashutosh.dixit@intel.com> MIME-Version: 1.0 Subject: [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write 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: igt-dev@lists.freedesktop.org List-ID: Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write. For CI only. Please don't review. Signed-off-by: Ashutosh Dixit --- lib/ioctl_wrappers.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 3781286d8..076bcafa5 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -55,6 +55,7 @@ #include "igt_debugfs.h" #include "igt_sysfs.h" #include "config.h" +#include "i915/gem_mman.h" #ifdef HAVE_VALGRIND #include @@ -353,7 +354,11 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6 */ void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length) { - igt_assert_eq(__gem_write(fd, handle, offset, buf, length), 0); + /* offset arg of gem_mmap__device_coherent must be 0 */ + void *ptr = gem_mmap__device_coherent(fd, handle, 0, offset + length, PROT_WRITE); + + memcpy(ptr + offset, buf + offset, length); + munmap(ptr, offset + length); } int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length) @@ -385,7 +390,11 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len */ void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length) { - igt_assert_eq(__gem_read(fd, handle, offset, buf, length), 0); + /* offset arg of gem_mmap__device_coherent must be 0 */ + void *ptr = gem_mmap__device_coherent(fd, handle, 0, offset + length, PROT_READ); + + memcpy(buf + offset, ptr + offset, length); + munmap(ptr, offset + length); } int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write) -- 2.26.2.108.g048abe1751 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev