Commit 147b5983 authored by Monk Liu's avatar Monk Liu Committed by Alex Deucher

drm/amdgpu:add lock_reset for SRIOV

this lock is used for sriov_gpu_reset, only get this mutex
can run into sriov_gpu_reset.

we have couple source triggers gpu_reset for SRIOV:
1) submit timedout and trigger reset voluntarily
2) invalid instruction detected by ENGINE and trigger reset voluntarily
2) hypervisor found world switch hang and trigger flr and notify guest to
   do reset.

all need take care and we need a mutex to protect the consistency of
reset routine.
Signed-off-by: default avatarMonk Liu <Monk.Liu@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent ed17c71b
...@@ -2351,6 +2351,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) ...@@ -2351,6 +2351,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary)
struct amdgpu_ring *ring; struct amdgpu_ring *ring;
struct dma_fence *fence = NULL, *next = NULL; struct dma_fence *fence = NULL, *next = NULL;
mutex_lock(&adev->virt.lock_reset);
atomic_inc(&adev->gpu_reset_counter); atomic_inc(&adev->gpu_reset_counter);
/* block TTM */ /* block TTM */
...@@ -2436,6 +2437,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary) ...@@ -2436,6 +2437,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary)
dev_info(adev->dev, "GPU reset failed\n"); dev_info(adev->dev, "GPU reset failed\n");
} }
mutex_unlock(&adev->virt.lock_reset);
return r; return r;
} }
......
...@@ -98,6 +98,7 @@ void amdgpu_virt_init_setting(struct amdgpu_device *adev) ...@@ -98,6 +98,7 @@ void amdgpu_virt_init_setting(struct amdgpu_device *adev)
adev->enable_virtual_display = true; adev->enable_virtual_display = true;
mutex_init(&adev->virt.lock_kiq); mutex_init(&adev->virt.lock_kiq);
mutex_init(&adev->virt.lock_reset);
} }
uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg) uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
......
...@@ -47,6 +47,7 @@ struct amdgpu_virt { ...@@ -47,6 +47,7 @@ struct amdgpu_virt {
bool chained_ib_support; bool chained_ib_support;
uint32_t reg_val_offs; uint32_t reg_val_offs;
struct mutex lock_kiq; struct mutex lock_kiq;
struct mutex lock_reset;
struct amdgpu_irq_src ack_irq; struct amdgpu_irq_src ack_irq;
struct amdgpu_irq_src rcv_irq; struct amdgpu_irq_src rcv_irq;
struct delayed_work flr_work; struct delayed_work flr_work;
......
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