aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2013-10-30 06:29:50 -0400
committerThomas Hellstrom <thellstrom@vmware.com>2013-11-06 07:36:12 -0500
commitda95c788ef0c645378ffccb7060a0df1a33aee38 (patch)
treed09283dd7a99a2afa40398ebadcd29b8cdd505dd /drivers/gpu/drm/ttm
parent9a0599ddeae012a771bba5e23393fc52d8a59d89 (diff)
drm/ttm: Fix ttm_bo_move_memcpy
All error paths will want to keep the mm node, so handle this at the function exit. This fixes an ioremap failure error path. Also add some comments to make the function a bit easier to understand. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 8369e35c0dce..4834c463c38b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -343,21 +343,25 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
343 if (ret) 343 if (ret)
344 goto out; 344 goto out;
345 345
346 /*
347 * Single TTM move. NOP.
348 */
346 if (old_iomap == NULL && new_iomap == NULL) 349 if (old_iomap == NULL && new_iomap == NULL)
347 goto out2; 350 goto out2;
351
352 /*
353 * Move nonexistent data. NOP.
354 */
348 if (old_iomap == NULL && ttm == NULL) 355 if (old_iomap == NULL && ttm == NULL)
349 goto out2; 356 goto out2;
350 357
351 /* TTM might be null for moves within the same region. 358 /*
359 * TTM might be null for moves within the same region.
352 */ 360 */
353 if (ttm && ttm->state == tt_unpopulated) { 361 if (ttm && ttm->state == tt_unpopulated) {
354 ret = ttm->bdev->driver->ttm_tt_populate(ttm); 362 ret = ttm->bdev->driver->ttm_tt_populate(ttm);
355 if (ret) { 363 if (ret)
356 /* if we fail here don't nuke the mm node
357 * as the bo still owns it */
358 old_copy.mm_node = NULL;
359 goto out1; 364 goto out1;
360 }
361 } 365 }
362 366
363 add = 0; 367 add = 0;
@@ -383,11 +387,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
383 prot); 387 prot);
384 } else 388 } else
385 ret = ttm_copy_io_page(new_iomap, old_iomap, page); 389 ret = ttm_copy_io_page(new_iomap, old_iomap, page);
386 if (ret) { 390 if (ret)
387 /* failing here, means keep old copy as-is */
388 old_copy.mm_node = NULL;
389 goto out1; 391 goto out1;
390 }
391 } 392 }
392 mb(); 393 mb();
393out2: 394out2:
@@ -405,7 +406,12 @@ out1:
405 ttm_mem_reg_iounmap(bdev, old_mem, new_iomap); 406 ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
406out: 407out:
407 ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap); 408 ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
408 ttm_bo_mem_put(bo, &old_copy); 409
410 /*
411 * On error, keep the mm node!
412 */
413 if (!ret)
414 ttm_bo_mem_put(bo, &old_copy);
409 return ret; 415 return ret;
410} 416}
411EXPORT_SYMBOL(ttm_bo_move_memcpy); 417EXPORT_SYMBOL(ttm_bo_move_memcpy);