[igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write

Ashutosh Dixit ashutosh.dixit at intel.com
Sat Aug 29 03:32:47 UTC 2020


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 <ashutosh.dixit at intel.com>
---
 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 <valgrind/valgrind.h>
@@ -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



More information about the igt-dev mailing list