igt/gem_tiled_wc: Fix! Finish!

It helps when testing whether tiled data read back through a linear
mmaping to first tile the data. And not repeatedly unmapping the linear
map stops it from segfaulting.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88686
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2015-01-22 07:52:09 +00:00
parent 3d65ff780d
commit 5e9fac5491

View File

@ -68,7 +68,7 @@ create_bo(int fd)
gem_set_tiling(fd, handle, I915_TILING_X, WIDTH * sizeof(uint32_t)); gem_set_tiling(fd, handle, I915_TILING_X, WIDTH * sizeof(uint32_t));
/* Fill the BO with dwords starting at start_val */ /* Fill the BO with dwords starting at start_val */
data = gem_mmap__wc(fd, handle, 0, SIZE, PROT_READ | PROT_WRITE); data = gem_mmap__gtt(fd, handle, SIZE, PROT_READ | PROT_WRITE);
for (i = 0; i < WIDTH*HEIGHT; i++) for (i = 0; i < WIDTH*HEIGHT; i++)
data[i] = i; data[i] = i;
munmap(data, SIZE); munmap(data, SIZE);
@ -101,7 +101,9 @@ calculate_expected(int offset)
int tile_y = tile_off / tile_width; int tile_y = tile_off / tile_width;
int tile_x = (tile_off % tile_width) / 4; int tile_x = (tile_off % tile_width) / 4;
igt_debug("%3d, %3d, %3d,%3d\n", base_x, base_y, tile_x, tile_y); igt_debug("%s(%d): %3d, %3d, %3d,%3d = %d\n",
__func__, offset, base_x, base_y, tile_x, tile_y,
(base_y + tile_y) * WIDTH + base_x + tile_x);
return (base_y + tile_y) * WIDTH + base_x + tile_x; return (base_y + tile_y) * WIDTH + base_x + tile_x;
} }
@ -221,6 +223,8 @@ igt_simple_main
igt_skip("unknown swizzling"); igt_skip("unknown swizzling");
break; break;
} }
igt_debug("Checking offset %d swizzled %s -> %d\n",
j, swizzle_str, swizzled_offset);
expected_val = calculate_expected(swizzled_offset); expected_val = calculate_expected(swizzled_offset);
found_val = linear[j / 4]; found_val = linear[j / 4];
igt_assert_f(expected_val == found_val, igt_assert_f(expected_val == found_val,
@ -229,8 +233,8 @@ igt_simple_main
i, found_val, expected_val, j, i, found_val, expected_val, j,
offset, offset + len, offset, offset + len,
swizzle_str); swizzle_str);
munmap(linear, last_page - first_page);
} }
munmap(linear, last_page - first_page);
} }
close(fd); close(fd);