* [PATCH net] pds_core: keep the health thread stopped during reset
@ 2026-07-21 16:21 Nikhil P. Rao
2026-07-21 19:54 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Nikhil P. Rao @ 2026-07-21 16:21 UTC (permalink / raw)
To: netdev
Cc: kuba, brett.creeley, eric.joyner, andrew+netdev, davem, edumazet,
pabeni, Nikhil P. Rao
Commit d9407ff11809 ("pds_core: Prevent health thread from running
during reset/remove") stops the health thread with cancel_work_sync()
before a reset, but a devcmd timeout during pdsc_fw_down() re-queues
health_work, so pdsc_health_thread() runs again mid-reset and double
allocates the core DMA queues via pdsc_fw_up().
Only the reset path is affected. On remove, PDSC_S_STOPPING_DRIVER gates
the health thread.
Track the health thread's stopped state so a work item queued after the
cancel bails out.
Fixes: d9407ff11809 ("pds_core: Prevent health thread from running during reset/remove")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260629200358.2626129-1-nikhil.rao%40amd.com?part=2
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
---
drivers/net/ethernet/amd/pds_core/core.c | 3 +++
drivers/net/ethernet/amd/pds_core/core.h | 1 +
drivers/net/ethernet/amd/pds_core/main.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
index 38a2446571af..c4cba7194da0 100644
--- a/drivers/net/ethernet/amd/pds_core/core.c
+++ b/drivers/net/ethernet/amd/pds_core/core.c
@@ -635,6 +635,9 @@ void pdsc_health_thread(struct work_struct *work)
unsigned long mask;
bool healthy;
+ if (READ_ONCE(pdsc->health_stopped))
+ return;
+
mutex_lock(&pdsc->config_lock);
/* Don't do a check when in a transition state */
diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h
index b7fe9ad73349..a1d41329209f 100644
--- a/drivers/net/ethernet/amd/pds_core/core.h
+++ b/drivers/net/ethernet/amd/pds_core/core.h
@@ -171,6 +171,7 @@ struct pdsc {
struct timer_list wdtimer;
unsigned int wdtimer_period;
struct work_struct health_work;
+ bool health_stopped;
struct devlink_health_reporter *fw_reporter;
u32 fw_recoveries;
diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c
index 22db78343eb0..32e1d7069969 100644
--- a/drivers/net/ethernet/amd/pds_core/main.c
+++ b/drivers/net/ethernet/amd/pds_core/main.c
@@ -463,6 +463,7 @@ static void pdsc_stop_health_thread(struct pdsc *pdsc)
if (pdsc->pdev->is_virtfn)
return;
+ WRITE_ONCE(pdsc->health_stopped, true);
timer_shutdown_sync(&pdsc->wdtimer);
if (pdsc->health_work.func)
cancel_work_sync(&pdsc->health_work);
@@ -473,6 +474,7 @@ static void pdsc_restart_health_thread(struct pdsc *pdsc)
if (pdsc->pdev->is_virtfn)
return;
+ WRITE_ONCE(pdsc->health_stopped, false);
timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0);
mod_timer(&pdsc->wdtimer, jiffies + 1);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] pds_core: keep the health thread stopped during reset
2026-07-21 16:21 [PATCH net] pds_core: keep the health thread stopped during reset Nikhil P. Rao
@ 2026-07-21 19:54 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-07-21 19:54 UTC (permalink / raw)
To: Nikhil P. Rao
Cc: netdev, brett.creeley, eric.joyner, andrew+netdev, davem,
edumazet, pabeni
On Tue, 21 Jul 2026 16:21:41 +0000 Nikhil P. Rao wrote:
> Commit d9407ff11809 ("pds_core: Prevent health thread from running
> during reset/remove") stops the health thread with cancel_work_sync()
> before a reset, but a devcmd timeout during pdsc_fw_down() re-queues
> health_work, so pdsc_health_thread() runs again mid-reset and double
> allocates the core DMA queues via pdsc_fw_up().
Would using disable_work instead of cancel_work fix this without
the extra state? The patch reads a bit racy, IIUC the cancel work
can't be trusted, which in turn puts in question calling it in the
first place.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-21 19:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 16:21 [PATCH net] pds_core: keep the health thread stopped during reset Nikhil P. Rao
2026-07-21 19:54 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox