drm/amdgpu: Fix crash when hot unplug in BACO.
Subsystems (2)
PATCH 1/1 drm/amdgpu: Fix crash when hot unplug in BACO.
Problem:
When device goes into sleep state due to prolonged innactivity (e.g. BACO sleep) and then hot unplugged, PCI core will try to wake up the device as part of unplug process. Since the device is gone all HW programming during rpm resume fails leading to a bad SW state later during pci remove handling.
Fix:
Use a flag we use for PCIe error recovery to avoid accessing registres. This allows to succefully complete rpm resume sequence and finish pci remove.
P.S Must use pci_device_is_present and not drm_dev_enter/exit here since rpm resume happens before PCI remove and so the unplug flag is not set yet.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
@@ -1555,6 +1555,11 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (!adev->runpm)return -EINVAL ; +/* Avoids registers access if device is physically gone */ +if (!pci_device_is_present (adev->pdev)) + adev->in_pci_err_recovery = true; + +if (amdgpu_device_supports_px (drm_dev)) { drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;
Signature · 1 line
2.25.1
Quoted 9 lines · Andrey Grodzovsky
Problem:
When device goes into sleep state due to prolonged innactivity (e.g. BACO sleep) and then hot unplugged, PCI core will try to wake up the device as part of unplug process. Since the device is gone all HW programming during rpm resume fails leading to a bad SW state later during pci remove handling.
Quoted 4 lines
Fix:
Use a flag we use for PCIe error recovery to avoid accessing registres. This allows to succefully complete rpm resume sequence and finish pci remove.
Might make sense to create a preliminary patch to change the name of this flag to something like no_hw_access since it's not specific to pci error handling.
Alex
Quoted 28 lines
P.SMust usepci_device_is_presentand not drm_dev_enter/exit here since rpm resume happens before PCI remove and so the unplug flag is not set yet.Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-1@@ -1555,6 +1555,11 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (!adev->runpm)return -EINVAL ; +/* Avoids registers access if device is physically gone */ +if (!pci_device_is_present (adev->pdev)) + adev->in_pci_err_recovery = true; + +if (amdgpu_device_supports_px (drm_dev)) { drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ; --
Quoted 2 lines
2.25.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Will do.
Andrey
Quoted 46 lines · Alex Deucher
Quoted 8 lines · Andrey Grodzovsky
Problem:
When device goes into sleep state due to prolonged innactivity (e.g. BACO sleep) and then hot unplugged, PCI core will try to wake up the device as part of unplug process. Since the device is gone all HW programming during rpm resume fails leading to a bad SW state later during pci remove handling.Quoted 4 lines
Fix:
Use a flag we use for PCIe error recovery to avoid accessing registres. This allows to succefully complete rpm resume sequence and finish pci remove.Might make sense to create a preliminary patch to change the name of this flag to something like
no_hw_accesssince it's not specific to pci error handling.Alex
Quoted 26 lines
P.SMust usepci_device_is_presentand not drm_dev_enter/exit here since rpm resume happens before PCI remove and so the unplug flag is not set yet.Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-0@@ -1555,6 +1555,11 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (!adev->runpm)return -EINVAL ; +/* Avoids registers access if device is physically gone */ +if (!pci_device_is_present (adev->pdev)) + adev->in_pci_err_recovery = true; + +if (amdgpu_device_supports_px (drm_dev)) { drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;
Quoted 3 lines
Quoted 3 lines
--
2.25.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx