drm/amdgpu: Move reset domain locking in DPC handler
Subsystems (2)
PATCH 1/1 drm/amdgpu: Move reset domain locking in DPC handler
Lock reset domain unconditionally because on resume we unlock it unconditionally.
This solved mutex deadlock when handling both FATAL and non FATAL PCI errors one after another.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -7
@@ -5531,18 +5531,18 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta adev->pci_channel_state = state; +/* +* Locking adev->reset_domain->sem will prevent any external access +* to GPU during PCI error recovery +*/ +amdgpu_device_lock_reset_domain (adev->reset_domain); +amdgpu_device_set_mp1_state (adev); +switch (state) {case pci_channel_io_normal:return PCI_ERS_RESULT_CAN_RECOVER ;/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen: -/* -* Locking adev->reset_domain->sem will prevent any external access -* to GPU during PCI error recovery -*/ -amdgpu_device_lock_reset_domain (adev->reset_domain); -amdgpu_device_set_mp1_state (adev); -/* * Block any work scheduling as we do for regular GPU reset * for the duration of the recovery
Signature · 1 line
2.25.1
Am 13.04.22 um 21:31 schrieb Andrey Grodzovsky:
Quoted 18 lines
Lock reset domain unconditionally because on resume we unlock it unconditionally.
This solved mutex deadlock when handling both FATAL and non FATAL PCI errors one after another.Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5531,18 +5531,18 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta adev->pci_channel_state = state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta · line 5543
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+/* +* Locking adev->reset_domain->sem will prevent any external access +* to GPU during PCI error recovery +*/ +amdgpu_device_lock_reset_domain (adev->reset_domain); +amdgpu_device_set_mp1_state (adev); +switch (state) {case pci_channel_io_normal:return PCI_ERS_RESULT_CAN_RECOVER ;
BTW: Where are we unlocking that again?
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-7/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen: -/* -* Locking adev->reset_domain->sem will prevent any external access -* to GPU during PCI error recovery -*/ -amdgpu_device_lock_reset_domain (adev->reset_domain); -amdgpu_device_set_mp1_state (adev); -/* * Block any work scheduling as we do for regular GPU reset * for the duration of the recovery
It's in amdgpu_pci_resume.
Andrey, shall we modify the code accordingly in amdgpu_pci_resume as well? Otherwise, an unset/unlock leak will happen when pci_channel_state != pci_channel_io_frozen.
Regards,
Guchun
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Thursday, April 14, 2022 2:40 PM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Antonovitch, Anatoli <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Move reset domain locking in DPC handler
Am 13.04.22 um 21:31 schrieb Andrey Grodzovsky:
Quoted 20 lines
Lock reset domain unconditionally because on resume we unlock it unconditionally.
This solved mutex deadlock when handling both FATAL and non FATAL PCI errors one after another.Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5531,18 +5531,18 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staadev->pci_channel_state = state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta · line 5543
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+/* +* Locking adev->reset_domain->sem will prevent any external access +* to GPU during PCI error recovery +*/ +amdgpu_device_lock_reset_domain (adev->reset_domain); +amdgpu_device_set_mp1_state (adev); +switch (state) {case pci_channel_io_normal:return PCI_ERS_RESULT_CAN_RECOVER ;
BTW: Where are we unlocking that again?
Quoted 12 lines
/* Fatal error, prepare for slot reset */
casepci_channel_io_frozen:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-7-/* -* Locking adev->reset_domain->sem will prevent any external access -* to GPU during PCI error recovery -*/ -amdgpu_device_lock_reset_domain (adev->reset_domain); -amdgpu_device_set_mp1_state (adev); -/* * Block any work scheduling as we do for regular GPU reset * for the duration of the recovery
Yea, i need to improve it a bit, ignore this one, will be back with V2.
Andrey
Quoted 61 lines · Guchun
It's in
amdgpu_pci_resume.Andrey, shall we modify the code accordingly in
amdgpu_pci_resumeas well? Otherwise, an unset/unlock leak will happen whenpci_channel_state!=pci_channel_io_frozen.Regards,
Guchun-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Thursday, April 14, 2022 2:40 PM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Antonovitch, Anatoli <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Move reset domain locking in DPC handlerAm 13.04.22 um 21:31 schrieb Andrey Grodzovsky:
Quoted 20 lines
Lock reset domain unconditionally because on resume we unlock it unconditionally.
This solved mutex deadlock when handling both FATAL and non FATAL PCI errors one after another.Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5531,18 +5531,18 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staadev->pci_channel_state = state;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta · line 5543
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+/* +* Locking adev->reset_domain->sem will prevent any external access +* to GPU during PCI error recovery +*/ +amdgpu_device_lock_reset_domain (adev->reset_domain); +amdgpu_device_set_mp1_state (adev); +switch (state) {case pci_channel_io_normal:return PCI_ERS_RESULT_CAN_RECOVER ;BTW: Where are we unlocking that again?
Quoted 12 lines
/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-7-/* -* Locking adev->reset_domain->sem will prevent any external access -* to GPU during PCI error recovery -*/ -amdgpu_device_lock_reset_domain (adev->reset_domain); -amdgpu_device_set_mp1_state (adev); -/* * Block any work scheduling as we do for regular GPU reset * for the duration of the recovery
My bad, I see u already fixed this in amd-staging-drm-next. We had an issue in an internal branch with this and just reinvented the wheel :))
Andrey
Quoted 66 lines · Andrey Grodzovsky
Yea, i need to improve it a bit, ignore this one, will be back with V2.
Andrey
Quoted 61 lines · Guchun
It's in
amdgpu_pci_resume.Andrey, shall we modify the code accordingly in
amdgpu_pci_resumeas well? Otherwise, an unset/unlock leak will happen whenpci_channel_state!=pci_channel_io_frozen.Regards,
Guchun-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Thursday, April 14, 2022 2:40 PM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Antonovitch, Anatoli <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Move reset domain locking in DPC handlerAm 13.04.22 um 21:31 schrieb Andrey Grodzovsky:
Quoted 21 lines
Lock reset domain unconditionally because on resume we unlock it unconditionally.
This solved mutex deadlock when handling both FATAL and non FATAL PCI errors one after another.Signed-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 14 +++++++-------1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5531,18 +5531,18 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staadev->pci_channel_state= state;
+ /*
+ * Lockingadev->reset_domain->semwill prevent any external accessQuoted 8 lines
+ * to GPU during PCI error recovery
+ */
+amdgpu_device_lock_reset_domain(adev->reset_domain); +amdgpu_device_set_mp1_state(adev);
+
switch (state) {
casepci_channel_io_normal:
returnPCI_ERS_RESULT_CAN_RECOVER;BTW: Where are we unlocking that again?
Quoted 13 lines
/* Fatal error, prepare for slot reset */
casepci_channel_io_frozen:
- /*
- * Lockingadev->reset_domain->semwill prevent any external access
- * to GPU during PCI error recovery
- */
-amdgpu_device_lock_reset_domain(adev->reset_domain);
-amdgpu_device_set_mp1_state(adev);
-
/*
* Block any work scheduling as we do for regular GPU reset
* for the duration of the recovery
Quoted 24 lines · Christian König
Am 13.04.22 um 21:31 schrieb Andrey Grodzovsky:
Quoted 21 lines
Lock reset domain unconditionally because on resume we unlock it unconditionally.
This solved mutex deadlock when handling both FATAL and non FATAL PCI errors one after another.Signed-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 14 +++++++-------1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5531,18 +5531,18 @@ pci_ers_result_tamdgpu_pci_error_detected(struct
pci_dev*pdev,pci_channel_staadev->pci_channel_state= state;
+ /*
+ * Lockingadev->reset_domain->semwill prevent any external access + * to GPU during PCI error recovery
+ */
Quoted 8 lines
Quoted 6 lines
+
amdgpu_device_lock_reset_domain(adev->reset_domain); +amdgpu_device_set_mp1_state(adev);
+
switch (state) {
casepci_channel_io_normal:
returnPCI_ERS_RESULT_CAN_RECOVER;BTW: Where are we unlocking that again?
In amdgpu_pci_resume, but you made realize I can do this better. I will be back with V2.
Andrey
Quoted 15 lines
Quoted 14 lines
/* Fatal error, prepare for slot reset */
casepci_channel_io_frozen:
- /*
- * Lockingadev->reset_domain->semwill prevent any external access
- * to GPU during PCI error recovery
- */
-amdgpu_device_lock_reset_domain(adev->reset_domain); -amdgpu_device_set_mp1_state(adev);
-
/*
* Block any work scheduling as we do for regular GPU reset
* for the duration of the recovery