Skip to contentSkip to conversation

drm/amdgpu: stop scheduler when calling hw_fini (v2)

PATCH In review Guchun Chen 4 participants 4 messages Aug 30, 2021 – Aug 31, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: stop scheduler when calling hw_fini (v2)

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise a potential race will occur and the ring will get no chance to stay empty before suspend.

v2: Call drm_sched_resubmit_job before drm_sched_start to restart jobs from the pending list.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +8 -0
index b439eb7d4177..fd4ba076ff8a 100644
@@ -552,6 +552,9 @@ void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev)
 		if (!ring || !ring->fence_drv.initialized)
 			continue;
 
+		if (!ring->no_scheduler)
+			drm_sched_stop(&ring->sched, NULL);
+
 		/* You can't wait for HW to signal if it's gone */
 		if (!drm_dev_is_unplugged(&adev->ddev))
 			r = amdgpu_fence_wait_empty(ring);
@@ -611,6 +614,11 @@ void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev)
 		if (!ring || !ring->fence_drv.initialized)
 			continue;
 
+		if (!ring->no_scheduler) {
+			drm_sched_resubmit_jobs(&ring->sched);
+			drm_sched_start(&ring->sched, true);
+		}
+
 		/* enable the interrupt */
 		if (ring->fence_drv.irq_src)
 			amdgpu_irq_get(adev, ring->fence_drv.irq_src,
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 30.08.21 um 08:08 schrieb Guchun Chen:

Quoted 11 lines

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise a potential race will occur and the ring will get no chance to stay empty before suspend.

v2: Call drm_sched_resubmit_job before drm_sched_start to restart jobs from the pending list.

Quoted 30 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +8 -0
index b439eb7d4177..fd4ba076ff8a 100644
@@ -552,6 +552,9 @@ void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev)
  		if (!ring || !ring->fence_drv.initialized)
  			continue;
 
+		if (!ring->no_scheduler)
+			drm_sched_stop(&ring->sched, NULL);
+
  		/* You can't wait for HW to signal if it's gone */
  		if (!drm_dev_is_unplugged(&adev->ddev))
  			r = amdgpu_fence_wait_empty(ring);
@@ -611,6 +614,11 @@ void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev)
  		if (!ring || !ring->fence_drv.initialized)
  			continue;
 
+		if (!ring->no_scheduler) {
+			drm_sched_resubmit_jobs(&ring->sched);
+			drm_sched_start(&ring->sched, true);
+		}
+
  		/* enable the interrupt */
  		if (ring->fence_drv.irq_src)
  			amdgpu_irq_get(adev, ring->fence_drv.irq_src,
#2 lore raw

Looks good to me too.

Andrey

Quoted 46 lines · Christian König

Am 30.08.21 um 08:08 schrieb Guchun Chen:

Quoted 11 lines

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise a potential race will occur and the ring will get no chance to stay empty before suspend.

v2: Call drm_sched_resubmit_job before drm_sched_start to restart jobs from the pending list.

Quoted 30 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 8 ++++++++

  1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2 -0
index b439eb7d4177..fd4ba076ff8a 100644
@@ -552,6 +552,9 @@ void amdgpu_fence_driver_hw_fini(struct 
 amdgpu_device *adev)
           if (!ring || !ring->fence_drv.initialized)
               continue;
   +        if (!ring->no_scheduler)
+            drm_sched_stop(&ring->sched, NULL);
+
           /* You can't wait for HW to signal if it's gone */
           if (!drm_dev_is_unplugged(&adev->ddev))

              r = amdgpu_fence_wait_empty(ring);

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4 -0
@@ -611,6 +614,11 @@ void amdgpu_fence_driver_hw_init(struct 
 amdgpu_device *adev)
           if (!ring || !ring->fence_drv.initialized)
               continue;
   +        if (!ring->no_scheduler) {
+            drm_sched_resubmit_jobs(&ring->sched);
+            drm_sched_start(&ring->sched, true);
+        }
+
           /* enable the interrupt */
           if (ring->fence_drv.irq_src)

              amdgpu_irq_get(adev, ring->fence_drv.irq_src,

#3 lore raw
In reply to Guchun Chen
Quoted 6 lines · Guchun Chen

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise a potential race will occur and the ring will get no chance to stay empty before suspend.

Quoted 6 lines

v2: Call drm_sched_resubmit_job before drm_sched_start to restart jobs from the pending list.

Maybe add:

Fixes 067f44c8b459 ("drm/amdgpu: avoid over-handle of fence driver

fini in s3 test (v2)")
?

Alex

Quoted 33 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +8 -1
index b439eb7d4177..fd4ba076ff8a 100644
@@ -552,6 +552,9 @@ void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev)
                if (!ring || !ring->fence_drv.initialized)
                        continue;
 
+               if (!ring->no_scheduler)
+                       drm_sched_stop(&ring->sched, NULL);
+
                /* You can't wait for HW to signal if it's gone */
                if (!drm_dev_is_unplugged(&adev->ddev))
                        r = amdgpu_fence_wait_empty(ring);
@@ -611,6 +614,11 @@ void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev)
                if (!ring || !ring->fence_drv.initialized)
                        continue;
 
+               if (!ring->no_scheduler) {
+                       drm_sched_resubmit_jobs(&ring->sched);
+                       drm_sched_start(&ring->sched, true);
+               }
+
                /* enable the interrupt */
                if (ring->fence_drv.irq_src)
                        amdgpu_irq_get(adev, ring->fence_drv.irq_src,
--

2.17.1