From d3bf83af031a2e1c937b3f66fd3fbaec72864525 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 15 Jan 2015 08:49:59 +0000 Subject: [PATCH] igt/gem_mmap_wc/set-cache-level: Exercise set-cache-level WARNing With the introduction of mmap(wc) and its unbound GTT write domain, we can now hit the warning inside set-cache-level, complaining about the failure to do correct cpu cache tracking. Signed-off-by: Chris Wilson --- tests/gem_mmap_wc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/gem_mmap_wc.c b/tests/gem_mmap_wc.c index 2edb332a..c945ba85 100644 --- a/tests/gem_mmap_wc.c +++ b/tests/gem_mmap_wc.c @@ -315,6 +315,51 @@ test_write_gtt_read_wc(int fd) munmap(dst, OBJECT_SIZE); } +static void +test_set_cache_level(int fd) +{ + struct drm_mode_cursor arg; + struct drm_mode_card_res res; + uint32_t crtc[32]; + int active_crtc = 0; + int n; + + /* We want to trigger an old WARN in set-cache-level when + * it sees an unbound object in the GTT domain, following + * the introduction of mmap(wc). + */ + + memset(&arg, 0, sizeof(arg)); + arg.flags = DRM_MODE_CURSOR_BO; + arg.width = arg.height = 64; + arg.handle = gem_create(fd, 64*64*4); + set_domain(fd, arg.handle); + + /* Bind the object to the cursor to force set-cache-level(DISPLAY) */ + memset(&res, 0, sizeof(res)); + res.count_crtcs = 32; + res.crtc_id_ptr = (uintptr_t)crtc; + do_ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res); + for (n = 0; n < res.count_crtcs; n++) { + struct drm_mode_crtc mode; + + memset(&mode, 0, sizeof(mode)); + mode.crtc_id = crtc[n]; + do_ioctl(fd, DRM_IOCTL_MODE_GETCRTC, &mode); + + if (!mode.mode_valid) + continue; + + active_crtc++; + + arg.crtc_id = crtc[n]; + do_ioctl(fd, DRM_IOCTL_MODE_CURSOR, &arg); + } + + gem_close(fd, arg.handle); + igt_require(active_crtc); +} + struct thread_fault_concurrent { pthread_t thread; int id; @@ -414,6 +459,8 @@ igt_main test_write_cpu_read_wc(fd); igt_subtest("write-gtt-read-wc") test_write_gtt_read_wc(fd); + igt_subtest("set-cache-level") + test_set_cache_level(fd); igt_fixture close(fd);