Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: mvneta_bm: add suspend/resume to prevent crash after resume
@ 2026-06-11  2:09 Yun Zhou
  2026-06-11  6:03 ` Andrew Lunn
  2026-06-12 16:50 ` Simon Horman
  0 siblings, 2 replies; 4+ messages in thread
From: Yun Zhou @ 2026-06-11  2:09 UTC (permalink / raw)
  To: marcin.s.wojtas, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, yun.zhou

The mvneta driver uses the hardware Buffer Manager (BM) for RX buffer
allocation. During suspend, mvneta disables its clock, causing BM to
lose all buffer address state. On resume, mvneta_bm_port_init() re-
attaches the BM pool to the NIC, but BM hardware returns stale/garbage
buffer addresses. When NAPI poll processes these buffers, DMA cache
sync hits an invalid virtual address causing a kernel panic:

  Unable to handle kernel paging request at virtual address b0000080
  PC is at v7_dma_inv_range
  Call trace:
   v7_dma_inv_range from arch_sync_dma_for_cpu+0x94/0x158
   arch_sync_dma_for_cpu from __dma_sync_single_for_cpu+0xc4/0x15c
   __dma_sync_single_for_cpu from mvneta_rx_swbm+0x6c8/0xf48
   mvneta_rx_swbm from mvneta_poll+0x6fc/0x70c
   mvneta_poll from __napi_poll.constprop.0+0x2c/0x1e0
   __napi_poll.constprop.0 from net_rx_action+0x160/0x2c4
   net_rx_action from handle_softirqs+0xd8/0x2b8
   handle_softirqs from run_ksoftirqd+0x30/0x94
   run_ksoftirqd from smpboot_thread_fn+0x100/0x204
   smpboot_thread_fn from kthread+0xf4/0x110
   kthread from ret_from_fork+0x14/0x28

Fix by adding suspend/resume callbacks to the BM driver:
- suspend: stop BM unit and disable clock
- resume: enable clock, reinitialize BM defaults and restart pools

Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
---
 drivers/net/ethernet/marvell/mvneta_bm.c | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvneta_bm.c b/drivers/net/ethernet/marvell/mvneta_bm.c
index 6bb380494919..a0800b99c007 100644
--- a/drivers/net/ethernet/marvell/mvneta_bm.c
+++ b/drivers/net/ethernet/marvell/mvneta_bm.c
@@ -477,6 +477,30 @@ static void mvneta_bm_remove(struct platform_device *pdev)
 	clk_disable_unprepare(priv->clk);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int mvneta_bm_suspend(struct device *dev)
+{
+	struct mvneta_bm *priv = dev_get_drvdata(dev);
+
+	mvneta_bm_write(priv, MVNETA_BM_COMMAND_REG, MVNETA_BM_STOP_MASK);
+	clk_disable_unprepare(priv->clk);
+	return 0;
+}
+
+static int mvneta_bm_resume(struct device *dev)
+{
+	struct mvneta_bm *priv = dev_get_drvdata(dev);
+
+	clk_prepare_enable(priv->clk);
+	mdelay(1);
+	mvneta_bm_default_set(priv);
+	mvneta_bm_pools_init(priv);
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(mvneta_bm_pm_ops, mvneta_bm_suspend, mvneta_bm_resume);
+
 static const struct of_device_id mvneta_bm_match[] = {
 	{ .compatible = "marvell,armada-380-neta-bm" },
 	{ }
@@ -489,6 +513,7 @@ static struct platform_driver mvneta_bm_driver = {
 	.driver = {
 		.name = MVNETA_BM_DRIVER_NAME,
 		.of_match_table = mvneta_bm_match,
+		.pm = &mvneta_bm_pm_ops,
 	},
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-12 16:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11  2:09 [PATCH] net: mvneta_bm: add suspend/resume to prevent crash after resume Yun Zhou
2026-06-11  6:03 ` Andrew Lunn
2026-06-11  7:23   ` Zhou, Yun
2026-06-12 16:50 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox