summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gpu_error.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-09-11 12:57:47 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-09-14 21:21:38 +0100
commit8e3ffa8d027554b5ba41131a31fcd96d248d1991 (patch)
tree69fed9ef95b9fb8cfffc8c72866a87ab3c1c323f /drivers/gpu/drm/i915/i915_gpu_error.c
parent8db601f09127eb974e6fcf7fb30c70344d5727f6 (diff)
downloadlinux-8e3ffa8d027554b5ba41131a31fcd96d248d1991.tar.bz2
drm/i915: Limit number of capture objects
If we fail to allocate an array for a large number of user requested capture objects, reduce the array size and try to grab at least some of the objects! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180911115810.8917-3-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gpu_error.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gpu_error.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 8c81cf3aa182..1175fec08fe1 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1391,15 +1391,20 @@ static void request_record_user_bo(struct i915_request *request,
{
struct i915_capture_list *c;
struct drm_i915_error_object **bo;
- long count;
+ long count, max;
- count = 0;
+ max = 0;
for (c = request->capture_list; c; c = c->next)
- count++;
+ max++;
+ if (!max)
+ return;
- bo = NULL;
- if (count)
- bo = kcalloc(count, sizeof(*bo), GFP_ATOMIC);
+ bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC);
+ if (!bo) {
+ /* If we can't capture everything, try to capture something. */
+ max = min_t(long, max, PAGE_SIZE / sizeof(*bo));
+ bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC);
+ }
if (!bo)
return;
@@ -1408,7 +1413,8 @@ static void request_record_user_bo(struct i915_request *request,
bo[count] = i915_error_object_create(request->i915, c->vma);
if (!bo[count])
break;
- count++;
+ if (++count == max)
+ break;
}
ee->user_bo = bo;