[net-next,v5,04/19] xsk: freeze deferred pool teardown during system sleep

Message ID 20260927-submit-stmmac-reset-fixes-v1-v5-4-feec6c14dd06@gmail.com (mailing list archive)
State New
Headers
Series net: stmmac: preserve datapath state across MTU and resume failures |

Commit Message

James Hilliard Sept. 27, 2026, 9:59 p.m. UTC
Pool destruction calls the driver under RTNL from system_wq. That queue
is not frozen during system sleep, so ndo_bpf() can run after the device
suspend callback has gated its clocks or after the noirq phase.

Use the freezable workqueue for deferred pool release. Work already
running completes before device suspend, and newly queued destruction
waits until device resume. The pool, UMEM and netdev references remain
owned by the work until then. This does not replace driver error
handling after a failed resume.

Fixes: 1c1efc2af158 ("xsk: Create and free buffer pool independently from umem")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 net/xdp/xsk_buff_pool.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Björn Töpel Sept. 28, 2026, 12:16 p.m. UTC | #1
James Hilliard <james.hilliard1@gmail.com> writes:

> Pool destruction calls the driver under RTNL from system_wq. That queue
> is not frozen during system sleep, so ndo_bpf() can run after the device
> suspend callback has gated its clocks or after the noirq phase.
>
> Use the freezable workqueue for deferred pool release. Work already
> running completes before device suspend, and newly queued destruction
> waits until device resume. The pool, UMEM and netdev references remain
> owned by the work until then. This does not replace driver error
> handling after a failed resume.
>
> Fixes: 1c1efc2af158 ("xsk: Create and free buffer pool independently from umem")
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>

This fix should go as a separate net fix for AF_XDP (potentially paired
with a minimal stmac-fix).

> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index 9d2d94f1fb75..c58f56f24a9c 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -337,7 +337,10 @@ bool xp_put_pool(struct xsk_buff_pool *pool)
>  
>  	if (refcount_dec_and_test(&pool->users)) {
>  		INIT_WORK(&pool->work, xp_release_deferred);
> -		schedule_work(&pool->work);
> +		/* Teardown calls ndo_bpf(), which may need powered hardware.
> +		 * RTNL alone does not exclude the device's system PM callbacks.
> +		 */

Remove the comment, please. The commit message is enough in this case.


Björn
  

Patch

diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 9d2d94f1fb75..c58f56f24a9c 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -337,7 +337,10 @@  bool xp_put_pool(struct xsk_buff_pool *pool)
 
 	if (refcount_dec_and_test(&pool->users)) {
 		INIT_WORK(&pool->work, xp_release_deferred);
-		schedule_work(&pool->work);
+		/* Teardown calls ndo_bpf(), which may need powered hardware.
+		 * RTNL alone does not exclude the device's system PM callbacks.
+		 */
+		queue_work(system_freezable_wq, &pool->work);
 		return true;
 	}