diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-09-11 07:57:47 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-09-14 16:21:38 -0400 |
commit | 8e3ffa8d027554b5ba41131a31fcd96d248d1991 (patch) | |
tree | 69fed9ef95b9fb8cfffc8c72866a87ab3c1c323f | |
parent | 8db601f09127eb974e6fcf7fb30c70344d5727f6 (diff) |
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
-rw-r--r-- | drivers/gpu/drm/i915/i915_gpu_error.c | 20 |
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, | |||
1391 | { | 1391 | { |
1392 | struct i915_capture_list *c; | 1392 | struct i915_capture_list *c; |
1393 | struct drm_i915_error_object **bo; | 1393 | struct drm_i915_error_object **bo; |
1394 | long count; | 1394 | long count, max; |
1395 | 1395 | ||
1396 | count = 0; | 1396 | max = 0; |
1397 | for (c = request->capture_list; c; c = c->next) | 1397 | for (c = request->capture_list; c; c = c->next) |
1398 | count++; | 1398 | max++; |
1399 | if (!max) | ||
1400 | return; | ||
1399 | 1401 | ||
1400 | bo = NULL; | 1402 | bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC); |
1401 | if (count) | 1403 | if (!bo) { |
1402 | bo = kcalloc(count, sizeof(*bo), GFP_ATOMIC); | 1404 | /* If we can't capture everything, try to capture something. */ |
1405 | max = min_t(long, max, PAGE_SIZE / sizeof(*bo)); | ||
1406 | bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC); | ||
1407 | } | ||
1403 | if (!bo) | 1408 | if (!bo) |
1404 | return; | 1409 | return; |
1405 | 1410 | ||
@@ -1408,7 +1413,8 @@ static void request_record_user_bo(struct i915_request *request, | |||
1408 | bo[count] = i915_error_object_create(request->i915, c->vma); | 1413 | bo[count] = i915_error_object_create(request->i915, c->vma); |
1409 | if (!bo[count]) | 1414 | if (!bo[count]) |
1410 | break; | 1415 | break; |
1411 | count++; | 1416 | if (++count == max) |
1417 | break; | ||
1412 | } | 1418 | } |
1413 | 1419 | ||
1414 | ee->user_bo = bo; | 1420 | ee->user_bo = bo; |