dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Roger He <Hongbo.He@amd.com>
To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Roger He <Hongbo.He@amd.com>
Subject: [PATCH 6/7] drm/ttm: add ttm_bo_evict_swapout_allowable to check bo is allowable to evict or swapout
Date: Wed, 20 Dec 2017 18:35:00 +0800	[thread overview]
Message-ID: <1513766101-15993-6-git-send-email-Hongbo.He@amd.com> (raw)
In-Reply-To: <1513766101-15993-1-git-send-email-Hongbo.He@amd.com>

extract this function since eviction and swapout share same logic

Change-Id: I80a475a93fceed8d66d74a1832c815a0756341ac
Signed-off-by: Roger He <Hongbo.He@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index e7595b4..313925c 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -706,6 +706,23 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
 }
 EXPORT_SYMBOL(ttm_bo_eviction_valuable);
 
+static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
+			struct ttm_operation_ctx *ctx, bool *locked)
+{
+	bool ret = false;
+
+	*locked = false;
+	if (bo->resv == ctx->resv) {
+		if (ctx->allow_reserved_eviction || !list_empty(&bo->ddestroy))
+			ret = true;
+	} else {
+		*locked = reservation_object_trylock(bo->resv);
+		ret = *locked;
+	}
+
+	return ret;
+}
+
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
 			       uint32_t mem_type,
 			       const struct ttm_place *place,
@@ -721,21 +738,13 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
 	spin_lock(&glob->lru_lock);
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
 		list_for_each_entry(bo, &man->lru[i], lru) {
-			if (bo->resv == ctx->resv) {
-				if (!ctx->allow_reserved_eviction &&
-				    list_empty(&bo->ddestroy))
-					continue;
-			} else {
-				locked = reservation_object_trylock(bo->resv);
-				if (!locked)
-					continue;
-			}
+			if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked))
+				continue;
 
 			if (place && !bdev->driver->eviction_valuable(bo,
 								      place)) {
 				if (locked)
 					reservation_object_unlock(bo->resv);
-				locked = false;
 				continue;
 			}
 			break;
-- 
2.7.4

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

  parent reply	other threads:[~2017-12-20 10:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 10:34 [PATCH 1/7] drm/ttm: call ttm_bo_swapout directly when ttm shrink Roger He
2017-12-20 10:34 ` [PATCH 3/7] drm/ttm: use an operation ctx for ttm_mem_global_alloc_page Roger He
     [not found]   ` <1513766101-15993-3-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-20 13:35     ` Christian König
     [not found]       ` <edd81ee9-bb23-84c4-4065-2b424c95724e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-21  6:05         ` He, Roger
     [not found]           ` <BN6PR1201MB0114CD1510459BE13D0BF292FD0D0-6iU6OBHu2P8MH+E/uqw63WrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-12-21  8:15             ` Thomas Hellstrom
2017-12-20 10:35 ` Roger He [this message]
2017-12-21  7:50   ` [PATCH 6/7] drm/ttm: add ttm_bo_evict_swapout_allowable to check bo is allowable to evict or swapout Thomas Hellstrom
2017-12-25  3:10     ` He, Roger
     [not found] ` <1513766101-15993-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-20 10:34   ` [PATCH 2/7] drm/ttm: use an operation ctx for ttm_mem_global_alloc Roger He
     [not found]     ` <1513766101-15993-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-20 13:33       ` Christian König
     [not found]         ` <15e3b956-8777-8fb1-2709-5409a756f0be-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-24 23:24           ` Sinclair Yeh
     [not found]             ` <20180124232346.GA59165-WSU1YMatGzO44ywRPIzf9A@public.gmane.org>
2018-01-25  8:31               ` Christian König
2017-12-21  8:07     ` Thomas Hellstrom
2017-12-20 10:34   ` [PATCH 4/7] drm/ttm: use an operation ctx for ttm_tt_populate in ttm_bo_driver Roger He
2017-12-20 14:20     ` Christian König
2017-12-20 10:34   ` [PATCH 5/7] drm/ttm: use an operation ctx for ttm_tt_bind Roger He
2017-12-20 10:35   ` [PATCH 7/7] drm/ttm: enable swapout of per VM BOs during allocation and allows reaping of deleted BOs Roger He
     [not found]     ` <1513766101-15993-7-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-21  7:58       ` Thomas Hellstrom
2017-12-21  8:18         ` Christian König
2017-12-20 13:29   ` [PATCH 1/7] drm/ttm: call ttm_bo_swapout directly when ttm shrink Christian König
2017-12-21  7:34   ` Thomas Hellstrom
     [not found]     ` <b0f51ff0-950e-bbe0-0032-e0e714d94350-4+hqylr40dJg9hUCZPvPmw@public.gmane.org>
2017-12-21  9:17       ` He, Roger

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=1513766101-15993-6-git-send-email-Hongbo.He@amd.com \
    --to=hongbo.he@amd.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