Skip to content

Commit 248b061

Browse files
Guchun Chenalexdeucher
authored andcommitted
drm/amdgpu: handle the case of pci_channel_io_frozen only in amdgpu_pci_resume
In current code, when a PCI error state pci_channel_io_normal is detectd, it will report PCI_ERS_RESULT_CAN_RECOVER status to PCI driver, and PCI driver will continue the execution of PCI resume callback report_resume by pci_walk_bridge, and the callback will go into amdgpu_pci_resume finally, where write lock is releasd unconditionally without acquiring such lock first. In this case, a deadlock will happen when other threads start to acquire the read lock. To fix this, add a member in amdgpu_device strucutre to cache pci_channel_state, and only continue the execution in amdgpu_pci_resume when it's pci_channel_io_frozen. Fixes: c9a6b82 ("drm/amdgpu: Implement DPC recovery") Suggested-by: Andrey Grodzovsky <[email protected]> Signed-off-by: Guchun Chen <[email protected]> Reviewed-by: Andrey Grodzovsky <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 714d9e4 commit 248b061

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ struct amdgpu_device {
10871087

10881088
bool no_hw_access;
10891089
struct pci_saved_state *pci_state;
1090+
pci_channel_state_t pci_channel_state;
10901091

10911092
struct amdgpu_reset_control *reset_cntl;
10921093
};

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5399,6 +5399,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta
53995399
return PCI_ERS_RESULT_DISCONNECT;
54005400
}
54015401

5402+
adev->pci_channel_state = state;
5403+
54025404
switch (state) {
54035405
case pci_channel_io_normal:
54045406
return PCI_ERS_RESULT_CAN_RECOVER;
@@ -5541,6 +5543,10 @@ void amdgpu_pci_resume(struct pci_dev *pdev)
55415543

55425544
DRM_INFO("PCI error: resume callback!!\n");
55435545

5546+
/* Only continue execution for the case of pci_channel_io_frozen */
5547+
if (adev->pci_channel_state != pci_channel_io_frozen)
5548+
return;
5549+
55445550
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
55455551
struct amdgpu_ring *ring = adev->rings[i];
55465552

0 commit comments

Comments
 (0)