@@ -184,6 +184,45 @@ test_disable_prefault_write(int fd)
gem_close(fd, src);
}
+static void
+test_disable_prefault_read(int fd)
+{
+ uint32_t src, dst;
+ void *ptr;
+ int i;
+ uint8_t *tmp;
+
+ src = gem_create(fd, OBJECT_SIZE);
+ dst = gem_create(fd, OBJECT_SIZE);
+
+ /* write test_val to dst object */
+ ptr = gem_mmap__cpu(fd, dst, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+ assert(ptr != NULL);
+ tmp = (uint8_t *)ptr;
+ memset(tmp, TEST_VALUE, OBJECT_SIZE);
+
+ drmtest_disable_prefault();
+ ptr = mmap_bo(fd, src, OBJECT_SIZE);
+ gem_read(fd, dst, 0, ptr, OBJECT_SIZE);
+ munmap(ptr, OBJECT_SIZE);
+ drmtest_enable_prefault();
+
+ /* compare src object to test_val */
+ ptr = gem_mmap__cpu(fd, src, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+ assert(ptr != NULL);
+ tmp = (uint8_t *)ptr;
+ for (i = 0; i < OBJECT_SIZE; i++) {
+ if (tmp[i] != TEST_VALUE) {
+ printf("mismatch at %i, got: %i\n",
+ i, tmp[i]);
+ break;
+ }
+ }
+
+ gem_close(fd, dst);
+ gem_close(fd, src);
+}
+
int main(int argc, char **argv)
{
int fd;
@@ -204,6 +243,9 @@ int main(int argc, char **argv)
if (drmtest_run_subtest("write"))
test_disable_prefault_write(fd);
+ if (drmtest_run_subtest("read"))
+ test_disable_prefault_read(fd);
+
close(fd);
return 0;
First disable prefault, then map src bo to gtt map, so pread from dst bo to src bo, it will run pread_slow path, finally enable prefault Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> --- tests/gem_disable_prefault.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)