summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-10-02 13:24:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-10-02 15:30:44 +0100
commitdfe324f34c53af095bfe54b322e1a338421a6b0e (patch)
tree639ee1e19db8928a78e87ebfe106a09bf8f95169 /drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
parent006e570128f413759b9df64b51bae79903679c9b (diff)
drm/i915/selftests: Extract random_offset() for use with a prng
For selftests, we desire repeatability and so prefer using a prng with known seed over true randomness. Extract random_offset() as a selftest utility that can take the prng state. Suggested-by: Matthew Auld <matthew.auld@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191002122430.23205-1-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/selftests/i915_gem_gtt.c')
-rw-r--r--drivers/gpu/drm/i915/selftests/i915_gem_gtt.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 0d40e0b42923..f901bbb9586e 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -1299,6 +1299,7 @@ static int igt_gtt_reserve(void *arg)
{
struct i915_ggtt *ggtt = arg;
struct drm_i915_gem_object *obj, *on;
+ I915_RND_STATE(prng);
LIST_HEAD(objects);
u64 total;
int err = -ENODEV;
@@ -1425,9 +1426,10 @@ static int igt_gtt_reserve(void *arg)
goto out;
}
- offset = random_offset(0, ggtt->vm.total,
- 2*I915_GTT_PAGE_SIZE,
- I915_GTT_MIN_ALIGNMENT);
+ offset = igt_random_offset(&prng,
+ 0, ggtt->vm.total,
+ 2 * I915_GTT_PAGE_SIZE,
+ I915_GTT_MIN_ALIGNMENT);
err = i915_gem_gtt_reserve(&ggtt->vm, &vma->node,
obj->base.size,
@@ -1772,6 +1774,7 @@ static int igt_cs_tlb(void *arg)
struct intel_context *ce;
struct drm_file *file;
struct i915_vma *vma;
+ I915_RND_STATE(prng);
unsigned int i;
u32 *result;
u32 *batch;
@@ -1885,8 +1888,9 @@ static int igt_cs_tlb(void *arg)
struct i915_request *rq;
u64 offset;
- offset = random_offset(0, vm->total - PAGE_SIZE,
- chunk_size, PAGE_SIZE);
+ offset = igt_random_offset(&prng,
+ 0, vm->total - PAGE_SIZE,
+ chunk_size, PAGE_SIZE);
err = vm->allocate_va_range(vm, offset, chunk_size);
if (err)