Skip to content

Commit 6013aa8

Browse files
sgruszkajlawryno
authored andcommitted
accel/ivpu: Cancel recovery work
Prevent running recovery_work after device is removed. Fixes: 852be13 ("accel/ivpu: Add PM support") Signed-off-by: Stanislaw Gruszka <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Jacek Lawrynowicz <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4522ad7 commit 6013aa8

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

drivers/accel/ivpu/ivpu_drv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ static void ivpu_dev_fini(struct ivpu_device *vdev)
580580
ivpu_pm_disable(vdev);
581581
ivpu_shutdown(vdev);
582582
ivpu_job_done_thread_fini(vdev);
583+
ivpu_pm_cancel_recovery(vdev);
584+
583585
ivpu_ipc_fini(vdev);
584586
ivpu_fw_fini(vdev);
585587
ivpu_mmu_global_context_fini(vdev);

drivers/accel/ivpu/ivpu_pm.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,18 @@ static int ivpu_resume(struct ivpu_device *vdev)
9898
static void ivpu_pm_recovery_work(struct work_struct *work)
9999
{
100100
struct ivpu_pm_info *pm = container_of(work, struct ivpu_pm_info, recovery_work);
101-
struct ivpu_device *vdev = pm->vdev;
101+
struct ivpu_device *vdev = pm->vdev;
102102
char *evt[2] = {"IVPU_PM_EVENT=IVPU_RECOVER", NULL};
103103
int ret;
104104

105-
ret = pci_reset_function(to_pci_dev(vdev->drm.dev));
106-
if (ret)
105+
retry:
106+
ret = pci_try_reset_function(to_pci_dev(vdev->drm.dev));
107+
if (ret == -EAGAIN && !drm_dev_is_unplugged(&vdev->drm)) {
108+
cond_resched();
109+
goto retry;
110+
}
111+
112+
if (ret && ret != -EAGAIN)
107113
ivpu_err(vdev, "Failed to reset VPU: %d\n", ret);
108114

109115
kobject_uevent_env(&vdev->drm.dev->kobj, KOBJ_CHANGE, evt);
@@ -306,6 +312,11 @@ int ivpu_pm_init(struct ivpu_device *vdev)
306312
return 0;
307313
}
308314

315+
void ivpu_pm_cancel_recovery(struct ivpu_device *vdev)
316+
{
317+
cancel_work_sync(&vdev->pm->recovery_work);
318+
}
319+
309320
void ivpu_pm_enable(struct ivpu_device *vdev)
310321
{
311322
struct device *dev = vdev->drm.dev;

drivers/accel/ivpu/ivpu_pm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct ivpu_pm_info {
2121
int ivpu_pm_init(struct ivpu_device *vdev);
2222
void ivpu_pm_enable(struct ivpu_device *vdev);
2323
void ivpu_pm_disable(struct ivpu_device *vdev);
24+
void ivpu_pm_cancel_recovery(struct ivpu_device *vdev);
2425

2526
int ivpu_pm_suspend_cb(struct device *dev);
2627
int ivpu_pm_resume_cb(struct device *dev);

0 commit comments

Comments
 (0)