Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/ttm: make common function for wait/free node path.

The pipeline and accel cleansups has similiar paths here.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200917043040.146575-8-airlied@gmail.com

+20 -18
+20 -18
drivers/gpu/drm/ttm/ttm_bo_util.c
··· 526 526 } 527 527 EXPORT_SYMBOL(ttm_bo_kunmap); 528 528 529 + static int ttm_bo_wait_free_node(struct ttm_buffer_object *bo, 530 + bool dst_use_tt) 531 + { 532 + int ret; 533 + ret = ttm_bo_wait(bo, false, false); 534 + if (ret) 535 + return ret; 536 + 537 + if (!dst_use_tt) 538 + ttm_bo_tt_destroy(bo); 539 + ttm_bo_free_old_node(bo); 540 + return 0; 541 + } 542 + 529 543 static int ttm_bo_move_to_ghost(struct ttm_buffer_object *bo, 530 544 struct dma_fence *fence, 531 545 bool dst_use_tt) ··· 590 576 int ret; 591 577 592 578 dma_resv_add_excl_fence(bo->base.resv, fence); 593 - if (evict) { 594 - ret = ttm_bo_wait(bo, false, false); 595 - if (ret) 596 - return ret; 597 - 598 - if (!man->use_tt) 599 - ttm_bo_tt_destroy(bo); 600 - ttm_bo_free_old_node(bo); 601 - } else { 579 + if (evict) 580 + ret = ttm_bo_wait_free_node(bo, man->use_tt); 581 + else 602 582 ret = ttm_bo_move_to_ghost(bo, fence, man->use_tt); 603 - if (ret) 604 - return ret; 605 - } 583 + if (ret) 584 + return ret; 606 585 607 586 ttm_bo_assign_mem(bo, new_mem); 608 587 ··· 645 638 * 646 639 * Should never happen in pratice. 647 640 */ 648 - 649 - ret = ttm_bo_wait(bo, false, false); 641 + ret = ttm_bo_wait_free_node(bo, to->use_tt); 650 642 if (ret) 651 643 return ret; 652 - 653 - if (!to->use_tt) 654 - ttm_bo_tt_destroy(bo); 655 - ttm_bo_free_old_node(bo); 656 644 } 657 645 658 646 ttm_bo_assign_mem(bo, new_mem);