diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-09-01 21:26:29 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-09-01 21:27:52 +0100 |
commit | c1d427b0d764c919a34fe0b2249d941649e31216 (patch) | |
tree | 792ae48870c2f7294b03d14cecbb7e0f1357e62f /tests | |
parent | 768f6cc854f5d04a067c8c64297563655b8e54f9 (diff) |
igt/pm_rps: Remove reliance on guessing the busy workload
Create an unbounded batch in order to ensure that the workload doesn't
disappear before the wait and so we should be given the RPS waitboost.
References: https://bugs.freedesktop.org/show_bug.cgi?id=97564
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pm_rps.c | 77 |
1 files changed, 62 insertions, 15 deletions
diff --git a/tests/pm_rps.c b/tests/pm_rps.c index ea085862..5a54d9d4 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -560,14 +560,67 @@ static void reset_gpu(void) close(fd); } -static void waitboost(bool reset) +static uint32_t *make_busy(int fd, uint32_t handle) { - const uint32_t bbe = MI_BATCH_BUFFER_END; - struct drm_i915_gem_exec_object2 object; + const int gen = intel_gen(intel_get_drm_devid(fd)); + struct drm_i915_gem_exec_object2 obj; + struct drm_i915_gem_relocation_entry reloc; struct drm_i915_gem_execbuffer2 execbuf; + uint32_t *batch; + int i; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)&obj; + execbuf.buffer_count = 1; + + memset(&obj, 0, sizeof(obj)); + obj.handle = handle; + + obj.relocs_ptr = (uintptr_t)&reloc; + obj.relocation_count = 1; + memset(&reloc, 0, sizeof(reloc)); + + batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + + reloc.target_handle = obj.handle; /* recurse */ + reloc.presumed_offset = 0; + reloc.offset = sizeof(uint32_t); + reloc.delta = 0; + reloc.read_domains = I915_GEM_DOMAIN_COMMAND; + reloc.write_domain = 0; + + i = 0; + batch[i] = MI_BATCH_BUFFER_START; + if (gen >= 8) { + batch[i] |= 1 << 8 | 1; + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 6) { + batch[i] |= 1 << 8; + batch[++i] = 0; + } else { + batch[i] |= 2 << 6; + batch[++i] = 0; + if (gen < 4) { + batch[i] |= 1; + reloc.delta = 1; + } + } + i++; + + gem_execbuf(fd, &execbuf); + return batch; +} + +static void waitboost(bool reset) +{ int pre_freqs[NUMFREQ]; int boost_freqs[NUMFREQ]; int post_freqs[NUMFREQ]; + uint32_t *batch, handle; + int64_t timeout = 1; int fd = drm_open_driver(DRIVER_INTEL); @@ -588,20 +641,14 @@ static void waitboost(bool reset) } igt_debug("Wait for gpu...\n"); - memset(&object, 0, sizeof(object)); - object.handle = gem_create(fd, 4096); - gem_write(fd, object.handle, 0, &bbe, sizeof(bbe)); - memset(&execbuf, 0, sizeof(execbuf)); - execbuf.buffers_ptr = (uintptr_t)&object; - execbuf.buffer_count = 1; - do { - for (int i = 0; i < 64; i++) - gem_execbuf(fd, &execbuf); - } while (!gem_bo_busy(fd, object.handle)); - gem_sync(fd, object.handle); + handle = gem_create(fd, 4096); + batch = make_busy(fd, handle); + gem_wait(fd, handle, &timeout); read_freqs(boost_freqs); dump(boost_freqs); - gem_close(fd, object.handle); + *batch = MI_BATCH_BUFFER_END; + munmap(batch, 4096); + gem_close(fd, handle); igt_debug("Apply low load again...\n"); sleep(1); |