From: Koral Ilgun <kora…@adtran.com> When the last offload of a bridge port stops while the port stays in the bridge, the bridge keeps the hwdom of the port. Patch 2 clears it, as v1 did. The LLM review of v1 found that the skip in nbp_switchdev_hwdom_set() lets a port that stays in the bridge get -EBUSY, and that nbp_switchdev_add() then keeps offload_count. Patch 1 fixes the count first, so that no commit of the series has that fault. Daniel Machon reported that the fault reproduces on lan969x and that v1 clears it, while he prepares a LAG series for sparx5/lan969x: https://lore.kernel.org/netdev/2026…@DEN-DL-M70577.microsemi.net/ Test: net/main c1c39137dcc3 plus a local change with empty LAG ops in dsa_loop, x86_64 in QEMU (TCG), dsa_loop with tag protocol none. A local trace printed offload_count and the hwdom; a local knob made nbp_switchdev_hwdom_set() return -EBUSY as with all hwdoms busy. - Leak, 70 rounds: base and patch 1 alone fail in round 64; patch 2 alone and the series pass 70 of 70. - A LAG that is a bridge port before its first switch port joins: base gives it hwdom 0 and a later port copies hwdom 0; with patch 2 both get hwdom 1. - The same LAG with the knob on: patch 2 alone keeps offload_count 1 after the EBUSY, accepts the retry with hwdom 0 and keeps hwdom 0 after the knob is off. The series refuses both tries with count 0 and then gives hwdom 1. - A ping between two veth ports of the bridge, with an offloaded dsa_loop port in it: 20 of 20 on each kernel. W=1 builds of net/bridge/ with allmodconfig, allyesconfig and an x86_64_defconfig-based config, and sparse (C=2), show no warnings on base, patch 1 and patch 2. No WARNING or BUG in the logs. Not tested: a frame with offload_fwd_mark, so also the egress refusal and the LAG leave window; a port with TX forwarding offload (mv88e6xxx, tag_8021q); a real -EBUSY (the knob replaces a full busy_hwdoms); an offload from a second switch; dsa_port_change_conduit(); mlxsw and the other drivers that call switchdev_bridge_port_unoffload(); team; bridge VLAN filtering; the error path of br_switchdev_port_offload(); an unoffload while frames go through the bridge; the kernel selftests; lockdep, KASAN and KCSAN. Patch 1 changes one case on rocker. rocker_netdevice_event() only warns when switchdev_bridge_port_offload() fails, so the port stays in the bridge after -EBUSY, and ofdpa_port_bridge_leave() calls switchdev_bridge_port_unoffload() without a check. Before patch 1 the stale offload_count balanced that call. With patch 1, nbp_switchdev_del() hits WARN_ON(!p->offload_count) and returns. It needs all hwdoms busy, and it comes from a read of the source. Rocker can fail the join on that error in a separate patch. Stable: neither patch applies before v7.2. Both have context from f76ae12b6ba3 ("net: bridge: use atomic ops to read/change p->flags (III)"), so older trees need a backport that adapts that context. v2: - new patch 1: count an offload only after its hwdom is set - patch 2: describe the receive side of the LAG leave window and the window in dsa_port_change_conduit(); read the hwdom once with READ_ONCE() in nbp_switchdev_frame_mark() and nbp_switchdev_allowed_egress(); name the mlxsw cases; add the tests of the self match and of frames through the bridge - rebased on net/main c1c39137dcc3 v1: https://lore.kernel.org/netdev/2026…@gmail.com/ Koral Ilgun (2): net: bridge: switchdev: count an offload only after its hwdom is set net: bridge: switchdev: clear the hwdom of a port that stops the offload net/bridge/br_switchdev.c | 70 +++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 21 deletions(-) base-commit: c1c39137dcc3134010566ff29a81c93124efa539
-- 2.43.0