* [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic
@ 2026-11-20 20:24 Chris Babroski
2026-11-20 20:24 ` [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX Chris Babroski
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Chris Babroski @ 2026-11-20 20:24 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, davthompson, cbabroski
Background
----------
On BlueField 2 and BlueField 3 the MAC HW is designed to repeatedly send
pause frames to its link partner when the RX FIFO is full. The internal
Ethernet switch on BlueField that is connected to this port is also
designed to stop traffic on all ports when it receives a high number of
continuous pause frames from one of the ports.
What this means is that when the MAC RX FIFO cannot be drained (e.g. due
to panic), it is possible to reproduce a scenario under steady and high
network load where the network becomes inaccessible for other devices
connected to the 3-port switch, namely the OOB host and DPU-BMC.
What this patch series does
---------------------------
Register a panic notifier at highest priority that disables MAC RX and
clears the RX FIFO to ensure that the MAC can no longer receive packets
or send pause frames after a kernel panic.
Add protection in the mlxbf_gige driver for the case when firmware
disables the MAC after handling a fatal error or panic that the kernel
could not detect.
Testing
-------
The following testing was done:
* Verified no performance difference when testing with iperf.
* No regressions found when copying large files to and from DUT.
* Repeated module load/unload succeeds.
* Bringing interface down and up repeatedly succeeds.
* Flooded the interface with broadcast packets to keep MAC RX FIFO full
while monitoring pause frames received on the internal 3 port switch.
With this test setup verified pause frames stopped after:
* ATF FW panic
* kernel panic triggered with sysrq
* power off
* reboot
* module unload
* No unexpected kernel Oops or warnings when implementing custom ATF FW
to disable OOB MAC while mlxbf_gige is actively draining the RX queue.
Chris Babroski (2):
mlxbf_gige: protect against MAC disable during TX
mlxbf_gige: disable MAC after kernel panic
.../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h | 2 +
.../mellanox/mlxbf_gige/mlxbf_gige_main.c | 39 +++++++++++++++++++
.../mellanox/mlxbf_gige/mlxbf_gige_tx.c | 29 +++++++++-----
3 files changed, 60 insertions(+), 10 deletions(-)
base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX 2026-11-20 20:24 [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic Chris Babroski @ 2026-11-20 20:24 ` Chris Babroski 2026-11-24 20:44 ` netdev-bot+sashiko 2026-11-20 20:24 ` [PATCH net-next v1 2/2] mlxbf_gige: disable MAC after kernel panic Chris Babroski 2026-11-20 20:27 ` [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic netdev-bot+sinfo 2 siblings, 1 reply; 7+ messages in thread From: Chris Babroski @ 2026-11-20 20:24 UTC (permalink / raw) To: netdev, linux-kernel Cc: andrew+netdev, davem, edumazet, kuba, pabeni, davthompson, cbabroski On BlueField, firmware can disable and reset the OOB MAC when it handles a fatal error or panic. If Linux is still actively transmitting packets while the MAC is disabled, then it's possible for the HW consumer index to be reset while the SW completion index in the driver remains the same. This can cause the two indices to suddenly become far apart, with a difference that is potentially larger than the TX queue length itself. Previously, mlxbf_gige_handle_tx_complete() would continue to loop around the TX queue, counting packets and freeing their memory, until the two indices were equal. If entries were already freed the first time through the queue, then a second attempt could cause a NULL pointer dereference. Bound the loop over the length of the TX queue so entries are not handled more than once, and check that the skb at tx_wqe_index is not NULL before handling. After the loop, set the SW completion index to the new HW consumer index to prevent future polls from walking the queue again. In normal operation the loop already exits with the two indices equal, so there is no change in behavior. TX is not recovered after a sudden MAC disable. If firmware has disabled the MAC then the system is in a state where it will be rebooting automatically or needs manual intervention to recover. Signed-off-by: Chris Babroski <cbabroski@nvidia.com> --- .../mellanox/mlxbf_gige/mlxbf_gige_tx.c | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c index 04982e888c63..73c3033591d5 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c @@ -130,6 +130,7 @@ bool mlxbf_gige_handle_tx_complete(struct mlxbf_gige *priv) u64 *tx_wqe_addr; u64 tx_status; u16 tx_ci; + u16 entry; tx_status = readq(priv->base + MLXBF_GIGE_TX_STATUS); if (tx_status & MLXBF_GIGE_TX_STATUS_DATA_FIFO_FULL) @@ -143,7 +144,8 @@ bool mlxbf_gige_handle_tx_complete(struct mlxbf_gige *priv) * to be supported, that is TX consumer index wrapped from 0xFFFF * to 0 while TX completion index is still < 0xFFFF. */ - for (; priv->prev_tx_ci != tx_ci; priv->prev_tx_ci++) { + for (entry = 0; priv->prev_tx_ci != tx_ci && entry < priv->tx_q_entries; + priv->prev_tx_ci++, entry++) { tx_wqe_index = priv->prev_tx_ci % priv->tx_q_entries; /* Each TX WQE is 16 bytes. The 8 MSB store the 2KB TX * buffer address and the 8 LSB contain information @@ -152,18 +154,25 @@ bool mlxbf_gige_handle_tx_complete(struct mlxbf_gige *priv) tx_wqe_addr = priv->tx_wqe_base + (tx_wqe_index * MLXBF_GIGE_TX_WQE_SZ_QWORDS); - stats->tx_packets++; - stats->tx_bytes += MLXBF_GIGE_TX_WQE_PKT_LEN(tx_wqe_addr); - - dma_unmap_single(priv->dev, *tx_wqe_addr, - priv->tx_skb[tx_wqe_index]->len, DMA_TO_DEVICE); - dev_consume_skb_any(priv->tx_skb[tx_wqe_index]); - priv->tx_skb[tx_wqe_index] = NULL; + if (priv->tx_skb[tx_wqe_index]) { + stats->tx_packets++; + stats->tx_bytes += MLXBF_GIGE_TX_WQE_PKT_LEN(tx_wqe_addr); + dma_unmap_single(priv->dev, *tx_wqe_addr, + priv->tx_skb[tx_wqe_index]->len, DMA_TO_DEVICE); + dev_consume_skb_any(priv->tx_skb[tx_wqe_index]); + priv->tx_skb[tx_wqe_index] = NULL; - /* Ensure completion of updates across all cores */ - mb(); + /* Ensure completion of updates across all cores */ + mb(); + } } + /* At this point the completion index should be equal to the + * consumer index. If they aren't then the driver is out of sync + * from the HW's state and needs to be adjusted. + */ + priv->prev_tx_ci = tx_ci; + /* Since the TX ring was likely just drained, check if TX queue * had previously been stopped and now that there are TX buffers * available the TX queue can be awakened. -- 2.34.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX 2026-11-20 20:24 ` [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX Chris Babroski @ 2026-11-24 20:44 ` netdev-bot+sashiko 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-24 20:44 UTC (permalink / raw) To: cbabroski Cc: netdev, linux-kernel, andrew+netdev, davem, edumazet, kuba, pabeni, davthompson Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 3 · Low: 2 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). - [Medium] The patch resyncs only the consumer side (`priv->prev_tx_ci = tx_ci`, mlxbf_gige_tx.c:174) and leaves `priv->tx_pi` unchanged. - [Medium] When the HW consumer index goes backwards (e.g. prev_tx_ci=500, tx_pi=510, CI reads 0), `(u16)(tx_ci - prev_tx_ci)`… - [Medium] In the desync case the new loop bound lets the NAPI completion walk all `tx_q_entries` slots starting at prev_tx_ci. - [Low] This commit fixes a NULL pointer dereference (oops in NAPI/softirq context) in mlxbf_gige_handle_tx_complete() that a… - [Low] The comment above the TX completion loop in mlxbf_gige_handle_tx_complete() (lines 140-146) still says the logic… -- mlxbf_gige: protect against MAC disable during TX This patch limits the TX completion loop in mlxbf_gige_handle_tx_complete() to tx_q_entries iterations and skips NULL tx_skb[] slots. After the loop it sets prev_tx_ci to the HW consumer index. The goal is to fix a NULL pointer dereference seen when firmware disables and resets the OOB MAC while TX is in flight. > Previously, mlxbf_gige_handle_tx_complete() would continue to loop > around the TX queue, counting packets and freeing their memory, until > the two indices were equal. If entries were already freed the first time > through the queue, then a second attempt could cause a NULL pointer > dereference. [Severity: Low] This fixes a NULL pointer dereference in NAPI context, so should it carry a Fixes: tag? The unbounded loop and the unconditional priv->tx_skb[tx_wqe_index]->len dereference both come from: Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") > diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c > index 04982e888c635..73c3033591d59 100644 > --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c > +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_tx.c [ ... ] > @@ -143,7 +144,8 @@ bool mlxbf_gige_handle_tx_complete(struct mlxbf_gige *priv) > * to be supported, that is TX consumer index wrapped from 0xFFFF > * to 0 while TX completion index is still < 0xFFFF. > */ > - for (; priv->prev_tx_ci != tx_ci; priv->prev_tx_ci++) { > + for (entry = 0; priv->prev_tx_ci != tx_ci && entry < priv->tx_q_entries; > + priv->prev_tx_ci++, entry++) { [Severity: Medium] When the indices are out of sync, can this loop run past tx_pi into slots that mlxbf_gige_start_xmit() owns? mlxbf_gige_handle_tx_complete() runs from mlxbf_gige_poll(), which mlxbf_gige_rx_intr() can schedule. It holds neither priv->lock nor the netdev TX lock. Take prev_tx_ci = 1000, tx_pi = 1005 and a CI reset to 0. The loop visits ring positions 1000 through 1127, and positions 1005 onward are free slots that another CPU may be filling at the same time: CPU1 mlxbf_gige_start_xmit() *tx_wqe_addr = tx_buf_dma; /* outside priv->lock */ ... spin_lock_irqsave(&priv->lock, flags); priv->tx_skb[priv->tx_pi % priv->tx_q_entries] = tx_skb; priv->tx_pi++; CPU2 mlxbf_gige_handle_tx_complete() if (priv->tx_skb[tx_wqe_index]) { ... dma_unmap_single(priv->dev, *tx_wqe_addr, ...); dev_consume_skb_any(priv->tx_skb[tx_wqe_index]); Could CPU2 free an skb that CPU1 has just queued? The plain NULL check also doesn't order the *tx_wqe_addr load after the tx_skb[] load. On the producer side, nothing orders the WQE store before the tx_skb[] store. On arm64, could CPU2 see the new skb together with the old, already unmapped DMA address? That would unmap a stale address a second time and leak the new mapping. Would bounding the walk by tx_pi - prev_tx_ci, sampled under priv->lock, keep it out of producer-owned slots? [Severity: Low] This isn't a bug, but the comment above this loop still says the completion logic "needs to loop until the completion index (in SW) equals TX consumer index (from HW)". With the new tx_q_entries bound, the loop can exit with prev_tx_ci != tx_ci. Should the comment be updated? > tx_wqe_index = priv->prev_tx_ci % priv->tx_q_entries; > /* Each TX WQE is 16 bytes. The 8 MSB store the 2KB TX > * buffer address and the 8 LSB contain information > @@ -152,18 +154,25 @@ bool mlxbf_gige_handle_tx_complete(struct mlxbf_gige *priv) > tx_wqe_addr = priv->tx_wqe_base + > (tx_wqe_index * MLXBF_GIGE_TX_WQE_SZ_QWORDS); > > - stats->tx_packets++; > - stats->tx_bytes += MLXBF_GIGE_TX_WQE_PKT_LEN(tx_wqe_addr); > - > - dma_unmap_single(priv->dev, *tx_wqe_addr, > - priv->tx_skb[tx_wqe_index]->len, DMA_TO_DEVICE); > - dev_consume_skb_any(priv->tx_skb[tx_wqe_index]); > - priv->tx_skb[tx_wqe_index] = NULL; > + if (priv->tx_skb[tx_wqe_index]) { > + stats->tx_packets++; > + stats->tx_bytes += MLXBF_GIGE_TX_WQE_PKT_LEN(tx_wqe_addr); > + dma_unmap_single(priv->dev, *tx_wqe_addr, > + priv->tx_skb[tx_wqe_index]->len, DMA_TO_DEVICE); > + dev_consume_skb_any(priv->tx_skb[tx_wqe_index]); [Severity: Medium] Suppose the HW consumer index goes backwards, for example prev_tx_ci = 500, tx_pi = 510 and CI reads 0. Then (u16)(tx_ci - prev_tx_ci) looks like almost a full wrap, and this loop runs all tx_q_entries iterations. Every non-NULL slot is unmapped, freed and counted in tx_packets/tx_bytes. That includes the in-flight descriptors between prev_tx_ci and tx_pi, which the hardware never completed. The coherent WQE ring still holds the bus addresses of those freed buffers. mlxbf_gige_start_xmit() also keeps writing a tx_pi that is far ahead of the HW CI: writeq(priv->tx_pi, priv->base + MLXBF_GIGE_TX_PRODUCER_INDEX); The only thing stopping the device from DMAing out of these buffers is the commit message's statement that firmware has disabled the MAC. Nothing here checks MAC or DMA enable state. If TX DMA is still active when CI is seen going backwards, or if firmware re-enables the MAC later, can the device read freed and possibly reallocated pages? Before this patch the kernel oopsed in this path, so those pages were not reused while the system kept running. > + priv->tx_skb[tx_wqe_index] = NULL; > > - /* Ensure completion of updates across all cores */ > - mb(); > + /* Ensure completion of updates across all cores */ > + mb(); > + } > } > > + /* At this point the completion index should be equal to the > + * consumer index. If they aren't then the driver is out of sync > + * from the HW's state and needs to be adjusted. > + */ > + priv->prev_tx_ci = tx_ci; [Severity: Medium] Only the consumer side is resynced here, and priv->tx_pi stays where it was. mlxbf_gige_tx_buffs_avail() assumes prev_tx_ci trails tx_pi by less than tx_q_entries. Does this break that assumption? mlxbf_gige_tx_buffs_avail() computes: avail = ((priv->tx_q_entries + priv->prev_tx_ci - priv->tx_pi) % priv->tx_q_entries) - 1; The u16 operands are promoted to int. With tx_q_entries = 128, tx_pi = 1000 and the HW CI reset to 0, the numerator is negative. avail comes out as -105 and is returned as the u16 value 65431. Once tx_pi - prev_tx_ci is larger than tx_q_entries, avail can never be 0. If the queue was stopped because the ring was full, the code right after this resync wakes it: if (netif_queue_stopped(priv->netdev) && mlxbf_gige_tx_buffs_avail(priv)) netif_wake_queue(priv->netdev); After that, this check in mlxbf_gige_start_xmit() never fires again: if (!mlxbf_gige_tx_buffs_avail(priv)) { /* TX ring is full, inform stack */ netif_stop_queue(netdev); With the MAC disabled nothing completes, because every poll sees prev_tx_ci == tx_ci. After tx_q_entries more packets, mlxbf_gige_start_xmit() starts overwriting slots that still hold DMA-mapped skbs: priv->tx_skb[priv->tx_pi % priv->tx_q_entries] = tx_skb; Does each overwrite leak the old skb, its DMA mapping and its socket wmem charge? In the example above that continues until tx_pi wraps the 16 bits, roughly 64K packets. The driver has no ndo_tx_timeout and doesn't log the desync, so nothing else stops it. A related case: the walk is bounded by tx_q_entries, not by the posted window tx_pi - prev_tx_ci. A CI reset that lands within tx_q_entries of prev_tx_ci, for example prev_tx_ci = 65500, tx_pi = 65505 and CI = 0, is handled as a normal completion and ends up in the same state. Packets the disabled MAC never sent are also counted in tx_packets/tx_bytes and released with dev_consume_skb_any(), rather than counted as drops. The commit message says: TX is not recovered after a sudden MAC disable. Should it also say that the driver keeps accepting packets and leaking them in this state? Alternatively, should the queue be stopped once the desync is detected? > /* Since the TX ring was likely just drained, check if TX queue > * had previously been stopped and now that there are TX buffers > * available the TX queue can be awakened. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795206150.git.cbabroski%40nvidia.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v1 2/2] mlxbf_gige: disable MAC after kernel panic 2026-11-20 20:24 [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic Chris Babroski 2026-11-20 20:24 ` [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX Chris Babroski @ 2026-11-20 20:24 ` Chris Babroski 2026-11-24 20:44 ` netdev-bot+sashiko 2026-11-20 20:27 ` [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic netdev-bot+sinfo 2 siblings, 1 reply; 7+ messages in thread From: Chris Babroski @ 2026-11-20 20:24 UTC (permalink / raw) To: netdev, linux-kernel Cc: andrew+netdev, davem, edumazet, kuba, pabeni, davthompson, cbabroski After a kernel panic the MAC continues to receive packets into the RX FIFO even though the driver can no longer process them. By default, the MAC HW is designed to repeatedly send pause frames to its link partner when the RX FIFO is full. The internal Ethernet switch on BlueField that is connected to this port is also designed to stop traffic on all ports when it receives a high number of continuous pause frames from one of the ports. What this means is that when the kernel panics on BlueField, it is possible to reproduce a scenario under steady and high network load where the network becomes inaccessible for other devices connected to the 3-port switch, namely the OOB host and DPU-BMC. Register a panic notifier at highest priority that disables MAC RX and clears the RX FIFO to ensure that the MAC can no longer receive packets or send pause frames. Signed-off-by: Chris Babroski <cbabroski@nvidia.com> --- .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h | 2 + .../mellanox/mlxbf_gige/mlxbf_gige_main.c | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h index e7777700ee18..c63bdfae4344 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h @@ -13,6 +13,7 @@ #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/irqreturn.h> #include <linux/netdevice.h> +#include <linux/notifier.h> #include <linux/irq.h> #include <linux/phy.h> @@ -130,6 +131,7 @@ struct mlxbf_gige { u8 hw_version; struct mlxbf_gige_mdio_gw *mdio_gw; int prev_speed; + struct notifier_block panic_nb; }; /* Rx Work Queue Element definitions */ diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c index d1f8a72cae53..76da71108345 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c @@ -12,6 +12,7 @@ #include <linux/interrupt.h> #include <linux/iopoll.h> #include <linux/module.h> +#include <linux/panic_notifier.h> #include <linux/phy.h> #include <linux/platform_device.h> #include <linux/rtnetlink.h> @@ -127,6 +128,27 @@ static int mlxbf_gige_clean_port(struct mlxbf_gige *priv) return err; } +static void mlxbf_gige_disable_port(struct mlxbf_gige *priv) +{ + u64 control; + + /* Disable RX DMA */ + control = readq(priv->base + MLXBF_GIGE_RX_DMA); + control &= ~MLXBF_GIGE_RX_DMA_EN; + writeq(control, priv->base + MLXBF_GIGE_RX_DMA); + + /* Disable port */ + control = readq(priv->base + MLXBF_GIGE_CONTROL); + control &= ~MLXBF_GIGE_CONTROL_PORT_EN; + writeq(control, priv->base + MLXBF_GIGE_CONTROL); + + /* Disable interrupts */ + writeq(0, priv->base + MLXBF_GIGE_INT_EN); + + /* Ensure completion of disable writes before cleaning the port */ + mb(); +} + static int mlxbf_gige_open(struct net_device *netdev) { struct mlxbf_gige *priv = netdev_priv(netdev); @@ -382,6 +404,17 @@ static struct mlxbf_gige_link_cfg mlxbf_gige_link_cfgs[] = { } }; +static int mlxbf_gige_on_panic(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct mlxbf_gige *priv; + + priv = container_of(nb, struct mlxbf_gige, panic_nb); + mlxbf_gige_disable_port(priv); + mlxbf_gige_clean_port(priv); + return NOTIFY_DONE; +} + static int mlxbf_gige_probe(struct platform_device *pdev) { struct phy_device *phydev; @@ -446,6 +479,10 @@ static int mlxbf_gige_probe(struct platform_device *pdev) /* Write initial MAC address to hardware */ mlxbf_gige_initial_mac(priv); + priv->panic_nb.priority = INT_MAX; + priv->panic_nb.notifier_call = mlxbf_gige_on_panic; + atomic_notifier_chain_register(&panic_notifier_list, &priv->panic_nb); + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (err) { dev_err(&pdev->dev, "DMA configuration failed: %pe\n", ERR_PTR(err)); @@ -497,6 +534,7 @@ static int mlxbf_gige_probe(struct platform_device *pdev) return 0; out: + atomic_notifier_chain_unregister(&panic_notifier_list, &priv->panic_nb); mlxbf_gige_mdio_remove(priv); return err; } @@ -507,6 +545,7 @@ static void mlxbf_gige_remove(struct platform_device *pdev) unregister_netdev(priv->netdev); phy_disconnect(priv->netdev->phydev); + atomic_notifier_chain_unregister(&panic_notifier_list, &priv->panic_nb); mlxbf_gige_mdio_remove(priv); platform_set_drvdata(pdev, NULL); } -- 2.34.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v1 2/2] mlxbf_gige: disable MAC after kernel panic 2026-11-20 20:24 ` [PATCH net-next v1 2/2] mlxbf_gige: disable MAC after kernel panic Chris Babroski @ 2026-11-24 20:44 ` netdev-bot+sashiko 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-24 20:44 UTC (permalink / raw) To: cbabroski Cc: netdev, linux-kernel, andrew+netdev, davem, edumazet, kuba, pabeni, davthompson Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 2 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). - [Medium] The new MAC quiesce never runs on the kdump path, so after a panic the pause-frame storm the commit message describes can still… - [Medium] The commit message says the notifier "disables MAC RX and clears the RX FIFO". - [Low] The commit fixes a production failure: after a panic, the BlueField internal switch stops traffic to the OOB host and DPU-BMC. - [Low] mlxbf_gige_on_panic() clears MLXBF_GIGE_CONTROL_PORT_EN (in mlxbf_gige_disable_port()) and only then calls mlxbf_gige_clean_port(). -- mlxbf_gige: disable MAC after kernel panic This commit registers a panic notifier at INT_MAX priority from mlxbf_gige_probe(). On panic, the notifier disables RX DMA, the port and interrupts, then soft-resets the port with mlxbf_gige_clean_port(). The goal is to stop the MAC from filling the RX FIFO and sending pause frames to the internal BlueField switch. > Register a panic notifier at highest priority that disables MAC RX and > clears the RX FIFO to ensure that the MAC can no longer receive packets > or send pause frames. > > Signed-off-by: Chris Babroski <cbabroski@nvidia.com> [Severity: Low] Should this carry a Fixes: tag, and possibly Cc: stable? The commit message describes a user-visible failure: after a panic, the internal switch stops traffic to the OOB host and DPU-BMC. The missing panic-time quiesce goes back to when the driver was added: Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver") > diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c > index d1f8a72cae537..76da711083453 100644 > --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c > +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c [ ... ] > @@ -127,6 +128,27 @@ static int mlxbf_gige_clean_port(struct mlxbf_gige *priv) > return err; > } > > +static void mlxbf_gige_disable_port(struct mlxbf_gige *priv) > +{ > + u64 control; > + > + /* Disable RX DMA */ > + control = readq(priv->base + MLXBF_GIGE_RX_DMA); > + control &= ~MLXBF_GIGE_RX_DMA_EN; > + writeq(control, priv->base + MLXBF_GIGE_RX_DMA); > + > + /* Disable port */ > + control = readq(priv->base + MLXBF_GIGE_CONTROL); > + control &= ~MLXBF_GIGE_CONTROL_PORT_EN; > + writeq(control, priv->base + MLXBF_GIGE_CONTROL); > + > + /* Disable interrupts */ > + writeq(0, priv->base + MLXBF_GIGE_INT_EN); [Severity: Medium] The commit message says the notifier "disables MAC RX and clears the RX FIFO". This code goes further. It clears MLXBF_GIGE_CONTROL_PORT_EN for the whole port and zeroes MLXBF_GIGE_INT_EN, and then mlxbf_gige_on_panic() soft-resets the port with mlxbf_gige_clean_port(). Can this break netconsole on this interface during a panic? netconsole registers as an atomic-unsafe nbcon console: drivers/net/netconsole.c: con->flags = CON_ENABLED | CON_NBCON | CON_NBCON_ATOMIC_UNSAFE | flags; During a panic, these consoles only print from nbcon_atomic_flush_unsafe(). vpanic() calls that long after the notifier chain: kernel/panic.c:vpanic() { ... atomic_notifier_call_chain(&panic_notifier_list, 0, buf); ... console_flush_on_panic(CONSOLE_FLUSH_PENDING); nbcon_atomic_flush_unsafe(); ... } At INT_MAX priority, this notifier runs first in the chain. Suppose a netconsole target is bound to the mlxbf_gige OOB port. The pending panic output (the "Kernel panic - not syncing" line, the backtrace, the panic_print output) then goes out through netpoll -> mlxbf_gige_start_xmit() on a port that is already disabled and reset. Wouldn't that output be lost without any warning? This assumes that clearing PORT_EN and doing the soft reset also stop TX. The commit message relies on the same assumption when it says the MAC can no longer send pause frames. The commit message also doesn't cover the TX side, the netconsole interaction, or why INT_MAX priority is needed. Could it be updated to explain these? [ ... ] > @@ -382,6 +404,17 @@ static struct mlxbf_gige_link_cfg mlxbf_gige_link_cfgs[] = { > } > }; > > +static int mlxbf_gige_on_panic(struct notifier_block *nb, > + unsigned long action, void *data) > +{ > + struct mlxbf_gige *priv; > + > + priv = container_of(nb, struct mlxbf_gige, panic_nb); > + mlxbf_gige_disable_port(priv); > + mlxbf_gige_clean_port(priv); > + return NOTIFY_DONE; > +} [Severity: Low] Does the hardware support doing these steps in this order? mlxbf_gige_disable_port() clears PORT_EN before mlxbf_gige_clean_port() runs. Until now the driver has always called clean_port with the port enabled. For example, in mlxbf_gige_open(): control = readq(priv->base + MLXBF_GIGE_CONTROL); control |= MLXBF_GIGE_CONTROL_PORT_EN; writeq(control, priv->base + MLXBF_GIGE_CONTROL); mlxbf_gige_cache_stats(priv); err = mlxbf_gige_clean_port(priv); mlxbf_gige_stop() also calls mlxbf_gige_clean_port() with PORT_EN still set. The CLEAN_PORT_EN soft reset may need the port enabled to flush the RX FIFO and raise MLXBF_GIGE_STATUS_READY. If so, readq_poll_timeout_atomic() in mlxbf_gige_clean_port() would spin for 100ms and then return -ETIMEDOUT. Because the return value is ignored here, the RX FIFO could stay full with nothing reported. Would it make sense to clean the port before clearing PORT_EN, or at least log the timeout? [ ... ] > @@ -446,6 +479,10 @@ static int mlxbf_gige_probe(struct platform_device *pdev) > /* Write initial MAC address to hardware */ > mlxbf_gige_initial_mac(priv); > > + priv->panic_nb.priority = INT_MAX; > + priv->panic_nb.notifier_call = mlxbf_gige_on_panic; > + atomic_notifier_chain_register(&panic_notifier_list, &priv->panic_nb); [Severity: Medium] Does this handle the kdump case? Suppose a crash kernel is loaded and crash_kexec_post_notifiers is left at its default. vpanic() then hands control to the crash kernel before the panic notifier chain runs: kernel/panic.c:vpanic() { ... if (!_crash_kexec_post_notifiers) __crash_kexec(NULL); ... atomic_notifier_call_chain(&panic_notifier_list, 0, buf); ... } In that case mlxbf_gige_on_panic() never runs. PORT_EN, RX_DMA_EN and the broadcast, local MAC and multicast RX filters all stay enabled. The RX WQ and CQ still point at the panicked kernel's buffers. Once those WQEs are used up, wouldn't the RX FIFO fill again and bring back the pause frame storm the commit message describes? The crash kernel's mlxbf_gige_probe() only partly helps: for (i = 0; i <= MLXBF_GIGE_MAX_FILTER_IDX; i++) mlxbf_gige_disable_mac_rx_filter(priv, i); mlxbf_gige_disable_multicast_rx(priv); mlxbf_gige_disable_promisc(priv); Probe never clears RX_DMA_EN or PORT_EN and never calls mlxbf_gige_clean_port(). A FIFO that is already full only gets drained if the crash kernel opens the interface, or at the reboot after the dump. If the crash kernel doesn't load this driver at all, nothing quiesces the port. Should probe also fully quiesce and clean the port? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795206150.git.cbabroski%40nvidia.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic 2026-11-20 20:24 [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic Chris Babroski 2026-11-20 20:24 ` [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX Chris Babroski 2026-11-20 20:24 ` [PATCH net-next v1 2/2] mlxbf_gige: disable MAC after kernel panic Chris Babroski @ 2026-11-20 20:27 ` netdev-bot+sinfo 2026-11-20 20:43 ` Chris Babroski 2 siblings, 1 reply; 7+ messages in thread From: netdev-bot+sinfo @ 2026-11-20 20:27 UTC (permalink / raw) To: Chris Babroski Cc: netdev, linux-kernel, andrew+netdev, davem, edumazet, kuba, pabeni, davthompson Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. 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. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- 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] 7+ messages in thread
* Re: [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic 2026-11-20 20:27 ` [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic netdev-bot+sinfo @ 2026-11-20 20:43 ` Chris Babroski 0 siblings, 0 replies; 7+ messages in thread From: Chris Babroski @ 2026-11-20 20:43 UTC (permalink / raw) To: netdev-bot+sinfo Cc: andrew+netdev, cbabroski, davem, davthompson, edumazet, kuba, linux-kernel, netdev, pabeni > This is an automated message. This series looks like a fix, but its > commit messages seem to be missing some information: > > - How the issue was discovered, e.g. hit in production, hit during > development, syzbot report, manual code inspection, LLM or static > analysis tool scan. This is a theoretical issue that has not yet been seen in production. It can, however, be reproduced manually. It was found because we hit a similar issue in production last year that caused OOB network traffic to stop when our UEFI FW could not process packets fast enough during HTTP boot to keep the RX FIFO drained (see cover letter for more background about how this affects the network). After fixing the FW to prevent that case from occurring, we decided it would be good to add protection to our kernel driver to ensure that a kernel panic does not leave the OOB MAC in a state where the RX FIFO can continue to fill while nothing can drain it. Chris ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-24 20:44 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-20 20:24 [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic Chris Babroski 2026-11-20 20:24 ` [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX Chris Babroski 2026-11-24 20:44 ` netdev-bot+sashiko 2026-11-20 20:24 ` [PATCH net-next v1 2/2] mlxbf_gige: disable MAC after kernel panic Chris Babroski 2026-11-24 20:44 ` netdev-bot+sashiko 2026-11-20 20:27 ` [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic netdev-bot+sinfo 2026-11-20 20:43 ` Chris Babroski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®