gem_mmap_gtt: Test mmaping less than the full object

A bug was recently introduced into the kernel that happened when the vma
was smaller than the object. Test that.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-06-21 15:39:09 +01:00
parent 9f28ba5ef3
commit fedb9b6342

View File

@ -111,6 +111,40 @@ test_access(int fd)
MAP_SHARED, fd2, mmap_arg.offset));
}
static void
test_short(int fd)
{
struct drm_i915_gem_mmap_gtt mmap_arg;
int pages, p;
mmap_arg.handle = gem_create(fd, OBJECT_SIZE);
igt_assert(mmap_arg.handle);
igt_assert(drmIoctl(fd,
DRM_IOCTL_I915_GEM_MMAP_GTT,
&mmap_arg) == 0);
for (pages = 1; pages <= OBJECT_SIZE / 4096; pages <<= 1) {
uint8_t *r, *w;
w = mmap64(0, pages * 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, mmap_arg.offset);
igt_assert(w != MAP_FAILED);
r = mmap64(0, pages * 4096, PROT_READ,
MAP_SHARED, fd, mmap_arg.offset);
igt_assert(r != MAP_FAILED);
for (p = 0; p < pages; p++) {
w[4096*p] = r[4096*p];
w[4096*p+4095] = r[4096*p+4095];
}
munmap(r, pages * 4096);
munmap(w, pages * 4096);
}
gem_close(fd, mmap_arg.handle);
}
static void
test_copy(int fd)
{
@ -308,6 +342,8 @@ igt_main
igt_subtest("access")
test_access(fd);
igt_subtest("short")
test_short(fd);
igt_subtest("copy")
test_copy(fd);
igt_subtest("read")