The RX VLAN offload mode is consumed by the receive path: stmmac_rx() and stmmac_dispatch_skb_zc() use hw_vlan_en to decide whether to take the VLAN tag from the RX descriptor, and the software stripping path uses the advertised RX VLAN feature bits. stmmac_set_features() changes that state at runtime, while RX NAPI can run concurrently. A frame received with one setting can therefore be processed after the setting has changed, which may lose a tag that was stripped or duplicate a tag that is still in the frame. The MAC register update also cannot be made atomic with respect to frames already in flight without stopping RX DMA and flushing the descriptor rings. Since this is an RX offload mode change and there is no cheap way to synchronize it with the receive path, only allow it while the interface is down. Mask the RX VLAN feature bits back to their currently advertised state in stmmac_fix_features() when the device is running, so ndo_set_features() never changes the mode under a live RX path. A request made while the interface is running is ignored and is not deferred to the next open; userspace must bring the interface down to change the RX VLAN offload. Fixes: 750011e239a5 ("net: stmmac: Add support for HW-accelerated VLAN stripping") Signed-off-by: Lorenzo Bianconi <lore…@oss.qualcomm.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d32d3e7b1b8c..b978e64399d4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6371,6 +6371,8 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, netdev_features_t features) { struct stmmac_priv *priv = netdev_priv(dev); + netdev_features_t vlan_rx = NETIF_F_HW_VLAN_CTAG_RX | + NETIF_F_HW_VLAN_STAG_RX; if (priv->plat->rx_coe == STMMAC_RX_COE_NONE) features &= ~NETIF_F_RXCSUM; @@ -6393,6 +6395,15 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, features &= ~NETIF_F_HW_VLAN_STAG_RX; } + /* The RX VLAN mode cannot be changed while RX is running: frames + * received under the old mode might otherwise be processed with the + * new one. Keep the current mode and defer the change until the + * interface is down. + */ + if (netif_running(dev) && + (features & vlan_rx) != (dev->features & vlan_rx)) + features = (features & ~vlan_rx) | (dev->features & vlan_rx); + return features; } --- base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a change-id: 20261205-stmmac-do-not-flip-vlan-offload-613a9cad635b Best regards,
-- Lorenzo Bianconi <lore…@oss.qualcomm.com>