Commit 2823f4f0 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/ttm: add context to driver move callback as well

Instead of passing the parameters manually.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Tested-by: default avatarDieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Acked-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 83876c1b
...@@ -553,10 +553,9 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, ...@@ -553,10 +553,9 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
return r; return r;
} }
static int amdgpu_bo_move(struct ttm_buffer_object *bo, static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
bool evict, bool interruptible, struct ttm_operation_ctx *ctx,
bool no_wait_gpu, struct ttm_mem_reg *new_mem)
struct ttm_mem_reg *new_mem)
{ {
struct amdgpu_device *adev; struct amdgpu_device *adev;
struct amdgpu_bo *abo; struct amdgpu_bo *abo;
...@@ -591,19 +590,21 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, ...@@ -591,19 +590,21 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo,
if (old_mem->mem_type == TTM_PL_VRAM && if (old_mem->mem_type == TTM_PL_VRAM &&
new_mem->mem_type == TTM_PL_SYSTEM) { new_mem->mem_type == TTM_PL_SYSTEM) {
r = amdgpu_move_vram_ram(bo, evict, interruptible, r = amdgpu_move_vram_ram(bo, evict, ctx->interruptible,
no_wait_gpu, new_mem); ctx->no_wait_gpu, new_mem);
} else if (old_mem->mem_type == TTM_PL_SYSTEM && } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
new_mem->mem_type == TTM_PL_VRAM) { new_mem->mem_type == TTM_PL_VRAM) {
r = amdgpu_move_ram_vram(bo, evict, interruptible, r = amdgpu_move_ram_vram(bo, evict, ctx->interruptible,
no_wait_gpu, new_mem); ctx->no_wait_gpu, new_mem);
} else { } else {
r = amdgpu_move_blit(bo, evict, no_wait_gpu, new_mem, old_mem); r = amdgpu_move_blit(bo, evict, ctx->no_wait_gpu,
new_mem, old_mem);
} }
if (r) { if (r) {
memcpy: memcpy:
r = ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu, new_mem); r = ttm_bo_move_memcpy(bo, ctx->interruptible,
ctx->no_wait_gpu, new_mem);
if (r) { if (r) {
return r; return r;
} }
......
...@@ -1328,8 +1328,9 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo, ...@@ -1328,8 +1328,9 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,
} }
static int static int
nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr, nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
bool no_wait_gpu, struct ttm_mem_reg *new_reg) struct ttm_operation_ctx *ctx,
struct ttm_mem_reg *new_reg)
{ {
struct nouveau_drm *drm = nouveau_bdev(bo->bdev); struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
struct nouveau_bo *nvbo = nouveau_bo(bo); struct nouveau_bo *nvbo = nouveau_bo(bo);
...@@ -1337,7 +1338,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr, ...@@ -1337,7 +1338,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
struct nouveau_drm_tile *new_tile = NULL; struct nouveau_drm_tile *new_tile = NULL;
int ret = 0; int ret = 0;
ret = ttm_bo_wait(bo, intr, no_wait_gpu); ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
if (ret) if (ret)
return ret; return ret;
...@@ -1361,22 +1362,26 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr, ...@@ -1361,22 +1362,26 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
/* Hardware assisted copy. */ /* Hardware assisted copy. */
if (drm->ttm.move) { if (drm->ttm.move) {
if (new_reg->mem_type == TTM_PL_SYSTEM) if (new_reg->mem_type == TTM_PL_SYSTEM)
ret = nouveau_bo_move_flipd(bo, evict, intr, ret = nouveau_bo_move_flipd(bo, evict,
no_wait_gpu, new_reg); ctx->interruptible,
ctx->no_wait_gpu, new_reg);
else if (old_reg->mem_type == TTM_PL_SYSTEM) else if (old_reg->mem_type == TTM_PL_SYSTEM)
ret = nouveau_bo_move_flips(bo, evict, intr, ret = nouveau_bo_move_flips(bo, evict,
no_wait_gpu, new_reg); ctx->interruptible,
ctx->no_wait_gpu, new_reg);
else else
ret = nouveau_bo_move_m2mf(bo, evict, intr, ret = nouveau_bo_move_m2mf(bo, evict,
no_wait_gpu, new_reg); ctx->interruptible,
ctx->no_wait_gpu, new_reg);
if (!ret) if (!ret)
goto out; goto out;
} }
/* Fallback to software copy. */ /* Fallback to software copy. */
ret = ttm_bo_wait(bo, intr, no_wait_gpu); ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
if (ret == 0) if (ret == 0)
ret = ttm_bo_move_memcpy(bo, intr, no_wait_gpu, new_reg); ret = ttm_bo_move_memcpy(bo, ctx->interruptible,
ctx->no_wait_gpu, new_reg);
out: out:
if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
......
...@@ -341,15 +341,14 @@ static void qxl_move_null(struct ttm_buffer_object *bo, ...@@ -341,15 +341,14 @@ static void qxl_move_null(struct ttm_buffer_object *bo,
new_mem->mm_node = NULL; new_mem->mm_node = NULL;
} }
static int qxl_bo_move(struct ttm_buffer_object *bo, static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
bool evict, bool interruptible, struct ttm_operation_ctx *ctx,
bool no_wait_gpu,
struct ttm_mem_reg *new_mem) struct ttm_mem_reg *new_mem)
{ {
struct ttm_mem_reg *old_mem = &bo->mem; struct ttm_mem_reg *old_mem = &bo->mem;
int ret; int ret;
ret = ttm_bo_wait(bo, interruptible, no_wait_gpu); ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
if (ret) if (ret)
return ret; return ret;
...@@ -358,7 +357,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, ...@@ -358,7 +357,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo,
qxl_move_null(bo, new_mem); qxl_move_null(bo, new_mem);
return 0; return 0;
} }
return ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu, return ttm_bo_move_memcpy(bo, ctx->interruptible, ctx->no_wait_gpu,
new_mem); new_mem);
} }
......
...@@ -393,17 +393,16 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, ...@@ -393,17 +393,16 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
return r; return r;
} }
static int radeon_bo_move(struct ttm_buffer_object *bo, static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
bool evict, bool interruptible, struct ttm_operation_ctx *ctx,
bool no_wait_gpu, struct ttm_mem_reg *new_mem)
struct ttm_mem_reg *new_mem)
{ {
struct radeon_device *rdev; struct radeon_device *rdev;
struct radeon_bo *rbo; struct radeon_bo *rbo;
struct ttm_mem_reg *old_mem = &bo->mem; struct ttm_mem_reg *old_mem = &bo->mem;
int r; int r;
r = ttm_bo_wait(bo, interruptible, no_wait_gpu); r = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
if (r) if (r)
return r; return r;
...@@ -433,19 +432,21 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, ...@@ -433,19 +432,21 @@ static int radeon_bo_move(struct ttm_buffer_object *bo,
if (old_mem->mem_type == TTM_PL_VRAM && if (old_mem->mem_type == TTM_PL_VRAM &&
new_mem->mem_type == TTM_PL_SYSTEM) { new_mem->mem_type == TTM_PL_SYSTEM) {
r = radeon_move_vram_ram(bo, evict, interruptible, r = radeon_move_vram_ram(bo, evict, ctx->interruptible,
no_wait_gpu, new_mem); ctx->no_wait_gpu, new_mem);
} else if (old_mem->mem_type == TTM_PL_SYSTEM && } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
new_mem->mem_type == TTM_PL_VRAM) { new_mem->mem_type == TTM_PL_VRAM) {
r = radeon_move_ram_vram(bo, evict, interruptible, r = radeon_move_ram_vram(bo, evict, ctx->interruptible,
no_wait_gpu, new_mem); ctx->no_wait_gpu, new_mem);
} else { } else {
r = radeon_move_blit(bo, evict, no_wait_gpu, new_mem, old_mem); r = radeon_move_blit(bo, evict, ctx->no_wait_gpu,
new_mem, old_mem);
} }
if (r) { if (r) {
memcpy: memcpy:
r = ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu, new_mem); r = ttm_bo_move_memcpy(bo, ctx->interruptible,
ctx->no_wait_gpu, new_mem);
if (r) { if (r) {
return r; return r;
} }
......
...@@ -327,8 +327,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, ...@@ -327,8 +327,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
ret = ttm_bo_move_ttm(bo, ctx->interruptible, ret = ttm_bo_move_ttm(bo, ctx->interruptible,
ctx->no_wait_gpu, mem); ctx->no_wait_gpu, mem);
else if (bdev->driver->move) else if (bdev->driver->move)
ret = bdev->driver->move(bo, evict, ctx->interruptible, ret = bdev->driver->move(bo, evict, ctx, mem);
ctx->no_wait_gpu, mem);
else else
ret = ttm_bo_move_memcpy(bo, ctx->interruptible, ret = ttm_bo_move_memcpy(bo, ctx->interruptible,
ctx->no_wait_gpu, mem); ctx->no_wait_gpu, mem);
......
...@@ -369,14 +369,13 @@ static void virtio_gpu_move_null(struct ttm_buffer_object *bo, ...@@ -369,14 +369,13 @@ static void virtio_gpu_move_null(struct ttm_buffer_object *bo,
new_mem->mm_node = NULL; new_mem->mm_node = NULL;
} }
static int virtio_gpu_bo_move(struct ttm_buffer_object *bo, static int virtio_gpu_bo_move(struct ttm_buffer_object *bo, bool evict,
bool evict, bool interruptible, struct ttm_operation_ctx *ctx,
bool no_wait_gpu,
struct ttm_mem_reg *new_mem) struct ttm_mem_reg *new_mem)
{ {
int ret; int ret;
ret = ttm_bo_wait(bo, interruptible, no_wait_gpu); ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
if (ret) if (ret)
return ret; return ret;
......
...@@ -409,15 +409,13 @@ struct ttm_bo_driver { ...@@ -409,15 +409,13 @@ struct ttm_bo_driver {
* @bo: the buffer to move * @bo: the buffer to move
* @evict: whether this motion is evicting the buffer from * @evict: whether this motion is evicting the buffer from
* the graphics address space * the graphics address space
* @interruptible: Use interruptible sleeps if possible when sleeping. * @ctx: context for this move with parameters
* @no_wait: whether this should give up and return -EBUSY
* if this move would require sleeping
* @new_mem: the new memory region receiving the buffer * @new_mem: the new memory region receiving the buffer
* *
* Move a buffer between two memory regions. * Move a buffer between two memory regions.
*/ */
int (*move)(struct ttm_buffer_object *bo, bool evict, int (*move)(struct ttm_buffer_object *bo, bool evict,
bool interruptible, bool no_wait_gpu, struct ttm_operation_ctx *ctx,
struct ttm_mem_reg *new_mem); struct ttm_mem_reg *new_mem);
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment