Skip to content

Commit 2b198d4

Browse files
YiPeng Chaialexdeucher
authored andcommitted
drm/amdgpu: Add lock to serialize sriov command execution
Add lock to serialize sriov command execution. Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent c0e8704 commit 2b198d4

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ static void amdgpu_virt_init_ras(struct amdgpu_device *adev)
917917
RATELIMIT_MSG_ON_RELEASE);
918918

919919
mutex_init(&adev->virt.ras.ras_telemetry_mutex);
920+
mutex_init(&adev->virt.access_req_mutex);
920921

921922
adev->virt.ras.cper_rptr = 0;
922923
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ struct amdgpu_virt {
325325
/* Spinlock to protect access to the RLCG register interface */
326326
spinlock_t rlcg_reg_lock;
327327

328+
struct mutex access_req_mutex;
329+
328330
union amd_sriov_ras_caps ras_en_caps;
329331
union amd_sriov_ras_caps ras_telemetry_en_caps;
330332
struct amdgpu_virt_ras ras;

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,17 @@ static void xgpu_nv_mailbox_trans_msg (struct amdgpu_device *adev,
173173
static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev,
174174
enum idh_request req, u32 data1, u32 data2, u32 data3)
175175
{
176-
int r, retry = 1;
176+
struct amdgpu_virt *virt = &adev->virt;
177+
int r = 0, retry = 1;
177178
enum idh_event event = -1;
178179

180+
mutex_lock(&virt->access_req_mutex);
179181
send_request:
180182

181-
if (amdgpu_ras_is_rma(adev))
182-
return -ENODEV;
183+
if (amdgpu_ras_is_rma(adev)) {
184+
r = -ENODEV;
185+
goto out;
186+
}
183187

184188
xgpu_nv_mailbox_trans_msg(adev, req, data1, data2, data3);
185189

@@ -217,7 +221,7 @@ static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev,
217221

218222
if (req != IDH_REQ_GPU_INIT_DATA) {
219223
dev_err(adev->dev, "Doesn't get msg:%d from pf, error=%d\n", event, r);
220-
return r;
224+
goto out;
221225
} else /* host doesn't support REQ_GPU_INIT_DATA handshake */
222226
adev->virt.req_init_data_ver = 0;
223227
} else {
@@ -246,7 +250,10 @@ static int xgpu_nv_send_access_requests_with_param(struct amdgpu_device *adev,
246250
}
247251
}
248252

249-
return 0;
253+
out:
254+
mutex_unlock(&virt->access_req_mutex);
255+
256+
return r;
250257
}
251258

252259
static int xgpu_nv_send_access_requests(struct amdgpu_device *adev,

0 commit comments

Comments
 (0)