From: xinhui pan <xinhui.pan@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <alexander.deucher@amd.com>, <christian.koenig@amd.com>,
<chenli@uniontech.com>, <dri-devel@lists.freedesktop.org>,
xinhui pan <xinhui.pan@amd.com>
Subject: [PATCH v2 1/2] drm/ttm: Fix a deadlock if the target BO is not idle during swap
Date: Mon, 6 Sep 2021 09:12:09 +0800 [thread overview]
Message-ID: <20210906011210.80327-2-xinhui.pan@amd.com> (raw)
In-Reply-To: <20210906011210.80327-1-xinhui.pan@amd.com>
The ret value might be -EBUSY, caller will think lru lock is still
locked but actually NOT. So return -ENOSPC instead. Otherwise we hit
list corruption.
ttm_bo_cleanup_refs might fail too if BO is not idle. If we return 0,
caller(ttm_tt_populate -> ttm_global_swapout ->ttm_device_swapout) will
be stuck as we actually did not free any BO memory. This usually happens
when the fence is not signaled for a long time.
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 1fedd0eb67ba..f1367107925b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1159,9 +1159,9 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
}
if (bo->deleted) {
- ttm_bo_cleanup_refs(bo, false, false, locked);
+ ret = ttm_bo_cleanup_refs(bo, false, false, locked);
ttm_bo_put(bo);
- return 0;
+ return ret == -EBUSY ? -ENOSPC : ret;
}
ttm_bo_move_to_pinned(bo);
@@ -1215,7 +1215,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
if (locked)
dma_resv_unlock(bo->base.resv);
ttm_bo_put(bo);
- return ret;
+ return ret == -EBUSY ? -ENOSPC : ret;
}
void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)
--
2.25.1
next prev parent reply other threads:[~2021-09-06 1:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-06 1:12 [PATCH v2 0/2] Fix a hung during memory pressure test xinhui pan
2021-09-06 1:12 ` xinhui pan [this message]
2021-09-06 11:26 ` [PATCH v2 1/2] drm/ttm: Fix a deadlock if the target BO is not idle during swap Christian König
2021-09-07 1:52 ` Pan, Xinhui
2021-09-06 1:12 ` [PATCH v2 2/2] drm/amdpgu: Use VRAM domain in UVD IB test xinhui pan
2021-09-06 9:01 ` Christian König
2021-09-06 9:04 ` [PATCH v2 0/2] Fix a hung during memory pressure test Christian König
2021-09-06 10:16 ` Pan, Xinhui
2021-09-06 11:04 ` Christian König
-- strict thread matches above, loose matches on Subject: below --
2021-09-06 1:08 [PATCH v2 1/2] drm/ttm: Fix a deadlock if the target BO is not idle during swap Pan, Xinhui
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=20210906011210.80327-2-xinhui.pan@amd.com \
--to=xinhui.pan@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=chenli@uniontech.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