Skip to contentSkip to conversation

drm/amdgpu/vcn: drop extra cancel_delayed_work_sync()

PATCH In review Alex Deucher 5 participants 6 messages Aug 13, 2025 – Aug 21, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu/vcn: drop extra cancel_delayed_work_sync()

We already call this in the hw_fini() methods for all VCN instances, so no need to call it again in amdgpu_vcn_suspend().

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0 -2
index 9a76e11d1c184..fd8ebf4b5a824 100644
@@ -357,8 +357,6 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev, int i)
 	if (adev->vcn.harvest_config & (1 << i))
 		return 0;
 
-	cancel_delayed_work_sync(&adev->vcn.inst[i].idle_work);
-
 	/* err_event_athub and dpc recovery will corrupt VCPU buffer, so we need to
 	 * restore fw data and clear buffer in amdgpu_vcn_resume() */
 	if (in_ras_intr || adev->pcie_reset_ctx.in_link_reset)
Signature · 1 line
2.50.1
#1 lore raw

Ping?

Quoted 26 lines · Alex Deucher

We already call this in the hw_fini() methods for all VCN instances, so no need to call it again in amdgpu_vcn_suspend().

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0 -3
index 9a76e11d1c184..fd8ebf4b5a824 100644
@@ -357,8 +357,6 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev, int i)
        if (adev->vcn.harvest_config & (1 << i))
                return 0;
 
-       cancel_delayed_work_sync(&adev->vcn.inst[i].idle_work);
-
        /* err_event_athub and dpc recovery will corrupt VCPU buffer, so we need to
         * restore fw data and clear buffer in amdgpu_vcn_resume() */
        if (in_ras_intr || adev->pcie_reset_ctx.in_link_reset)
--

2.50.1

#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

one thing I noticed:
amdgpu_vcn_suspend() also gets called in vcn_v2_5_sw_fini() for example where there isn't cancel_delayed_work_sync() call. Does the removal work in this case?

David
On 8/20/2025 2:36 PM, Alex Deucher wrote:

Ping?

On Wed, Aug 13, 2025 at 3:37 PM Alex Deucher <[email protected]><mailto:[email protected]> wrote:

We already call this in the hw_fini() methods for all VCN instances, so no need to call it again in amdgpu_vcn_suspend().

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0 -2
index 9a76e11d1c184..fd8ebf4b5a824 100644
@@ -357,8 +357,6 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev, int i)
        if (adev->vcn.harvest_config & (1 << i))
                return 0;
 
-       cancel_delayed_work_sync(&adev->vcn.inst[i].idle_work);
-
        /* err_event_athub and dpc recovery will corrupt VCPU buffer, so we need to
         * restore fw data and clear buffer in amdgpu_vcn_resume() */
        if (in_ras_intr || adev->pcie_reset_ctx.in_link_reset)

--
2.50.1

#3 lore raw
Quoted 7 lines · David

[AMD Official Use Only - AMD Internal Distribution Only]

one thing I noticed:
amdgpu_vcn_suspend() also gets called in vcn_v2_5_sw_fini() for example where there isn't cancel_delayed_work_sync() call. Does the removal work in this case?

The sw callbacks are not supposed to touch any hardware, so that's wrong to begin with. That said, this should never end up doing anything because we've already cancelled the delayed worker in hw_fini and after hw_fini the hw is stopped so no work should be outstanding.

Alex

Quoted 34 lines

David
On 8/20/2025 2:36 PM, Alex Deucher wrote:

Ping?

On Wed, Aug 13, 2025 at 3:37 PM Alex Deucher <[email protected]> wrote:

We already call this in the hw_fini() methods for all VCN instances, so no need to call it again in amdgpu_vcn_suspend().

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0 -3
index 9a76e11d1c184..fd8ebf4b5a824 100644
@@ -357,8 +357,6 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev, int i)
        if (adev->vcn.harvest_config & (1 << i))
                return 0;
 
-       cancel_delayed_work_sync(&adev->vcn.inst[i].idle_work);
-
        /* err_event_athub and dpc recovery will corrupt VCPU buffer, so we need to
         * restore fw data and clear buffer in amdgpu_vcn_resume() */
        if (in_ras_intr || adev->pcie_reset_ctx.in_link_reset)
--

2.50.1

Tested-by David (Ming Qiang) Wu
#4 lore raw

Did some tests with the sw callbacks which were called with rmmod. It will fail if there are jobs, otherwise no need to cancel delayed work as there is not any outstanding work and idle handler called or not did not affect the removal of the module. insmod continues to work after that. The case for hw_fini works as expected.

Thanks,

David

Quoted 47 lines · Alex Deucher
Quoted 6 lines · David

[AMD Official Use Only - AMD Internal Distribution Only]

one thing I noticed:
amdgpu_vcn_suspend() also gets called in vcn_v2_5_sw_fini() for example where there isn't cancel_delayed_work_sync() call. Does the removal work in this case?

The sw callbacks are not supposed to touch any hardware, so that's wrong to begin with. That said, this should never end up doing anything because we've already cancelled the delayed worker in hw_fini and after hw_fini the hw is stopped so no work should be outstanding.

Alex

Quoted 33 lines

David
On 8/20/2025 2:36 PM, Alex Deucher wrote:

Ping?

On Wed, Aug 13, 2025 at 3:37 PM Alex Deucher<[email protected]> wrote:

We already call this in the hw_fini() methods for all VCN instances, so no need to call it again in amdgpu_vcn_suspend().

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0 -3
index 9a76e11d1c184..fd8ebf4b5a824 100644
@@ -357,8 +357,6 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev, int i)
         if (adev->vcn.harvest_config & (1 << i))
                 return 0;
 
-       cancel_delayed_work_sync(&adev->vcn.inst[i].idle_work);
-
         /* err_event_athub and dpc recovery will corrupt VCPU buffer, so we need to
          * restore fw data and clear buffer in amdgpu_vcn_resume() */
         if (in_ras_intr || adev->pcie_reset_ctx.in_link_reset)
--

2.50.1

Reviewed-by on v1 1/1
#5 lore raw
In reply to Alex Deucher

[AMD Official Use Only - AMD Internal Distribution Only]

Looks reasonable to me, the patch is:

Quoted 34 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: August 13, 2025 3:37 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu/vcn: drop extra cancel_delayed_work_sync()

We already call this in the hw_fini() methods for all VCN instances, so no need to call it again in amdgpu_vcn_suspend().

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0 -2
index 9a76e11d1c184..fd8ebf4b5a824 100644
@@ -357,8 +357,6 @@ int amdgpu_vcn_suspend(struct amdgpu_device
 *adev, int i)
      if (adev->vcn.harvest_config & (1 << i))
              return 0;
 
-     cancel_delayed_work_sync(&adev->vcn.inst[i].idle_work);
-
      /* err_event_athub and dpc recovery will corrupt VCPU buffer, so we

need to
* restore fw data and clear buffer in amdgpu_vcn_resume() */
if (in_ras_intr || adev->pcie_reset_ctx.in_link_reset)
--
2.50.1