diff options
author | Roger He <Hongbo.He@amd.com> | 2017-12-08 02:21:18 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-27 11:38:55 -0500 |
commit | 9de2fb99ebe059f7777b4c0463eca2946f2bda4d (patch) | |
tree | 9d620a073b86db04996eeabb38095464cccd0242 | |
parent | 279c01f6ef626d59b93383d183fb69173d3f7ac7 (diff) |
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>
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_memory.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 8 | ||||
-rw-r--r-- | include/drm/ttm/ttm_memory.h | 3 |
4 files changed, 16 insertions, 11 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index 525d3b601790..102b326d3c42 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c | |||
@@ -539,14 +539,10 @@ int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, | |||
539 | EXPORT_SYMBOL(ttm_mem_global_alloc); | 539 | EXPORT_SYMBOL(ttm_mem_global_alloc); |
540 | 540 | ||
541 | int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, | 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 | struct ttm_mem_zone *zone = NULL; | 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 | * Page allocations may be registed in a single zone | 548 | * Page allocations may be registed in a single zone |
@@ -560,7 +556,7 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, | |||
560 | if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) | 556 | if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) |
561 | zone = glob->zone_kernel; | 557 | zone = glob->zone_kernel; |
562 | #endif | 558 | #endif |
563 | return ttm_mem_global_alloc_zone(glob, zone, size, &ctx); | 559 | return ttm_mem_global_alloc_zone(glob, zone, size, ctx); |
564 | } | 560 | } |
565 | 561 | ||
566 | void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, | 562 | void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, |
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index b5ba6441489f..8f93ff30f78b 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c | |||
@@ -1061,6 +1061,10 @@ void ttm_page_alloc_fini(void) | |||
1061 | int ttm_pool_populate(struct ttm_tt *ttm) | 1061 | int ttm_pool_populate(struct ttm_tt *ttm) |
1062 | { | 1062 | { |
1063 | struct ttm_mem_global *mem_glob = ttm->glob->mem_glob; | 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 | unsigned i; | 1068 | unsigned i; |
1065 | int ret; | 1069 | int ret; |
1066 | 1070 | ||
@@ -1076,7 +1080,7 @@ int ttm_pool_populate(struct ttm_tt *ttm) | |||
1076 | 1080 | ||
1077 | for (i = 0; i < ttm->num_pages; ++i) { | 1081 | for (i = 0; i < ttm->num_pages; ++i) { |
1078 | ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], | 1082 | ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], |
1079 | PAGE_SIZE); | 1083 | PAGE_SIZE, &ctx); |
1080 | if (unlikely(ret != 0)) { | 1084 | if (unlikely(ret != 0)) { |
1081 | ttm_pool_unpopulate(ttm); | 1085 | ttm_pool_unpopulate(ttm); |
1082 | return -ENOMEM; | 1086 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index bda00b2ab51c..8aac86a16e22 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | |||
@@ -927,6 +927,10 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev) | |||
927 | { | 927 | { |
928 | struct ttm_tt *ttm = &ttm_dma->ttm; | 928 | struct ttm_tt *ttm = &ttm_dma->ttm; |
929 | struct ttm_mem_global *mem_glob = ttm->glob->mem_glob; | 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 | unsigned long num_pages = ttm->num_pages; | 934 | unsigned long num_pages = ttm->num_pages; |
931 | struct dma_pool *pool; | 935 | struct dma_pool *pool; |
932 | enum pool_type type; | 936 | enum pool_type type; |
@@ -962,7 +966,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev) | |||
962 | break; | 966 | break; |
963 | 967 | ||
964 | ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], | 968 | ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], |
965 | pool->size); | 969 | pool->size, &ctx); |
966 | if (unlikely(ret != 0)) { | 970 | if (unlikely(ret != 0)) { |
967 | ttm_dma_unpopulate(ttm_dma, dev); | 971 | ttm_dma_unpopulate(ttm_dma, dev); |
968 | return -ENOMEM; | 972 | return -ENOMEM; |
@@ -998,7 +1002,7 @@ skip_huge: | |||
998 | } | 1002 | } |
999 | 1003 | ||
1000 | ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], | 1004 | ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], |
1001 | pool->size); | 1005 | pool->size, &ctx); |
1002 | if (unlikely(ret != 0)) { | 1006 | if (unlikely(ret != 0)) { |
1003 | ttm_dma_unpopulate(ttm_dma, dev); | 1007 | ttm_dma_unpopulate(ttm_dma, dev); |
1004 | return -ENOMEM; | 1008 | return -ENOMEM; |
diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index 755c107817da..8936285b6543 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h | |||
@@ -84,7 +84,8 @@ extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, | |||
84 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, | 84 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, |
85 | uint64_t amount); | 85 | uint64_t amount); |
86 | extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, | 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 | extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, | 89 | extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, |
89 | struct page *page, uint64_t size); | 90 | struct page *page, uint64_t size); |
90 | extern size_t ttm_round_pot(size_t size); | 91 | extern size_t ttm_round_pot(size_t size); |