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

drm/ttm: add ttm_bo_pipeline_gutting

Allows us to gut a BO of it's backing store when the driver says that it
isn't needed any more.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Roger He <Hongbo.He@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
5d951098 48527e52

+45 -3
+12 -3
drivers/gpu/drm/ttm/ttm_bo.c
··· 622 622 623 623 reservation_object_assert_held(bo->resv); 624 624 625 + placement.num_placement = 0; 626 + placement.num_busy_placement = 0; 627 + bdev->driver->evict_flags(bo, &placement); 628 + 629 + if (!placement.num_placement && !placement.num_busy_placement) { 630 + ret = ttm_bo_pipeline_gutting(bo); 631 + if (ret) 632 + return ret; 633 + 634 + return ttm_tt_create(bo, false); 635 + } 636 + 625 637 evict_mem = bo->mem; 626 638 evict_mem.mm_node = NULL; 627 639 evict_mem.bus.io_reserved_vm = false; 628 640 evict_mem.bus.io_reserved_count = 0; 629 641 630 - placement.num_placement = 0; 631 - placement.num_busy_placement = 0; 632 - bdev->driver->evict_flags(bo, &placement); 633 642 ret = ttm_bo_mem_space(bo, &placement, &evict_mem, ctx); 634 643 if (ret) { 635 644 if (ret != -ERESTARTSYS) {
+24
drivers/gpu/drm/ttm/ttm_bo_util.c
··· 801 801 return 0; 802 802 } 803 803 EXPORT_SYMBOL(ttm_bo_pipeline_move); 804 + 805 + int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) 806 + { 807 + struct ttm_buffer_object *ghost; 808 + int ret; 809 + 810 + ret = ttm_buffer_object_transfer(bo, &ghost); 811 + if (ret) 812 + return ret; 813 + 814 + ret = reservation_object_copy_fences(ghost->resv, bo->resv); 815 + /* Last resort, wait for the BO to be idle when we are OOM */ 816 + if (ret) 817 + ttm_bo_wait(bo, false, false); 818 + 819 + memset(&bo->mem, 0, sizeof(bo->mem)); 820 + bo->mem.mem_type = TTM_PL_SYSTEM; 821 + bo->ttm = NULL; 822 + 823 + ttm_bo_unreserve(ghost); 824 + ttm_bo_unref(&ghost); 825 + 826 + return 0; 827 + }
+9
include/drm/ttm/ttm_bo_driver.h
··· 850 850 struct ttm_mem_reg *new_mem); 851 851 852 852 /** 853 + * ttm_bo_pipeline_gutting. 854 + * 855 + * @bo: A pointer to a struct ttm_buffer_object. 856 + * 857 + * Pipelined gutting a BO of it's backing store. 858 + */ 859 + int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo); 860 + 861 + /** 853 862 * ttm_io_prot 854 863 * 855 864 * @c_state: Caching state.