Skip to contentSkip to conversation

drm/amdgpu: stop scheduler when calling hw_fini

PATCH In review Guchun Chen 3 participants 4 messages Aug 27, 2021 – Aug 29, 2021

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

PATCH 1/1 drm/amdgpu: stop scheduler when calling hw_fini

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise the ring will not be empty before suspend.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +6 -0
index b439eb7d4177..d6e429e63604 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,9 @@ void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev)
 		if (!ring || !ring->fence_drv.initialized)
 			continue;
 
+		if (!ring->no_scheduler)
+			drm_sched_start(&ring->sched, false);
+
 		/* 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
#1 lore raw

In general that looks good to me, but what could be is that we now try to stop/start the scheduler during reset twice.

Andrey what do you think?

Christian.

Am 27.08.21 um 12:40 schrieb Guchun Chen:

Quoted 34 lines

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise the ring will not be empty before suspend.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +6 -0
index b439eb7d4177..d6e429e63604 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,9 @@ void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev)
  		if (!ring || !ring->fence_drv.initialized)
  			continue;
 
+		if (!ring->no_scheduler)
+			drm_sched_start(&ring->sched, false);
+
  		/* enable the interrupt */
  		if (ring->fence_drv.irq_src)
  			amdgpu_irq_get(adev, ring->fence_drv.irq_src,
#2 lore raw

I don't think it will start/stop twice because amdgpu_fence_driver_hw_fini/inint is not called during reset.

I am worried about calling drm_sched_start without calling drm_sched_resubmit_job first since that the place where the jobs are actually restarted. Also calling drm_sched_start with false flag  wrong here since it skips all the pending list handling.

Andrey

Quoted 42 lines · Christian König

In general that looks good to me, but what could be is that we now try to stop/start the scheduler during reset twice.

Andrey what do you think?

Christian.

Am 27.08.21 um 12:40 schrieb Guchun Chen:

Quoted 34 lines

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise the ring will not be empty before suspend.

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

  1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2 -0
index b439eb7d4177..d6e429e63604 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 +2 -0
@@ -611,6 +614,9 @@ void amdgpu_fence_driver_hw_init(struct 
 amdgpu_device *adev)
           if (!ring || !ring->fence_drv.initialized)
               continue;
   +        if (!ring->no_scheduler)
+            drm_sched_start(&ring->sched, false);
+
           /* enable the interrupt */
           if (ring->fence_drv.irq_src)

              amdgpu_irq_get(adev, ring->fence_drv.irq_src,

#3 lore raw

[Public]

Hi Andrey and Christian,

Thanks for your comment, I will send out a new patch set later on after I verify it.

Regards,
Guchun

-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Saturday, August 28, 2021 2:28 AM
To: Koenig, Christian <[email protected]>; Chen, Guchun <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: stop scheduler when calling hw_fini

I don't think it will start/stop twice because amdgpu_fence_driver_hw_fini/inint is not called during reset.

I am worried about calling drm_sched_start without calling drm_sched_resubmit_job first since that the place where the jobs are actually restarted. Also calling drm_sched_start with false flag  wrong here since it skips all the pending list handling.

Andrey

Quoted 44 lines · Christian König

In general that looks good to me, but what could be is that we now try to stop/start the scheduler during reset twice.

Andrey what do you think?

Christian.

Am 27.08.21 um 12:40 schrieb Guchun Chen:

Quoted 35 lines

This gurantees no more work on the ring can be submitted to hardware in suspend/resume case, otherwise the ring will not be empty before suspend.

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

  1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2 -0
index b439eb7d4177..d6e429e63604 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,9 @@ void amdgpu_fence_driver_hw_init(struct
amdgpu_device *adev)
          if (!ring || !ring->fence_drv.initialized) continue;
  +        if (!ring->no_scheduler)
+            drm_sched_start(&ring->sched, false);
+
          /* enable the interrupt */
          if (ring->fence_drv.irq_src) amdgpu_irq_get(adev, ring->fence_drv.irq_src,