* [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases
@ 2026-11-12 10:21 Meghana Malladi
2026-11-12 10:21 ` [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash Meghana Malladi
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Meghana Malladi @ 2026-11-12 10:21 UTC (permalink / raw)
To: diogo.ivo, haokexin, philippe.schenker, devnexen, horms,
jacob.e.keller, m-malladi, pabeni, kuba, edumazet, davem,
andrew+netdev
Cc: linux-kernel, netdev, linux-arm-kernel, Vignesh Raghavendra,
danishanwar
Non-offloaded switch mode is failing to forward packets. This patch series
introduces fixes to ensure smooth operation of switch mode in both offload
and non-offload cases.
patch(1/3): Fix TX timestamp cleanup crash (ERR_PTR slot handling)
patch(2/3): Fix phylib stop/start in emac_restart (R30 command race)
patch(3/3): Fix bridge port_vlan and flooding state (multicast/unicast forwarding)
v2: https://lore.kernel.org/all/20261027131732.3411403-1-m-malladi@ti.com/
Meghana Malladi (3):
net: ti: icssg-prueth: Fix TX timestamp cleanup crash
net: ti: icssg-prueth: Fix phylib stop/start in emac_restart
net: ti: icssg-prueth: Fix bridge port_vlan and flooding state
drivers/net/ethernet/ti/icssg/icssg_common.c | 9 ++--
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 46 ++++++++++++++++++--
drivers/net/ethernet/ti/icssg/icssg_prueth.h | 4 ++
3 files changed, 52 insertions(+), 7 deletions(-)
base-commit: af6f95c3300e3d234c813b80f831dd7b80b3eaf2
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash 2026-11-12 10:21 [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases Meghana Malladi @ 2026-11-12 10:21 ` Meghana Malladi 2026-11-16 13:54 ` netdev-bot+sashiko 2026-11-12 10:21 ` [PATCH net v3 RESEND 2/3] net: ti: icssg-prueth: Fix phylib stop/start in emac_restart Meghana Malladi ` (2 subsequent siblings) 3 siblings, 1 reply; 8+ messages in thread From: Meghana Malladi @ 2026-11-12 10:21 UTC (permalink / raw) To: diogo.ivo, haokexin, philippe.schenker, devnexen, horms, jacob.e.keller, m-malladi, pabeni, kuba, edumazet, davem, andrew+netdev Cc: linux-kernel, netdev, linux-arm-kernel, Vignesh Raghavendra, danishanwar prueth_cleanup_tx_ts() incorrectly frees ERR_PTR(-EBUSY) slots. The TX path reserves slots with ERR_PTR(-EBUSY) before storing the real skb pointer. Use IS_ERR_OR_NULL() to skip these reserved slots during cleanup, preventing NULL pointer dereference and freeing errors. Fixes: e2dc7bfd677fc ("net: ti: icssg-prueth: Move common functions into a separate file") Signed-off-by: Meghana Malladi <m-malladi@ti.com> --- Changes from v2(v3-v2): - Added this commit in the series which fixes the pre-existing issues flagged by sashiko drivers/net/ethernet/ti/icssg/icssg_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/ethernet/ti/icssg/icssg_common.c index 4a7d1a6f470b..8cb2ad2ebece 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_common.c +++ b/drivers/net/ethernet/ti/icssg/icssg_common.c @@ -1426,10 +1426,13 @@ void prueth_cleanup_tx_ts(struct prueth_emac *emac) int i; for (i = 0; i < PRUETH_MAX_TX_TS_REQUESTS; i++) { - if (emac->tx_ts_skb[i]) { + /* Slot may hold ERR_PTR(-EBUSY) if the TX path reserved it + * but has not yet stored the real skb pointer. Skip the free + * but still clear the slot so it can be reused. + */ + if (!IS_ERR_OR_NULL(emac->tx_ts_skb[i])) dev_kfree_skb_any(emac->tx_ts_skb[i]); - emac->tx_ts_skb[i] = NULL; - } + emac->tx_ts_skb[i] = NULL; } } EXPORT_SYMBOL_GPL(prueth_cleanup_tx_ts); -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash 2026-11-12 10:21 ` [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash Meghana Malladi @ 2026-11-16 13:54 ` netdev-bot+sashiko 0 siblings, 0 replies; 8+ messages in thread From: netdev-bot+sashiko @ 2026-11-16 13:54 UTC (permalink / raw) To: m-malladi Cc: diogo.ivo, haokexin, philippe.schenker, devnexen, horms, jacob.e.keller, pabeni, kuba, edumazet, davem, andrew+netdev, linux-kernel, netdev, linux-arm-kernel, vigneshr, danishanwar Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 2 (2) · Medium: 3 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The patch only makes prueth_cleanup_tx_ts() aware of the ERR_PTR(-EBUSY) sentinel. - [High] The ERR_PTR(-EBUSY) state exists only between prueth_tx_ts_cookie_get() (icssg_common.c:1184) and the store… - [Medium] The Fixes: tag names the wrong commit. - [Medium] The commit message and the new comment misdescribe both the trigger and the effect. - [Medium] The new check in prueth_cleanup_tx_ts() loads emac->tx_ts_skb[i] twice with plain, non-READ_ONCE loads: once in… Pre-existing issues: - [High] This problem wasn't introduced by this patch, but prueth_cleanup_tx_ts() (phylib work context) and the TX timestamp… - [High] This problem wasn't introduced by this patch, but prueth_tx_ts_cookie_get() (icssg_common.c:1177-1190) reserves a slot… -- net: ti: icssg-prueth: Fix TX timestamp cleanup crash This patch changes prueth_cleanup_tx_ts() to skip slots that hold NULL or the ERR_PTR(-EBUSY) reservation sentinel. It still clears every slot to NULL. The goal is to stop dev_kfree_skb_any() from being called on a slot that the TX path has reserved but not yet filled. > Fixes: e2dc7bfd677fc ("net: ti: icssg-prueth: Move common functions into a separate file") [Severity: Medium] Is this the right commit for the Fixes: tag? e2dc7bfd677fc is a code move, and its message says it introduces no functional changes. Before that commit, icssg_prueth.c already had prueth_tx_ts_cookie_get() storing ERR_PTR(-EBUSY), and a static prueth_cleanup_tx_ts() with the same check: if (emac->tx_ts_skb[i]) { dev_kfree_skb_any(emac->tx_ts_skb[i]); Both came from 186734c15886 ("net: ti: icssg-prueth: add packet timestamping and ptp support"), which landed in v6.6. e2dc7bfd677fc landed in v6.10. Stable tooling that follows the current tag would skip 6.6.y, which has the same cleanup code. Should this be: Fixes: 186734c15886 ("net: ti: icssg-prueth: add packet timestamping and ptp support") > diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/ethernet/ti/icssg/icssg_common.c > index 4a7d1a6f470b1..8cb2ad2ebece5 100644 > --- a/drivers/net/ethernet/ti/icssg/icssg_common.c > +++ b/drivers/net/ethernet/ti/icssg/icssg_common.c > @@ -1426,10 +1426,13 @@ void prueth_cleanup_tx_ts(struct prueth_emac *emac) > int i; > > for (i = 0; i < PRUETH_MAX_TX_TS_REQUESTS; i++) { > - if (emac->tx_ts_skb[i]) { > + /* Slot may hold ERR_PTR(-EBUSY) if the TX path reserved it > + * but has not yet stored the real skb pointer. Skip the free > + * but still clear the slot so it can be reused. > + */ [Severity: Medium] Do this comment and the commit message accurately describe when the slot holds ERR_PTR(-EBUSY)? Only prueth_tx_ts_cookie_get() writes the sentinel. A few instructions later, icssg_ndo_start_xmit() overwrites it, with no return or goto in between: tx_ts_cookie = prueth_tx_ts_cookie_get(emac); if (tx_ts_cookie >= 0) { skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; ... emac->tx_ts_skb[tx_ts_cookie] = skb_get(skb); So prueth_cleanup_tx_ts() can only see the sentinel while an xmit is running at the same time. The commit message doesn't describe this as a race. The commit message also says "preventing NULL pointer dereference". Wouldn't the original failure be a dereference of the ERR_PTR value inside kfree_skb(), not a NULL dereference? The comment says the slot is cleared "so it can be reused". The xmit that reserved the slot is still running, though, and will store skb_get(skb) into it anyway. Could the commit message and the comment describe the actual race? > + if (!IS_ERR_OR_NULL(emac->tx_ts_skb[i])) > dev_kfree_skb_any(emac->tx_ts_skb[i]); [Severity: Medium] Can these two plain loads of emac->tx_ts_skb[i] return different values? Three things change the slot with no common lock: icssg_ndo_start_xmit() on any TX queue, tx_ts_work(), and the xmit error paths. Consider this sequence: - The load in IS_ERR_OR_NULL() sees a valid skb. - tx_ts_work() takes that skb and writes NULL. - Another xmit reserves the slot before the second load. The result is dev_kfree_skb_any(ERR_PTR(-EBUSY)), which is the crash this patch is meant to prevent. This only happens if the compiler emits two separate loads, which C allows for plain accesses. Would it be safer to read the slot once into a local with READ_ONCE() or xchg()? The underlying fix still needs a lock. [Severity: High] This isn't a bug introduced by this patch, but what stops this free from racing with the TX timestamp consumers? prueth_cleanup_tx_ts() runs from the phylib link change path. Meanwhile, tx_ts_work() (threaded tx_ts_irq) and prueth_tx_ts_sr1() (threaded mgm IRQ) read and then clear the same slot without a lock: skb = emac->tx_ts_skb[tsr.cookie]; emac->tx_ts_skb[tsr.cookie] = NULL; /* free slot */ ... skb_tstamp_tx(skb, &ssh); dev_consume_skb_any(skb); Suppose tx_ts_work() reads skb S, and prueth_cleanup_tx_ts() also reads S and calls dev_kfree_skb_any(S) before tx_ts_work() writes NULL. tx_ts_work() then calls skb_tstamp_tx() and dev_consume_skb_any() on a reference that has already been dropped. If TX completion has already released the base reference, isn't that a use-after-free followed by a double free? The error paths in icssg_ndo_start_xmit() race with cleanup the same way: cleanup_tx_ts: if (in_tx_ts) { dev_kfree_skb_any(emac->tx_ts_skb[tx_ts_cookie]); emac->tx_ts_skb[tx_ts_cookie] = NULL; } Both sides can drop the skb_get() reference, and then drop_free_skb frees the base reference. prueth_cleanup_tx_ts() also still doesn't adjust tx_ts_pending. > - emac->tx_ts_skb[i] = NULL; > - } > + emac->tx_ts_skb[i] = NULL; [Severity: High] The ERR_PTR(-EBUSY) case only happens while icssg_ndo_start_xmit() is running. Can this unlocked NULL write then overwrite the skb that the xmit is about to store? emac_adjust_link() does: netif_tx_stop_all_queues(ndev); prueth_cleanup_tx_ts(emac); emac_adjust_link_sr1() does the same. netif_tx_stop_all_queues() only sets the XOFF bits and doesn't wait for an xmit that is already running: CPU0 (emac_adjust_link) CPU1 (icssg_ndo_start_xmit) prueth_tx_ts_cookie_get() tx_ts_skb[k] = ERR_PTR(-EBUSY) prueth_cleanup_tx_ts() IS_ERR_OR_NULL(tx_ts_skb[k]) -> true, skip free tx_ts_skb[k] = skb_get(skb) tx_ts_skb[k] = NULL Does this leak the skb_get() reference on the skb, along with its socket's sk_wmem_alloc charge? When the timestamp response for k arrives, tx_ts_work() sees NULL, logs "Invalid TX TS cookie" and breaks without decrementing tx_ts_pending. Once the slot is NULL, an xmit on another TX queue can also reserve the same index through prueth_tx_ts_cookie_get(), while the original xmit still owns it. Two in-flight packets then share one cookie. The original xmit's error paths (cleanup_tx_ts and free_desc_stop_q_busy_cleanup_tx_ts) would call: dev_kfree_skb_any(emac->tx_ts_skb[tx_ts_cookie]); on whatever the slot holds at that point. That may be the other packet's skb or ERR_PTR(-EBUSY). Cleanup and the xmit error path can also still both free the same valid skb pointer. Instead of another value check, would this need netif_tx_disable() before the cleanup? It would also need a lock shared by prueth_tx_ts_cookie_get(), the xmit error paths, tx_ts_work() and prueth_cleanup_tx_ts(). [Severity: High] This makes prueth_cleanup_tx_ts() aware of the sentinel. Don't the timestamp completion handlers still treat any non-NULL slot as a valid skb? tx_ts_work() in icssg_prueth.c only rejects NULL: if (tsr.cookie >= PRUETH_MAX_TX_TS_REQUESTS || !emac->tx_ts_skb[tsr.cookie]) { An ERR_PTR(-EBUSY) slot passes this check, and the later if (!skb) check can't catch it. The value then goes to skb_tstamp_tx() and dev_consume_skb_any(). prueth_tx_ts_sr1() in icssg_prueth_sr1.c only checks the cookie range: skb = emac->tx_ts_skb[cookie]; emac->tx_ts_skb[cookie] = NULL; /* free slot */ ... skb_tstamp_tx(skb, &ssh); skb_tstamp_tx() dereferences orig_skb->sk, so an empty slot causes a NULL dereference. prueth_cleanup_tx_ts() sets every slot to NULL on link-down. It doesn't reset tx_ts_pending, and it doesn't synchronize with firmware timestamp responses already queued for those cookies. On SR1, consider this sequence: - A timestamped frame is sent. - The firmware posts the response. - The link goes down. emac_adjust_link_sr1()->prueth_cleanup_tx_ts() can then NULL the slot before prueth_rx_mgm_ts_thread_sr1()->prueth_tx_ts_sr1() runs, which leads to skb_tstamp_tx(NULL, ...). On SR2, a stale response for cookie k could be handled while a new xmit holds k reserved. That would pass ERR_PTR(-EBUSY) to skb_tstamp_tx(). If the stale response is handled after the new skb_get() store, the old timestamp is attached to an unrelated packet. The missing NULL check in prueth_tx_ts_sr1() predates this patch. This commit is fixing the case where a reserved or cleared slot is used as an skb, so should tx_ts_work() and prueth_tx_ts_sr1() be covered as well? [Severity: High] This is a pre-existing issue, but is the slot reservation in prueth_tx_ts_cookie_get() safe across TX queues? for (i = 0; i < PRUETH_MAX_TX_TS_REQUESTS; i++) { if (!emac->tx_ts_skb[i]) { emac->tx_ts_skb[i] = ERR_PTR(-EBUSY); /* reserve slot */ return i; } } All TX queues of the netdev share emac->tx_ts_skb[] (up to PRUETH_MAX_TX_QUEUES on SR2). icssg_ndo_start_xmit(), however, is only serialized by each queue's own lock. Two CPUs sending HW-timestamped skbs on different queues could both see slot i as NULL and both reserve it. Both packets would then carry cookie i in epib[0]: - The second skb_get(skb) store overwrites the first, which leaks the first skb and its socket's wmem charge. - tx_ts_pending is incremented twice for one slot. - The first response could attach one packet's timestamp to the other. - The second response would hit "Invalid TX TS cookie". Suppose xmit B's ERR_PTR(-EBUSY) write lands after xmit A has stored its skb. A's error path would then call dev_kfree_skb_any(ERR_PTR(-EBUSY)). SR1 uses a single TX queue and doesn't appear to be affected. Would a spinlock around tx_ts_skb[], or cmpxchg() for the reservation, be needed here? This also looks like the root cause of the reservation window races above. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112102140.2744508-1-m-malladi%40ti.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v3 RESEND 2/3] net: ti: icssg-prueth: Fix phylib stop/start in emac_restart 2026-11-12 10:21 [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases Meghana Malladi 2026-11-12 10:21 ` [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash Meghana Malladi @ 2026-11-12 10:21 ` Meghana Malladi 2026-11-16 13:54 ` netdev-bot+sashiko 2026-11-12 10:21 ` [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state Meghana Malladi 2026-11-12 10:26 ` [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases netdev-bot+sinfo 3 siblings, 1 reply; 8+ messages in thread From: Meghana Malladi @ 2026-11-12 10:21 UTC (permalink / raw) To: diogo.ivo, haokexin, philippe.schenker, devnexen, horms, jacob.e.keller, m-malladi, pabeni, kuba, edumazet, davem, andrew+netdev Cc: linux-kernel, netdev, linux-arm-kernel, Vignesh Raghavendra, danishanwar Call phy_stop()/phy_start() around the firmware halt in prueth_emac_restart() to prevent phylib from issuing R30 commands to the stopped PRU. Without this, emac_adjust_link() can race with firmware reload and write invalid state. Fixes: 9facce84f4062 ("net: ti: icssg-prueth: Fix firmware load sequence.") Signed-off-by: Meghana Malladi <m-malladi@ti.com> --- Changes from v2(v3-v2): - Added this commit in the series which fixes the pre-existing issues flagged by sashiko drivers/net/ethernet/ti/icssg/icssg_prueth.c | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index 591be5c8056b..ef5dce595f68 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -1837,6 +1837,14 @@ static int prueth_emac_restart(struct prueth *prueth) struct prueth_emac *emac1 = prueth->emac[PRUETH_MAC1]; int ret; + /* Halt phylib to stop emac_adjust_link() from issuing R30 commands + * to the PRU while the firmware is stopped. + */ + if (emac0->ndev->phydev) + phy_stop(emac0->ndev->phydev); + if (emac1->ndev->phydev) + phy_stop(emac1->ndev->phydev); + /* Detach the net_device for both PRUeth ports*/ if (netif_running(emac0->ndev)) netif_device_detach(emac0->ndev); @@ -1847,20 +1855,20 @@ static int prueth_emac_restart(struct prueth *prueth) ret = icssg_set_port_state(emac0, ICSSG_EMAC_PORT_DISABLE); ret |= icssg_set_port_state(emac1, ICSSG_EMAC_PORT_DISABLE); if (ret) - return ret; + goto restart_phy; /* Stop both pru cores for both PRUeth ports*/ ret = prueth_emac_common_stop(prueth); if (ret) { dev_err(prueth->dev, "Failed to stop the firmwares"); - return ret; + goto restart_phy; } /* Start both pru cores for both PRUeth ports */ ret = prueth_emac_common_start(prueth); if (ret) { dev_err(prueth->dev, "Failed to start the firmwares"); - return ret; + goto restart_phy; } /* Enable forwarding for both PRUeth ports */ @@ -1871,6 +1879,13 @@ static int prueth_emac_restart(struct prueth *prueth) netif_device_attach(emac0->ndev); netif_device_attach(emac1->ndev); +restart_phy: + /* Resume phylib now that the firmware is running again. */ + if (emac0->ndev->phydev) + phy_start(emac0->ndev->phydev); + if (emac1->ndev->phydev) + phy_start(emac1->ndev->phydev); + return ret; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 RESEND 2/3] net: ti: icssg-prueth: Fix phylib stop/start in emac_restart 2026-11-12 10:21 ` [PATCH net v3 RESEND 2/3] net: ti: icssg-prueth: Fix phylib stop/start in emac_restart Meghana Malladi @ 2026-11-16 13:54 ` netdev-bot+sashiko 0 siblings, 0 replies; 8+ messages in thread From: netdev-bot+sashiko @ 2026-11-16 13:54 UTC (permalink / raw) To: m-malladi Cc: diogo.ivo, haokexin, philippe.schenker, devnexen, horms, jacob.e.keller, pabeni, kuba, edumazet, davem, andrew+netdev, linux-kernel, netdev, linux-arm-kernel, vigneshr, danishanwar Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 2 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] prueth_emac_restart() (drivers/net/ethernet/ti/icssg/icssg_prueth.c) now calls phy_stop()… - [Medium] The new restart_phy error label in prueth_emac_restart() restarts phylib even when the firmware is known to be stopped. - [Medium] The commit message presents phy_stop()/phy_start() only as a way to block emac_adjust_link() R30 commands. -- net: ti: icssg-prueth: Fix phylib stop/start in emac_restart This patch adds phy_stop() calls for both ports before prueth_emac_restart() halts the PRU firmware, and phy_start() calls after the restart. It also turns the early error returns into a goto to a new restart_phy label. The goal is to keep emac_adjust_link() from sending R30 commands to the PRU while it is stopped. > diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c > index 591be5c8056b4..ef5dce595f68a 100644 > --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c > +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c > @@ -1837,6 +1837,14 @@ static int prueth_emac_restart(struct prueth *prueth) > struct prueth_emac *emac1 = prueth->emac[PRUETH_MAC1]; > int ret; > > + /* Halt phylib to stop emac_adjust_link() from issuing R30 commands > + * to the PRU while the firmware is stopped. > + */ > + if (emac0->ndev->phydev) > + phy_stop(emac0->ndev->phydev); > + if (emac1->ndev->phydev) > + phy_stop(emac1->ndev->phydev); [Severity: High] What happens when one of the ports is down at this point? emac_phy_connect() runs at probe, so ndev->phydev is never NULL here. None of the callers check netif_running(): prueth_netdevice_port_link()->icssg_change_mode()->prueth_emac_restart() prueth_netdevice_port_unlink()->prueth_emac_restart() prueth_hsr_port_link()->icssg_change_mode()->prueth_emac_restart() prueth_hsr_port_unlink()->prueth_emac_restart() prueth_emac_restart() itself checks netif_running() before calling netif_device_detach(), so it already expects ports to be down sometimes. A port that was never opened has its PHY in PHY_READY. A port closed by emac_ndo_stop() has its PHY in PHY_HALTED. phy_stop() WARNs and returns for both of those states: drivers/net/phy/phy.c:phy_stop() { ... if (!phy_is_started(phydev) && phydev->state != PHY_DOWN && phydev->state != PHY_ERROR) { WARN(1, "called from state %s\n", phy_state_to_str(phydev->state)); return; } ... } The phy_start() at restart_phy runs unconditionally. It accepts READY and HALTED, so it resumes the PHY and starts the state machine on a netdev that is administratively down. Once autoneg completes, emac_adjust_link() runs for the closed port. It sends icssg_config_set_speed() and ICSSG_EMAC_PORT_FORWARD commands and wakes the tx queues. Before this patch, that PHY stayed halted. If both ports are down, emacs_initialized is 0 and the PRUs are not running. Then icssg_set_port_state(ICSSG_EMAC_PORT_DISABLE) times out, the code jumps to restart_phy, and both PHYs are started. Wouldn't emac_adjust_link() then send R30 commands to the halted PRU cores, which is the case this patch is meant to prevent? On the next ifup, emac_ndo_open() calls phy_start() while the PHY is already in PHY_UP, PHY_NOLINK or PHY_RUNNING. phy_start() then WARNs and does nothing. A CAP_NET_ADMIN user can hit this with "ip link set ethX master br0", or by adding the port to an HSR/PRP master, while the other ICSSG port is down. Would it work to record which ports were running, or phy_is_started(), before calling phy_stop(), and restart only those PHYs? [Severity: Medium] The commit message describes phy_stop() and phy_start() only as a way to block emac_adjust_link() R30 commands. phy_stop() also does more than that. It sets PHY_HALTED and runs _phy_state_machine() synchronously. That path clears phydev->link, calls phy_link_down() and returns PHY_STATE_WORK_SUSPEND, so the PHY gets suspended. phy_start() later resumes it and restarts autoneg. So does every bridge or HSR/PRP join or leave that reaches prueth_emac_restart() now take the physical link down on both ports and force a full renegotiation? The link partner and the bridge, STP or HSR layer would see the carrier drop. Should the commit message mention this? This also seems to turn the forced resync in prueth_emac_common_start() into a no-op on the restart path: prueth_emac_common_start() { ... emac->link = 0; mutex_lock(&emac->ndev->phydev->lock); emac_adjust_link(emac->ndev); mutex_unlock(&emac->ndev->phydev->lock); ... } After phy_stop(), phydev->link is already 0. emac_adjust_link() sees no state change, so speed and FORWARD programming waits until autoneg finishes after phy_start(). > + > /* Detach the net_device for both PRUeth ports*/ > if (netif_running(emac0->ndev)) > netif_device_detach(emac0->ndev); > @@ -1847,20 +1855,20 @@ static int prueth_emac_restart(struct prueth *prueth) > ret = icssg_set_port_state(emac0, ICSSG_EMAC_PORT_DISABLE); > ret |= icssg_set_port_state(emac1, ICSSG_EMAC_PORT_DISABLE); > if (ret) > - return ret; > + goto restart_phy; > > /* Stop both pru cores for both PRUeth ports*/ > ret = prueth_emac_common_stop(prueth); > if (ret) { > dev_err(prueth->dev, "Failed to stop the firmwares"); > - return ret; > + goto restart_phy; > } > > /* Start both pru cores for both PRUeth ports */ > ret = prueth_emac_common_start(prueth); > if (ret) { > dev_err(prueth->dev, "Failed to start the firmwares"); > - return ret; > + goto restart_phy; > } [ ... ] > @@ -1871,6 +1879,13 @@ static int prueth_emac_restart(struct prueth *prueth) > netif_device_attach(emac0->ndev); > netif_device_attach(emac1->ndev); > > +restart_phy: > + /* Resume phylib now that the firmware is running again. */ > + if (emac0->ndev->phydev) > + phy_start(emac0->ndev->phydev); > + if (emac1->ndev->phydev) > + phy_start(emac1->ndev->phydev); [Severity: Medium] Does this comment hold on the error paths? Say prueth_emac_common_stop() succeeds and then prueth_emac_common_start() fails in icssg_config(), prueth_emac_start() or icss_iep_init(). Its own unwind leaves the PRUs stopped and classification disabled. The goto restart_phy still calls phy_start() on both PHYs. When the state machine runs again, emac_adjust_link() calls icssg_config_set_speed() and icssg_set_port_state() against the halted PRU. Each call polls for up to 10ms before it times out. Isn't that the case the commit message says this patch fixes? "to prevent phylib from issuing R30 commands to the stopped PRU" The label also comes after netif_device_attach(), so both netdevs stay detached while phylib toggles carrier and tx queues on them. The netdevs were already left detached on error before this patch. Should phylib be restarted only after the firmware has actually come back up? > + > return ret; > } > -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112102140.2744508-1-m-malladi%40ti.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state 2026-11-12 10:21 [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases Meghana Malladi 2026-11-12 10:21 ` [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash Meghana Malladi 2026-11-12 10:21 ` [PATCH net v3 RESEND 2/3] net: ti: icssg-prueth: Fix phylib stop/start in emac_restart Meghana Malladi @ 2026-11-12 10:21 ` Meghana Malladi 2026-11-16 13:54 ` netdev-bot+sashiko 2026-11-12 10:26 ` [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases netdev-bot+sinfo 3 siblings, 1 reply; 8+ messages in thread From: Meghana Malladi @ 2026-11-12 10:21 UTC (permalink / raw) To: diogo.ivo, haokexin, philippe.schenker, devnexen, horms, jacob.e.keller, m-malladi, pabeni, kuba, edumazet, davem, andrew+netdev Cc: linux-kernel, netdev, linux-arm-kernel, Vignesh Raghavendra, danishanwar Bridge formation only set port_vlan on the second emac, leaving the first without VLAN configuration; fixed by setting port_vlan on both emacs. Firmware restart in non-offload bridge mode cleared IFF_PROMISC-driven UC/MC flooding state, breaking unicast forwarding; fixed by tracking flooding state and restoring it after every firmware restart, including the switch-to-EMAC and HSR-to-EMAC transitions in prueth_netdevice_port_unlink() and prueth_hsr_port_unlink(). Store the flood-enable flags before issuing the firmware commands so that a concurrent icssg_enable_fw_offload() call cannot read a stale false value if it runs between the command and the flag update. Add a NULL check for emac slots in icssg_enable_fw_offload() to handle single-port DT configurations where one prueth->emac[] slot is unused. Fixes: 161087db66d6b ("net: ti: icssg-prueth: Add Support for Multicast filtering with VLAN in HSR mode") Signed-off-by: Meghana Malladi <m-malladi@ti.com> --- Changes from v2(v3-v2): - Fixed race: uc/mc_flooding_enabled flags set BEFORE firmware commands - Added icssg_enable_fw_offload() after restart in bridge unlink path - Added icssg_enable_fw_offload() after restart in HSR unlink path drivers/net/ethernet/ti/icssg/icssg_prueth.c | 25 +++++++++++++++++++- drivers/net/ethernet/ti/icssg/icssg_prueth.h | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index ef5dce595f68..48539460ee49 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -213,6 +213,8 @@ static void icssg_enable_fw_offload(struct prueth *prueth) for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) { emac = prueth->emac[mac]; + if (!emac) + continue; if (prueth->is_hsr_offload_mode) { if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM) icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE); @@ -241,6 +243,17 @@ static void icssg_enable_fw_offload(struct prueth *prueth) icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE); } } + + /* Re-apply flooding state cleared by firmware restart. + * In switch mode, flooding is managed by the bridge via + * switchdev callbacks, not tracked by these flags. + */ + if (!prueth->is_switch_mode && netif_running(emac->ndev)) { + if (emac->uc_flooding_enabled) + icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE); + if (emac->mc_flooding_enabled) + icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); + } } } @@ -1286,16 +1299,23 @@ static void emac_ndo_set_rx_mode_work(struct work_struct *work) icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_DISABLE); if (promisc) { + emac->uc_flooding_enabled = true; + emac->mc_flooding_enabled = true; icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE); icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); return; } if (allmulti) { + emac->mc_flooding_enabled = true; + emac->uc_flooding_enabled = false; icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); return; } + emac->uc_flooding_enabled = false; + emac->mc_flooding_enabled = false; + if (emac->prueth->is_hsr_offload_mode) { /* Track basic add/delete via callbacks */ __dev_mc_sync(ndev, icssg_prueth_hsr_add_mcast, @@ -1934,7 +1954,8 @@ static int prueth_netdevice_port_link(struct net_device *ndev, prueth->br_members & BIT(PRUETH_PORT_MII1)) { prueth->is_switch_mode = true; prueth->default_vlan = PRUETH_DFLT_VLAN_SW; - emac->port_vlan = prueth->default_vlan; + prueth->emac[PRUETH_MAC0]->port_vlan = prueth->default_vlan; + prueth->emac[PRUETH_MAC1]->port_vlan = prueth->default_vlan; icssg_change_mode(prueth); } } @@ -1960,6 +1981,7 @@ static void prueth_netdevice_port_unlink(struct net_device *ndev) dev_err(prueth->dev, "Failed to restart the firmwares, aborting the process"); return; } + icssg_enable_fw_offload(prueth); } prueth_offload_fwd_mark_update(prueth); @@ -2024,6 +2046,7 @@ static void prueth_hsr_port_unlink(struct net_device *ndev) dev_err(prueth->dev, "Failed to restart the firmwares, aborting the process"); return; } + icssg_enable_fw_offload(prueth); netdev_dbg(ndev, "Disabling HSR Offload mode\n"); } } diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h index df93d15c5b78..832e654a102c 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -242,6 +242,10 @@ struct prueth_emac { bool offload_fwd_mark; int port_vlan; + /* UC/MC flooding state - preserved across firmware restarts */ + unsigned int uc_flooding_enabled : 1; + unsigned int mc_flooding_enabled : 1; + struct delayed_work stats_work; u64 stats[ICSSG_NUM_MIIG_STATS]; u64 pa_stats[ICSSG_NUM_PA_STATS]; -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state 2026-11-12 10:21 ` [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state Meghana Malladi @ 2026-11-16 13:54 ` netdev-bot+sashiko 0 siblings, 0 replies; 8+ messages in thread From: netdev-bot+sashiko @ 2026-11-16 13:54 UTC (permalink / raw) To: m-malladi Cc: diogo.ivo, haokexin, philippe.schenker, devnexen, horms, jacob.e.keller, pabeni, kuba, edumazet, davem, andrew+netdev, linux-kernel, netdev, linux-arm-kernel, vigneshr, danishanwar Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 1 (1) · Medium: 1 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] icssg_enable_fw_offload() (lines 247-256) skips the new flood- restore block whenever prueth->is_switch_mode is set. - [Medium] The new uc/mc_flooding_enabled bitfields are written by emac_ndo_set_rx_mode_work(), which runs from schedule_work() (line… - [Low] The Fixes: tag names the wrong commit. Pre-existing issues: - [High] This problem wasn't introduced by this patch, but emac_ndo_set_rx_mode_work() has a check-then-use race that can lead to… -- net: ti: icssg-prueth: Fix bridge port_vlan and flooding state This patch sets port_vlan on both emacs when a bridge is formed. It also records the UC/MC flooding state set from IFF_PROMISC/IFF_ALLMULTI so that icssg_enable_fw_offload() can re-apply it after firmware restarts, and adds a NULL check for unused emac slots in icssg_enable_fw_offload(). > Fixes: 161087db66d6b ("net: ti: icssg-prueth: Add Support for Multicast filtering with VLAN in HSR mode") [Severity: Low] Is this the right commit for the Fixes: tag? In prueth_netdevice_port_link(), 161087db66d6b only replaced the hardcoded default_vlan of 1 with PRUETH_DFLT_VLAN_SW. It did not touch the port_vlan assignment, the restart paths or the flooding logic. This patch fixes the single-emac assignment: emac->port_vlan = prueth->default_vlan; That assignment and the switch mode unlink logic appear to come from abd5576b9c57 ("net: ti: icssg-prueth: Add support for ICSSG switch firmware"). The restart in prueth_netdevice_port_unlink() with no re-apply step afterwards was reworked in 9facce84f406 ("net: ti: icssg-prueth: Fix firmware load sequence."). With the current tag, stable tooling would not pick up trees that have abd5576b9c57 (v6.11 and later) but not 161087db66d6b (v6.14). The patch also combines three fixes with different origins: port_vlan on both emacs, the flood state restore, and the NULL check in icssg_enable_fw_offload(). Could they be split, each with its own Fixes: tag? > diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c > index ef5dce595f68a..48539460ee499 100644 > --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c > +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c [ ... ] > @@ -241,6 +243,17 @@ static void icssg_enable_fw_offload(struct prueth *prueth) > icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE); > } > } > + > + /* Re-apply flooding state cleared by firmware restart. > + * In switch mode, flooding is managed by the bridge via > + * switchdev callbacks, not tracked by these flags. > + */ > + if (!prueth->is_switch_mode && netif_running(emac->ndev)) { [Severity: High] Is the comment above accurate? In icssg_switchdev.c, UC flooding is never handled through switchdev, because BR_FLOOD is rejected: prueth_switchdev_attr_br_flags_pre_set() { if (brport_flags.mask & ~(BR_LEARNING | BR_MCAST_FLOOD)) return -EINVAL; } prueth_switchdev_attr_br_flags_set() handles only BR_MCAST_FLOOD, and only when a brport flag changes. Nothing replays it after the driver restarts the firmware. Also, emac_ndo_set_rx_mode_work() has no is_switch_mode check. It drives UC/MC flooding from IFF_PROMISC/IFF_ALLMULTI and updates these flags in switch mode too. Does the EMAC to switch restart then still lose the flooding state? Take this sequence: ip link set ethA master br0 ip link set ethB master br0 When ethA joins, br_add_if()->br_manage_promisc() puts it in promisc. rx_mode_work then sets uc/mc_flooding_enabled and enables flooding. When ethB joins: prueth_netdevice_port_link() prueth->is_switch_mode = true; icssg_change_mode() prueth_emac_restart() <- firmware flooding state lost icssg_enable_fw_offload() <- restore skipped, is_switch_mode br_port_set_promisc() returns early for ethA because it is already BR_PROMISC, so no new rx_mode_work runs for ethA. ethB is put into promisc only after the upper link, in nbp_update_port_count(). Its rx_mode_work runs after the restart and re-enables flooding on ethB only. ethA would then be in switch mode with UC/MC flooding off in firmware, while its flags still say true. The commit message says flooding is restored "after every firmware restart", but this restart path does not seem to be covered. > + if (emac->uc_flooding_enabled) > + icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE); > + if (emac->mc_flooding_enabled) > + icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); > + } > } > } > > @@ -1286,16 +1299,23 @@ static void emac_ndo_set_rx_mode_work(struct work_struct *work) > icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_DISABLE); > > if (promisc) { > + emac->uc_flooding_enabled = true; > + emac->mc_flooding_enabled = true; > icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE); > icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); > return; > } > > if (allmulti) { > + emac->mc_flooding_enabled = true; > + emac->uc_flooding_enabled = false; > icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE); > return; > } > > + emac->uc_flooding_enabled = false; > + emac->mc_flooding_enabled = false; > + [Severity: Medium] Setting the flags before the ENABLE commands handles the stale false case. Is the matching stale true case on the disable side still open? The work writes these flags without rtnl or any driver lock. icssg_enable_fw_offload() reads them without a lock, under rtnl, from the netdevice notifier. prueth_emac_restart() does not flush or cancel rx_mode_work. The DISABLE commands go out at the top of emac_ndo_set_rx_mode_work(), but the flags are only cleared here. Suppose promisc was on and IFF_PROMISC has just been cleared: rx_mode_work prueth_netdevice_port_unlink() prueth_emac_restart() UC_FLOODING_DISABLE MC_FLOODING_DISABLE icssg_enable_fw_offload() reads uc/mc_flooding_enabled == true (stale) UC_FLOODING_ENABLE MC_FLOODING_ENABLE uc_flooding_enabled = false mc_flooding_enabled = false Would the firmware then keep flooding, with IFF_PROMISC off and the flags false, until the next rx mode change? The allmulti branch above has the same ordering for uc_flooding_enabled. This window opens on every bridge unlink. del_nbp()->nbp_delete_promisc() calls dev_set_promiscuity(-1), which queues rx_mode_work right before netdev_upper_dev_unlink() triggers the unlink restart. prueth_hsr_port_unlink() and icssg_change_mode() can race in the same way. Each R30 command the work sends while the firmware is stopped can also wait for its 10 ms timeout, which widens the window. > if (emac->prueth->is_hsr_offload_mode) { [Severity: High] This isn't a bug introduced by this patch, but can this check-then-use cause a NULL pointer dereference of prueth->hsr_dev? It appears to date from 161087db66d6b. The work reads is_hsr_offload_mode here without rtnl. It then issues sleeping FDB commands through __dev_mc_sync() and icssg_hsr_handle_multicast_sync(); icssg_send_fdb_msg() polls for up to 20 seconds per command. Only after that does it run: if (rtnl_trylock()) { vlan_for_each(emac->prueth->hsr_dev, icssg_update_vlan_mcast, emac); rtnl_unlock(); } Meanwhile, prueth_hsr_port_unlink() can run under rtnl: prueth->is_hsr_offload_mode = false; ... prueth->hsr_dev = NULL; ret = prueth_emac_restart(prueth); The work's FDB commands can stall while the firmware is stopped, so it can stay between the check and the trylock for the whole unlink. The trylock then succeeds, and vlan_for_each(NULL, ...) dereferences dev->vlan_info on a NULL dev. Separately, if rtnl is held when rtnl_trylock() runs (for example by the notifier doing the restart), the VLAN multicast sync is silently skipped and never retried. Should is_hsr_offload_mode and hsr_dev be re-checked under rtnl, and the sync be deferred rather than skipped? > /* Track basic add/delete via callbacks */ > __dev_mc_sync(ndev, icssg_prueth_hsr_add_mcast, [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112102140.2744508-1-m-malladi%40ti.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases 2026-11-12 10:21 [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases Meghana Malladi ` (2 preceding siblings ...) 2026-11-12 10:21 ` [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state Meghana Malladi @ 2026-11-12 10:26 ` netdev-bot+sinfo 3 siblings, 0 replies; 8+ messages in thread From: netdev-bot+sinfo @ 2026-11-12 10:26 UTC (permalink / raw) To: Meghana Malladi Cc: diogo.ivo, haokexin, philippe.schenker, devnexen, horms, jacob.e.keller, pabeni, kuba, edumazet, davem, andrew+netdev, linux-kernel, netdev, linux-arm-kernel, Vignesh Raghavendra, danishanwar Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages. - What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-16 13:55 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-12 10:21 [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases Meghana Malladi 2026-11-12 10:21 ` [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash Meghana Malladi 2026-11-16 13:54 ` netdev-bot+sashiko 2026-11-12 10:21 ` [PATCH net v3 RESEND 2/3] net: ti: icssg-prueth: Fix phylib stop/start in emac_restart Meghana Malladi 2026-11-16 13:54 ` netdev-bot+sashiko 2026-11-12 10:21 ` [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state Meghana Malladi 2026-11-16 13:54 ` netdev-bot+sashiko 2026-11-12 10:26 ` [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases netdev-bot+sinfo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox