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

drm/ttm: use an operation ctx for ttm_mem_global_alloc_page

forward the operation context to ttm_mem_global_alloc_page as well,
and the ultimate goal is swapout enablement for reserved BOs.

Here reserved BOs refer to all the BOs which share same reservation object

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

authored by

Roger He and committed by
Alex Deucher
9de2fb99 279c01f6

+16 -11
+3 -7
drivers/gpu/drm/ttm/ttm_memory.c
··· 539 539 EXPORT_SYMBOL(ttm_mem_global_alloc); 540 540 541 541 int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, 542 - struct page *page, uint64_t size) 542 + struct page *page, uint64_t size, 543 + struct ttm_operation_ctx *ctx) 543 544 { 544 - 545 545 struct ttm_mem_zone *zone = NULL; 546 - struct ttm_operation_ctx ctx = { 547 - .interruptible = false, 548 - .no_wait_gpu = false 549 - }; 550 546 551 547 /** 552 548 * Page allocations may be registed in a single zone ··· 556 560 if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) 557 561 zone = glob->zone_kernel; 558 562 #endif 559 - return ttm_mem_global_alloc_zone(glob, zone, size, &ctx); 563 + return ttm_mem_global_alloc_zone(glob, zone, size, ctx); 560 564 } 561 565 562 566 void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page,
+5 -1
drivers/gpu/drm/ttm/ttm_page_alloc.c
··· 1061 1061 int ttm_pool_populate(struct ttm_tt *ttm) 1062 1062 { 1063 1063 struct ttm_mem_global *mem_glob = ttm->glob->mem_glob; 1064 + struct ttm_operation_ctx ctx = { 1065 + .interruptible = false, 1066 + .no_wait_gpu = false 1067 + }; 1064 1068 unsigned i; 1065 1069 int ret; 1066 1070 ··· 1080 1076 1081 1077 for (i = 0; i < ttm->num_pages; ++i) { 1082 1078 ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], 1083 - PAGE_SIZE); 1079 + PAGE_SIZE, &ctx); 1084 1080 if (unlikely(ret != 0)) { 1085 1081 ttm_pool_unpopulate(ttm); 1086 1082 return -ENOMEM;
+6 -2
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
··· 927 927 { 928 928 struct ttm_tt *ttm = &ttm_dma->ttm; 929 929 struct ttm_mem_global *mem_glob = ttm->glob->mem_glob; 930 + struct ttm_operation_ctx ctx = { 931 + .interruptible = false, 932 + .no_wait_gpu = false 933 + }; 930 934 unsigned long num_pages = ttm->num_pages; 931 935 struct dma_pool *pool; 932 936 enum pool_type type; ··· 966 962 break; 967 963 968 964 ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], 969 - pool->size); 965 + pool->size, &ctx); 970 966 if (unlikely(ret != 0)) { 971 967 ttm_dma_unpopulate(ttm_dma, dev); 972 968 return -ENOMEM; ··· 1002 998 } 1003 999 1004 1000 ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], 1005 - pool->size); 1001 + pool->size, &ctx); 1006 1002 if (unlikely(ret != 0)) { 1007 1003 ttm_dma_unpopulate(ttm_dma, dev); 1008 1004 return -ENOMEM;
+2 -1
include/drm/ttm/ttm_memory.h
··· 84 84 extern void ttm_mem_global_free(struct ttm_mem_global *glob, 85 85 uint64_t amount); 86 86 extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, 87 - struct page *page, uint64_t size); 87 + struct page *page, uint64_t size, 88 + struct ttm_operation_ctx *ctx); 88 89 extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, 89 90 struct page *page, uint64_t size); 90 91 extern size_t ttm_round_pot(size_t size);