Skip to content

Commit 9f538b4

Browse files
Jenishkumar Maheshbhai Patelkuba-moo
authored andcommitted
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: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Jenishkumar Maheshbhai Patel <jpatel2@marvell.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Link: https://lore.kernel.org/r/20240119035914.2595665-1-jpatel2@marvell.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a5f5eee commit 9f538b4

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,12 +614,38 @@ static void mvpp23_bm_set_8pool_mode(struct mvpp2 *priv)
614614
mvpp2_write(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG, val);
615615
}
616616

617+
/* Cleanup pool before actual initialization in the OS */
618+
static void mvpp2_bm_pool_cleanup(struct mvpp2 *priv, int pool_id)
619+
{
620+
unsigned int thread = mvpp2_cpu_to_thread(priv, get_cpu());
621+
u32 val;
622+
int i;
623+
624+
/* Drain the BM from all possible residues left by firmware */
625+
for (i = 0; i < MVPP2_BM_POOL_SIZE_MAX; i++)
626+
mvpp2_thread_read(priv, thread, MVPP2_BM_PHY_ALLOC_REG(pool_id));
627+
628+
put_cpu();
629+
630+
/* Stop the BM pool */
631+
val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(pool_id));
632+
val |= MVPP2_BM_STOP_MASK;
633+
mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(pool_id), val);
634+
}
635+
617636
static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv)
618637
{
619638
enum dma_data_direction dma_dir = DMA_FROM_DEVICE;
620639
int i, err, poolnum = MVPP2_BM_POOLS_NUM;
621640
struct mvpp2_port *port;
622641

642+
if (priv->percpu_pools)
643+
poolnum = mvpp2_get_nrxqs(priv) * 2;
644+
645+
/* Clean up the pool state in case it contains stale state */
646+
for (i = 0; i < poolnum; i++)
647+
mvpp2_bm_pool_cleanup(priv, i);
648+
623649
if (priv->percpu_pools) {
624650
for (i = 0; i < priv->port_count; i++) {
625651
port = priv->port_list[i];
@@ -629,7 +655,6 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv)
629655
}
630656
}
631657

632-
poolnum = mvpp2_get_nrxqs(priv) * 2;
633658
for (i = 0; i < poolnum; i++) {
634659
/* the pool in use */
635660
int pn = i / (poolnum / 2);

0 commit comments

Comments
 (0)