All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Emily Deng <Emily.Deng@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: Fix some unload driver issues
Date: Fri, 5 Mar 2021 08:54:56 +0100	[thread overview]
Message-ID: <3c929a45-c8d6-904b-25ce-2909e530dead@gmail.com> (raw)
In-Reply-To: <20210305012019.58196-1-Emily.Deng@amd.com>

Am 05.03.21 um 02:20 schrieb Emily Deng:
> When unloading driver after killing some applications, it will hit sdma
> flush tlb job timeout which is called by ttm_bo_delay_delete. So
> to avoid the job submit after fence driver fini, call ttm_bo_lock_delayed_workqueue
> before fence driver fini. And also put drm_sched_fini before waiting fence.

Good catch, Reviewed-by: Christian König <christian.koenig@amd.com> for 
this part.

> Set adev->gart.ptr to null to fix null pointer when calling amdgpu_gart_unbind
> in amdgpu_bo_fini which is after gart_fini.

For that one I'm wondering if we shouldn't rather rework or double check 
the tear down order.

On the other hand the hardware should be idle by now (this comes after 
the fence_driver_fini, doesn't it?) and it looks cleaner on it's own.

Regards,
Christian.

>
> Signed-off-by: Emily Deng <Emily.Deng@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  | 5 +++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c   | 1 +
>   3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index a11760ec3924..de0597d34588 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3594,6 +3594,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>   {
>   	dev_info(adev->dev, "amdgpu: finishing device.\n");
>   	flush_delayed_work(&adev->delayed_init_work);
> +	ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
>   	adev->shutdown = true;
>   
>   	kfree(adev->pci_state);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index 143a14f4866f..6d16f58ac91e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -531,6 +531,8 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
>   
>   		if (!ring || !ring->fence_drv.initialized)
>   			continue;
> +		if (!ring->no_scheduler)
> +			drm_sched_fini(&ring->sched);
>   		r = amdgpu_fence_wait_empty(ring);
>   		if (r) {
>   			/* no need to trigger GPU reset as we are unloading */
> @@ -539,8 +541,7 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
>   		if (ring->fence_drv.irq_src)
>   			amdgpu_irq_put(adev, ring->fence_drv.irq_src,
>   				       ring->fence_drv.irq_type);
> -		if (!ring->no_scheduler)
> -			drm_sched_fini(&ring->sched);
> +
>   		del_timer_sync(&ring->fence_drv.fallback_timer);
>   		for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
>   			dma_fence_put(ring->fence_drv.fences[j]);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> index 23823a57374f..f1ede4b43d07 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> @@ -202,6 +202,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
>   		return;
>   	}
>   	amdgpu_bo_unref(&adev->gart.bo);
> +	adev->gart.ptr = NULL;
>   }
>   
>   /*

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

  reply	other threads:[~2021-03-05  7:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05  1:20 [PATCH] drm/amdgpu: Fix some unload driver issues Emily Deng
2021-03-05  7:54 ` Christian König [this message]
2021-03-05  8:43   ` Deng, Emily
2021-03-05  8:51     ` Christian König
2021-03-05  8:52       ` Deng, Emily
  -- strict thread matches above, loose matches on Subject: below --
2021-03-05  9:04 Emily Deng
2021-03-05  9:53 ` 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=3c929a45-c8d6-904b-25ce-2909e530dead@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Emily.Deng@amd.com \
    --cc=amd-gfx@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 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.