drm/amdgpu: add missed write lock for pci detected state pci_channel_io_normal
Subsystems (2)
PATCH 1/1 drm/amdgpu: add missed write lock for pci detected state pci_channel_io_normal
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
@@ -5370,6 +5370,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_staswitch (state) {case pci_channel_io_normal: +amdgpu_device_lock_adev (adev,NULL );return PCI_ERS_RESULT_CAN_RECOVER ;/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:
Signature · 1 line
2.17.1
Quoted 6 lines · Guchun Chen
When a PCI error state
pci_channel_io_normalis detectd, it will reportPCI_ERS_RESULT_CAN_RECOVERstatus to PCI driver, and PCI driver will continue the execution of PCI resume callbackreport_resumebypci_walk_bridge, and the callback will go intoamdgpu_pci_resumefinally, where write lock is releasd unconditionally without acquiring such lock.
Good catch but, the issue is even wider in scope, what about drm_sched_resubmit_jobs and drm_sched_start called without being stopped before ? Better to put the entire scope of code in this function under flag that set only in pci_channel_io_frozen. As far as i remember we don't need to do anything in case of pci_channel_io_normal.
Andrey
Quoted 19 lines
Fixes c9a6b82f45e2("drm/amdgpu: Implement DPC recovery")Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -5370,6 +5370,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_staswitch (state) {case pci_channel_io_normal: +amdgpu_device_lock_adev (adev,NULL );return PCI_ERS_RESULT_CAN_RECOVER ;/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:
[Public]
Hi Andrey,
Do you mean to move the code of drm_sched_resubmit_jobs and drm_sched_start in amdgpu_pci_resume to amdgpu_pci_error_detected, under the case pci_channel_io_frozen? Then leave amdgpu_pci_resume as a null function, and in this way, we can drop the acquire/lock write lock for case of pci_channel_io_normal as well?
Regards,
Guchun
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, October 1, 2021 10:22 AM
To: Chen, Guchun <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add missed write lock for pci detected state pci_channel_io_normal
Quoted 6 lines · Guchun Chen
When a PCI error state
pci_channel_io_normalis detectd, it will reportPCI_ERS_RESULT_CAN_RECOVERstatus to PCI driver, and PCI driver will continue the execution of PCI resume callbackreport_resumebypci_walk_bridge, and the callback will go intoamdgpu_pci_resumefinally, where write lock is releasd unconditionally without acquiring such lock.
Good catch but, the issue is even wider in scope, what about drm_sched_resubmit_jobs and drm_sched_start called without being stopped before ? Better to put the entire scope of code in this function under flag that set only in pci_channel_io_frozen. As far as i remember we don't need to do anything in case of pci_channel_io_normal.
Andrey
Quoted 21 lines
Fixes c9a6b82f45e2("drm/amdgpu: Implement DPC recovery")Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5370,6 +5370,7 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staswitch (state) { case pci_channel_io_normal:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+amdgpu_device_lock_adev (adev,NULL );return PCI_ERS_RESULT_CAN_RECOVER ;/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:
No, scheduler restart and device unlock must take place inamdgpu_pci_resume (see struct pci_error_handlers for the various states of PCI recovery). So just add a flag (probably in amdgpu_device) so we can remember what pci_channel_state_t we came from (unfortunately it's not passed to us in amdgpu_pci_resume) and unless it's set don't do anything in amdgpu_pci_resume.
Andrey
Quoted 50 lines · Guchun
[Public]
Hi Andrey,
Do you mean to move the code of
drm_sched_resubmit_jobsanddrm_sched_startinamdgpu_pci_resumetoamdgpu_pci_error_detected, under the casepci_channel_io_frozen? Then leaveamdgpu_pci_resumeas a null function, and in this way, we can drop the acquire/lock write lock for case ofpci_channel_io_normalas well?Regards,
Guchun-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, October 1, 2021 10:22 AM
To: Chen, Guchun <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add missed write lock for pci detected statepci_channel_io_normalQuoted 6 lines · Guchun Chen
When a PCI error state
pci_channel_io_normalis detectd, it will reportPCI_ERS_RESULT_CAN_RECOVERstatus to PCI driver, and PCI driver will continue the execution of PCI resume callbackreport_resumebypci_walk_bridge, and the callback will go intoamdgpu_pci_resumefinally, where write lock is releasd unconditionally without acquiring such lock.Good catch but, the issue is even wider in scope, what about
drm_sched_resubmit_jobsanddrm_sched_startcalled without being stopped before ? Better to put the entire scope of code in this function under flag that set only inpci_channel_io_frozen. As far as i remember we don't need to do anything in case ofpci_channel_io_normal.Andrey
Quoted 20 lines
Fixes c9a6b82f45e2("drm/amdgpu: Implement DPC recovery")Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5370,6 +5370,7 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staswitch (state) { case pci_channel_io_normal:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+amdgpu_device_lock_adev (adev,NULL );return PCI_ERS_RESULT_CAN_RECOVER ;/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:
[Public]
Got your point. Will send a new patch to address this.
Regards,
Guchun
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, October 1, 2021 10:29 PM
To: Chen, Guchun <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add missed write lock for pci detected state pci_channel_io_normal
No, scheduler restart and device unlock must take place inamdgpu_pci_resume (see struct pci_error_handlers for the various states of PCI recovery). So just add a flag (probably in amdgpu_device) so we can remember what pci_channel_state_t we came from (unfortunately it's not passed to us in amdgpu_pci_resume) and unless it's set don't do anything in amdgpu_pci_resume.
Andrey
Quoted 53 lines · Guchun
[Public]
Hi Andrey,
Do you mean to move the code of
drm_sched_resubmit_jobsanddrm_sched_startinamdgpu_pci_resumetoamdgpu_pci_error_detected, under the casepci_channel_io_frozen? Then leaveamdgpu_pci_resumeas a null function, and in this way, we can drop the acquire/lock write lock for case ofpci_channel_io_normalas well?Regards,
Guchun-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, October 1, 2021 10:22 AM
To: Chen, Guchun <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add missed write lock for pci detected statepci_channel_io_normalQuoted 6 lines · Guchun Chen
When a PCI error state
pci_channel_io_normalis detectd, it will reportPCI_ERS_RESULT_CAN_RECOVERstatus to PCI driver, and PCI driver will continue the execution of PCI resume callbackreport_resumebypci_walk_bridge, and the callback will go intoamdgpu_pci_resumefinally, where write lock is releasd unconditionally without acquiring such lock.Good catch but, the issue is even wider in scope, what about
drm_sched_resubmit_jobsanddrm_sched_startcalled without being stopped before ? Better to put the entire scope of code in this function under flag that set only inpci_channel_io_frozen. As far as i remember we don't need to do anything in case ofpci_channel_io_normal.Andrey
Quoted 20 lines
Fixes c9a6b82f45e2("drm/amdgpu: Implement DPC recovery")Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5370,6 +5370,7 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staswitch (state) { case pci_channel_io_normal:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+amdgpu_device_lock_adev (adev,NULL );return PCI_ERS_RESULT_CAN_RECOVER ;/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:
[Public]
Hi Andrey,
A new patch with subject "drm/amdgpu: handle the case of pci_channel_io_frozen only in amdgpu_pci_resume" has been sent, pls review it. Thanks.
Regards,
Guchun
-----Original Message-----
From: Chen, Guchun
Sent: Friday, October 1, 2021 11:21 PM
To: Grodzovsky, Andrey <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add missed write lock for pci detected state pci_channel_io_normal
[Public]
Got your point. Will send a new patch to address this.
Regards,
Guchun
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, October 1, 2021 10:29 PM
To: Chen, Guchun <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add missed write lock for pci detected state pci_channel_io_normal
No, scheduler restart and device unlock must take place inamdgpu_pci_resume (see struct pci_error_handlers for the various states of PCI recovery). So just add a flag (probably in amdgpu_device) so we can remember what pci_channel_state_t we came from (unfortunately it's not passed to us in amdgpu_pci_resume) and unless it's set don't do anything in amdgpu_pci_resume.
Andrey
Quoted 53 lines · Guchun
[Public]
Hi Andrey,
Do you mean to move the code of
drm_sched_resubmit_jobsanddrm_sched_startinamdgpu_pci_resumetoamdgpu_pci_error_detected, under the casepci_channel_io_frozen? Then leaveamdgpu_pci_resumeas a null function, and in this way, we can drop the acquire/lock write lock for case ofpci_channel_io_normalas well?Regards,
Guchun-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, October 1, 2021 10:22 AM
To: Chen, Guchun <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add missed write lock for pci detected statepci_channel_io_normalQuoted 6 lines · Guchun Chen
When a PCI error state
pci_channel_io_normalis detectd, it will reportPCI_ERS_RESULT_CAN_RECOVERstatus to PCI driver, and PCI driver will continue the execution of PCI resume callbackreport_resumebypci_walk_bridge, and the callback will go intoamdgpu_pci_resumefinally, where write lock is releasd unconditionally without acquiring such lock.Good catch but, the issue is even wider in scope, what about
drm_sched_resubmit_jobsanddrm_sched_startcalled without being stopped before ? Better to put the entire scope of code in this function under flag that set only inpci_channel_io_frozen. As far as i remember we don't need to do anything in case ofpci_channel_io_normal.Andrey
Quoted 20 lines
Fixes c9a6b82f45e2("drm/amdgpu: Implement DPC recovery")Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5370,6 +5370,7 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staswitch (state) { case pci_channel_io_normal:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0+amdgpu_device_lock_adev (adev,NULL );return PCI_ERS_RESULT_CAN_RECOVER ;/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen: