Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Maciej Fijalkowski
Thu, 08 Oct 2026 09:02
Re: [PATCH net v2 2/2] net: stmmac: Stop Tx queue when (en|dis)abling XSK pools
Author: Maciej Fijalkowski
Date: Thu, 08 Oct 2026 09:02
Date: Thu, 08 Oct 2026 09:02
96 lines
18551 bytes
18551 bytes
On Mon, Oct 05, 2026 at 09:09:33AM +0200, Kurt Kanzenbach wrote:
> When enabling or disabling XSK pools in parallel to Tx traffic, kernel
> crashes occur. For VLAN tagged frames that happens in stmmac_xmit() ->
> dwmac4_set_vlan_tag() and for normal frames in stmmac_xmit() ->
> dwmac4_set_addr(). Both of these functions access the Tx DMA descriptors.
>
> The XDP pool (en|dis)ablement frees and reallocates the Tx DMA resources:
>
> stmmac_disable_tx_queue:
> __free_dma_tx_desc_resources
>
> stmmac_enable_tx_queue:
> __alloc_dma_tx_desc_resources
> __init_dma_tx_desc_rings
>
> NAPI is disabled during that allocation window, but the Tx queue is not
> stopped. Therefore, add the stopping of the Tx queue during the enabling
> and disabling of XSK pools. Update trans_start when stopping the queue
> to avoid spurious watchdog timeouts.
>
> The issue can be easily reproduced by:
>
> 1. Run iperf
> 2. Run application which opens an AF_XDP/ZC socket
>
> Fixes: 132c32ee5bc0 ("net: stmmac: Add TX via XDP zero-copy socket")
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
> index d7e4db7224b0..883bd3fe8089 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
> @@ -6,6 +6,16 @@
> #include "stmmac.h"
> #include "stmmac_xdp.h"
>
> +static void stmmac_xdp_stop_tx_queue(struct stmmac_priv *priv, u16 queue)
> +{
> + struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue);
> +
> + __netif_tx_lock_bh(nq);
> + txq_trans_cond_update(nq);
> + netif_tx_stop_queue(nq);
> + __netif_tx_unlock_bh(nq);
> +}
> +
> static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,
> struct xsk_buff_pool *pool, u16 queue)
> {
> @@ -36,6 +46,7 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,
> if (need_update) {
> napi_disable(&ch->rx_napi);
> napi_disable(&ch->tx_napi);
> + stmmac_xdp_stop_tx_queue(priv, queue);
FWIW you can look at what I did at ice driver (ice_qp_dis()) where I used
a bigger hammer here; I think updating trans_start is kinda a workaround.
https://lore.kernel.org/netdev/20240708221416.625850-1-anthony.l.nguyen@intel.com/
> stmmac_disable_rx_queue(priv, queue);
> stmmac_disable_tx_queue(priv, queue);
> }
> @@ -46,6 +57,7 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,
> stmmac_enable_rx_queue(priv, queue);
> stmmac_enable_tx_queue(priv, queue);
> napi_enable(&ch->rxtx_napi);
> + netif_tx_wake_queue(netdev_get_tx_queue(priv->dev, queue));
>
> err = stmmac_xsk_wakeup(priv->dev, queue, XDP_WAKEUP_RX);
> if (err)
> @@ -73,6 +85,7 @@ static int stmmac_xdp_disable_pool(struct stmmac_priv *priv, u16 queue)
>
> if (need_update) {
> napi_disable(&ch->rxtx_napi);
> + stmmac_xdp_stop_tx_queue(priv, queue);
> stmmac_disable_rx_queue(priv, queue);
> stmmac_disable_tx_queue(priv, queue);
> synchronize_rcu();
> @@ -87,6 +100,7 @@ static int stmmac_xdp_disable_pool(struct stmmac_priv *priv, u16 queue)
> stmmac_enable_tx_queue(priv, queue);
> napi_enable(&ch->rx_napi);
> napi_enable(&ch->tx_napi);
> + netif_tx_wake_queue(netdev_get_tx_queue(priv->dev, queue));
> }
>
> return 0;
>
> --
> 2.47.3
>
>
Re: [PATCH net v2 2/2] net: stmmac: Stop Tx queue when (en|dis)abling XSK pools
Author: Kurt Kanzenbach
Date: Thu, 08 Oct 2026 12:51
Date: Thu, 08 Oct 2026 12:51
103 lines
11087 bytes
11087 bytes
--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Hi Maciej,
On Thu Oct 08 2026, Maciej Fijalkowski wrote:
> On Mon, Oct 05, 2026 at 09:09:33AM +0200, Kurt Kanzenbach wrote:
>> When enabling or disabling XSK pools in parallel to Tx traffic, kernel
>> crashes occur. For VLAN tagged frames that happens in stmmac_xmit() ->
>> dwmac4_set_vlan_tag() and for normal frames in stmmac_xmit() ->
>> dwmac4_set_addr(). Both of these functions access the Tx DMA descriptors.
>>=20
>> The XDP pool (en|dis)ablement frees and reallocates the Tx DMA resources:
>>=20
>> stmmac_disable_tx_queue:
>> __free_dma_tx_desc_resources
>>=20
>> stmmac_enable_tx_queue:
>> __alloc_dma_tx_desc_resources
>> __init_dma_tx_desc_rings
>>=20
>> NAPI is disabled during that allocation window, but the Tx queue is not
>> stopped. Therefore, add the stopping of the Tx queue during the enabling
>> and disabling of XSK pools. Update trans_start when stopping the queue
>> to avoid spurious watchdog timeouts.
>>=20
>> The issue can be easily reproduced by:
>>=20
>> 1. Run iperf
>> 2. Run application which opens an AF_XDP/ZC socket
>>=20
>> Fixes: 132c32ee5bc0 ("net: stmmac: Add TX via XDP zero-copy socket")
>> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
>> ---
>> drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>>=20
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/=
net/ethernet/stmicro/stmmac/stmmac_xdp.c
>> index d7e4db7224b0..883bd3fe8089 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
>> @@ -6,6 +6,16 @@
>> #include "stmmac.h"
>> #include "stmmac_xdp.h"
>>=20=20
>> +static void stmmac_xdp_stop_tx_queue(struct stmmac_priv *priv, u16 queu=
e)
>> +{
>> + struct netdev_queue *nq =3D netdev_get_tx_queue(priv->dev, queue);
>> +
>> + __netif_tx_lock_bh(nq);
>> + txq_trans_cond_update(nq);
>> + netif_tx_stop_queue(nq);
>> + __netif_tx_unlock_bh(nq);
>> +}
>> +
>> static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,
>> struct xsk_buff_pool *pool, u16 queue)
>> {
>> @@ -36,6 +46,7 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *=
priv,
>> if (need_update) {
>> napi_disable(&ch->rx_napi);
>> napi_disable(&ch->tx_napi);
>> + stmmac_xdp_stop_tx_queue(priv, queue);
>
> FWIW you can look at what I did at ice driver (ice_qp_dis()) where I used
> a bigger hammer here; I think updating trans_start is kinda a workaround.
>
> https://lore.kernel.org/netdev/20240708221416.625850-1-anthony.l.nguyen@i=
ntel.com/
>
Actually, trans_start is already updated by netif_tx_stop_queue(). I'd
just remove txq_trans_cond_update() for next version.
Thanks,
Kurt
--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQJHBAEBCgAxFiEEvLm/ssjDfdPf21mSwZPR8qpGc4IFAmrHkdcTHGt1cnRAbGlu
dXRyb25peC5kZQAKCRDBk9HyqkZzgmJBD/oCmsRqLOaLWkOVSVG1QP9cmCBH00WQ
LRmmxbFk4UDutQJxHN4bezt5EZ6eJqvCf5WM/uI9WkyMlA65QMEm96UbHmGYhY/O
2fdXL7X5W2wpY31IcZ15svH39ow99M+z+Qa7bOaZVMrZxaWWvyHEhv+qUESR4ot/
lYvobo99/AorlX8Urfb/e+x3r1NCOXZJz5IIXq+9L4sAby16gJdQtvfvDdmfdN8Y
Fr8DxMII4MoRHHcPjvMYxbYaAaGSDaK/H61e6DODTrRMCHE4322KkjMSqx/KxCBH
zvXeMsqkWlnSTM0srBGuszFy/9kfOKWyk68q44fhuefGOaBv2xB8ZBGt8Xoz4aqq
Mip7UslQqXVVjZCJfbUnH+zwcaJBIJA3QOQT0HebM5unR7YZDCPPc/oCL6q66G0Q
Z61H3lzDorpXGBUUindVQvB4XLWkO6xOagPLN0Nu3fuHDIqirxrPYpSko3K3xKg/
AsLDTMAGIKG29OoSOjlikRm+6gbkXtiH4E82IJWem/IWiQsrtXj27FHPkoWivHKJ
oLhS9/3kWsoqO0VExHQLlh6/HTIH8358JForUyGvFLJzJxGGQVpjzmlKRfXplF9W
th4/Y3yHhPZ16SPgDUFl6oKAQPXlUjbamJqkdbvHCUJ4zKtj2j3x6fDeYh3xN/Bk
8c5IpCJvzgpfJQ==
=3nkW
-----END PGP SIGNATURE-----
--=-=-=--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads