Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2] pds_core: keep the health thread stopped during reset
@ 2026-07-22  0:16 Nikhil P. Rao
  2026-07-22 20:03 ` Jacob Keller
  2026-07-23 14:17 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Nikhil P. Rao @ 2026-07-22  0:16 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.

Use disable_work_sync() instead, it cancels the pending work and
disables the item, so the pdsc_fw_down() re-queue becomes a no-op.
pdsc_restart_health_thread() re-enables it with enable_work().

Fixes: d9407ff11809 ("pds_core: Prevent health thread from running during reset/remove")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
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/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c
index 22db78343eb0..3e34350b169b 100644
--- a/drivers/net/ethernet/amd/pds_core/main.c
+++ b/drivers/net/ethernet/amd/pds_core/main.c
@@ -465,7 +465,7 @@ static void pdsc_stop_health_thread(struct pdsc *pdsc)
 
 	timer_shutdown_sync(&pdsc->wdtimer);
 	if (pdsc->health_work.func)
-		cancel_work_sync(&pdsc->health_work);
+		disable_work_sync(&pdsc->health_work);
 }
 
 static void pdsc_restart_health_thread(struct pdsc *pdsc)
@@ -473,6 +473,7 @@ static void pdsc_restart_health_thread(struct pdsc *pdsc)
 	if (pdsc->pdev->is_virtfn)
 		return;
 
+	enable_work(&pdsc->health_work);
 	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 v2] pds_core: keep the health thread stopped during reset
  2026-07-22  0:16 [PATCH net v2] pds_core: keep the health thread stopped during reset Nikhil P. Rao
@ 2026-07-22 20:03 ` Jacob Keller
  2026-07-23 14:17 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2026-07-22 20:03 UTC (permalink / raw)
  To: Nikhil P. Rao, netdev
  Cc: kuba, brett.creeley, eric.joyner, andrew+netdev, davem, edumazet,
	pabeni

On 7/21/2026 5:16 PM, 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.
> 
> Use disable_work_sync() instead, it cancels the pending work and
> disables the item, so the pdsc_fw_down() re-queue becomes a no-op.
> pdsc_restart_health_thread() re-enables it with enable_work().
> 
> Fixes: d9407ff11809 ("pds_core: Prevent health thread from running during reset/remove")
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> 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>
> ---

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

>  drivers/net/ethernet/amd/pds_core/main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c
> index 22db78343eb0..3e34350b169b 100644
> --- a/drivers/net/ethernet/amd/pds_core/main.c
> +++ b/drivers/net/ethernet/amd/pds_core/main.c
> @@ -465,7 +465,7 @@ static void pdsc_stop_health_thread(struct pdsc *pdsc)
>  
>  	timer_shutdown_sync(&pdsc->wdtimer);
>  	if (pdsc->health_work.func)
> -		cancel_work_sync(&pdsc->health_work);
> +		disable_work_sync(&pdsc->health_work);
>  }
>  
>  static void pdsc_restart_health_thread(struct pdsc *pdsc)
> @@ -473,6 +473,7 @@ static void pdsc_restart_health_thread(struct pdsc *pdsc)
>  	if (pdsc->pdev->is_virtfn)
>  		return;
>  
> +	enable_work(&pdsc->health_work);
>  	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 v2] pds_core: keep the health thread stopped during reset
  2026-07-22  0:16 [PATCH net v2] pds_core: keep the health thread stopped during reset Nikhil P. Rao
  2026-07-22 20:03 ` Jacob Keller
@ 2026-07-23 14:17 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-07-23 14:17 UTC (permalink / raw)
  To: nikhil.rao
  Cc: Jakub Kicinski, netdev, brett.creeley, eric.joyner, andrew+netdev,
	davem, edumazet, pabeni

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
--- Patch [1]: [PATCH net v2] pds_core: keep the health thread stopped during reset ---
commit 253bc338bd6e7dd7e1be6b7664ab1b26f176624e
Author: Nikhil P. Rao <nikhil.rao@amd.com>

pds_core: keep the health thread stopped during reset

This commit replaces cancel_work_sync() with disable_work_sync() for the
health thread to ensure it doesn't get re-queued by a timeout during reset.
It then restarts the thread using enable_work().

Link: https://sashiko.dev/#/patchset/20260629200358.2626129-1-nikhil.rao%40amd.com?part=2

> diff --git a/drivers/net/ethernet/amd/pds_core/main.c b/drivers/net/ethernet/amd/pds_core/main.c
> index 8d94a4d70395e..ccb8aa7b95f7e 100644
> --- a/drivers/net/ethernet/amd/pds_core/main.c
> +++ b/drivers/net/ethernet/amd/pds_core/main.c
> @@ -471,7 +471,7 @@ static void pdsc_stop_health_thread(struct pdsc *pdsc)
>  
>  	timer_shutdown_sync(&pdsc->wdtimer);
>  	if (pdsc->health_work.func)
> -		cancel_work_sync(&pdsc->health_work);
> +		disable_work_sync(&pdsc->health_work);

[Severity: High]
Could this lead to an unbalanced disable count during an Advanced Error
Reporting (AER) reset?

Unlike cancel_work_sync(), disable_work_sync() increments a depth counter.
During an AER fatal error, pdsc_pci_error_detected() manually invokes
pdsc_reset_prepare(), which calls pdsc_stop_health_thread(), setting the
disable count to 1.

Later, the AER resume path in pdsc_pci_error_resume() calls
pci_reset_function_locked(), which internally calls the driver's
.reset_prepare callback a second time:

drivers/pci/pci.c:pci_reset_function_locked() {
	pci_dev_save_and_disable(dev);
	rc = __pci_reset_function_locked(dev);
	pci_dev_restore(dev);
}

Because pci_dev_save_and_disable() invokes the driver's .reset_prepare,
the disable count increments to 2. However, pci_dev_restore() only triggers
.reset_done once, which means enable_work() is only called once.

Will this leave the health work item permanently disabled (with a count of 1),
preventing the driver from monitoring firmware health or triggering future
recoveries?
-- 
pw-bot: cr

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

end of thread, other threads:[~2026-07-23 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22  0:16 [PATCH net v2] pds_core: keep the health thread stopped during reset Nikhil P. Rao
2026-07-22 20:03 ` Jacob Keller
2026-07-23 14:17 ` Jakub Kicinski

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