Commit 54a85db8 authored by Andrey Grodzovsky's avatar Andrey Grodzovsky

drm/amdgpu: Fix hang on device removal.

If removing while commands in flight you cannot wait to flush the
HW fences on a ring since the device is gone.
Signed-off-by: default avatarAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210512142648.666476-13-andrey.grodzovsky@amd.com
parent ca4e1724
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <drm/drm_drv.h>
#include "amdgpu.h" #include "amdgpu.h"
#include "amdgpu_trace.h" #include "amdgpu_trace.h"
...@@ -525,8 +526,7 @@ int amdgpu_fence_driver_init(struct amdgpu_device *adev) ...@@ -525,8 +526,7 @@ int amdgpu_fence_driver_init(struct amdgpu_device *adev)
*/ */
void amdgpu_fence_driver_fini_hw(struct amdgpu_device *adev) void amdgpu_fence_driver_fini_hw(struct amdgpu_device *adev)
{ {
unsigned i, j; int i, r;
int r;
for (i = 0; i < AMDGPU_MAX_RINGS; i++) { for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
struct amdgpu_ring *ring = adev->rings[i]; struct amdgpu_ring *ring = adev->rings[i];
...@@ -535,11 +535,15 @@ void amdgpu_fence_driver_fini_hw(struct amdgpu_device *adev) ...@@ -535,11 +535,15 @@ void amdgpu_fence_driver_fini_hw(struct amdgpu_device *adev)
continue; continue;
if (!ring->no_scheduler) if (!ring->no_scheduler)
drm_sched_fini(&ring->sched); drm_sched_fini(&ring->sched);
/* You can't wait for HW to signal if it's gone */
if (!drm_dev_is_unplugged(&adev->ddev))
r = amdgpu_fence_wait_empty(ring); r = amdgpu_fence_wait_empty(ring);
if (r) { else
r = -ENODEV;
/* no need to trigger GPU reset as we are unloading */ /* no need to trigger GPU reset as we are unloading */
if (r)
amdgpu_fence_driver_force_completion(ring); amdgpu_fence_driver_force_completion(ring);
}
if (ring->fence_drv.irq_src) if (ring->fence_drv.irq_src)
amdgpu_irq_put(adev, ring->fence_drv.irq_src, amdgpu_irq_put(adev, ring->fence_drv.irq_src,
ring->fence_drv.irq_type); ring->fence_drv.irq_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment