[PATCH 04/12] drm/amdgpu/sriov:cleanup gpu rest mlock
Monk Liu
Monk.Liu at amd.com
Sat Sep 30 06:03:44 UTC 2017
this mutex lock is for preventing multi-thread concurrrently
executing the sriov_gpu_reset, now we use atomic_add_unless
to replace it.
Change-Id: Id07e364764252a631cb75b01c7b7ff8d173d6c95
Signed-off-by: Monk Liu <Monk.Liu at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 ++++---
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 --
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 1 -
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f507894..56a9ebe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2751,9 +2751,11 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, struct amdgpu_job *job)
struct amdgpu_ring *ring;
struct dma_fence *fence = NULL, *next = NULL;
- mutex_lock(&adev->virt.lock_reset);
+ /* other thread is already into the gpu reset so just quit */
+ if (!atomic_add_unless(&adev->in_sriov_reset, 1, 1))
+ return 0;
+
atomic_inc(&adev->gpu_reset_counter);
- atomic_set(&adev->in_sriov_reset, 1);
/* block TTM */
resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
@@ -2865,7 +2867,6 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, struct amdgpu_job *job)
}
atomic_set(&adev->in_sriov_reset, 0);
- mutex_unlock(&adev->virt.lock_reset);
return r;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index ab05121..64930ef 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -107,8 +107,6 @@ void amdgpu_virt_init_setting(struct amdgpu_device *adev)
adev->enable_virtual_display = true;
adev->cg_flags = 0;
adev->pg_flags = 0;
-
- mutex_init(&adev->virt.lock_reset);
}
uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
index afcfb8b..a3cbd5a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
@@ -53,7 +53,6 @@ struct amdgpu_virt {
uint64_t csa_vmid0_addr;
bool chained_ib_support;
uint32_t reg_val_offs;
- struct mutex lock_reset;
struct amdgpu_irq_src ack_irq;
struct amdgpu_irq_src rcv_irq;
struct work_struct flr_work;
--
2.7.4
More information about the amd-gfx
mailing list