Skip to contentSkip to conversation

accel/ivpu: Flush pending jobs of device's workqueues

PATCH In review Maciej Falkowski 4 participants 5 messages Apr 1, 2025 – Apr 11, 2025

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

PATCH 1/1 accel/ivpu: Flush pending jobs of device's workqueues

Use flush_work() instead of cancel_work_sync() for driver workqueues to guarantee that remaining pending work will be handled.

Fixes bc3e5f48b7ee ("accel/ivpu: Use workqueue for IRQ handling")
---
 drivers/accel/ivpu/ivpu_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +3 -3
index 4fa73189502e..5e3888ff1022 100644
@@ -421,9 +421,9 @@ void ivpu_prepare_for_reset(struct ivpu_device *vdev)
 {
 	ivpu_hw_irq_disable(vdev);
 	disable_irq(vdev->irq);
-	cancel_work_sync(&vdev->irq_ipc_work);
-	cancel_work_sync(&vdev->irq_dct_work);
-	cancel_work_sync(&vdev->context_abort_work);
+	flush_work(&vdev->irq_ipc_work);
+	flush_work(&vdev->irq_dct_work);
+	flush_work(&vdev->context_abort_work);
 	ivpu_ipc_disable(vdev);
 	ivpu_mmu_disable(vdev);
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Maciej Falkowski

Use flush_work() instead of cancel_work_sync() for driver workqueues to guarantee that remaining pending work will be handled.

Fixes bc3e5f48b7ee ("accel/ivpu: Use workqueue for IRQ handling")
---
  drivers/accel/ivpu/ivpu_drv.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +0 -0
index 4fa73189502e..5e3888ff1022 100644

drivers/accel/ivpu/ivpu_drv.c void ivpu_prepare_for_reset(struct ivpu_device *vdev) · line 426

Quoted 9 lines
drivers/accel/ivpu/ivpu_drv.c +3 -3
@@ -421,9 +421,9 @@ void ivpu_prepare_for_reset(struct ivpu_device *vdev)
  {
  	ivpu_hw_irq_disable(vdev);
  	disable_irq(vdev->irq);
-	cancel_work_sync(&vdev->irq_ipc_work);
-	cancel_work_sync(&vdev->irq_dct_work);
-	cancel_work_sync(&vdev->context_abort_work);
+	flush_work(&vdev->irq_ipc_work);
+	flush_work(&vdev->irq_dct_work);
+	flush_work(&vdev->context_abort_work);
Quoted 3 lines
drivers/accel/ivpu/ivpu_drv.c +0 -0
  	ivpu_ipc_disable(vdev);
  	ivpu_mmu_disable(vdev);
  }
Reviewed-by on v1 1/1
#2 lore raw
In reply to Maciej Falkowski
Quoted 6 lines · Maciej Falkowski

Use flush_work() instead of cancel_work_sync() for driver workqueues to guarantee that remaining pending work will be handled.

Fixes bc3e5f48b7ee ("accel/ivpu: Use workqueue for IRQ handling")

The fixes tag suggests that this is a bug fix, but the commit text doesn't really tell me why cancel_work_sync() is bad. Does it leave the driver in some incomplete state that prevents later recovery?

Put another way, "why is it necessary for the pending work to be handled?" appears unanswered.

With that

#3 lore raw
Quoted 11 lines · Jeff Hugo
Quoted 6 lines · Maciej Falkowski

Use flush_work() instead of cancel_work_sync() for driver workqueues to guarantee that remaining pending work will be handled.

Fixes bc3e5f48b7ee ("accel/ivpu: Use workqueue for IRQ handling")

The fixes tag suggests that this is a bug fix, but the commit text doesn't really tell me why cancel_work_sync() is bad.  Does it leave the driver in some incomplete state that prevents later recovery?

Put another way, "why is it necessary for the pending work to be handled?" appears unanswered.

You are right, thank you for pointing this out. FYI I will include the following explanation in the patch message:

This will resolve two issues that were encountered where a driver was left in an incomplete state as the bottom-half was canceled:
a) Cancelling context-abort of a job that is still executing and is causing translation faults which is going to cause additional TDRs,
b) Cancelling bottom-half of a DCT (duty-cycle throttling) request which will cause a device to not be adjusted to an external frequency request.

Best regards,
Maciej

Quoted 3 lines

With that

#4 lore raw
In reply to Maciej Falkowski

Applied with updated commit message to drm-misc-fixes

Quoted 27 lines · Maciej Falkowski

Use flush_work() instead of cancel_work_sync() for driver workqueues to guarantee that remaining pending work will be handled.

Fixes bc3e5f48b7ee ("accel/ivpu: Use workqueue for IRQ handling")
---
 drivers/accel/ivpu/ivpu_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +3 -3
index 4fa73189502e..5e3888ff1022 100644
@@ -421,9 +421,9 @@ void ivpu_prepare_for_reset(struct ivpu_device *vdev)
 {
 	ivpu_hw_irq_disable(vdev);
 	disable_irq(vdev->irq);
-	cancel_work_sync(&vdev->irq_ipc_work);
-	cancel_work_sync(&vdev->irq_dct_work);
-	cancel_work_sync(&vdev->context_abort_work);
+	flush_work(&vdev->irq_ipc_work);
+	flush_work(&vdev->irq_dct_work);
+	flush_work(&vdev->context_abort_work);
 	ivpu_ipc_disable(vdev);
 	ivpu_mmu_disable(vdev);
 }