All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Emily Deng <Emily.Deng-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/amdgpu: Fix the dead lock issue.
Date: Mon, 10 Sep 2018 09:06:22 +0200	[thread overview]
Message-ID: <fe055a6c-0859-7404-6236-2c22eb8e3df5@gmail.com> (raw)
In-Reply-To: <1536552453-18595-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org>

Am 10.09.2018 um 06:07 schrieb Emily Deng:
> It will ramdomly have the dead lock issue when test TDR:
> 1. amdgpu_device_handle_vram_lost gets the lock shadow_list_lock
> 2. amdgpu_bo_create locked the bo's resv lock
> 3. amdgpu_bo_create_shadow is waiting for the shadow_list_lock
> 4. amdgpu_device_recover_vram_from_shadow is waiting for the bo's resv
> lock.
>
> Signed-off-by: Emily Deng <Emily.Deng@amd.com>

Good catch, problem is the fix doesn't work like this because the lock 
won't be dropped at this point in most cases.

Instead you need to fix amdgpu_device_recover_vram_from_shadow to make a 
local copy of the list.

You can do this by grabbing a reference to each BO and moving it to a 
local list.

Regards,
Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index de990bd..c75447d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -557,12 +557,8 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
>   	bp.resv = bo->tbo.resv;
>   
>   	r = amdgpu_bo_do_create(adev, &bp, &bo->shadow);
> -	if (!r) {
> +	if (!r)
>   		bo->shadow->parent = amdgpu_bo_ref(bo);
> -		mutex_lock(&adev->shadow_list_lock);
> -		list_add_tail(&bo->shadow_list, &adev->shadow_list);
> -		mutex_unlock(&adev->shadow_list_lock);
> -	}
>   
>   	return r;
>   }
> @@ -603,6 +599,12 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
>   		if (!bp->resv)
>   			reservation_object_unlock((*bo_ptr)->tbo.resv);
>   
> +		if (!r) {
> +			mutex_lock(&adev->shadow_list_lock);
> +			list_add_tail(&(*bo_ptr)->shadow_list, &adev->shadow_list);
> +			mutex_unlock(&adev->shadow_list_lock);
> +		}
> +
>   		if (r)
>   			amdgpu_bo_unref(bo_ptr);
>   	}

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

  parent reply	other threads:[~2018-09-10  7:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10  4:07 [PATCH] drm/amdgpu: Fix the dead lock issue Emily Deng
     [not found] ` <1536552453-18595-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org>
2018-09-10  7:06   ` Christian König [this message]
     [not found]     ` <fe055a6c-0859-7404-6236-2c22eb8e3df5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-10  7:19       ` Deng, Emily
     [not found]         ` <BN7PR12MB2644EBCEAD5A7EAD4700FDD28F050-Zx/IyJUqfGKoYeSiBV3SvgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-09-10  7:23           ` Christian König
     [not found]             ` <6798b857-49ec-06b3-f25f-f9df91a1ae20-5C7GfCeVMHo@public.gmane.org>
2018-09-10  7:57               ` Deng, Emily
2018-09-11  2:51 Emily Deng
     [not found] ` <1536634293-26099-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org>
2018-09-11  3:01   ` Zhang, Jerry (Junwei)
2018-09-11  3:03   ` zhoucm1
     [not found]     ` <bf049e4b-321f-33b4-dad2-708269515e90-5C7GfCeVMHo@public.gmane.org>
2018-09-11  3:23       ` Deng, Emily
     [not found]         ` <BN7PR12MB2644CEE78E8E6D658D1A686E8F040-Zx/IyJUqfGKoYeSiBV3SvgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-09-11  3:27           ` zhoucm1
     [not found]             ` <fcbc7544-d08d-4051-c554-f1f9cecb87e1-5C7GfCeVMHo@public.gmane.org>
2018-09-11  3:32               ` Deng, Emily
     [not found]                 ` <BN7PR12MB2644E374B512DC7EF10CA6D08F040-Zx/IyJUqfGKoYeSiBV3SvgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-09-11  3:37                   ` zhoucm1
     [not found]                     ` <be67e50d-f161-c7da-256e-149ed1b56f26-5C7GfCeVMHo@public.gmane.org>
2018-09-11  5:41                       ` zhoucm1
     [not found]                         ` <83f7a45f-1aee-a2a8-bc82-f3433157c6cb-5C7GfCeVMHo@public.gmane.org>
2018-09-11  6:40                           ` Christian König
     [not found]                             ` <c67be83d-aecd-a291-a564-15f1fe501680-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-11  6:55                               ` Deng, Emily

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=fe055a6c-0859-7404-6236-2c22eb8e3df5@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Emily.Deng-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@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 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.