From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 4/8] drm/ttm: use the operation context inside TTM
Date: Fri, 17 Nov 2017 11:49:31 +0100 [thread overview]
Message-ID: <20171117104935.4150-5-christian.koenig@amd.com> (raw)
In-Reply-To: <20171117104935.4150-1-christian.koenig@amd.com>
Instead of passing down the parameters manually to every function.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 67 +++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 38 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 63c1a97b3589..4ed30ffa411f 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -269,9 +269,8 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
}
static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
- struct ttm_mem_reg *mem,
- bool evict, bool interruptible,
- bool no_wait_gpu)
+ struct ttm_mem_reg *mem, bool evict,
+ struct ttm_operation_ctx *ctx)
{
struct ttm_bo_device *bdev = bo->bdev;
bool old_is_pci = ttm_mem_reg_is_pci(bdev, &bo->mem);
@@ -325,12 +324,14 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED))
- ret = ttm_bo_move_ttm(bo, interruptible, no_wait_gpu, mem);
+ ret = ttm_bo_move_ttm(bo, ctx->interruptible,
+ ctx->no_wait_gpu, mem);
else if (bdev->driver->move)
- ret = bdev->driver->move(bo, evict, interruptible,
- no_wait_gpu, mem);
+ ret = bdev->driver->move(bo, evict, ctx->interruptible,
+ ctx->no_wait_gpu, mem);
else
- ret = ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu, mem);
+ ret = ttm_bo_move_memcpy(bo, ctx->interruptible,
+ ctx->no_wait_gpu, mem);
if (ret) {
if (bdev->driver->move_notify) {
@@ -653,10 +654,9 @@ void ttm_bo_unlock_delayed_workqueue(struct ttm_bo_device *bdev, int resched)
}
EXPORT_SYMBOL(ttm_bo_unlock_delayed_workqueue);
-static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
- bool no_wait_gpu)
+static int ttm_bo_evict(struct ttm_buffer_object *bo,
+ struct ttm_operation_ctx *ctx)
{
- struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
struct ttm_bo_device *bdev = bo->bdev;
struct ttm_mem_reg evict_mem;
struct ttm_placement placement;
@@ -672,7 +672,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
placement.num_placement = 0;
placement.num_busy_placement = 0;
bdev->driver->evict_flags(bo, &placement);
- ret = ttm_bo_mem_space(bo, &placement, &evict_mem, &ctx);
+ ret = ttm_bo_mem_space(bo, &placement, &evict_mem, ctx);
if (ret) {
if (ret != -ERESTARTSYS) {
pr_err("Failed to find memory space for buffer 0x%p eviction\n",
@@ -682,8 +682,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
goto out;
}
- ret = ttm_bo_handle_move_mem(bo, &evict_mem, true,
- interruptible, no_wait_gpu);
+ ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, ctx);
if (unlikely(ret)) {
if (ret != -ERESTARTSYS)
pr_err("Buffer eviction failed\n");
@@ -713,8 +712,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
struct reservation_object *resv,
uint32_t mem_type,
const struct ttm_place *place,
- bool interruptible,
- bool no_wait_gpu)
+ struct ttm_operation_ctx *ctx)
{
struct ttm_bo_global *glob = bdev->glob;
struct ttm_mem_type_manager *man = &bdev->man[mem_type];
@@ -759,8 +757,8 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
kref_get(&bo->list_kref);
if (!list_empty(&bo->ddestroy)) {
- ret = ttm_bo_cleanup_refs(bo, interruptible, no_wait_gpu,
- locked);
+ ret = ttm_bo_cleanup_refs(bo, ctx->interruptible,
+ ctx->no_wait_gpu, locked);
kref_put(&bo->list_kref, ttm_bo_release_list);
return ret;
}
@@ -768,7 +766,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock);
- ret = ttm_bo_evict(bo, interruptible, no_wait_gpu);
+ ret = ttm_bo_evict(bo, ctx);
if (locked) {
ttm_bo_unreserve(bo);
} else {
@@ -826,8 +824,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
uint32_t mem_type,
const struct ttm_place *place,
struct ttm_mem_reg *mem,
- bool interruptible,
- bool no_wait_gpu)
+ struct ttm_operation_ctx *ctx)
{
struct ttm_bo_device *bdev = bo->bdev;
struct ttm_mem_type_manager *man = &bdev->man[mem_type];
@@ -839,8 +836,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
return ret;
if (mem->mm_node)
break;
- ret = ttm_mem_evict_first(bdev, bo->resv, mem_type, place,
- interruptible, no_wait_gpu);
+ ret = ttm_mem_evict_first(bdev, bo->resv, mem_type, place, ctx);
if (unlikely(ret != 0))
return ret;
} while (1);
@@ -997,9 +993,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
return 0;
}
- ret = ttm_bo_mem_force_space(bo, mem_type, place, mem,
- ctx->interruptible,
- ctx->no_wait_gpu);
+ ret = ttm_bo_mem_force_space(bo, mem_type, place, mem, ctx);
if (ret == 0 && mem->mm_node) {
mem->placement = cur_flags;
return 0;
@@ -1018,11 +1012,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
EXPORT_SYMBOL(ttm_bo_mem_space);
static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
- struct ttm_placement *placement,
- bool interruptible,
- bool no_wait_gpu)
+ struct ttm_placement *placement,
+ struct ttm_operation_ctx *ctx)
{
- struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
int ret = 0;
struct ttm_mem_reg mem;
@@ -1036,11 +1028,10 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
/*
* Determine where to move the buffer.
*/
- ret = ttm_bo_mem_space(bo, placement, &mem, &ctx);
+ ret = ttm_bo_mem_space(bo, placement, &mem, ctx);
if (ret)
goto out_unlock;
- ret = ttm_bo_handle_move_mem(bo, &mem, false, interruptible,
- no_wait_gpu);
+ ret = ttm_bo_handle_move_mem(bo, &mem, false, ctx);
out_unlock:
if (ret && mem.mm_node)
ttm_bo_mem_put(bo, &mem);
@@ -1102,8 +1093,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
* Check whether we need to move buffer.
*/
if (!ttm_bo_mem_compat(placement, &bo->mem, &new_flags)) {
- ret = ttm_bo_move_buffer(bo, placement, ctx->interruptible,
- ctx->no_wait_gpu);
+ ret = ttm_bo_move_buffer(bo, placement, ctx);
if (ret)
return ret;
} else {
@@ -1328,6 +1318,7 @@ EXPORT_SYMBOL(ttm_bo_create);
static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
unsigned mem_type)
{
+ struct ttm_operation_ctx ctx = { false, false };
struct ttm_mem_type_manager *man = &bdev->man[mem_type];
struct ttm_bo_global *glob = bdev->glob;
struct dma_fence *fence;
@@ -1342,8 +1333,8 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
while (!list_empty(&man->lru[i])) {
spin_unlock(&glob->lru_lock);
- ret = ttm_mem_evict_first(bdev, NULL, mem_type, NULL,
- false, false);
+ ret = ttm_mem_evict_first(bdev, NULL, mem_type,
+ NULL, &ctx);
if (ret)
return ret;
spin_lock(&glob->lru_lock);
@@ -1740,6 +1731,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)
if (bo->mem.mem_type != TTM_PL_SYSTEM ||
bo->ttm->caching_state != tt_cached) {
+ struct ttm_operation_ctx ctx = { false, false };
struct ttm_mem_reg evict_mem;
evict_mem = bo->mem;
@@ -1747,8 +1739,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)
evict_mem.placement = TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED;
evict_mem.mem_type = TTM_PL_SYSTEM;
- ret = ttm_bo_handle_move_mem(bo, &evict_mem, true,
- false, false);
+ ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, &ctx);
if (unlikely(ret != 0))
goto out;
}
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-11-17 10:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 10:49 Operation context for TTM Christian König
2017-11-17 10:49 ` [PATCH 1/8] drm/ttm: add operation ctx to ttm_bo_validate v2 Christian König
[not found] ` <20171117104935.4150-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-11-20 10:14 ` Daniel Vetter
2017-11-17 10:49 ` [PATCH 2/8] drm/ttm: use an operation ctx for ttm_bo_init_reserved Christian König
[not found] ` <20171117104935.4150-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-11-17 10:49 ` [PATCH 3/8] drm/ttm: use an operation context for ttm_bo_mem_space v2 Christian König
2017-11-17 10:49 ` [PATCH 5/8] drm/ttm: add context to driver move callback as well Christian König
2017-11-17 10:49 ` [PATCH 6/8] drm/ttm: add number of bytes moved to the operation context Christian König
2017-11-17 10:49 ` [PATCH 8/8] drm/amdgpu: use the new TTM bytes moved counter v2 Christian König
[not found] ` <20171117104935.4150-9-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-11-20 2:38 ` Chunming Zhou
2017-11-17 14:55 ` Operation context for TTM Michel Dänzer
2017-11-17 20:26 ` Felix Kuehling
2017-11-20 4:35 ` Dieter Nützel
[not found] ` <cb11aafa8199f35d8ab93f7199c1f1c0-0hun7QTegEsDD4udEopG9Q@public.gmane.org>
2017-11-21 2:49 ` Dieter Nützel
2017-11-17 10:49 ` Christian König [this message]
2017-11-17 10:49 ` [PATCH 7/8] drm/amdgpu: forward operation context to ttm_bo_mem_space Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171117104935.4150-5-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox