AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: wentalou <Wentao.Lou-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/amdgpu: amdgpu_device_recover_vram got NULL of shadow->parent
Date: Tue, 16 Apr 2019 11:53:10 +0200	[thread overview]
Message-ID: <06709c9f-5154-cebb-4031-b14bd3eec9bb@gmail.com> (raw)
In-Reply-To: <1555399026-17671-1-git-send-email-Wentao.Lou-5C7GfCeVMHo@public.gmane.org>

Am 16.04.19 um 09:17 schrieb wentalou:
> amdgpu_bo_destroy had a bug by calling amdgpu_bo_unref outside mutex_lock.
> If amdgpu_device_recover_vram executed between amdgpu_bo_unref and list_del_init,
> it would get NULL of shadow->parent, then caused Call Trace and GPU reset failed.
>
> Change-Id: I41d7b54605e613e87ee03c3ad89c191063c19230
> Signed-off-by: Wentao Lou <Wentao.Lou@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index ec9e450..0df8158 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -88,12 +88,16 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
>   	if (bo->gem_base.import_attach)
>   		drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg);
>   	drm_gem_object_release(&bo->gem_base);
> -	amdgpu_bo_unref(&bo->parent);
> +	/* in case amdgpu_device_recover_vram got NULL of bo->parent */
>   	if (!list_empty(&bo->shadow_list)) {
>   		mutex_lock(&adev->shadow_list_lock);
>   		list_del_init(&bo->shadow_list);
> +		amdgpu_bo_unref(&bo->parent);
>   		mutex_unlock(&adev->shadow_list_lock);
>   	}
> +	else
> +		amdgpu_bo_unref(&bo->parent);
> +

Please just move amdgpu_bo_unref(&bo->parent); after the "if".

Regards,
Christian.

>   	kfree(bo->metadata);
>   	kfree(bo);
>   }

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

  parent reply	other threads:[~2019-04-16  9:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16  7:17 [PATCH] drm/amdgpu: amdgpu_device_recover_vram got NULL of shadow->parent wentalou
     [not found] ` <1555399026-17671-1-git-send-email-Wentao.Lou-5C7GfCeVMHo@public.gmane.org>
2019-04-16  9:53   ` Christian König [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-04-16 10:46 wentalou
     [not found] ` <1555411616-18423-1-git-send-email-Wentao.Lou-5C7GfCeVMHo@public.gmane.org>
2019-04-16 10:52   ` 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=06709c9f-5154-cebb-4031-b14bd3eec9bb@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Wentao.Lou-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox