From: Roger He <Hongbo.He@amd.com>
To: dri-devel@lists.freedesktop.org
Cc: Roger He <Hongbo.He@amd.com>
Subject: [PATCH 4/5] drm/ttm: add new function to check if bo is allowable to evict or swapout
Date: Thu, 21 Dec 2017 17:42:52 +0800 [thread overview]
Message-ID: <1513849373-7970-4-git-send-email-Hongbo.He@amd.com> (raw)
In-Reply-To: <1513849373-7970-1-git-send-email-Hongbo.He@amd.com>
extract a function as ttm_bo_evict_swapout_allowable since eviction and
swapout can 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
next prev parent reply other threads:[~2017-12-21 9:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 9:42 [PATCH 1/5] drm/ttm: use an operation ctx for ttm_mem_global_alloc_page Roger He
2017-12-21 9:42 ` [PATCH 2/5] drm/ttm: use an operation ctx for ttm_tt_populate in ttm_bo_driver Roger He
2017-12-21 9:42 ` [PATCH 3/5] drm/ttm: use an operation ctx for ttm_tt_bind Roger He
2017-12-21 9:42 ` Roger He [this message]
2017-12-21 9:42 ` [PATCH 5/5] drm/ttm: enable swapout of per VM BOs during allocation Roger He
2017-12-21 10:02 ` [PATCH 1/5] drm/ttm: use an operation ctx for ttm_mem_global_alloc_page 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=1513849373-7970-4-git-send-email-Hongbo.He@amd.com \
--to=hongbo.he@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