linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] net: mvpp2: clear BM pool before initialization
@ 2024-01-16  5:57 Jenishkumar Maheshbhai Patel
  2024-01-16  9:26 ` Russell King (Oracle)
  2024-01-16 15:11 ` Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: Jenishkumar Maheshbhai Patel @ 2024-01-16  5:57 UTC (permalink / raw)
  To: marcin.s.wojtas, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel
  Cc: Jenishkumar Maheshbhai Patel

Register value persisted after booting the kernel using
kexec which resulted in kernel panic. Thus cleared the
BM pool registers before initialisation to fix the issue.

Signed-off-by: Jenishkumar Maheshbhai Patel <jpatel2@marvell.com>
---
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 820b1fabe297..8223c00d1f91 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -614,12 +614,40 @@ 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)
+{
+	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_read(priv, MVPP2_BM_PHY_ALLOC_REG(pool_id));
+	/* 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);
+	/* Mask BM all interrupts */
+	mvpp2_write(priv, MVPP2_BM_INTR_MASK_REG(pool_id), 0);
+	/* Clear BM cause register */
+	mvpp2_write(priv, MVPP2_BM_INTR_CAUSE_REG(pool_id), 0);
+}
+
 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;
+
+	for (i = 0; i < poolnum; i++) {
+		/* Make sure about the pool state in case it was
+		 * used by firmware.
+		 */
+		mvpp2_bm_pool_cleanup(priv, i);
+	}
+
 	if (priv->percpu_pools) {
 		for (i = 0; i < priv->port_count; i++) {
 			port = priv->port_list[i];
-- 
2.25.1


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

* Re: [PATCH 1/1] net: mvpp2: clear BM pool before initialization
  2024-01-16  5:57 [PATCH 1/1] net: mvpp2: clear BM pool before initialization Jenishkumar Maheshbhai Patel
@ 2024-01-16  9:26 ` Russell King (Oracle)
  2024-01-16 11:42   ` [EXT] " Jenishkumar Patel [C]
  2024-01-16 15:11 ` Jakub Kicinski
  1 sibling, 1 reply; 5+ messages in thread
From: Russell King (Oracle) @ 2024-01-16  9:26 UTC (permalink / raw)
  To: Jenishkumar Maheshbhai Patel
  Cc: marcin.s.wojtas, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

On Mon, Jan 15, 2024 at 09:57:54PM -0800, Jenishkumar Maheshbhai Patel wrote:
>  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;
> +
> +	for (i = 0; i < poolnum; i++) {
> +		/* Make sure about the pool state in case it was
> +		 * used by firmware.
> +		 */
> +		mvpp2_bm_pool_cleanup(priv, i);
> +	}

	/* Clean up the pool state in case it contains stale state */
	for (i = 0; i < poolnum; i++)
		mvpp2_bm_pool_cleanup(priv, i);

Doesn't need quite as many lines!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* RE: [EXT] Re: [PATCH 1/1] net: mvpp2: clear BM pool before initialization
  2024-01-16  9:26 ` Russell King (Oracle)
@ 2024-01-16 11:42   ` Jenishkumar Patel [C]
  0 siblings, 0 replies; 5+ messages in thread
From: Jenishkumar Patel [C] @ 2024-01-16 11:42 UTC (permalink / raw)
  To: 'Russell King'
  Cc: marcin.s.wojtas@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org



-----Original Message-----
From: Russell King <linux@armlinux.org.uk> 
Sent: Tuesday, January 16, 2024 2:56 PM
To: Jenishkumar Patel [C] <jpatel2@marvell.com>
Cc: marcin.s.wojtas@gmail.com; davem@davemloft.net; edumazet@google.com; kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: [EXT] Re: [PATCH 1/1] net: mvpp2: clear BM pool before initialization

External Email

----------------------------------------------------------------------
On Mon, Jan 15, 2024 at 09:57:54PM -0800, Jenishkumar Maheshbhai Patel wrote:
>  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;
> +
> +	for (i = 0; i < poolnum; i++) {
> +		/* Make sure about the pool state in case it was
> +		 * used by firmware.
> +		 */
> +		mvpp2_bm_pool_cleanup(priv, i);
> +	}

	/* Clean up the pool state in case it contains stale state */
	for (i = 0; i < poolnum; i++)
		mvpp2_bm_pool_cleanup(priv, i);

Doesn't need quite as many lines!

I will address the comments in v2

--
RMK's Patch system: https://urldefense.proofpoint.com/v2/url?u=https-3A__www.armlinux.org.uk_developer_patches_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=weFk2fYEO0yNIZAlSXwm82u5QM08YlNJaQ39RhfTtUo&m=2U4cWAQSanajVfFvpZbZdhHMcQ4rsCILgPZ1Nk_k-CE3HMuIv3y5IPWQ4KgdJgAG&s=IbrApY-e2TWgCw8YQJc7W48jpUGy29BTy_MfcTkwQ8I&e=
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH 1/1] net: mvpp2: clear BM pool before initialization
  2024-01-16  5:57 [PATCH 1/1] net: mvpp2: clear BM pool before initialization Jenishkumar Maheshbhai Patel
  2024-01-16  9:26 ` Russell King (Oracle)
@ 2024-01-16 15:11 ` Jakub Kicinski
  2024-01-17  3:55   ` [EXT] " Jenishkumar Patel [C]
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2024-01-16 15:11 UTC (permalink / raw)
  To: Jenishkumar Maheshbhai Patel
  Cc: marcin.s.wojtas, linux, davem, edumazet, pabeni, netdev,
	linux-kernel

On Mon, 15 Jan 2024 21:57:54 -0800 Jenishkumar Maheshbhai Patel wrote:
> Register value persisted after booting the kernel using
> kexec which resulted in kernel panic. Thus cleared the
> BM pool registers before initialisation to fix the issue.

s/persisted/persist/
s/resulted/results/
s/cleared/clear/

When you post v2 please add a Fixes tag -- it may be the first commit
that added this driver if the issue has always been there.

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

* RE: [EXT] Re: [PATCH 1/1] net: mvpp2: clear BM pool before initialization
  2024-01-16 15:11 ` Jakub Kicinski
@ 2024-01-17  3:55   ` Jenishkumar Patel [C]
  0 siblings, 0 replies; 5+ messages in thread
From: Jenishkumar Patel [C] @ 2024-01-17  3:55 UTC (permalink / raw)
  To: 'Jakub Kicinski'
  Cc: marcin.s.wojtas@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org


-----Original Message-----
From: Jakub Kicinski <kuba@kernel.org> 
Sent: Tuesday, January 16, 2024 8:41 PM
To: Jenishkumar Patel [C] <jpatel2@marvell.com>
Cc: marcin.s.wojtas@gmail.com; linux@armlinux.org.uk; davem@davemloft.net; edumazet@google.com; pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: [EXT] Re: [PATCH 1/1] net: mvpp2: clear BM pool before initialization

External Email

----------------------------------------------------------------------
On Mon, 15 Jan 2024 21:57:54 -0800 Jenishkumar Maheshbhai Patel wrote:
> Register value persisted after booting the kernel using kexec which 
> resulted in kernel panic. Thus cleared the BM pool registers before 
> initialisation to fix the issue.

s/persisted/persist/
s/resulted/results/
s/cleared/clear/

When you post v2 please add a Fixes tag -- it may be the first commit that added this driver if the issue has always been there.

I will make corrections and post it in v2.

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

end of thread, other threads:[~2024-01-17  3:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-16  5:57 [PATCH 1/1] net: mvpp2: clear BM pool before initialization Jenishkumar Maheshbhai Patel
2024-01-16  9:26 ` Russell King (Oracle)
2024-01-16 11:42   ` [EXT] " Jenishkumar Patel [C]
2024-01-16 15:11 ` Jakub Kicinski
2024-01-17  3:55   ` [EXT] " Jenishkumar Patel [C]

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).