From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: Thomas Hellstrom <thellstrom@vmware.com>
Cc: dri-devel@lists.freedesktop.org
Subject: [PATCH] drm/ttm: do not check if list is empty in ttm_bo_force_list_clean, v2
Date: Fri, 30 Nov 2012 09:05:21 +0100 [thread overview]
Message-ID: <50B868C1.8000703@canonical.com> (raw)
Just use the return error from ttm_mem_evict_first instead.
Changes since v1:
- Add warning if list is not empty, nothing else we can do here.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8ab23ae..9028327 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1323,25 +1323,25 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
struct ttm_bo_global *glob = bdev->glob;
int ret;
- /*
- * Can't use standard list traversal since we're unlocking.
- */
-
- spin_lock(&glob->lru_lock);
- while (!list_empty(&man->lru)) {
- spin_unlock(&glob->lru_lock);
+ do {
ret = ttm_mem_evict_first(bdev, mem_type, false, false);
- if (ret) {
- if (allow_errors) {
- return ret;
- } else {
- pr_err("Cleanup eviction failed\n");
- }
+ if (ret && ret != -EBUSY && !allow_errors) {
+ pr_err("Cleanup eviction failed with %i\n", ret);
+ ret = 0;
}
+ } while (!ret);
+
+ if (likely(ret == -EBUSY)) {
+ /*
+ * lru list should be empty, verify this is the case.
+ */
spin_lock(&glob->lru_lock);
+ WARN_ON(!list_empty(&man->lru));
+ if (list_empty(&man->lru) || !allow_errors)
+ ret = 0;
+ spin_unlock(&glob->lru_lock);
}
- spin_unlock(&glob->lru_lock);
- return 0;
+ return ret;
}
int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
next reply other threads:[~2012-11-30 8:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-30 8:05 Maarten Lankhorst [this message]
2012-11-30 9:04 ` [PATCH] drm/ttm: do not check if list is empty in ttm_bo_force_list_clean, v2 Thomas Hellstrom
2012-11-30 10:16 ` Maarten Lankhorst
2012-11-30 11:55 ` Thomas Hellstrom
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=50B868C1.8000703@canonical.com \
--to=maarten.lankhorst@canonical.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=thellstrom@vmware.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.