netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bnx2x: Fix error recovering in switch configuration
@ 2022-08-25 20:00 Thinh Tran
  2022-08-27  1:44 ` Jakub Kicinski
  2022-08-30  9:19 ` [EXT] [PATCH] bnx2x: Fix error recovering in switch configuration Manish Chopra
  0 siblings, 2 replies; 41+ messages in thread
From: Thinh Tran @ 2022-08-25 20:00 UTC (permalink / raw)
  To: kuba; +Cc: netdev, aelior, davem, manishc, skalluru, Thinh Tran

As the BCM57810 and other I/O adapters are connected
through a PCIe switch, the bnx2x driver causes unexpected
system hang/crash while handling PCIe switch errors, if 
its error handler is called after other drivers' handlers.

In this case, after numbers of bnx2x_tx_timout(), the
bnx2x_nic_unload() is  called, frees up resources and
calls bnx2x_napi_disable(). Then when EEH calls its
error handler, the bnx2x_io_error_detected() and
bnx2x_io_slot_reset() also calling bnx2x_napi_disable()
and freeing the resources.

This patch will:
- reduce the numbers of bnx2x_panic_dump() while in
  bnx2x_tx_timeout(), avoid filling up dmesg buffer.
- use checking new napi_enable flags to prevent calling 
  disable again which causing system hangs.
- cheking if fp->page_pool already freed avoid system
  crash.

Signed-off-by: Thinh Tran <thinhtr@linux.vnet.ibm.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h   |  4 ++++
 .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c   | 24 ++++++++++++++++++-
 .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h   |  3 +++
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index dd5945c4bfec..7fa23d47907a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1509,6 +1509,10 @@ struct bnx2x {
 	bool			cnic_loaded;
 	struct cnic_eth_dev	*(*cnic_probe)(struct net_device *);
 
+	bool			napi_enable;
+	bool			cnic_napi_enable;
+	int			tx_timeout_cnt;
+
 	/* Flag that indicates that we can start looking for FCoE L2 queue
 	 * completions in the default status block.
 	 */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 712b5595bc39..bb8d91f44642 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1860,37 +1860,49 @@ static int bnx2x_setup_irqs(struct bnx2x *bp)
 static void bnx2x_napi_enable_cnic(struct bnx2x *bp)
 {
 	int i;
+	if (bp->cnic_napi_enable)
+		return;
 
 	for_each_rx_queue_cnic(bp, i) {
 		napi_enable(&bnx2x_fp(bp, i, napi));
 	}
+	bp->cnic_napi_enable = true;
 }
 
 static void bnx2x_napi_enable(struct bnx2x *bp)
 {
 	int i;
+	if (bp->napi_enable)
+		return;
 
 	for_each_eth_queue(bp, i) {
 		napi_enable(&bnx2x_fp(bp, i, napi));
 	}
+	bp->napi_enable = true;
 }
 
 static void bnx2x_napi_disable_cnic(struct bnx2x *bp)
 {
 	int i;
+	if (!bp->cnic_napi_enable)
+		return;
 
 	for_each_rx_queue_cnic(bp, i) {
 		napi_disable(&bnx2x_fp(bp, i, napi));
 	}
+	bp->cnic_napi_enable = false;
 }
 
 static void bnx2x_napi_disable(struct bnx2x *bp)
 {
 	int i;
+	if (!bp->napi_enable)
+		return;
 
 	for_each_eth_queue(bp, i) {
 		napi_disable(&bnx2x_fp(bp, i, napi));
 	}
+	bp->napi_enable = false;
 }
 
 void bnx2x_netif_start(struct bnx2x *bp)
@@ -2554,6 +2566,7 @@ int bnx2x_load_cnic(struct bnx2x *bp)
 	}
 
 	/* Add all CNIC NAPI objects */
+	bp->cnic_napi_enable = false;
 	bnx2x_add_all_napi_cnic(bp);
 	DP(NETIF_MSG_IFUP, "cnic napi added\n");
 	bnx2x_napi_enable_cnic(bp);
@@ -2701,7 +2714,9 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 	 */
 	bnx2x_setup_tc(bp->dev, bp->max_cos);
 
+	bp->tx_timeout_cnt = 0;
 	/* Add all NAPI objects */
+	bp->napi_enable = false;
 	bnx2x_add_all_napi(bp);
 	DP(NETIF_MSG_IFUP, "napi added\n");
 	bnx2x_napi_enable(bp);
@@ -4982,7 +4997,14 @@ void bnx2x_tx_timeout(struct net_device *dev, unsigned int txqueue)
 	 */
 	if (!bp->panic)
 #ifndef BNX2X_STOP_ON_ERROR
-		bnx2x_panic_dump(bp, false);
+	{
+		if (++bp->tx_timeout_cnt > 3) {
+			bnx2x_panic_dump(bp, false);
+			bp->tx_timeout_cnt = 0;
+		} else {
+			netdev_err(bp->dev, "TX timeout %d times\n", bp->tx_timeout_cnt);
+		}
+	}
 #else
 		bnx2x_panic();
 #endif
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index d8b1824c334d..7e1d38a2c7ec 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -1018,6 +1018,9 @@ static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp,
 	if (fp->mode == TPA_MODE_DISABLED)
 		return;
 
+	if (!fp->page_pool.page)
+		return;
+
 	for (i = 0; i < last; i++)
 		bnx2x_free_rx_sge(bp, fp, i);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread
* Re: [Patch v6 0/4] bnx2x: Fix error recovering in switch configuration
@ 2023-11-16 16:08 Thinh Tran
  2023-11-16 20:56 ` Simon Horman
  2024-01-17 21:56 ` Thinh Tran
  0 siblings, 2 replies; 41+ messages in thread
From: Thinh Tran @ 2023-11-16 16:08 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: aelior, davem, edumazet, manishc, netdev, pabeni, skalluru,
	VENKATA.SAI.DUGGI, Thinh Tran, Abdul Haleem, David Christensen,
	Simon Horman

Hi,

Could we proceed with advancing these patches? They've been in the 
"Awaiting Upstream" state for a while now. Notably, one of them has 
successfully made it to the mainline kernel:
  [v6,1/4] bnx2x: new flag for tracking HW resource
 
https://github.com/torvalds/linux/commit/bf23ffc8a9a777dfdeb04232e0946b803adbb6a9

As testing the latest kernel, we are still encountering crashes due to 
the absence of one of the patches:
   [v6,3/4] bnx2x: Prevent access to a freed page in page_pool.

Is there anything specific I need to do to help moving these patches 
forward?
We would greatly appreciate if they could be incorporated into the 
mainline kernel.

Thank you,
Thinh Tran

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

end of thread, other threads:[~2024-01-18 16:53 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25 20:00 [PATCH] bnx2x: Fix error recovering in switch configuration Thinh Tran
2022-08-27  1:44 ` Jakub Kicinski
2022-08-30 16:15   ` Thinh Tran
2022-09-16 19:51   ` [PATCH v2] " Thinh Tran
2022-09-19 13:53     ` [EXT] " Manish Chopra
2022-09-21 20:11       ` Thinh Tran
2022-09-28 21:33         ` Thinh Tran
2022-10-10 22:01           ` Thinh Tran
2022-10-17 11:14             ` Manish Chopra
2022-10-20 19:12               ` Thinh Tran
2023-07-19 22:02     ` [Patch v3] " Thinh Tran
2023-07-24 11:48       ` Simon Horman
2023-07-24 22:50       ` Jakub Kicinski
2023-07-27 13:29         ` Thinh Tran
2023-07-28 21:11     ` [PATCH v4] " Thinh Tran
2023-08-01  0:47       ` Jakub Kicinski
2023-08-01  8:30         ` Paolo Abeni
2023-08-07 21:15           ` Thinh Tran
2023-08-07 21:08         ` Thinh Tran
2023-08-07 21:24           ` Jakub Kicinski
2023-08-07 21:35           ` Jakub Kicinski
2023-08-11 20:15       ` [Patch v5 0/4] " Thinh Tran
2023-08-11 20:15         ` [Patch v5 1/4] bnx2x: new the bp->nic_stopped variable for checking NIC status Thinh Tran
2023-08-11 20:15         ` [Patch v5 2/4] bnx2x: factor out common code to bnx2x_stop_nic() Thinh Tran
2023-08-11 22:08           ` Jakub Kicinski
2023-08-11 20:15         ` [Patch v5 3/4] bnx2x: Prevent access to a freed page in page_pool Thinh Tran
2023-08-11 20:15         ` [Patch v5 4/4] bnx2x: prevent excessive debug information during a TX timeout Thinh Tran
2023-08-11 22:09         ` [Patch v5 0/4] bnx2x: Fix error recovering in switch configuration Jakub Kicinski
2023-08-18 13:24           ` Thinh Tran
2023-08-18 16:14       ` [Patch v6 " Thinh Tran
2023-08-18 16:14         ` [Patch v6 1/4] bnx2x: new flag for track HW resource Thinh Tran
2023-08-18 16:14         ` [Patch v6 2/4] bnx2x: factor out common code to bnx2x_stop_nic() Thinh Tran
2023-08-18 16:14         ` [Patch v6 3/4] bnx2x: Prevent access to a freed page in page_pool Thinh Tran
2023-08-18 16:14         ` [Patch v6 4/4] bnx2x: prevent excessive debug information during a TX timeout Thinh Tran
2022-08-30  9:19 ` [EXT] [PATCH] bnx2x: Fix error recovering in switch configuration Manish Chopra
2022-08-30 21:01   ` Thinh Tran
  -- strict thread matches above, loose matches on Subject: below --
2023-11-16 16:08 [Patch v6 0/4] " Thinh Tran
2023-11-16 20:56 ` Simon Horman
2024-01-17 21:56 ` Thinh Tran
2024-01-17 23:55   ` Jakub Kicinski
2024-01-18 16:53     ` Thinh Tran

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).