aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gpu_error.c
diff options
context:
space:
mode:
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 f7f2aa71d8d9..2835cacd0d08 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1365,15 +1365,20 @@ static void request_record_user_bo(struct i915_request *request,
1365{ 1365{
1366 struct i915_capture_list *c; 1366 struct i915_capture_list *c;
1367 struct drm_i915_error_object **bo; 1367 struct drm_i915_error_object **bo;
1368 long count; 1368 long count, max;
1369 1369
1370 count = 0; 1370 max = 0;
1371 for (c = request->capture_list; c; c = c->next) 1371 for (c = request->capture_list; c; c = c->next)
1372 count++; 1372 max++;
1373 if (!max)
1374 return;
1373 1375
1374 bo = NULL; 1376 bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC);
1375 if (count) 1377 if (!bo) {
1376 bo = kcalloc(count, sizeof(*bo), GFP_ATOMIC); 1378 /* If we can't capture everything, try to capture something. */
1379 max = min_t(long, max, PAGE_SIZE / sizeof(*bo));
1380 bo = kmalloc_array(max, sizeof(*bo), GFP_ATOMIC);
1381 }
1377 if (!bo) 1382 if (!bo)
1378 return; 1383 return;
1379 1384
@@ -1382,7 +1387,8 @@ static void request_record_user_bo(struct i915_request *request,
1382 bo[count] = i915_error_object_create(request->i915, c->vma); 1387 bo[count] = i915_error_object_create(request->i915, c->vma);
1383 if (!bo[count]) 1388 if (!bo[count])
1384 break; 1389 break;
1385 count++; 1390 if (++count == max)
1391 break;
1386 } 1392 }
1387 1393
1388 ee->user_bo = bo; 1394 ee->user_bo = bo;