From e12d69496a6bef09ac6c0f792b8d60a65cf5e0bf Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 18 Mar 2019 08:26:38 +0000 Subject: i915/gem_mmap_gtt: Check that the initial pagefault is non-blocking Historically, the GTT pagefault invoked set-domain(GTT) to transparently handle swapin. However, this implied that the GTT faults were synchronous with GPU rendering, which was not the desired ABI, as synchronisation is explicit via calls to GEM_WAIT or GEM_SET_DOMAIN. In MMAP_GTT_VERSION, this accidental ABI is removed and so we test it is gone and does not come back. For completeness, we verify that the other mmap paths didn't block on initial pagefaulting. Signed-off-by: Chris Wilson Reviewed-by: Matthew Auld --- tests/i915/gem_mmap.c | 22 ++++++++++++++++++++++ tests/i915/gem_mmap_gtt.c | 35 +++++++++++++++++++++++++++++++++++ tests/i915/gem_mmap_wc.c | 21 +++++++++++++++++++++ 3 files changed, 78 insertions(+) (limited to 'tests/i915') diff --git a/tests/i915/gem_mmap.c b/tests/i915/gem_mmap.c index 05a40d8a..227ae7ca 100644 --- a/tests/i915/gem_mmap.c +++ b/tests/i915/gem_mmap.c @@ -116,6 +116,25 @@ test_huge_bo(int huge) free(cpu_pattern); } +static void +test_pf_nonblock(int i915) +{ + igt_spin_t *spin; + uint32_t *ptr; + + spin = igt_spin_batch_new(i915); + + igt_set_timeout(1, "initial pagefaulting did not complete within 1s"); + + ptr = gem_mmap__cpu(i915, spin->handle, 0, 4096, PROT_WRITE); + ptr[256] = 0; + munmap(ptr, 4096); + + igt_reset_timeout(); + + igt_spin_batch_free(i915, spin); +} + static int mmap_ioctl(int i915, struct drm_i915_gem_mmap *arg) { int err = 0; @@ -248,6 +267,9 @@ igt_main gem_close(fd, handle); } + igt_subtest("pf-nonblock") + test_pf_nonblock(fd); + igt_subtest("basic-small-bo") test_huge_bo(-1); igt_subtest("big-bo") diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c index e6244fd0..9a00f4ea 100644 --- a/tests/i915/gem_mmap_gtt.c +++ b/tests/i915/gem_mmap_gtt.c @@ -287,6 +287,39 @@ test_wc(int fd) 5*gtt_writes/256., 5*cpu_writes/256.); } +static int mmap_gtt_version(int i915) +{ + int val = 0; + struct drm_i915_getparam gp = { + gp.param = 40, /* MMAP_GTT_VERSION */ + gp.value = &val, + }; + + ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp); + return val; +} + +static void +test_pf_nonblock(int i915) +{ + igt_spin_t *spin; + uint32_t *ptr; + + igt_require(mmap_gtt_version(i915) >= 3); + + spin = igt_spin_batch_new(i915); + + igt_set_timeout(1, "initial pagefaulting did not complete within 1s"); + + ptr = gem_mmap__gtt(i915, spin->handle, 4096, PROT_WRITE); + ptr[256] = 0; + munmap(ptr, 4096); + + igt_reset_timeout(); + + igt_spin_batch_free(i915, spin); +} + static void test_write_gtt(int fd) { @@ -900,6 +933,8 @@ igt_main test_write_cpu_read_gtt(fd); igt_subtest("basic-wc") test_wc(fd); + igt_subtest("pf-nonblock") + test_pf_nonblock(fd); igt_subtest("basic-small-bo") test_huge_bo(fd, -1, I915_TILING_NONE); diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c index b8cff46e..e3ffc5ad 100644 --- a/tests/i915/gem_mmap_wc.c +++ b/tests/i915/gem_mmap_wc.c @@ -442,6 +442,25 @@ test_fault_concurrent(int fd) } } +static void +test_pf_nonblock(int i915) +{ + igt_spin_t *spin; + uint32_t *ptr; + + spin = igt_spin_batch_new(i915); + + igt_set_timeout(1, "initial pagefaulting did not complete within 1s"); + + ptr = gem_mmap__wc(i915, spin->handle, 0, 4096, PROT_WRITE); + ptr[256] = 0; + munmap(ptr, 4096); + + igt_reset_timeout(); + + igt_spin_batch_free(i915, spin); +} + static void run_without_prefault(int fd, void (*func)(int fd)) @@ -581,6 +600,8 @@ igt_main test_write_cpu_read_wc(fd, 0); igt_subtest("write-gtt-read-wc") test_write_gtt_read_wc(fd); + igt_subtest("pf-nonblock") + test_pf_nonblock(fd); igt_subtest("set-cache-level") test_set_cache_level(fd); -- cgit v1.2.3