dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: christian.koenig@amd.com, bskeggs@redhat.com
Subject: [PATCH 10/10] drm/ttm: reverse move calling pattern.
Date: Wed, 23 Sep 2020 13:04:54 +1000	[thread overview]
Message-ID: <20200923030454.362731-11-airlied@gmail.com> (raw)
In-Reply-To: <20200923030454.362731-1-airlied@gmail.com>

From: Dave Airlie <airlied@redhat.com>

Call the driver move function if it exists, otherwise use the
fallback ttm/memcpy paths.

Signed-off-by: Dave Airlie <airlied@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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-09-23  3:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23  3:04 [PATCH 00/10] ttm driver cleanups and invert move Dave Airlie
2020-09-23  3:04 ` [PATCH 01/10] drm/radeon: kill radeon_bo_wait Dave Airlie
2020-09-23 14:34   ` Christian König
2020-09-23  3:04 ` [PATCH 02/10] drm/qxl: kill unused bo wait wrapper Dave Airlie
2020-09-23 14:35   ` Christian König
2020-09-23  3:04 ` [PATCH 03/10] drm/radeon: cleanup ttm operation ctx usage Dave Airlie
2020-09-23 14:38   ` Christian König
2020-09-23  3:04 ` [PATCH 04/10] drm/nouveau/ttm: plumb ctx through move functions Dave Airlie
2020-09-23 14:39   ` Christian König
2020-09-23  3:04 ` [PATCH 05/10] drm/ttm: add bo wait that takes a ctx wrapper Dave Airlie
2020-09-23 14:40   ` Christian König
2020-09-23  3:04 ` [PATCH 06/10] drm/ttm: handle the SYSTEM->TT path in same place as others Dave Airlie
2020-09-23  3:04 ` [PATCH 07/10] drm/amdgpu/ttm: handle tt moves properly Dave Airlie
2020-09-23 14:45   ` Christian König
2020-09-24  0:46     ` Dave Airlie
2020-09-24  2:35       ` Dave Airlie
2020-09-24  9:48       ` Christian König
2020-09-23  3:04 ` [PATCH 08/10] drm/radeon/ttm: handle ttm " Dave Airlie
2020-09-23  3:04 ` [PATCH 09/10] drm/nouveau/ttm: " Dave Airlie
2020-09-23  3:04 ` Dave Airlie [this message]
2020-09-23 14:45   ` [PATCH 10/10] drm/ttm: reverse move calling pattern Christian König
2020-09-23 20:43     ` Dave Airlie

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=20200923030454.362731-11-airlied@gmail.com \
    --to=airlied@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --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