drm/amdgpu: wait for all rings to drain before runtime suspending
Subsystems (2)
PATCH 1/1 drm/amdgpu: wait for all rings to drain before runtime suspending
Add a safety check to runtime suspend to make sure all outstanding fences have signaled before we suspend. Doesn't fix any known issue.
We already do this via the fence driver suspend function, but we just force completion rather than bailing. This bails on runtime suspend so we can try again later once the fences are signaled to avoid missing any outstanding work.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +11 -1
@@ -1214,13 +1214,23 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev);struct amdgpu_device *adev = drm_dev->dev_private; -int ret; +int ret, i;if (!adev->runpm) {pm_runtime_forbid (dev);return -EBUSY ; } +/* wait for all rings to drain before suspending */ +for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { +struct amdgpu_ring *ring = adev->rings[i]; +if (ring && ring->sched.ready) { + ret =amdgpu_fence_wait_empty (ring); +if (ret) +return -EBUSY ; + } + } +if (amdgpu_device_supports_boco (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev);
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 7 lines · Alex Deucher
Add a safety check to runtime suspend to make sure all outstanding fences have signaled before we suspend. Doesn't fix any known issue.
We already do this via the fence driver suspend function, but we just force completion rather than bailing. This bails on runtime suspend so we can try again later once the fences are signaled to avoid missing any outstanding work.
The idea sounds OK to me, but if you want to drain the rings, you should make sure no more submission, right?
So you should park all schedulers before waiting for all outstanding fences completed.
-David
Quoted 25 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-1@@ -1214,13 +1214,23 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev);struct amdgpu_device *adev = drm_dev->dev_private; -int ret; +int ret, i;if (!adev->runpm) {pm_runtime_forbid (dev);return -EBUSY ; } +/* wait for all rings to drain before suspending */ +for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) { +struct amdgpu_ring *ring = adev->rings[i];
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct device *dev) · line 1236
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7
-0+if (ring && ring->sched.ready) { + ret =amdgpu_fence_wait_empty (ring); +if (ret) +return -EBUSY ; + } + } +if (amdgpu_device_supports_boco (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 11.12.19 um 03:26 schrieb zhoucm1:
Quoted 13 lines · Alex Deucher
Quoted 7 lines
Add a safety check to runtime suspend to make sure all outstanding fences have signaled before we suspend. Doesn't fix any known issue.
We already do this via the fence driver suspend function, but we just force completion rather than bailing. This bails on runtime suspend so we can try again later once the fences are signaled to avoid missing any outstanding work.
The idea sounds OK to me, but if you want to drain the rings, you should make sure no more submission, right?
So you should park all schedulers before waiting for all outstanding fences completed.
At that point userspace should already be put to hold, so no new submissions. But it probably won't hurt stopping the scheduler anyway.
But another issue I see is what happens if we locked up the hardware?
Christian.
Quoted 33 lines
-David
Quoted 30 lines
Signed-off-by Alex Deucher <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 12 +++++++++++-1 file changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1@@ -1214,13 +1214,23 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) struct pci_dev *pdev = to_pci_dev(dev); struct drm_device *drm_dev = pci_get_drvdata(pdev); struct amdgpu_device *adev = drm_dev->dev_private; - int ret; + int ret, i; if (!adev->runpm) { pm_runtime_forbid(dev); return -EBUSY; }+ /* wait for all rings to drain before suspending */ + for (i = 0; i <
AMDGPU_MAX_RINGS; i++) {
+ structamdgpu_ring*ring = adev->rings[i]; + if (ring &&ring->sched.ready) {
+ ret =amdgpu_fence_wait_empty(ring); + if (ret)
+ return-EBUSY;
+ }
+ }
Quoted 8 lines
Quoted 4 lines
+
if (amdgpu_device_supports_boco(drm_dev))drm_dev->switch_power_state=DRM_SWITCH_POWER_CHANGING;drm_kms_helper_poll_disable(drm_dev);_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 12 lines · Christian König
Am 11.12.19 um 03:26 schrieb zhoucm1:
Quoted 10 lines · Alex Deucher
Quoted 7 lines
Add a safety check to runtime suspend to make sure all outstanding fences have signaled before we suspend. Doesn't fix any known issue.
We already do this via the fence driver suspend function, but we just force completion rather than bailing. This bails on runtime suspend so we can try again later once the fences are signaled to avoid missing any outstanding work.
Quoted 9 lines
Quoted 5 lines
The idea sounds OK to me, but if you want to drain the rings, you should make sure no more submission, right?
So you should park all schedulers before waiting for all outstanding fences completed.
At that point userspace should already be put to hold, so no new submissions. But it probably won't hurt stopping the scheduler anyway.
Any ioctl calls will wake the hw again or increase the usage count.
Quoted 2 lines
But another issue I see is what happens if we locked up the hardware?
Regular GPU reset would kick in eventually.
Alex
Quoted 45 lines
Christian.
Quoted 42 lines
-David
Quoted 25 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-1@@ -1214,13 +1214,23 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) struct pci_dev *pdev = to_pci_dev(dev);struct drm_device *drm_dev =pci_get_drvdata (pdev);struct amdgpu_device *adev = drm_dev->dev_private; -int ret; +int ret, i;if (!adev->runpm) {pm_runtime_forbid (dev);return -EBUSY ; } +/* wait for all rings to drain before suspending */ + for (i = 0; i < AMDGPU_MAX_RINGS; i++) { +struct amdgpu_ring *ring = adev->rings[i];drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int · line 1235
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7
-0+if (ring && ring->sched.ready) { + ret =amdgpu_fence_wait_empty (ring); +if (ret) +return -EBUSY ; + } + } +if (amdgpu_device_supports_boco (drm_dev)) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;drm_kms_helper_poll_disable (drm_dev);_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx