[PATCH 10/10] drm/ttm: reverse move calling pattern.
Dave Airlie
airlied at gmail.com
Wed Sep 23 03:04:54 UTC 2020
From: Dave Airlie <airlied at redhat.com>
Call the driver move function if it exists, otherwise use the
fallback ttm/memcpy paths.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 993a87443c37..3d9c62cdf38d 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -229,6 +229,23 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
}
EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
+static int ttm_bo_move_fallback(struct ttm_buffer_object *bo,
+ struct ttm_operation_ctx *ctx,
+ struct ttm_resource *mem)
+{
+ struct ttm_resource_manager *old_man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
+ struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, mem->mem_type);
+
+ if (old_man->use_tt && new_man->use_tt) {
+ if (bo->mem.mem_type == TTM_PL_SYSTEM) {
+ ttm_bo_assign_mem(bo, mem);
+ return 0;
+ } else
+ return ttm_bo_move_ttm(bo, ctx, mem);
+ } else
+ return ttm_bo_move_memcpy(bo, ctx, mem);
+}
+
static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
struct ttm_resource *mem, bool evict,
struct ttm_operation_ctx *ctx)
@@ -270,17 +287,10 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
if (bdev->driver->move_notify)
bdev->driver->move_notify(bo, evict, mem);
- if (old_man->use_tt && new_man->use_tt) {
- if (bo->mem.mem_type == TTM_PL_SYSTEM) {
- ttm_bo_assign_mem(bo, mem);
- ret = 0;
- } else
- ret = ttm_bo_move_ttm(bo, ctx, mem);
- }
- else if (bdev->driver->move)
+ if (bdev->driver->move)
ret = bdev->driver->move(bo, evict, ctx, mem);
else
- ret = ttm_bo_move_memcpy(bo, ctx, mem);
+ ret = ttm_bo_move_fallback(bo, ctx, mem);
if (ret) {
if (bdev->driver->move_notify) {
--
2.27.0
More information about the dri-devel
mailing list