All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/amdgpu: fix a potential deadlock in amdgpu_bo_create_restricted()
@ 2017-02-09 10:33 Samuel Pitoiset
       [not found] ` <20170209103337.1522-1-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Samuel Pitoiset @ 2017-02-09 10:33 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Samuel Pitoiset

When ttm_bo_init() fails, the reservation mutex should be unlocked.

In debug build, the kernel reported "possible recursive locking
detected" in this codepath. For debugging purposes, I also added
a "WARN_ON(ww_mutex_is_locked())" when ttm_bo_init() fails and the
mutex was locked as expected.

This should fix (random) GPU hangs. The easy way to reproduce the
issue is to change the "Super Sampling" option from 1.0 to 2.0 in
Hitman. It will create a huge buffer, evict a bunch of buffers
(around ~5k) and deadlock.

This regression has been introduced pretty recently.

v2: only release the mutex if resv is NULL

Fixes: 12a852219583 ("drm/amdgpu: improve AMDGPU_GEM_CREATE_VRAM_CLEARED handling (v2)")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index d1ef1d064de4..556236a112c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -403,8 +403,11 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
 			&bo->placement, page_align, !kernel, NULL,
 			acc_size, sg, resv ? resv : &bo->tbo.ttm_resv,
 			&amdgpu_ttm_bo_destroy);
-	if (unlikely(r != 0))
+	if (unlikely(r != 0)) {
+		if (!resv)
+			ww_mutex_unlock(&bo->tbo.resv->lock);
 		return r;
+	}
 
 	bo->tbo.priority = ilog2(bo->tbo.num_pages);
 	if (kernel)
-- 
2.11.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-02-14 17:31 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09 10:33 [PATCH v2 1/2] drm/amdgpu: fix a potential deadlock in amdgpu_bo_create_restricted() Samuel Pitoiset
     [not found] ` <20170209103337.1522-1-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-09 10:33   ` [PATCH v2 2/2] drm/amdgpu: report the number of bytes moved at buffer creation Samuel Pitoiset
     [not found]     ` <20170209103337.1522-2-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 16:28       ` Nicolai Hähnle
     [not found]         ` <758a0adf-3e8c-1860-7528-0099a82e79da-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 16:39           ` Christian König
2017-02-13 17:50           ` Samuel Pitoiset
2017-02-09 16:08   ` [PATCH v2 1/2] drm/amdgpu: fix a potential deadlock in amdgpu_bo_create_restricted() Christian König
2017-02-13 16:25   ` Nicolai Hähnle
     [not found]     ` <ef49a53a-6011-0de1-9ff6-3755851daf10-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 17:49       ` Samuel Pitoiset
     [not found]         ` <3fc6e61c-cc70-7b10-9abb-45a4f22b3909-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 17:52           ` Samuel Pitoiset
2017-02-13 18:04           ` Nicolai Hähnle
     [not found]             ` <7c0ece9f-8983-317b-0eae-adaf535c6d06-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 18:09               ` Nicolai Hähnle
     [not found]                 ` <ed01ca29-e255-62f8-ca99-f079de294eda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 18:38                   ` Samuel Pitoiset
     [not found]                     ` <aaa5ce51-e2e0-f368-c3f0-b94b5afe3881-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 18:58                       ` Nicolai Hähnle
     [not found]                         ` <4185541c-a3a4-7681-4539-54c5daddd0ac-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 19:03                           ` Nicolai Hähnle
     [not found]                             ` <60486a5c-0ac3-675e-86f6-67f67db1213c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-14  2:56                               ` zhoucm1
     [not found]                                 ` <58A271E0.9090807-5C7GfCeVMHo@public.gmane.org>
2017-02-14  8:30                                   ` Nicolai Hähnle
2017-02-14 17:31                                   ` Alex Deucher
2017-02-13 22:13                           ` Samuel Pitoiset
2017-02-13 18:11               ` Samuel Pitoiset
     [not found]                 ` <e8a51ac0-8319-810a-0fb8-992c3afd4f34-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 18:19                   ` Nicolai Hähnle
     [not found]                     ` <eeafbad0-ca3b-ba03-7068-f54dd2119267-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 18:32                       ` Samuel Pitoiset
     [not found]                         ` <4d8bb8a9-d2b7-2ade-0dd0-8762e1dcc7a5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-13 18:41                           ` Christian König
     [not found]                             ` <39ea0637-7794-865e-dbf7-6109d295064e-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-02-13 18:45                               ` Samuel Pitoiset

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.