From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 2/2] drm/ttm: fix ttm_bo_cleanup_refs_or_queue once more
Date: Mon, 4 Sep 2017 21:02:46 +0200 [thread overview]
Message-ID: <1504551766-5093-2-git-send-email-deathsimple@vodafone.de> (raw)
In-Reply-To: <1504551766-5093-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
From: Christian König <christian.koenig@amd.com>
With shared reservation objects __ttm_bo_reserve() can easily fail even on
destroyed BOs. This prevents correct handling when we need to individualize
the reservation object.
Fix this by individualizing the object before even trying to reserve it.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 180ce62..bee77d3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -440,28 +440,29 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
struct ttm_bo_global *glob = bo->glob;
int ret;
+ ret = ttm_bo_individualize_resv(bo);
+ if (ret) {
+ /* Last resort, if we fail to allocate memory for the
+ * fences block for the BO to become idle
+ */
+ reservation_object_wait_timeout_rcu(bo->resv, true, false,
+ 30 * HZ);
+ spin_lock(&glob->lru_lock);
+ goto error;
+ }
+
spin_lock(&glob->lru_lock);
ret = __ttm_bo_reserve(bo, false, true, NULL);
-
if (!ret) {
- if (!ttm_bo_wait(bo, false, true)) {
+ if (reservation_object_test_signaled_rcu(&bo->ttm_resv, true)) {
ttm_bo_del_from_lru(bo);
spin_unlock(&glob->lru_lock);
+ if (bo->resv != &bo->ttm_resv)
+ reservation_object_unlock(&bo->ttm_resv);
ttm_bo_cleanup_memtype_use(bo);
-
return;
}
- ret = ttm_bo_individualize_resv(bo);
- if (ret) {
- /* Last resort, if we fail to allocate memory for the
- * fences block for the BO to become idle and free it.
- */
- spin_unlock(&glob->lru_lock);
- ttm_bo_wait(bo, true, true);
- ttm_bo_cleanup_memtype_use(bo);
- return;
- }
ttm_bo_flush_all_fences(bo);
/*
@@ -474,11 +475,12 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo)
ttm_bo_add_to_lru(bo);
}
- if (bo->resv != &bo->ttm_resv)
- reservation_object_unlock(&bo->ttm_resv);
__ttm_bo_unreserve(bo);
}
+ if (bo->resv != &bo->ttm_resv)
+ reservation_object_unlock(&bo->ttm_resv);
+error:
kref_get(&bo->list_kref);
list_add_tail(&bo->ddestroy, &bdev->ddestroy);
spin_unlock(&glob->lru_lock);
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-09-04 19:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 19:02 [PATCH 1/2] dma-buf: make reservation_object_copy_fences rcu save Christian König
[not found] ` <1504551766-5093-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-09-04 19:02 ` Christian König [this message]
[not found] ` <1504551766-5093-2-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-09-07 7:33 ` [PATCH 2/2] drm/ttm: fix ttm_bo_cleanup_refs_or_queue once more zhoucm1
2017-09-07 7:13 ` [PATCH 1/2] dma-buf: make reservation_object_copy_fences rcu save Christian König
[not found] ` <6a9be9a4-34b2-c8de-0da8-d8f4024bac74-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-09-07 7:24 ` zhoucm1
2017-09-08 6:17 ` Daniel Vetter
2017-09-10 7:30 ` Maarten Lankhorst
[not found] ` <6b53a3c4-87ee-437d-63b3-4d2369ba2208-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-09-11 12:53 ` Christian König
2017-09-11 13:56 ` Maarten Lankhorst
[not found] ` <dbcc9a56-f6bf-c552-bdd1-363042536fb2-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-09-11 14:45 ` Christian König
[not found] ` <88b860d7-3377-0378-93fd-a64c274538f3-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-09-11 15:13 ` Maarten Lankhorst
2017-09-11 15:22 ` Christian König
[not found] ` <1e15bc3d-e2c8-4c95-fe0c-e91d08f19fb8-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-09-11 15:24 ` Christian König
[not found] ` <5c473978-55b5-e284-7012-33d0d098d964-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-09-11 15:29 ` Maarten Lankhorst
[not found] ` <3944c1e3-aaa9-27cb-7017-f9345d9c8a6f-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-09-11 15:45 ` 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=1504551766-5093-2-git-send-email-deathsimple@vodafone.de \
--to=deathsimple-antagkrnahcb1svskn2v4q@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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