Skip to content

Commit 9de2fb9

Browse files
Roger Healexdeucher
authored andcommitted
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>
1 parent 279c01f commit 9de2fb9

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎drivers/gpu/drm/ttm/ttm_memory.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,10 @@ int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
539539
EXPORT_SYMBOL(ttm_mem_global_alloc);
540540

541541
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)
543544
{
544-
545545
struct ttm_mem_zone *zone = NULL;
546-
struct ttm_operation_ctx ctx = {
547-
.interruptible = false,
548-
.no_wait_gpu = false
549-
};
550546

551547
/**
552548
* Page allocations may be registed in a single zone
@@ -560,7 +556,7 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob,
560556
if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL)
561557
zone = glob->zone_kernel;
562558
#endif
563-
return ttm_mem_global_alloc_zone(glob, zone, size, &ctx);
559+
return ttm_mem_global_alloc_zone(glob, zone, size, ctx);
564560
}
565561

566562
void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page,

‎drivers/gpu/drm/ttm/ttm_page_alloc.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,10 @@ void ttm_page_alloc_fini(void)
10611061
int ttm_pool_populate(struct ttm_tt *ttm)
10621062
{
10631063
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+
};
10641068
unsigned i;
10651069
int ret;
10661070

@@ -1076,7 +1080,7 @@ int ttm_pool_populate(struct ttm_tt *ttm)
10761080

10771081
for (i = 0; i < ttm->num_pages; ++i) {
10781082
ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i],
1079-
PAGE_SIZE);
1083+
PAGE_SIZE, &ctx);
10801084
if (unlikely(ret != 0)) {
10811085
ttm_pool_unpopulate(ttm);
10821086
return -ENOMEM;

‎drivers/gpu/drm/ttm/ttm_page_alloc_dma.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,10 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev)
927927
{
928928
struct ttm_tt *ttm = &ttm_dma->ttm;
929929
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+
};
930934
unsigned long num_pages = ttm->num_pages;
931935
struct dma_pool *pool;
932936
enum pool_type type;
@@ -962,7 +966,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev)
962966
break;
963967

964968
ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i],
965-
pool->size);
969+
pool->size, &ctx);
966970
if (unlikely(ret != 0)) {
967971
ttm_dma_unpopulate(ttm_dma, dev);
968972
return -ENOMEM;
@@ -998,7 +1002,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev)
9981002
}
9991003

10001004
ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i],
1001-
pool->size);
1005+
pool->size, &ctx);
10021006
if (unlikely(ret != 0)) {
10031007
ttm_dma_unpopulate(ttm_dma, dev);
10041008
return -ENOMEM;

‎include/drm/ttm/ttm_memory.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
8484
extern void ttm_mem_global_free(struct ttm_mem_global *glob,
8585
uint64_t amount);
8686
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);
8889
extern void ttm_mem_global_free_page(struct ttm_mem_global *glob,
8990
struct page *page, uint64_t size);
9091
extern size_t ttm_round_pot(size_t size);

0 commit comments

Comments
 (0)