Netdev List
 help / color / mirror / Atom feed
* [PATCH net v3] pds_core: keep the health thread stopped during reset
@ 2026-07-27 16:45 Nikhil P. Rao
  2026-07-29 22:53 ` Jacob Keller
  2026-07-31  0:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Nikhil P. Rao @ 2026-07-27 16:45 UTC (permalink / raw)
  To: netdev
  Cc: kuba, brett.creeley, eric.joyner, andrew+netdev, davem, edumazet,
	pabeni, jacob.e.keller, 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 and the workqueue is destroyed.

Use disable_work_sync() to cancel health_work and block further
queue_work() on it, and enable_work() in pdsc_restart_health_thread() to
re-allow it after the reset.

disable_work_sync() keeps a disable depth, so every disable must be
matched by one enable. pdsc_reset_prepare() stops the health thread and
pdsc_reset_done() restarts it. On the AER path pdsc_pci_error_detected()
calls pdsc_reset_prepare(), then pdsc_pci_error_resume() re-inits via
pci_reset_function_locked() (pds_core has no .slot_reset handler), which
runs the pair again - stopping the thread twice but restarting it once.
Gate the disable and enable on a health_stopped flag so each fires at
most once per stopped/running transition.

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.h |  1 +
 drivers/net/ethernet/amd/pds_core/main.c | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

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 8d94a4d70395..71a1d4b001c2 100644
--- a/drivers/net/ethernet/amd/pds_core/main.c
+++ b/drivers/net/ethernet/amd/pds_core/main.c
@@ -470,8 +470,10 @@ static void pdsc_stop_health_thread(struct pdsc *pdsc)
 		return;
 
 	timer_shutdown_sync(&pdsc->wdtimer);
-	if (pdsc->health_work.func)
-		cancel_work_sync(&pdsc->health_work);
+	if (pdsc->health_work.func && !pdsc->health_stopped) {
+		disable_work_sync(&pdsc->health_work);
+		pdsc->health_stopped = true;
+	}
 }
 
 static void pdsc_restart_health_thread(struct pdsc *pdsc)
@@ -479,6 +481,10 @@ static void pdsc_restart_health_thread(struct pdsc *pdsc)
 	if (pdsc->pdev->is_virtfn)
 		return;
 
+	if (pdsc->health_stopped) {
+		enable_work(&pdsc->health_work);
+		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] 3+ messages in thread

* Re: [PATCH net v3] pds_core: keep the health thread stopped during reset
  2026-07-27 16:45 [PATCH net v3] pds_core: keep the health thread stopped during reset Nikhil P. Rao
@ 2026-07-29 22:53 ` Jacob Keller
  2026-07-31  0:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2026-07-29 22:53 UTC (permalink / raw)
  To: Nikhil P. Rao, netdev
  Cc: kuba, brett.creeley, eric.joyner, andrew+netdev, davem, edumazet,
	pabeni

On 7/27/2026 9:45 AM, 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().
> 
> Only the reset path is affected: on remove PDSC_S_STOPPING_DRIVER gates
> the health thread and the workqueue is destroyed.
> 
> Use disable_work_sync() to cancel health_work and block further
> queue_work() on it, and enable_work() in pdsc_restart_health_thread() to
> re-allow it after the reset.
> 
> disable_work_sync() keeps a disable depth, so every disable must be
> matched by one enable. pdsc_reset_prepare() stops the health thread and
> pdsc_reset_done() restarts it. On the AER path pdsc_pci_error_detected()
> calls pdsc_reset_prepare(), then pdsc_pci_error_resume() re-inits via
> pci_reset_function_locked() (pds_core has no .slot_reset handler), which
> runs the pair again - stopping the thread twice but restarting it once.
> Gate the disable and enable on a health_stopped flag so each fires at
> most once per stopped/running transition.
> 
> 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>
> ---

This version looks good and has no complaints from Sashiko. Might be
nice to include a changelog, from what I can tell v3 includes the
health_stopped flag now to avoid issues with double-enable? Makes sense.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  drivers/net/ethernet/amd/pds_core/core.h |  1 +
>  drivers/net/ethernet/amd/pds_core/main.c | 10 ++++++++--
>  2 files changed, 9 insertions(+), 2 deletions(-)
> 
> 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 8d94a4d70395..71a1d4b001c2 100644
> --- a/drivers/net/ethernet/amd/pds_core/main.c
> +++ b/drivers/net/ethernet/amd/pds_core/main.c
> @@ -470,8 +470,10 @@ static void pdsc_stop_health_thread(struct pdsc *pdsc)
>  		return;
>  
>  	timer_shutdown_sync(&pdsc->wdtimer);
> -	if (pdsc->health_work.func)
> -		cancel_work_sync(&pdsc->health_work);
> +	if (pdsc->health_work.func && !pdsc->health_stopped) {
> +		disable_work_sync(&pdsc->health_work);
> +		pdsc->health_stopped = true;
> +	}
>  }
>  
>  static void pdsc_restart_health_thread(struct pdsc *pdsc)
> @@ -479,6 +481,10 @@ static void pdsc_restart_health_thread(struct pdsc *pdsc)
>  	if (pdsc->pdev->is_virtfn)
>  		return;
>  
> +	if (pdsc->health_stopped) {
> +		enable_work(&pdsc->health_work);
> +		pdsc->health_stopped = false;
> +	}
>  	timer_setup(&pdsc->wdtimer, pdsc_wdtimer_cb, 0);
>  	mod_timer(&pdsc->wdtimer, jiffies + 1);
>  }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v3] pds_core: keep the health thread stopped during reset
  2026-07-27 16:45 [PATCH net v3] pds_core: keep the health thread stopped during reset Nikhil P. Rao
  2026-07-29 22:53 ` Jacob Keller
@ 2026-07-31  0:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-31  0:00 UTC (permalink / raw)
  To: Nikhil P. Rao
  Cc: netdev, kuba, brett.creeley, eric.joyner, andrew+netdev, davem,
	edumazet, pabeni, jacob.e.keller

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 27 Jul 2026 16:45:48 +0000 you 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().
> 
> Only the reset path is affected: on remove PDSC_S_STOPPING_DRIVER gates
> the health thread and the workqueue is destroyed.
> 
> [...]

Here is the summary with links:
  - [net,v3] pds_core: keep the health thread stopped during reset
    https://git.kernel.org/netdev/net/c/cd09971dcc1c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-31  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 16:45 [PATCH net v3] pds_core: keep the health thread stopped during reset Nikhil P. Rao
2026-07-29 22:53 ` Jacob Keller
2026-07-31  0:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox