Skip to content

Commit e864180

Browse files
Victor Skvortsovalexdeucher
Victor Skvortsov
authored andcommitted
drm/amdgpu: Add lock around VF RLCG interface
flush_gpu_tlb may be called from another thread while device_gpu_recover is running. Both of these threads access registers through the VF RLCG interface during VF Full Access. Add a lock around this interface to prevent race conditions between these threads. Signed-off-by: Victor Skvortsov <[email protected]> Reviewed-by: Zhigang Luo <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 7978c4d commit e864180

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4049,6 +4049,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
40494049
mutex_init(&adev->grbm_idx_mutex);
40504050
mutex_init(&adev->mn_lock);
40514051
mutex_init(&adev->virt.vf_errors.lock);
4052+
mutex_init(&adev->virt.rlcg_reg_lock);
40524053
hash_init(adev->mn_hash);
40534054
mutex_init(&adev->psp.mutex);
40544055
mutex_init(&adev->notifier_lock);

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,9 @@ u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v, u32 f
982982
scratch_reg1 = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->scratch_reg1;
983983
scratch_reg2 = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->scratch_reg2;
984984
scratch_reg3 = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->scratch_reg3;
985+
986+
mutex_lock(&adev->virt.rlcg_reg_lock);
987+
985988
if (reg_access_ctrl->spare_int)
986989
spare_int = (void __iomem *)adev->rmmio + 4 * reg_access_ctrl->spare_int;
987990

@@ -1038,6 +1041,9 @@ u32 amdgpu_virt_rlcg_reg_rw(struct amdgpu_device *adev, u32 offset, u32 v, u32 f
10381041
}
10391042

10401043
ret = readl(scratch_reg0);
1044+
1045+
mutex_unlock(&adev->virt.rlcg_reg_lock);
1046+
10411047
return ret;
10421048
}
10431049

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ struct amdgpu_virt {
272272

273273
/* the ucode id to signal the autoload */
274274
uint32_t autoload_ucode_id;
275+
276+
struct mutex rlcg_reg_lock;
275277
};
276278

277279
struct amdgpu_video_codec_info;

0 commit comments

Comments
 (0)