From f4b1a580708b53a544ae7d4ce1770e087a4d6dfb Mon Sep 17 00:00:00 2001 From: Pavan Naregundi <92989231+pavannaregundi@users.noreply.github.com> Date: Wed, 14 Feb 2024 09:58:47 +0530 Subject: [PATCH] Fix kexec kernel panic in mvpp2 (#377) Signed-off-by: Pavan Naregundi --- ...-clear-BM-pool-before-initialization.patch | 72 +++++++++++++++++++ patch/series | 1 + 2 files changed, 73 insertions(+) create mode 100644 patch/0012-net-mvpp2-clear-BM-pool-before-initialization.patch diff --git a/patch/0012-net-mvpp2-clear-BM-pool-before-initialization.patch b/patch/0012-net-mvpp2-clear-BM-pool-before-initialization.patch new file mode 100644 index 000000000000..e0d066ecd819 --- /dev/null +++ b/patch/0012-net-mvpp2-clear-BM-pool-before-initialization.patch @@ -0,0 +1,72 @@ +From 09ca6f153d5d36f2f553f22dfca4e216654084fd Mon Sep 17 00:00:00 2001 +From: Jenishkumar Maheshbhai Patel +Date: Thu, 18 Jan 2024 19:59:14 -0800 +Subject: net: mvpp2: clear BM pool before initialization + +Register value persist after booting the kernel using +kexec which results in kernel panic. Thus clear the +BM pool registers before initialisation to fix the issue. + +Fixes: 3f518509dedc ("ethernet: Add new driver for Marvell Armada 375 network unit") +Signed-off-by: Jenishkumar Maheshbhai Patel +Reviewed-by: Maxime Chevallier +Link: https://lore.kernel.org/r/20240119035914.2595665-1-jpatel2@marvell.com +Signed-off-by: Jakub Kicinski +--- + .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 27 ++++++++++++++++++- + 1 file changed, 26 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +index b399bdb1c..5d6309ca7 100644 +--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c ++++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +@@ -614,12 +614,38 @@ static void mvpp23_bm_set_8pool_mode(struct mvpp2 *priv) + mvpp2_write(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG, val); + } + ++/* Cleanup pool before actual initialization in the OS */ ++static void mvpp2_bm_pool_cleanup(struct mvpp2 *priv, int pool_id) ++{ ++ unsigned int thread = mvpp2_cpu_to_thread(priv, get_cpu()); ++ u32 val; ++ int i; ++ ++ /* Drain the BM from all possible residues left by firmware */ ++ for (i = 0; i < MVPP2_BM_POOL_SIZE_MAX; i++) ++ mvpp2_thread_read(priv, thread, MVPP2_BM_PHY_ALLOC_REG(pool_id)); ++ ++ put_cpu(); ++ ++ /* Stop the BM pool */ ++ val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(pool_id)); ++ val |= MVPP2_BM_STOP_MASK; ++ mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(pool_id), val); ++} ++ + static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv) + { + enum dma_data_direction dma_dir = DMA_FROM_DEVICE; + int i, err, poolnum = MVPP2_BM_POOLS_NUM; + struct mvpp2_port *port; + ++ if (priv->percpu_pools) ++ poolnum = mvpp2_get_nrxqs(priv) * 2; ++ ++ /* Clean up the pool state in case it contains stale state */ ++ for (i = 0; i < poolnum; i++) ++ mvpp2_bm_pool_cleanup(priv, i); ++ + if (priv->percpu_pools) { + for (i = 0; i < priv->port_count; i++) { + port = priv->port_list[i]; +@@ -629,7 +655,6 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv) + } + } + +- poolnum = mvpp2_get_nrxqs(priv) * 2; + for (i = 0; i < poolnum; i++) { + /* the pool in use */ + int pn = i / (poolnum / 2); +-- +2.25.1 + diff --git a/patch/series b/patch/series index dafb0ca00418..52c534d3f7f6 100755 --- a/patch/series +++ b/patch/series @@ -156,6 +156,7 @@ cisco-npu-disable-other-bars.patch 0009-dt-bindings-marvell-Add-ARMADA-7K-properties.patch 0010-dts-marvell-Add-support-for-7020-comexpress.patch 0011-arm64-dts-marvell-Add-Nokia-7215-IXS-A1-board.patch +0012-net-mvpp2-clear-BM-pool-before-initialization.patch # amd-pensando elba support 0000-Add-support-for-the-TI-TPS53659.patch