diff options
author | Roger He <Hongbo.He@amd.com> | 2017-12-08 10:09:50 +0300 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-27 19:38:54 +0300 |
commit | 279c01f6ef626d59b93383d183fb69173d3f7ac7 (patch) | |
tree | 5874a26a7c74a50a483fbf18df1d9a2aadbc3026 /drivers/gpu/drm/ttm | |
parent | a6c26af8a4348a0ba2eb146b08f4d4d908cd9222 (diff) | |
download | linux-279c01f6ef626d59b93383d183fb69173d3f7ac7.tar.xz |
drm/ttm: use an operation ctx for ttm_mem_global_alloc
forward the operation context to ttm_mem_global_alloc as well, and the
ultimate goal is swapout enablement for reserved BOs
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
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>
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_memory.c | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_object.c | 13 |
3 files changed, 20 insertions, 10 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index f2cfa93cbba5..4424bf2db8ad 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1135,7 +1135,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, struct ttm_mem_global *mem_glob = bdev->glob->mem_glob; bool locked; - ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false); + ret = ttm_mem_global_alloc(mem_glob, acc_size, ctx); if (ret) { pr_err("Out of kernel memory\n"); if (destroy) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index 9130bdfb26ad..525d3b601790 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -508,7 +508,7 @@ out_unlock: static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, struct ttm_mem_zone *single_zone, uint64_t memory, - bool no_wait, bool interruptible) + struct ttm_operation_ctx *ctx) { int count = TTM_MEMORY_ALLOC_RETRIES; @@ -516,7 +516,7 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, single_zone, memory, true) != 0)) { - if (no_wait) + if (ctx->no_wait_gpu) return -ENOMEM; if (unlikely(count-- == 0)) return -ENOMEM; @@ -527,15 +527,14 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, } int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, - bool no_wait, bool interruptible) + struct ttm_operation_ctx *ctx) { /** * Normal allocations of kernel memory are registered in * all zones. */ - return ttm_mem_global_alloc_zone(glob, NULL, memory, no_wait, - interruptible); + return ttm_mem_global_alloc_zone(glob, NULL, memory, ctx); } EXPORT_SYMBOL(ttm_mem_global_alloc); @@ -544,6 +543,10 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, { 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 @@ -557,7 +560,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, false, false); + 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_object.c b/drivers/gpu/drm/ttm/ttm_object.c index 26a7ad0f4789..1aa2baa83959 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/ttm/ttm_object.c @@ -325,6 +325,10 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, struct ttm_ref_object *ref; struct drm_hash_item *hash; struct ttm_mem_global *mem_glob = tfile->tdev->mem_glob; + struct ttm_operation_ctx ctx = { + .interruptible = false, + .no_wait_gpu = false + }; int ret = -EINVAL; if (base->tfile != tfile && !base->shareable) @@ -350,7 +354,7 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, return -EPERM; ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref), - false, false); + &ctx); if (unlikely(ret != 0)) return ret; ref = kmalloc(sizeof(*ref), GFP_KERNEL); @@ -686,7 +690,10 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, dma_buf = prime->dma_buf; if (!dma_buf || !get_dma_buf_unless_doomed(dma_buf)) { DEFINE_DMA_BUF_EXPORT_INFO(exp_info); - + struct ttm_operation_ctx ctx = { + .interruptible = true, + .no_wait_gpu = false + }; exp_info.ops = &tdev->ops; exp_info.size = prime->size; exp_info.flags = flags; @@ -696,7 +703,7 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, * Need to create a new dma_buf, with memory accounting. */ ret = ttm_mem_global_alloc(tdev->mem_glob, tdev->dma_buf_size, - false, true); + &ctx); if (unlikely(ret != 0)) { mutex_unlock(&prime->mutex); goto out_unref; |