From 012588f2adc3bcf8a12fb7d158a0721260d04f37 Mon Sep 17 00:00:00 2001 From: Roger He Date: Fri, 8 Dec 2017 15:21:18 +0800 Subject: [PATCH 3732/4131] drm/ttm: use an operation ctx for ttm_mem_global_alloc_page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Roger He Signed-off-by: Alex Deucher --- drivers/gpu/drm/ttm/ttm_memory.c | 10 +++------- drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 +++++- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 9 +++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index ed43a6b..c1cbefe 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -545,15 +545,11 @@ int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, EXPORT_SYMBOL(ttm_mem_global_alloc); int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, - struct page *page, - bool no_wait, bool interruptible) + struct page *page, uint64_t size, + struct ttm_operation_ctx *ctx) { struct ttm_mem_zone *zone = NULL; - struct ttm_operation_ctx ctx = { - .interruptible = false, - .no_wait_gpu = false - }; /** * Page allocations may be registed in a single zone @@ -567,7 +563,7 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) zone = glob->zone_kernel; #endif - return ttm_mem_global_alloc_zone(glob, zone, size, &ctx); + return ttm_mem_global_alloc_zone(glob, zone, size, ctx); } 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 cd2d4de..ae8ec03 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -869,6 +869,10 @@ void ttm_page_alloc_fini(void) int ttm_pool_populate(struct ttm_tt *ttm) { struct ttm_mem_global *mem_glob = ttm->glob->mem_glob; + struct ttm_operation_ctx ctx = { + .interruptible = false, + .no_wait_gpu = false + }; unsigned i; int ret; @@ -885,7 +889,7 @@ int ttm_pool_populate(struct ttm_tt *ttm) } ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], - false, false); + PAGE_SIZE, &ctx); if (unlikely(ret != 0)) { ttm_pool_unpopulate(ttm); 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 90ddbdc..f9e8307 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -878,7 +878,12 @@ static int ttm_dma_pool_get_pages(struct dma_pool *pool, int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev) { struct ttm_tt *ttm = &ttm_dma->ttm; - struct ttm_mem_global *mem_glob = ttm->glob->mem_glob; + struct ttm_mem_global *mem_glob = ttm->glob->mem_glob; + struct ttm_operation_ctx ctx = { + .interruptible = false, + .no_wait_gpu = false + }; + unsigned long num_pages = ttm->num_pages; struct dma_pool *pool; enum pool_type type; unsigned i; @@ -913,7 +918,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev) } ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], - false, false); + pool->size, &ctx); if (unlikely(ret != 0)) { ttm_dma_unpopulate(ttm_dma, dev); return -ENOMEM; -- 2.7.4