Skip to content

Commit bd87409

Browse files
brettcreeleygregkh
authored andcommitted
pds_core: Prevent health thread from running during reset/remove
[ Upstream commit d9407ff ] The PCIe reset handlers can run at the same time as the health thread. This can cause the health thread to stomp on the PCIe reset. Fix this by preventing the health thread from running while a PCIe reset is happening. As part of this use timer_shutdown_sync() during reset and remove to make sure the timer doesn't ever get rearmed. Fixes: ffa5585 ("pds_core: implement pci reset handlers") Signed-off-by: Brett Creeley <brett.creeley@amd.com> Reviewed-by: Shannon Nelson <shannon.nelson@amd.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Link: https://lore.kernel.org/r/20240129234035.69802-2-brett.creeley@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7110e98 commit bd87409

File tree

1 file changed

+17
-2
lines changed
  • drivers/net/ethernet/amd/pds_core

1 file changed

+17
-2
lines changed

drivers/net/ethernet/amd/pds_core/main.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static int pdsc_init_pf(struct pdsc *pdsc)
298298
err_out_teardown:
299299
pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING);
300300
err_out_unmap_bars:
301-
del_timer_sync(&pdsc->wdtimer);
301+
timer_shutdown_sync(&pdsc->wdtimer);
302302
if (pdsc->wq)
303303
destroy_workqueue(pdsc->wq);
304304
mutex_destroy(&pdsc->config_lock);
@@ -425,7 +425,7 @@ static void pdsc_remove(struct pci_dev *pdev)
425425
*/
426426
pdsc_sriov_configure(pdev, 0);
427427

428-
del_timer_sync(&pdsc->wdtimer);
428+
timer_shutdown_sync(&pdsc->wdtimer);
429429
if (pdsc->wq)
430430
destroy_workqueue(pdsc->wq);
431431

@@ -449,10 +449,24 @@ static void pdsc_remove(struct pci_dev *pdev)
449449
devlink_free(dl);
450450
}
451451

452+
static void pdsc_stop_health_thread(struct pdsc *pdsc)
453+
{
454+
timer_shutdown_sync(&pdsc->wdtimer);
455+
if (pdsc->health_work.func)
456+
cancel_work_sync(&pdsc->health_work);
457+
}
458+
459+
static void pdsc_restart_health_thread(struct pdsc *pdsc)
460+
{
461+
timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0);
462+
mod_timer(&pdsc->wdtimer, jiffies + 1);
463+
}
464+
452465
static void pdsc_reset_prepare(struct pci_dev *pdev)
453466
{
454467
struct pdsc *pdsc = pci_get_drvdata(pdev);
455468

469+
pdsc_stop_health_thread(pdsc);
456470
pdsc_fw_down(pdsc);
457471

458472
pdsc_unmap_bars(pdsc);
@@ -489,6 +503,7 @@ static void pdsc_reset_done(struct pci_dev *pdev)
489503
}
490504

491505
pdsc_fw_up(pdsc);
506+
pdsc_restart_health_thread(pdsc);
492507
}
493508

494509
static const struct pci_error_handlers pdsc_err_handler = {

0 commit comments

Comments
 (0)