Skip to content

Commit d9407ff

Browse files
brettcreeleykuba-moo
authored andcommitted
pds_core: Prevent health thread from running during reset/remove
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 <[email protected]> Reviewed-by: Shannon Nelson <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4d322dc commit d9407ff

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
@@ -293,7 +293,7 @@ static int pdsc_init_pf(struct pdsc *pdsc)
293293
err_out_teardown:
294294
pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING);
295295
err_out_unmap_bars:
296-
del_timer_sync(&pdsc->wdtimer);
296+
timer_shutdown_sync(&pdsc->wdtimer);
297297
if (pdsc->wq)
298298
destroy_workqueue(pdsc->wq);
299299
mutex_destroy(&pdsc->config_lock);
@@ -420,7 +420,7 @@ static void pdsc_remove(struct pci_dev *pdev)
420420
*/
421421
pdsc_sriov_configure(pdev, 0);
422422

423-
del_timer_sync(&pdsc->wdtimer);
423+
timer_shutdown_sync(&pdsc->wdtimer);
424424
if (pdsc->wq)
425425
destroy_workqueue(pdsc->wq);
426426

@@ -445,10 +445,24 @@ static void pdsc_remove(struct pci_dev *pdev)
445445
devlink_free(dl);
446446
}
447447

448+
static void pdsc_stop_health_thread(struct pdsc *pdsc)
449+
{
450+
timer_shutdown_sync(&pdsc->wdtimer);
451+
if (pdsc->health_work.func)
452+
cancel_work_sync(&pdsc->health_work);
453+
}
454+
455+
static void pdsc_restart_health_thread(struct pdsc *pdsc)
456+
{
457+
timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0);
458+
mod_timer(&pdsc->wdtimer, jiffies + 1);
459+
}
460+
448461
void pdsc_reset_prepare(struct pci_dev *pdev)
449462
{
450463
struct pdsc *pdsc = pci_get_drvdata(pdev);
451464

465+
pdsc_stop_health_thread(pdsc);
452466
pdsc_fw_down(pdsc);
453467

454468
pci_free_irq_vectors(pdev);
@@ -486,6 +500,7 @@ void pdsc_reset_done(struct pci_dev *pdev)
486500
}
487501

488502
pdsc_fw_up(pdsc);
503+
pdsc_restart_health_thread(pdsc);
489504
}
490505

491506
static const struct pci_error_handlers pdsc_err_handler = {

0 commit comments

Comments
 (0)