Commit 34f5fe12 authored by Chris Wilson's avatar Chris Wilson

drm/i915/selftests: Move mock_vma to the heap to reduce stack_frame

An i915_vma struct on the stack may push the frame over the limit, if
set conservatively, so move it to the heap.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191125124856.1761176-1-chris@chris-wilson.co.uk
parent 4f88f874
...@@ -212,10 +212,12 @@ static int lowlevel_hole(struct drm_i915_private *i915, ...@@ -212,10 +212,12 @@ static int lowlevel_hole(struct drm_i915_private *i915,
unsigned long end_time) unsigned long end_time)
{ {
I915_RND_STATE(seed_prng); I915_RND_STATE(seed_prng);
struct i915_vma *mock_vma;
unsigned int size; unsigned int size;
struct i915_vma mock_vma;
memset(&mock_vma, 0, sizeof(struct i915_vma)); mock_vma = kzalloc(sizeof(*mock_vma), GFP_KERNEL);
if (!mock_vma)
return -ENOMEM;
/* Keep creating larger objects until one cannot fit into the hole */ /* Keep creating larger objects until one cannot fit into the hole */
for (size = 12; (hole_end - hole_start) >> size; size++) { for (size = 12; (hole_end - hole_start) >> size; size++) {
...@@ -239,8 +241,10 @@ static int lowlevel_hole(struct drm_i915_private *i915, ...@@ -239,8 +241,10 @@ static int lowlevel_hole(struct drm_i915_private *i915,
if (order) if (order)
break; break;
} while (count >>= 1); } while (count >>= 1);
if (!count) if (!count) {
kfree(mock_vma);
return -ENOMEM; return -ENOMEM;
}
GEM_BUG_ON(!order); GEM_BUG_ON(!order);
GEM_BUG_ON(count * BIT_ULL(size) > vm->total); GEM_BUG_ON(count * BIT_ULL(size) > vm->total);
...@@ -283,12 +287,12 @@ static int lowlevel_hole(struct drm_i915_private *i915, ...@@ -283,12 +287,12 @@ static int lowlevel_hole(struct drm_i915_private *i915,
vm->allocate_va_range(vm, addr, BIT_ULL(size))) vm->allocate_va_range(vm, addr, BIT_ULL(size)))
break; break;
mock_vma.pages = obj->mm.pages; mock_vma->pages = obj->mm.pages;
mock_vma.node.size = BIT_ULL(size); mock_vma->node.size = BIT_ULL(size);
mock_vma.node.start = addr; mock_vma->node.start = addr;
with_intel_runtime_pm(&i915->runtime_pm, wakeref) with_intel_runtime_pm(&i915->runtime_pm, wakeref)
vm->insert_entries(vm, &mock_vma, vm->insert_entries(vm, mock_vma,
I915_CACHE_NONE, 0); I915_CACHE_NONE, 0);
} }
count = n; count = n;
...@@ -311,6 +315,7 @@ static int lowlevel_hole(struct drm_i915_private *i915, ...@@ -311,6 +315,7 @@ static int lowlevel_hole(struct drm_i915_private *i915,
cleanup_freed_objects(i915); cleanup_freed_objects(i915);
} }
kfree(mock_vma);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment