* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-09-01 17:45 Ashutosh Dixit
2020-09-01 21:15 ` [igt-dev] ✗ Fi.CI.BAT: failure for lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write (rev8) Patchwork
0 siblings, 1 reply; 15+ messages in thread
From: Ashutosh Dixit @ 2020-09-01 17:45 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 107 +++++++++++++++++++++++++++++++--
lib/ioctl_wrappers.h | 6 +-
tests/i915/gem_madvise.c | 2 +-
tests/i915/gem_userptr_blits.c | 2 +-
tests/i915/gen9_exec_parse.c | 2 +-
tests/prime_vgem.c | 6 +-
6 files changed, 111 insertions(+), 14 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..4d58c6e4f 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>
@@ -323,7 +324,7 @@ void gem_close(int fd, uint32_t handle)
do_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close_bo);
}
-int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+int __gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
{
struct drm_i915_gem_pwrite gem_pwrite;
int err;
@@ -341,7 +342,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
}
/**
- * gem_write:
+ * gem_pwrite:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset within the buffer of the subrange
@@ -351,12 +352,12 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
* This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
* of a gem buffer object.
*/
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+void gem_pwrite(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);
+ igt_assert_eq(__gem_pwrite(fd, handle, offset, buf, length), 0);
}
-int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+int __gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
{
struct drm_i915_gem_pread gem_pread;
int err;
@@ -372,6 +373,100 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len
err = -errno;
return err;
}
+/**
+ * gem_pread:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to read into
+ * @length: size of the subrange
+ *
+ * This wraps the PREAD ioctl, which is to download a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ igt_assert_eq(__gem_pread(fd, handle, offset, buf, length), 0);
+}
+
+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 (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);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ igt_assert(map);
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
+}
+
+/**
+ * gem_write:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to write into the buffer
+ * @length: size of the subrange
+ *
+ * This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+{
+ mmap_write(fd, handle, offset, buf, length);
+}
+
+static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ void *map = NULL;
+
+ if (gem_has_llc(fd) || 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);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ igt_assert(map);
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
+}
+
/**
* gem_read:
* @fd: open i915 drm file descriptor
@@ -385,7 +480,7 @@ 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);
+ mmap_read(fd, handle, offset, buf, length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 870ac8b7b..5f83b0827 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -67,9 +67,11 @@ uint32_t gem_get_caching(int fd, uint32_t handle);
uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
void gem_close(int fd, uint32_t handle);
-int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+int __gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+void gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+int __gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
-int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 54c9befff..c88e74c7c 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -157,7 +157,7 @@ dontneed_before_pwrite(void)
handle = gem_create(fd, OBJECT_SIZE);
gem_madvise(fd, handle, I915_MADV_DONTNEED);
- igt_assert_eq(__gem_write(fd, handle, 0, &bbe, sizeof(bbe)), -EFAULT);
+ igt_assert_eq(__gem_pwrite(fd, handle, 0, &bbe, sizeof(bbe)), -EFAULT);
close(fd);
}
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 268423dcd..9de8b76a9 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -1429,7 +1429,7 @@ static void test_readonly_pwrite(int i915)
char data[4096];
memset(data, page, sizeof(data));
- igt_assert_eq(__gem_write(i915, handle, page << 12, data, sizeof(data)), -EINVAL);
+ igt_assert_eq(__gem_pwrite(i915, handle, page << 12, data, sizeof(data)), -EINVAL);
}
gem_close(i915, handle);
diff --git a/tests/i915/gen9_exec_parse.c b/tests/i915/gen9_exec_parse.c
index 8cd82f568..15a843481 100644
--- a/tests/i915/gen9_exec_parse.c
+++ b/tests/i915/gen9_exec_parse.c
@@ -670,7 +670,7 @@ static void test_invalid_length(const int i915, const uint32_t handle)
lri_ok, 4096,
0);
- igt_assert_eq(__gem_write(i915, handle, 0, noops, 4097), -EINVAL);
+ igt_assert_eq(__gem_pwrite(i915, handle, 0, noops, 4097), -EINVAL);
}
struct reg {
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 38e2026aa..ee9d866db 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -48,7 +48,7 @@ static void test_read(int vgem, int i915)
handle = prime_fd_to_handle(i915, dmabuf);
close(dmabuf);
- igt_skip_on_f(__gem_read(i915, handle, 0, &i, sizeof(i)),
+ igt_skip_on_f(__gem_pread(i915, handle, 0, &i, sizeof(i)),
"PREAD from dma-buf not supported on this hardware\n");
ptr = vgem_mmap(vgem, &scratch, PROT_WRITE);
@@ -86,7 +86,7 @@ static void test_fence_read(int i915, int vgem)
handle = prime_fd_to_handle(i915, dmabuf);
close(dmabuf);
- igt_skip_on_f(__gem_read(i915, handle, 0, &i, sizeof(i)),
+ igt_skip_on_f(__gem_pread(i915, handle, 0, &i, sizeof(i)),
"PREAD from dma-buf not supported on this hardware\n");
igt_fork(child, 1) {
@@ -272,7 +272,7 @@ static void test_write(int vgem, int i915)
handle = prime_fd_to_handle(i915, dmabuf);
close(dmabuf);
- igt_skip_on_f(__gem_write(i915, handle, 0, &i, sizeof(i)),
+ igt_skip_on_f(__gem_pwrite(i915, handle, 0, &i, sizeof(i)),
"PWRITE to dma-buf not supported on this hardware\n");
ptr = vgem_mmap(vgem, &scratch, PROT_READ);
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] ✗ Fi.CI.BAT: failure for lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write (rev8)
2020-09-01 17:45 [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write Ashutosh Dixit
@ 2020-09-01 21:15 ` Patchwork
0 siblings, 0 replies; 15+ messages in thread
From: Patchwork @ 2020-09-01 21:15 UTC (permalink / raw)
To: Ashutosh Dixit; +Cc: igt-dev
[-- Attachment #1.1: Type: text/plain, Size: 22761 bytes --]
== Series Details ==
Series: lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write (rev8)
URL : https://patchwork.freedesktop.org/series/81152/
State : failure
== Summary ==
CI Bug Log - changes from IGT_5776 -> IGTPW_4938
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_4938 absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_4938, please notify your bug team to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_4938:
### IGT changes ###
#### Possible regressions ####
* igt@prime_vgem@basic-fence-read:
- fi-bsw-kefka: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-kefka/igt@prime_vgem@basic-fence-read.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-kefka/igt@prime_vgem@basic-fence-read.html
- fi-cml-s: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cml-s/igt@prime_vgem@basic-fence-read.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cml-s/igt@prime_vgem@basic-fence-read.html
- fi-ilk-650: [PASS][5] -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-ilk-650/igt@prime_vgem@basic-fence-read.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-ilk-650/igt@prime_vgem@basic-fence-read.html
- fi-ivb-3770: [PASS][7] -> [INCOMPLETE][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-ivb-3770/igt@prime_vgem@basic-fence-read.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-ivb-3770/igt@prime_vgem@basic-fence-read.html
- fi-skl-6700k2: [PASS][9] -> [INCOMPLETE][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-6700k2/igt@prime_vgem@basic-fence-read.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-6700k2/igt@prime_vgem@basic-fence-read.html
- fi-skl-lmem: [PASS][11] -> [INCOMPLETE][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-lmem/igt@prime_vgem@basic-fence-read.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-lmem/igt@prime_vgem@basic-fence-read.html
- fi-cml-u2: [PASS][13] -> [INCOMPLETE][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cml-u2/igt@prime_vgem@basic-fence-read.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cml-u2/igt@prime_vgem@basic-fence-read.html
- fi-snb-2520m: [PASS][15] -> [INCOMPLETE][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-snb-2520m/igt@prime_vgem@basic-fence-read.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-snb-2520m/igt@prime_vgem@basic-fence-read.html
- fi-cfl-8700k: [PASS][17] -> [INCOMPLETE][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cfl-8700k/igt@prime_vgem@basic-fence-read.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cfl-8700k/igt@prime_vgem@basic-fence-read.html
- fi-byt-j1900: [PASS][19] -> [INCOMPLETE][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-byt-j1900/igt@prime_vgem@basic-fence-read.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-byt-j1900/igt@prime_vgem@basic-fence-read.html
- fi-hsw-4770: [PASS][21] -> [INCOMPLETE][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-hsw-4770/igt@prime_vgem@basic-fence-read.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-hsw-4770/igt@prime_vgem@basic-fence-read.html
- fi-icl-u2: [PASS][23] -> [INCOMPLETE][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-icl-u2/igt@prime_vgem@basic-fence-read.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-icl-u2/igt@prime_vgem@basic-fence-read.html
- fi-skl-6600u: [PASS][25] -> [INCOMPLETE][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-6600u/igt@prime_vgem@basic-fence-read.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-6600u/igt@prime_vgem@basic-fence-read.html
- fi-kbl-7500u: [PASS][27] -> [INCOMPLETE][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-7500u/igt@prime_vgem@basic-fence-read.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-7500u/igt@prime_vgem@basic-fence-read.html
- fi-kbl-guc: [PASS][29] -> [INCOMPLETE][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-guc/igt@prime_vgem@basic-fence-read.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-guc/igt@prime_vgem@basic-fence-read.html
- fi-skl-guc: [PASS][31] -> [INCOMPLETE][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-guc/igt@prime_vgem@basic-fence-read.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-guc/igt@prime_vgem@basic-fence-read.html
- fi-bwr-2160: [PASS][33] -> [INCOMPLETE][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bwr-2160/igt@prime_vgem@basic-fence-read.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bwr-2160/igt@prime_vgem@basic-fence-read.html
- fi-kbl-r: [PASS][35] -> [INCOMPLETE][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-r/igt@prime_vgem@basic-fence-read.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-r/igt@prime_vgem@basic-fence-read.html
- fi-blb-e6850: [PASS][37] -> [INCOMPLETE][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-blb-e6850/igt@prime_vgem@basic-fence-read.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-blb-e6850/igt@prime_vgem@basic-fence-read.html
- fi-cfl-8109u: [PASS][39] -> [INCOMPLETE][40]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cfl-8109u/igt@prime_vgem@basic-fence-read.html
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cfl-8109u/igt@prime_vgem@basic-fence-read.html
- fi-bsw-nick: [PASS][41] -> [INCOMPLETE][42]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-nick/igt@prime_vgem@basic-fence-read.html
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-nick/igt@prime_vgem@basic-fence-read.html
- fi-icl-y: [PASS][43] -> [INCOMPLETE][44]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-icl-y/igt@prime_vgem@basic-fence-read.html
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-icl-y/igt@prime_vgem@basic-fence-read.html
- fi-tgl-u2: [PASS][45] -> [INCOMPLETE][46]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-tgl-u2/igt@prime_vgem@basic-fence-read.html
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-tgl-u2/igt@prime_vgem@basic-fence-read.html
- fi-bsw-n3050: [PASS][47] -> [INCOMPLETE][48]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-n3050/igt@prime_vgem@basic-fence-read.html
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-n3050/igt@prime_vgem@basic-fence-read.html
* igt@prime_vgem@basic-read:
- fi-kbl-guc: [PASS][49] -> [FAIL][50] +1 similar issue
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-guc/igt@prime_vgem@basic-read.html
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-guc/igt@prime_vgem@basic-read.html
- fi-bwr-2160: [PASS][51] -> [FAIL][52] +1 similar issue
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bwr-2160/igt@prime_vgem@basic-read.html
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bwr-2160/igt@prime_vgem@basic-read.html
- fi-kbl-r: [PASS][53] -> [FAIL][54] +1 similar issue
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-r/igt@prime_vgem@basic-read.html
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-r/igt@prime_vgem@basic-read.html
- fi-bsw-nick: [PASS][55] -> [FAIL][56] +1 similar issue
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-nick/igt@prime_vgem@basic-read.html
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-nick/igt@prime_vgem@basic-read.html
- fi-cfl-8109u: [PASS][57] -> [FAIL][58] +1 similar issue
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cfl-8109u/igt@prime_vgem@basic-read.html
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cfl-8109u/igt@prime_vgem@basic-read.html
- fi-snb-2520m: [PASS][59] -> [FAIL][60] +1 similar issue
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-snb-2520m/igt@prime_vgem@basic-read.html
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-snb-2520m/igt@prime_vgem@basic-read.html
- fi-cfl-8700k: [PASS][61] -> [FAIL][62] +1 similar issue
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cfl-8700k/igt@prime_vgem@basic-read.html
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cfl-8700k/igt@prime_vgem@basic-read.html
- fi-icl-u2: [PASS][63] -> [FAIL][64] +1 similar issue
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-icl-u2/igt@prime_vgem@basic-read.html
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-icl-u2/igt@prime_vgem@basic-read.html
- fi-bsw-kefka: [PASS][65] -> [FAIL][66] +1 similar issue
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-kefka/igt@prime_vgem@basic-read.html
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-kefka/igt@prime_vgem@basic-read.html
- fi-skl-guc: [PASS][67] -> [FAIL][68] +1 similar issue
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-guc/igt@prime_vgem@basic-read.html
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-guc/igt@prime_vgem@basic-read.html
- fi-skl-6700k2: [PASS][69] -> [FAIL][70] +1 similar issue
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-6700k2/igt@prime_vgem@basic-read.html
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-6700k2/igt@prime_vgem@basic-read.html
- fi-elk-e7500: [PASS][71] -> [FAIL][72] +1 similar issue
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-elk-e7500/igt@prime_vgem@basic-read.html
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-elk-e7500/igt@prime_vgem@basic-read.html
* igt@prime_vgem@basic-write:
- fi-tgl-u2: [PASS][73] -> [FAIL][74] +1 similar issue
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-tgl-u2/igt@prime_vgem@basic-write.html
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-tgl-u2/igt@prime_vgem@basic-write.html
- fi-ivb-3770: [PASS][75] -> [FAIL][76] +1 similar issue
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-ivb-3770/igt@prime_vgem@basic-write.html
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-ivb-3770/igt@prime_vgem@basic-write.html
- fi-skl-lmem: [PASS][77] -> [FAIL][78] +1 similar issue
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-lmem/igt@prime_vgem@basic-write.html
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-lmem/igt@prime_vgem@basic-write.html
- fi-bsw-n3050: [PASS][79] -> [FAIL][80] +1 similar issue
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-n3050/igt@prime_vgem@basic-write.html
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-n3050/igt@prime_vgem@basic-write.html
- fi-ilk-650: [PASS][81] -> [FAIL][82] +1 similar issue
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-ilk-650/igt@prime_vgem@basic-write.html
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-ilk-650/igt@prime_vgem@basic-write.html
- fi-cml-s: [PASS][83] -> [FAIL][84] +1 similar issue
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cml-s/igt@prime_vgem@basic-write.html
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cml-s/igt@prime_vgem@basic-write.html
- fi-pnv-d510: [PASS][85] -> [FAIL][86] +1 similar issue
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-pnv-d510/igt@prime_vgem@basic-write.html
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-pnv-d510/igt@prime_vgem@basic-write.html
- fi-skl-6600u: [PASS][87] -> [FAIL][88] +1 similar issue
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-skl-6600u/igt@prime_vgem@basic-write.html
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-skl-6600u/igt@prime_vgem@basic-write.html
- fi-hsw-4770: [PASS][89] -> [FAIL][90] +1 similar issue
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-hsw-4770/igt@prime_vgem@basic-write.html
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-hsw-4770/igt@prime_vgem@basic-write.html
- fi-cml-u2: [PASS][91] -> [FAIL][92] +1 similar issue
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-cml-u2/igt@prime_vgem@basic-write.html
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-cml-u2/igt@prime_vgem@basic-write.html
- fi-byt-j1900: [PASS][93] -> [FAIL][94] +1 similar issue
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-byt-j1900/igt@prime_vgem@basic-write.html
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-byt-j1900/igt@prime_vgem@basic-write.html
- fi-blb-e6850: [PASS][95] -> [FAIL][96] +1 similar issue
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-blb-e6850/igt@prime_vgem@basic-write.html
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-blb-e6850/igt@prime_vgem@basic-write.html
- fi-icl-y: [PASS][97] -> [FAIL][98] +1 similar issue
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-icl-y/igt@prime_vgem@basic-write.html
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-icl-y/igt@prime_vgem@basic-write.html
- fi-kbl-7500u: [PASS][99] -> [FAIL][100] +1 similar issue
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-7500u/igt@prime_vgem@basic-write.html
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-7500u/igt@prime_vgem@basic-write.html
- fi-snb-2600: [PASS][101] -> [FAIL][102] +1 similar issue
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-snb-2600/igt@prime_vgem@basic-write.html
[102]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-snb-2600/igt@prime_vgem@basic-write.html
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses.
They do not affect the overall result.
* igt@prime_vgem@basic-fence-read:
- {fi-kbl-7560u}: [PASS][103] -> [INCOMPLETE][104]
[103]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-7560u/igt@prime_vgem@basic-fence-read.html
[104]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-7560u/igt@prime_vgem@basic-fence-read.html
- {fi-ehl-1}: [PASS][105] -> [INCOMPLETE][106]
[105]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-ehl-1/igt@prime_vgem@basic-fence-read.html
[106]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-ehl-1/igt@prime_vgem@basic-fence-read.html
* igt@prime_vgem@basic-write:
- {fi-ehl-1}: [PASS][107] -> [FAIL][108] +1 similar issue
[107]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-ehl-1/igt@prime_vgem@basic-write.html
[108]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-ehl-1/igt@prime_vgem@basic-write.html
- {fi-kbl-7560u}: [PASS][109] -> [FAIL][110] +1 similar issue
[109]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-7560u/igt@prime_vgem@basic-write.html
[110]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-7560u/igt@prime_vgem@basic-write.html
Known issues
------------
Here are the changes found in IGTPW_4938 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-byt-j1900: [PASS][111] -> [DMESG-WARN][112] ([i915#1982])
[111]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-byt-j1900/igt@i915_pm_rpm@basic-pci-d3-state.html
[112]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-byt-j1900/igt@i915_pm_rpm@basic-pci-d3-state.html
- fi-bsw-kefka: [PASS][113] -> [DMESG-WARN][114] ([i915#1982])
[113]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-kefka/igt@i915_pm_rpm@basic-pci-d3-state.html
[114]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-kefka/igt@i915_pm_rpm@basic-pci-d3-state.html
* igt@kms_flip@basic-flip-vs-wf_vblank@c-edp1:
- fi-icl-u2: [PASS][115] -> [DMESG-WARN][116] ([i915#1982])
[115]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-icl-u2/igt@kms_flip@basic-flip-vs-wf_vblank@c-edp1.html
[116]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-icl-u2/igt@kms_flip@basic-flip-vs-wf_vblank@c-edp1.html
* igt@prime_vgem@basic-fence-read:
- fi-elk-e7500: [PASS][117] -> [INCOMPLETE][118] ([i915#66])
[117]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-elk-e7500/igt@prime_vgem@basic-fence-read.html
[118]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-elk-e7500/igt@prime_vgem@basic-fence-read.html
- fi-bxt-dsi: [PASS][119] -> [INCOMPLETE][120] ([i915#1635])
[119]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bxt-dsi/igt@prime_vgem@basic-fence-read.html
[120]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bxt-dsi/igt@prime_vgem@basic-fence-read.html
- fi-apl-guc: [PASS][121] -> [INCOMPLETE][122] ([i915#1635])
[121]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-apl-guc/igt@prime_vgem@basic-fence-read.html
[122]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-apl-guc/igt@prime_vgem@basic-fence-read.html
- fi-pnv-d510: [PASS][123] -> [INCOMPLETE][124] ([i915#299])
[123]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-pnv-d510/igt@prime_vgem@basic-fence-read.html
[124]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-pnv-d510/igt@prime_vgem@basic-fence-read.html
- fi-snb-2600: [PASS][125] -> [INCOMPLETE][126] ([i915#82])
[125]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-snb-2600/igt@prime_vgem@basic-fence-read.html
[126]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-snb-2600/igt@prime_vgem@basic-fence-read.html
* igt@prime_vgem@basic-read:
- fi-apl-guc: [PASS][127] -> [FAIL][128] ([i915#1635]) +1 similar issue
[127]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-apl-guc/igt@prime_vgem@basic-read.html
[128]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-apl-guc/igt@prime_vgem@basic-read.html
* igt@prime_vgem@basic-write:
- fi-bxt-dsi: [PASS][129] -> [FAIL][130] ([i915#1635]) +1 similar issue
[129]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bxt-dsi/igt@prime_vgem@basic-write.html
[130]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bxt-dsi/igt@prime_vgem@basic-write.html
#### Possible fixes ####
* igt@i915_module_load@reload:
- fi-apl-guc: [TIMEOUT][131] ([i915#1418] / [i915#1635]) -> [PASS][132]
[131]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-apl-guc/igt@i915_module_load@reload.html
[132]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-apl-guc/igt@i915_module_load@reload.html
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-bsw-n3050: [DMESG-WARN][133] ([i915#1982]) -> [PASS][134]
[133]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-bsw-n3050/igt@i915_pm_rpm@basic-pci-d3-state.html
[134]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-bsw-n3050/igt@i915_pm_rpm@basic-pci-d3-state.html
* igt@i915_pm_rpm@module-reload:
- fi-apl-guc: [SKIP][135] ([fdo#109271] / [i915#1635]) -> [PASS][136]
[135]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-apl-guc/igt@i915_pm_rpm@module-reload.html
[136]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-apl-guc/igt@i915_pm_rpm@module-reload.html
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-icl-u2: [DMESG-WARN][137] ([i915#1982]) -> [PASS][138]
[137]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-icl-u2/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic.html
[138]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-icl-u2/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic.html
#### Warnings ####
* igt@i915_pm_rpm@module-reload:
- fi-kbl-guc: [DMESG-WARN][139] ([i915#2203]) -> [DMESG-FAIL][140] ([i915#2203])
[139]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5776/fi-kbl-guc/igt@i915_pm_rpm@module-reload.html
[140]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/fi-kbl-guc/igt@i915_pm_rpm@module-reload.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1418]: https://gitlab.freedesktop.org/drm/intel/issues/1418
[i915#1635]: https://gitlab.freedesktop.org/drm/intel/issues/1635
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2203]: https://gitlab.freedesktop.org/drm/intel/issues/2203
[i915#299]: https://gitlab.freedesktop.org/drm/intel/issues/299
[i915#66]: https://gitlab.freedesktop.org/drm/intel/issues/66
[i915#82]: https://gitlab.freedesktop.org/drm/intel/issues/82
Participating hosts (38 -> 33)
------------------------------
Missing (5): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_5776 -> IGTPW_4938
CI-20190529: 20190529
CI_DRM_8951: 5f8c53e35ef01a1d5e97db6005d3c308d3734bac @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_4938: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/index.html
IGT_5776: 46e4315096bcaa2465c82c547274627365b1a69e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4938/index.html
[-- Attachment #1.2: Type: text/html, Size: 25136 bytes --]
[-- Attachment #2: Type: text/plain, Size: 154 bytes --]
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2021-03-15 21:16 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2021-03-15 21:16 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write.
v11: Simplified patch to use previous __gem_read/__gem_write
v12: Fix CI failures in gem_madvise and gen9_exec_parse
v13: Skip mmap for 0 length read/write's
v14: Rebase on latest master, remove redundant asserts/checks in mmap_read/write
v15: Fix CI failures in gem_exec_parallel@userptr
v16: rebase, gem_exec_parallel@userptr no longer does a gem_read
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 103 +++++++++++++++++++++++++++++++++++++--
lib/ioctl_wrappers.h | 4 +-
tests/i915/gem_madvise.c | 2 +-
tests/prime_vgem.c | 8 +--
4 files changed, 108 insertions(+), 9 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 45415621b7..82eeeb447a 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>
@@ -342,7 +343,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
}
/**
- * gem_write:
+ * gem_pwrite:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset within the buffer of the subrange
@@ -352,7 +353,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
* This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
* of a gem buffer object.
*/
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+void gem_pwrite(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);
}
@@ -373,6 +374,102 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len
err = -errno;
return err;
}
+/**
+ * gem_pread:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to read into
+ * @length: size of the subrange
+ *
+ * This wraps the PREAD ioctl, which is to download a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ igt_assert_eq(__gem_read(fd, handle, offset, buf, length), 0);
+}
+
+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);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
+}
+
+/**
+ * gem_write:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to write into the buffer
+ * @length: size of the subrange
+ *
+ * This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+{
+ mmap_write(fd, handle, offset, buf, length);
+}
+
+static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ void *map = NULL;
+
+ if (!length)
+ return;
+
+ if (gem_has_llc(fd) || 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);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
+}
+
/**
* gem_read:
* @fd: open i915 drm file descriptor
@@ -386,7 +483,7 @@ 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);
+ mmap_read(fd, handle, offset, buf, length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 69e198419c..13ff799aab 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -68,8 +68,10 @@ uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
void gem_close(int fd, uint32_t handle);
int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+void gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 2cd0b5d7cc..ce78b76b9f 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -175,7 +175,7 @@ dontneed_before_exec(void)
memset(&exec, 0, sizeof(exec));
exec.handle = gem_create(fd, OBJECT_SIZE);
- gem_write(fd, exec.handle, 0, buf, sizeof(buf));
+ gem_pwrite(fd, exec.handle, 0, buf, sizeof(buf));
gem_madvise(fd, exec.handle, I915_MADV_DONTNEED);
execbuf.buffers_ptr = to_user_pointer(&exec);
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 07ff69a245..2d4d283141 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -59,7 +59,7 @@ static void test_read(int vgem, int i915)
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -94,14 +94,14 @@ static void test_fence_read(int i915, int vgem)
close(slave[1]);
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, 0);
}
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -279,7 +279,7 @@ static void test_write(int vgem, int i915)
gem_close(vgem, scratch.handle);
for (i = 0; i < 1024; i++)
- gem_write(i915, handle, 4096*i, &i, sizeof(i));
+ gem_pwrite(i915, handle, 4096*i, &i, sizeof(i));
gem_close(i915, handle);
for (i = 0; i < 1024; i++)
--
2.29.2
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2021-01-21 5:52 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2021-01-21 5:52 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write.
v11: Simplified patch to use previous __gem_read/__gem_write
v12: Fix CI failures in gem_madvise and gen9_exec_parse
v13: Skip mmap for 0 length read/write's
v14: Rebase on latest master, remove redundant asserts/checks in mmap_read/write
v15: Fix CI failures in gem_exec_parallel@userptr
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 103 ++++++++++++++++++++++++++++++++-
lib/ioctl_wrappers.h | 4 +-
tests/i915/gem_exec_parallel.c | 10 +++-
tests/i915/gem_madvise.c | 2 +-
tests/prime_vgem.c | 8 +--
5 files changed, 115 insertions(+), 12 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 45415621b7..82eeeb447a 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>
@@ -342,7 +343,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
}
/**
- * gem_write:
+ * gem_pwrite:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset within the buffer of the subrange
@@ -352,7 +353,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
* This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
* of a gem buffer object.
*/
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+void gem_pwrite(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);
}
@@ -373,6 +374,102 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len
err = -errno;
return err;
}
+/**
+ * gem_pread:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to read into
+ * @length: size of the subrange
+ *
+ * This wraps the PREAD ioctl, which is to download a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ igt_assert_eq(__gem_read(fd, handle, offset, buf, length), 0);
+}
+
+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);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
+}
+
+/**
+ * gem_write:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to write into the buffer
+ * @length: size of the subrange
+ *
+ * This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+{
+ mmap_write(fd, handle, offset, buf, length);
+}
+
+static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ void *map = NULL;
+
+ if (!length)
+ return;
+
+ if (gem_has_llc(fd) || 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);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
+}
+
/**
* gem_read:
* @fd: open i915 drm file descriptor
@@ -386,7 +483,7 @@ 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);
+ mmap_read(fd, handle, offset, buf, length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 69e198419c..13ff799aab 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -68,8 +68,10 @@ uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
void gem_close(int fd, uint32_t handle);
int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+void gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
diff --git a/tests/i915/gem_exec_parallel.c b/tests/i915/gem_exec_parallel.c
index d3dd06a654..b3b6217f7a 100644
--- a/tests/i915/gem_exec_parallel.c
+++ b/tests/i915/gem_exec_parallel.c
@@ -151,7 +151,8 @@ static void *thread(void *data)
return NULL;
}
-static void check_bo(int fd, uint32_t handle, int pass, struct thread *threads)
+static void check_bo(int fd, uint32_t flags, uint32_t handle, int pass,
+ struct thread *threads)
{
uint32_t x = hash32(handle * pass) % 1024;
uint32_t result;
@@ -161,7 +162,10 @@ static void check_bo(int fd, uint32_t handle, int pass, struct thread *threads)
igt_debug("Verifying result (pass=%d, handle=%d, thread %d)\n",
pass, handle, x);
- gem_read(fd, handle, x * sizeof(result), &result, sizeof(result));
+ if (flags & USERPTR)
+ gem_pread(fd, handle, x * sizeof(result), &result, sizeof(result));
+ else
+ gem_read(fd, handle, x * sizeof(result), &result, sizeof(result));
igt_assert_eq_u32(result, x);
}
@@ -258,7 +262,7 @@ static void all(int fd, struct intel_execution_engine2 *engine, unsigned flags)
pthread_join(threads[i].thread, NULL);
for (i = 0; i < NUMOBJ; i++) {
- check_bo(fd, handle[i], i, threads);
+ check_bo(fd, flags, handle[i], i, threads);
handle_close(fd, flags, handle[i], arg[i]);
}
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 623c8b0913..56cc8a0de9 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -175,7 +175,7 @@ dontneed_before_exec(void)
memset(&exec, 0, sizeof(exec));
exec.handle = gem_create(fd, OBJECT_SIZE);
- gem_write(fd, exec.handle, 0, buf, sizeof(buf));
+ gem_pwrite(fd, exec.handle, 0, buf, sizeof(buf));
gem_madvise(fd, exec.handle, I915_MADV_DONTNEED);
execbuf.buffers_ptr = to_user_pointer(&exec);
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 07ff69a245..2d4d283141 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -59,7 +59,7 @@ static void test_read(int vgem, int i915)
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -94,14 +94,14 @@ static void test_fence_read(int i915, int vgem)
close(slave[1]);
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, 0);
}
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -279,7 +279,7 @@ static void test_write(int vgem, int i915)
gem_close(vgem, scratch.handle);
for (i = 0; i < 1024; i++)
- gem_write(i915, handle, 4096*i, &i, sizeof(i));
+ gem_pwrite(i915, handle, 4096*i, &i, sizeof(i));
gem_close(i915, handle);
for (i = 0; i < 1024; i++)
--
2.29.2
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2021-01-21 2:20 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2021-01-21 2:20 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write.
v11: Simplified patch to use previous __gem_read/__gem_write
v12: Fix CI failures in gem_madvise and gen9_exec_parse
v13: Skip mmap for 0 length read/write's
v14: Rebase on latest master, remove redundant asserts/checks in mmap_read/write
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 103 +++++++++++++++++++++++++++++++++++++--
lib/ioctl_wrappers.h | 4 +-
tests/i915/gem_madvise.c | 2 +-
tests/prime_vgem.c | 8 +--
4 files changed, 108 insertions(+), 9 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 45415621b7..82eeeb447a 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>
@@ -342,7 +343,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
}
/**
- * gem_write:
+ * gem_pwrite:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset within the buffer of the subrange
@@ -352,7 +353,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
* This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
* of a gem buffer object.
*/
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+void gem_pwrite(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);
}
@@ -373,6 +374,102 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len
err = -errno;
return err;
}
+/**
+ * gem_pread:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to read into
+ * @length: size of the subrange
+ *
+ * This wraps the PREAD ioctl, which is to download a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ igt_assert_eq(__gem_read(fd, handle, offset, buf, length), 0);
+}
+
+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);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
+}
+
+/**
+ * gem_write:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to write into the buffer
+ * @length: size of the subrange
+ *
+ * This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+{
+ mmap_write(fd, handle, offset, buf, length);
+}
+
+static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ void *map = NULL;
+
+ if (!length)
+ return;
+
+ if (gem_has_llc(fd) || 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);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
+}
+
/**
* gem_read:
* @fd: open i915 drm file descriptor
@@ -386,7 +483,7 @@ 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);
+ mmap_read(fd, handle, offset, buf, length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 69e198419c..13ff799aab 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -68,8 +68,10 @@ uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
void gem_close(int fd, uint32_t handle);
int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+void gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 623c8b0913..56cc8a0de9 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -175,7 +175,7 @@ dontneed_before_exec(void)
memset(&exec, 0, sizeof(exec));
exec.handle = gem_create(fd, OBJECT_SIZE);
- gem_write(fd, exec.handle, 0, buf, sizeof(buf));
+ gem_pwrite(fd, exec.handle, 0, buf, sizeof(buf));
gem_madvise(fd, exec.handle, I915_MADV_DONTNEED);
execbuf.buffers_ptr = to_user_pointer(&exec);
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 07ff69a245..2d4d283141 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -59,7 +59,7 @@ static void test_read(int vgem, int i915)
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -94,14 +94,14 @@ static void test_fence_read(int i915, int vgem)
close(slave[1]);
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, 0);
}
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -279,7 +279,7 @@ static void test_write(int vgem, int i915)
gem_close(vgem, scratch.handle);
for (i = 0; i < 1024; i++)
- gem_write(i915, handle, 4096*i, &i, sizeof(i));
+ gem_pwrite(i915, handle, 4096*i, &i, sizeof(i));
gem_close(i915, handle);
for (i = 0; i < 1024; i++)
--
2.29.2
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-09-06 23:36 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-09-06 23:36 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write.
v11: Simplified patch to use previous __gem_read/__gem_write
v12: Fix CI failures in gem_madvise and gen9_exec_parse
v13: Skip mmap for 0 length read/write's
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 107 +++++++++++++++++++++++++++++++++++++--
lib/ioctl_wrappers.h | 4 +-
tests/i915/gem_madvise.c | 2 +-
tests/prime_vgem.c | 8 +--
4 files changed, 112 insertions(+), 9 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..4c660ca3a 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>
@@ -341,7 +342,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
}
/**
- * gem_write:
+ * gem_pwrite:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset within the buffer of the subrange
@@ -351,7 +352,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
* This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
* of a gem buffer object.
*/
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+void gem_pwrite(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);
}
@@ -372,6 +373,106 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len
err = -errno;
return err;
}
+/**
+ * gem_pread:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to read into
+ * @length: size of the subrange
+ *
+ * This wraps the PREAD ioctl, which is to download a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ igt_assert_eq(__gem_read(fd, handle, offset, buf, length), 0);
+}
+
+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);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ igt_assert(map);
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
+}
+
+/**
+ * gem_write:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to write into the buffer
+ * @length: size of the subrange
+ *
+ * This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+{
+ mmap_write(fd, handle, offset, buf, length);
+}
+
+static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ void *map = NULL;
+
+ if (!length)
+ return;
+
+ if (gem_has_llc(fd) || 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);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ igt_assert(map);
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
+}
+
/**
* gem_read:
* @fd: open i915 drm file descriptor
@@ -385,7 +486,7 @@ 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);
+ mmap_read(fd, handle, offset, buf, length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 870ac8b7b..143a397ea 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -68,8 +68,10 @@ uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
void gem_close(int fd, uint32_t handle);
int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+void gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 54c9befff..f26d5a79c 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -174,7 +174,7 @@ dontneed_before_exec(void)
memset(&exec, 0, sizeof(exec));
exec.handle = gem_create(fd, OBJECT_SIZE);
- gem_write(fd, exec.handle, 0, buf, sizeof(buf));
+ gem_pwrite(fd, exec.handle, 0, buf, sizeof(buf));
gem_madvise(fd, exec.handle, I915_MADV_DONTNEED);
execbuf.buffers_ptr = to_user_pointer(&exec);
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 38e2026aa..3f3b5f602 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -59,7 +59,7 @@ static void test_read(int vgem, int i915)
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -94,14 +94,14 @@ static void test_fence_read(int i915, int vgem)
close(slave[1]);
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, 0);
}
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -279,7 +279,7 @@ static void test_write(int vgem, int i915)
gem_close(vgem, scratch.handle);
for (i = 0; i < 1024; i++)
- gem_write(i915, handle, 4096*i, &i, sizeof(i));
+ gem_pwrite(i915, handle, 4096*i, &i, sizeof(i));
gem_close(i915, handle);
for (i = 0; i < 1024; i++)
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-09-06 17:38 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-09-06 17:38 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write.
v11: Simplified patch to use previous __gem_read/__gem_write
v12: Fix CI failures in gem_madvise and gen9_exec_parse
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 101 +++++++++++++++++++++++++++++++++--
lib/ioctl_wrappers.h | 4 +-
tests/i915/gem_madvise.c | 2 +-
tests/i915/gen9_exec_parse.c | 2 +-
tests/prime_vgem.c | 8 +--
5 files changed, 107 insertions(+), 10 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..65f4539f3 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>
@@ -341,7 +342,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
}
/**
- * gem_write:
+ * gem_pwrite:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset within the buffer of the subrange
@@ -351,7 +352,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
* This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
* of a gem buffer object.
*/
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+void gem_pwrite(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);
}
@@ -372,6 +373,100 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len
err = -errno;
return err;
}
+/**
+ * gem_pread:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to read into
+ * @length: size of the subrange
+ *
+ * This wraps the PREAD ioctl, which is to download a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ igt_assert_eq(__gem_read(fd, handle, offset, buf, length), 0);
+}
+
+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 (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);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ igt_assert(map);
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
+}
+
+/**
+ * gem_write:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to write into the buffer
+ * @length: size of the subrange
+ *
+ * This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+{
+ mmap_write(fd, handle, offset, buf, length);
+}
+
+static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ void *map = NULL;
+
+ if (gem_has_llc(fd) || 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);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ igt_assert(map);
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
+}
+
/**
* gem_read:
* @fd: open i915 drm file descriptor
@@ -385,7 +480,7 @@ 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);
+ mmap_read(fd, handle, offset, buf, length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 870ac8b7b..143a397ea 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -68,8 +68,10 @@ uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
void gem_close(int fd, uint32_t handle);
int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+void gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 54c9befff..f26d5a79c 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -174,7 +174,7 @@ dontneed_before_exec(void)
memset(&exec, 0, sizeof(exec));
exec.handle = gem_create(fd, OBJECT_SIZE);
- gem_write(fd, exec.handle, 0, buf, sizeof(buf));
+ gem_pwrite(fd, exec.handle, 0, buf, sizeof(buf));
gem_madvise(fd, exec.handle, I915_MADV_DONTNEED);
execbuf.buffers_ptr = to_user_pointer(&exec);
diff --git a/tests/i915/gen9_exec_parse.c b/tests/i915/gen9_exec_parse.c
index 8cd82f568..b5bb3fb20 100644
--- a/tests/i915/gen9_exec_parse.c
+++ b/tests/i915/gen9_exec_parse.c
@@ -144,7 +144,7 @@ static int __exec_batch(int i915, int engine, uint32_t cmd_bo,
struct drm_i915_gem_execbuffer2 execbuf;
struct drm_i915_gem_exec_object2 obj[1];
- gem_write(i915, cmd_bo, 0, cmds, size);
+ gem_pwrite(i915, cmd_bo, 0, cmds, size);
memset(obj, 0, sizeof(obj));
obj[0].handle = cmd_bo;
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 38e2026aa..3f3b5f602 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -59,7 +59,7 @@ static void test_read(int vgem, int i915)
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -94,14 +94,14 @@ static void test_fence_read(int i915, int vgem)
close(slave[1]);
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, 0);
}
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -279,7 +279,7 @@ static void test_write(int vgem, int i915)
gem_close(vgem, scratch.handle);
for (i = 0; i < 1024; i++)
- gem_write(i915, handle, 4096*i, &i, sizeof(i));
+ gem_pwrite(i915, handle, 4096*i, &i, sizeof(i));
gem_close(i915, handle);
for (i = 0; i < 1024; i++)
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-09-01 18:18 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-09-01 18:18 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in gem_read/write.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 107 +++++++++++++++++++++++++++++++--
lib/ioctl_wrappers.h | 6 +-
tests/i915/gem_madvise.c | 2 +-
tests/i915/gem_userptr_blits.c | 2 +-
tests/i915/gen9_exec_parse.c | 2 +-
tests/prime_vgem.c | 14 ++---
6 files changed, 115 insertions(+), 18 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..4d58c6e4f 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>
@@ -323,7 +324,7 @@ void gem_close(int fd, uint32_t handle)
do_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close_bo);
}
-int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+int __gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
{
struct drm_i915_gem_pwrite gem_pwrite;
int err;
@@ -341,7 +342,7 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
}
/**
- * gem_write:
+ * gem_pwrite:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset within the buffer of the subrange
@@ -351,12 +352,12 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
* This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
* of a gem buffer object.
*/
-void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+void gem_pwrite(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);
+ igt_assert_eq(__gem_pwrite(fd, handle, offset, buf, length), 0);
}
-int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+int __gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
{
struct drm_i915_gem_pread gem_pread;
int err;
@@ -372,6 +373,100 @@ int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t len
err = -errno;
return err;
}
+/**
+ * gem_pread:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to read into
+ * @length: size of the subrange
+ *
+ * This wraps the PREAD ioctl, which is to download a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ igt_assert_eq(__gem_pread(fd, handle, offset, buf, length), 0);
+}
+
+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 (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);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ igt_assert(map);
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
+}
+
+/**
+ * gem_write:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset within the buffer of the subrange
+ * @buf: pointer to the data to write into the buffer
+ * @length: size of the subrange
+ *
+ * This wraps the PWRITE ioctl, which is to upload a linear data to a subrange
+ * of a gem buffer object.
+ */
+void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length)
+{
+ mmap_write(fd, handle, offset, buf, length);
+}
+
+static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
+{
+ void *map = NULL;
+
+ if (gem_has_llc(fd) || 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);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ igt_assert(map);
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
+}
+
/**
* gem_read:
* @fd: open i915 drm file descriptor
@@ -385,7 +480,7 @@ 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);
+ mmap_read(fd, handle, offset, buf, length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 870ac8b7b..5f83b0827 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -67,9 +67,11 @@ uint32_t gem_get_caching(int fd, uint32_t handle);
uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
void gem_close(int fd, uint32_t handle);
-int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+int __gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+void gem_pwrite(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
+int __gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
+void gem_pread(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
-int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
void gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write);
diff --git a/tests/i915/gem_madvise.c b/tests/i915/gem_madvise.c
index 54c9befff..c88e74c7c 100644
--- a/tests/i915/gem_madvise.c
+++ b/tests/i915/gem_madvise.c
@@ -157,7 +157,7 @@ dontneed_before_pwrite(void)
handle = gem_create(fd, OBJECT_SIZE);
gem_madvise(fd, handle, I915_MADV_DONTNEED);
- igt_assert_eq(__gem_write(fd, handle, 0, &bbe, sizeof(bbe)), -EFAULT);
+ igt_assert_eq(__gem_pwrite(fd, handle, 0, &bbe, sizeof(bbe)), -EFAULT);
close(fd);
}
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 268423dcd..9de8b76a9 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -1429,7 +1429,7 @@ static void test_readonly_pwrite(int i915)
char data[4096];
memset(data, page, sizeof(data));
- igt_assert_eq(__gem_write(i915, handle, page << 12, data, sizeof(data)), -EINVAL);
+ igt_assert_eq(__gem_pwrite(i915, handle, page << 12, data, sizeof(data)), -EINVAL);
}
gem_close(i915, handle);
diff --git a/tests/i915/gen9_exec_parse.c b/tests/i915/gen9_exec_parse.c
index 8cd82f568..15a843481 100644
--- a/tests/i915/gen9_exec_parse.c
+++ b/tests/i915/gen9_exec_parse.c
@@ -670,7 +670,7 @@ static void test_invalid_length(const int i915, const uint32_t handle)
lri_ok, 4096,
0);
- igt_assert_eq(__gem_write(i915, handle, 0, noops, 4097), -EINVAL);
+ igt_assert_eq(__gem_pwrite(i915, handle, 0, noops, 4097), -EINVAL);
}
struct reg {
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 38e2026aa..b56eb8091 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -48,7 +48,7 @@ static void test_read(int vgem, int i915)
handle = prime_fd_to_handle(i915, dmabuf);
close(dmabuf);
- igt_skip_on_f(__gem_read(i915, handle, 0, &i, sizeof(i)),
+ igt_skip_on_f(__gem_pread(i915, handle, 0, &i, sizeof(i)),
"PREAD from dma-buf not supported on this hardware\n");
ptr = vgem_mmap(vgem, &scratch, PROT_WRITE);
@@ -59,7 +59,7 @@ static void test_read(int vgem, int i915)
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -86,7 +86,7 @@ static void test_fence_read(int i915, int vgem)
handle = prime_fd_to_handle(i915, dmabuf);
close(dmabuf);
- igt_skip_on_f(__gem_read(i915, handle, 0, &i, sizeof(i)),
+ igt_skip_on_f(__gem_pread(i915, handle, 0, &i, sizeof(i)),
"PREAD from dma-buf not supported on this hardware\n");
igt_fork(child, 1) {
@@ -94,14 +94,14 @@ static void test_fence_read(int i915, int vgem)
close(slave[1]);
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, 0);
}
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
for (i = 0; i < 1024; i++) {
uint32_t tmp;
- gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
+ gem_pread(i915, handle, 4096*i, &tmp, sizeof(tmp));
igt_assert_eq(tmp, i);
}
gem_close(i915, handle);
@@ -272,14 +272,14 @@ static void test_write(int vgem, int i915)
handle = prime_fd_to_handle(i915, dmabuf);
close(dmabuf);
- igt_skip_on_f(__gem_write(i915, handle, 0, &i, sizeof(i)),
+ igt_skip_on_f(__gem_pwrite(i915, handle, 0, &i, sizeof(i)),
"PWRITE to dma-buf not supported on this hardware\n");
ptr = vgem_mmap(vgem, &scratch, PROT_READ);
gem_close(vgem, scratch.handle);
for (i = 0; i < 1024; i++)
- gem_write(i915, handle, 4096*i, &i, sizeof(i));
+ gem_pwrite(i915, handle, 4096*i, &i, sizeof(i));
gem_close(i915, handle);
for (i = 0; i < 1024; i++)
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-09-01 2:52 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-09-01 2:52 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in
gem_read/write.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 65 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 63 insertions(+), 2 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..7c985fe41 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>
@@ -340,6 +341,11 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
return err;
}
+static bool is_cache_coherent(int fd, uint32_t handle)
+{
+ return gem_get_caching(fd, handle) != I915_CACHING_NONE;
+}
+
/**
* gem_write:
* @fd: open i915 drm file descriptor
@@ -353,7 +359,36 @@ 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);
+ void *map = NULL;
+
+ if (is_cache_coherent(fd, handle)) {
+ map = __gem_mmap_offset__cpu(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = __gem_mmap__cpu(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_CPU,
+ I915_GEM_DOMAIN_CPU);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ igt_assert(map);
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
}
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
@@ -385,7 +420,33 @@ 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);
+ void *map = NULL;
+
+ if (gem_has_llc(fd) || is_cache_coherent(fd, handle)) {
+ map = __gem_mmap_offset__cpu(fd, handle, 0,
+ offset + length, PROT_READ);
+ if (!map)
+ map = __gem_mmap__cpu(fd, handle, 0, offset + length,
+ PROT_READ);
+
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ igt_assert(map);
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-09-01 1:58 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-09-01 1:58 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in
gem_read/write.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 46 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..0b90f4c1a 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>
@@ -340,6 +341,11 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
return err;
}
+static bool is_cache_coherent(int fd, uint32_t handle)
+{
+ return gem_get_caching(fd, handle) != I915_CACHING_NONE;
+}
+
/**
* gem_write:
* @fd: open i915 drm file descriptor
@@ -353,7 +359,26 @@ 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);
+ void *map = NULL;
+
+ if (is_cache_coherent(fd, handle)) {
+ 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);
+ }
+
+ if (!map) {
+ map = __gem_mmap__device_coherent(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
}
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
@@ -385,7 +410,24 @@ 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);
+ void *map = NULL;
+
+ if (gem_has_llc(fd) || is_cache_coherent(fd, handle)) {
+ map = __gem_mmap__cpu_coherent(fd, handle, 0,
+ offset + length, PROT_READ);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap__device_coherent(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-08-31 22:52 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-08-31 22:52 UTC (permalink / raw)
To: igt-dev
FOR CI ONLY. PLEASE DON'T REVIEW.
Trial patch to replace PREAD/PWRITE ioctls with mmap + memcpy in
gem_read/write.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
lib/ioctl_wrappers.c | 61 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..b8e7118da 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>
@@ -340,6 +341,11 @@ int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
return err;
}
+static bool is_cache_coherent(int fd, uint32_t handle)
+{
+ return gem_get_caching(fd, handle) != I915_CACHING_NONE;
+}
+
/**
* gem_write:
* @fd: open i915 drm file descriptor
@@ -353,7 +359,34 @@ 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);
+ void *map = NULL;
+
+ if (is_cache_coherent(fd, handle)) {
+ map = __gem_mmap_offset__cpu(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = __gem_mmap__cpu(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+
+ if (map)
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_CPU,
+ I915_GEM_DOMAIN_CPU);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ | PROT_WRITE);
+
+ gem_set_domain(fd, handle,
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+ }
+
+ memcpy(map + offset, buf, length);
+ munmap(map, offset + length);
}
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
@@ -385,7 +418,31 @@ 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);
+ void *map = NULL;
+
+ if (gem_has_llc(fd) || is_cache_coherent(fd, handle)) {
+ map = __gem_mmap_offset__cpu(fd, handle, 0,
+ offset + length, PROT_READ);
+ if (!map)
+ map = __gem_mmap__cpu(fd, handle, 0, offset + length,
+ PROT_READ);
+
+ if (map)
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ }
+
+ if (!map) {
+ map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+ if (!map)
+ map = gem_mmap__wc(fd, handle, 0, offset + length,
+ PROT_READ);
+
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
+ }
+
+ memcpy(buf, map + offset, length);
+ munmap(map, offset + length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-08-31 20:24 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-08-31 20:24 UTC (permalink / raw)
To: igt-dev
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@intel.com>
---
lib/ioctl_wrappers.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..889dec3f0 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,12 @@ 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__cpu_coherent(fd, handle, 0, offset + length, PROT_WRITE);
+
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
+ memcpy(ptr + offset, buf, length);
+ munmap(ptr, offset + length);
}
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
@@ -385,7 +391,12 @@ 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__cpu_coherent(fd, handle, 0, offset + length, PROT_READ);
+
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
+ memcpy(buf, ptr + offset, length);
+ munmap(ptr, offset + length);
}
int __gem_set_domain(int fd, uint32_t handle, uint32_t read, uint32_t write)
--
2.27.0.112.g101b3204f3
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-08-29 5:09 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-08-29 5:09 UTC (permalink / raw)
To: igt-dev
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@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..77752e8db 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, 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, 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
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-08-29 3:32 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-08-29 3:32 UTC (permalink / raw)
To: igt-dev
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@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
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write
@ 2020-08-29 1:53 Ashutosh Dixit
0 siblings, 0 replies; 15+ messages in thread
From: Ashutosh Dixit @ 2020-08-29 1:53 UTC (permalink / raw)
To: igt-dev
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@intel.com>
---
lib/ioctl_wrappers.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 3781286d8..6955a0a09 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,10 @@ 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);
+ void *ptr = gem_mmap__device_coherent(fd, handle, offset, length, PROT_WRITE);
+
+ memcpy(ptr, buf + offset, length);
+ munmap(ptr, length);
}
int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
@@ -385,7 +389,10 @@ 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);
+ void *ptr = gem_mmap__device_coherent(fd, handle, offset, length, PROT_READ);
+
+ memcpy(buf + offset, ptr, length);
+ munmap(ptr, 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
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2021-03-15 21:16 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 17:45 [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write Ashutosh Dixit
2020-09-01 21:15 ` [igt-dev] ✗ Fi.CI.BAT: failure for lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write (rev8) Patchwork
-- strict thread matches above, loose matches on Subject: below --
2021-03-15 21:16 [igt-dev] [CI i-g-t] lib/ioctl_wrappers: Handle PREAD/PWRITE ioctls not supported in gem_read/write Ashutosh Dixit
2021-01-21 5:52 Ashutosh Dixit
2021-01-21 2:20 Ashutosh Dixit
2020-09-06 23:36 Ashutosh Dixit
2020-09-06 17:38 Ashutosh Dixit
2020-09-01 18:18 Ashutosh Dixit
2020-09-01 2:52 Ashutosh Dixit
2020-09-01 1:58 Ashutosh Dixit
2020-08-31 22:52 Ashutosh Dixit
2020-08-31 20:24 Ashutosh Dixit
2020-08-29 5:09 Ashutosh Dixit
2020-08-29 3:32 Ashutosh Dixit
2020-08-29 1:53 Ashutosh Dixit
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.