All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery.
@ 2015-12-10  0:35 Michael Chan
  2015-12-10  0:35 ` [PATCH net v2 1/4] bnxt_en: Fix bitmap declaration to work on 32-bit arches Michael Chan
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michael Chan @ 2015-12-10  0:35 UTC (permalink / raw)
  To: davem; +Cc: netdev

Fix a bitmap declaration bug and add missing tx timeout recovery.

v2: Fixed white space error.  Thanks Dave.

Michael Chan (4):
  bnxt_en: Fix bitmap declaration to work on 32-bit arches.
  bnxt_en: Change bp->state to bitmap.
  bnxt_en: Don't cancel sp_task from bnxt_close_nic().
  bnxt_en: Implement missing tx timeout reset logic.

 drivers/net/ethernet/broadcom/bnxt/bnxt.c       | 48 +++++++++++++++++--------
 drivers/net/ethernet/broadcom/bnxt/bnxt.h       |  6 ++--
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c |  2 +-
 3 files changed, 37 insertions(+), 19 deletions(-)

-- 
1.8.3.1

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

* [PATCH net v2 1/4] bnxt_en: Fix bitmap declaration to work on 32-bit arches.
  2015-12-10  0:35 [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery Michael Chan
@ 2015-12-10  0:35 ` Michael Chan
  2015-12-10  0:35 ` [PATCH net v2 2/4] bnxt_en: Change bp->state to bitmap Michael Chan
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Chan @ 2015-12-10  0:35 UTC (permalink / raw)
  To: davem; +Cc: netdev

The declaration of the bitmap vf_req_snif_bmap using fixed array of
unsigned long will only work on 64-bit archs.  Use DECLARE_BITMAP instead
which will work on all archs.

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index bdf094f..51671e3 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -2693,17 +2693,16 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)
 	req.ver_upd = DRV_VER_UPD;
 
 	if (BNXT_PF(bp)) {
-		unsigned long vf_req_snif_bmap[4];
+		DECLARE_BITMAP(vf_req_snif_bmap, 256);
 		u32 *data = (u32 *)vf_req_snif_bmap;
 
-		memset(vf_req_snif_bmap, 0, 32);
+		memset(vf_req_snif_bmap, 0, sizeof(vf_req_snif_bmap));
 		for (i = 0; i < ARRAY_SIZE(bnxt_vf_req_snif); i++)
 			__set_bit(bnxt_vf_req_snif[i], vf_req_snif_bmap);
 
-		for (i = 0; i < 8; i++) {
-			req.vf_req_fwd[i] = cpu_to_le32(*data);
-			data++;
-		}
+		for (i = 0; i < 8; i++)
+			req.vf_req_fwd[i] = cpu_to_le32(data[i]);
+
 		req.enables |=
 			cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_VF_REQ_FWD);
 	}
-- 
1.8.3.1

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

* [PATCH net v2 2/4] bnxt_en: Change bp->state to bitmap.
  2015-12-10  0:35 [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery Michael Chan
  2015-12-10  0:35 ` [PATCH net v2 1/4] bnxt_en: Fix bitmap declaration to work on 32-bit arches Michael Chan
@ 2015-12-10  0:35 ` Michael Chan
  2015-12-10  0:35 ` [PATCH net v2 3/4] bnxt_en: Don't cancel sp_task from bnxt_close_nic() Michael Chan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Chan @ 2015-12-10  0:35 UTC (permalink / raw)
  To: davem; +Cc: netdev

This allows multiple independent bits to be set for various states.
Subsequent patches to implement tx timeout reset will require this.

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c       | 8 ++++----
 drivers/net/ethernet/broadcom/bnxt/bnxt.h       | 5 ++---
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 51671e3..fd89e9d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4602,7 +4602,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
 			bp->nge_port_cnt = 1;
 	}
 
-	bp->state = BNXT_STATE_OPEN;
+	set_bit(BNXT_STATE_OPEN, &bp->state);
 	bnxt_enable_int(bp);
 	/* Enable TX queues */
 	bnxt_tx_enable(bp);
@@ -4678,7 +4678,7 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
 	/* Change device state to avoid TX queue wake up's */
 	bnxt_tx_disable(bp);
 
-	bp->state = BNXT_STATE_CLOSED;
+	clear_bit(BNXT_STATE_OPEN, &bp->state);
 	cancel_work_sync(&bp->sp_task);
 
 	/* Flush rings before disabling interrupts */
@@ -5080,7 +5080,7 @@ static void bnxt_sp_task(struct work_struct *work)
 	struct bnxt *bp = container_of(work, struct bnxt, sp_task);
 	int rc;
 
-	if (bp->state != BNXT_STATE_OPEN)
+	if (!test_bit(BNXT_STATE_OPEN, &bp->state))
 		return;
 
 	if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event))
@@ -5185,7 +5185,7 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
 	bp->timer.function = bnxt_timer;
 	bp->current_interval = BNXT_TIMER_INTERVAL;
 
-	bp->state = BNXT_STATE_CLOSED;
+	clear_bit(BNXT_STATE_OPEN, &bp->state);
 
 	return 0;
 
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 674bc51..a8b6881 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -925,9 +925,8 @@ struct bnxt {
 
 	struct timer_list	timer;
 
-	int			state;
-#define BNXT_STATE_CLOSED	0
-#define BNXT_STATE_OPEN		1
+	unsigned long		state;
+#define BNXT_STATE_OPEN		0
 
 	struct bnxt_irq	*irq_tbl;
 	u8			mac_addr[ETH_ALEN];
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index 7a9af28..ea044bb 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -21,7 +21,7 @@
 #ifdef CONFIG_BNXT_SRIOV
 static int bnxt_vf_ndo_prep(struct bnxt *bp, int vf_id)
 {
-	if (bp->state != BNXT_STATE_OPEN) {
+	if (!test_bit(BNXT_STATE_OPEN, &bp->state)) {
 		netdev_err(bp->dev, "vf ndo called though PF is down\n");
 		return -EINVAL;
 	}
-- 
1.8.3.1

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

* [PATCH net v2 3/4] bnxt_en: Don't cancel sp_task from bnxt_close_nic().
  2015-12-10  0:35 [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery Michael Chan
  2015-12-10  0:35 ` [PATCH net v2 1/4] bnxt_en: Fix bitmap declaration to work on 32-bit arches Michael Chan
  2015-12-10  0:35 ` [PATCH net v2 2/4] bnxt_en: Change bp->state to bitmap Michael Chan
@ 2015-12-10  0:35 ` Michael Chan
  2015-12-10  0:35 ` [PATCH net v2 4/4] bnxt_en: Implement missing tx timeout reset logic Michael Chan
  2015-12-12  4:34 ` [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Chan @ 2015-12-10  0:35 UTC (permalink / raw)
  To: davem; +Cc: netdev

When implementing driver reset from tx_timeout in the next patch,
bnxt_close_nic() will be called from the sp_task workqueue.  Calling
cancel_work() on sp_task will hang the workqueue.

Instead, set a new bit BNXT_STATE_IN_SP_TASK when bnxt_sp_task() is running.
bnxt_close_nic() will wait for BNXT_STATE_IN_SP_TASK to clear before
proceeding.

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++++++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  1 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index fd89e9d..f5f4489 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4679,7 +4679,9 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
 	bnxt_tx_disable(bp);
 
 	clear_bit(BNXT_STATE_OPEN, &bp->state);
-	cancel_work_sync(&bp->sp_task);
+	smp_mb__after_atomic();
+	while (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state))
+		msleep(20);
 
 	/* Flush rings before disabling interrupts */
 	bnxt_shutdown_nic(bp, irq_re_init);
@@ -5080,8 +5082,12 @@ static void bnxt_sp_task(struct work_struct *work)
 	struct bnxt *bp = container_of(work, struct bnxt, sp_task);
 	int rc;
 
-	if (!test_bit(BNXT_STATE_OPEN, &bp->state))
+	set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+	smp_mb__after_atomic();
+	if (!test_bit(BNXT_STATE_OPEN, &bp->state)) {
+		clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
 		return;
+	}
 
 	if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event))
 		bnxt_cfg_rx_mode(bp);
@@ -5107,6 +5113,9 @@ static void bnxt_sp_task(struct work_struct *work)
 	}
 	if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))
 		bnxt_reset_task(bp);
+
+	smp_mb__before_atomic();
+	clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
 }
 
 static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index a8b6881..f199f4c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -927,6 +927,7 @@ struct bnxt {
 
 	unsigned long		state;
 #define BNXT_STATE_OPEN		0
+#define BNXT_STATE_IN_SP_TASK	1
 
 	struct bnxt_irq	*irq_tbl;
 	u8			mac_addr[ETH_ALEN];
-- 
1.8.3.1

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

* [PATCH net v2 4/4] bnxt_en: Implement missing tx timeout reset logic.
  2015-12-10  0:35 [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery Michael Chan
                   ` (2 preceding siblings ...)
  2015-12-10  0:35 ` [PATCH net v2 3/4] bnxt_en: Don't cancel sp_task from bnxt_close_nic() Michael Chan
@ 2015-12-10  0:35 ` Michael Chan
  2015-12-12  4:34 ` [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Chan @ 2015-12-10  0:35 UTC (permalink / raw)
  To: davem; +Cc: netdev

The reset logic calls bnxt_close_nic() and bnxt_open_nic() under rtnl_lock
from bnxt_sp_task.  BNXT_STATE_IN_SP_TASK must be cleared before calling
bnxt_close_nic() to avoid deadlock.

v2: Fixed white space error.  Thanks Dave.

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index f5f4489..0c2c3f5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -5031,8 +5031,10 @@ static void bnxt_dbg_dump_states(struct bnxt *bp)
 static void bnxt_reset_task(struct bnxt *bp)
 {
 	bnxt_dbg_dump_states(bp);
-	if (netif_running(bp->dev))
-		bnxt_tx_disable(bp); /* prevent tx timout again */
+	if (netif_running(bp->dev)) {
+		bnxt_close_nic(bp, false, false);
+		bnxt_open_nic(bp, false, false);
+	}
 }
 
 static void bnxt_tx_timeout(struct net_device *dev)
@@ -5111,8 +5113,16 @@ static void bnxt_sp_task(struct work_struct *work)
 		bnxt_hwrm_tunnel_dst_port_free(
 			bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_VXLAN);
 	}
-	if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))
-		bnxt_reset_task(bp);
+	if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) {
+		/* bnxt_reset_task() calls bnxt_close_nic() which waits
+		 * for BNXT_STATE_IN_SP_TASK to clear.
+		 */
+		clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+		rtnl_lock();
+		bnxt_reset_task(bp);
+		set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
+		rtnl_unlock();
+	}
 
 	smp_mb__before_atomic();
 	clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
-- 
1.8.3.1

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

* Re: [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery.
  2015-12-10  0:35 [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery Michael Chan
                   ` (3 preceding siblings ...)
  2015-12-10  0:35 ` [PATCH net v2 4/4] bnxt_en: Implement missing tx timeout reset logic Michael Chan
@ 2015-12-12  4:34 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-12-12  4:34 UTC (permalink / raw)
  To: mchan; +Cc: netdev

From: Michael Chan <mchan@broadcom.com>
Date: Wed, 9 Dec 2015 19:35:40 -0500

> Fix a bitmap declaration bug and add missing tx timeout recovery.
> 
> v2: Fixed white space error.  Thanks Dave.

Series applied, thanks Michael.

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

end of thread, other threads:[~2015-12-12  4:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10  0:35 [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery Michael Chan
2015-12-10  0:35 ` [PATCH net v2 1/4] bnxt_en: Fix bitmap declaration to work on 32-bit arches Michael Chan
2015-12-10  0:35 ` [PATCH net v2 2/4] bnxt_en: Change bp->state to bitmap Michael Chan
2015-12-10  0:35 ` [PATCH net v2 3/4] bnxt_en: Don't cancel sp_task from bnxt_close_nic() Michael Chan
2015-12-10  0:35 ` [PATCH net v2 4/4] bnxt_en: Implement missing tx timeout reset logic Michael Chan
2015-12-12  4:34 ` [PATCH net v2 0/4] bnxt_en: Bug fix and add tx timeout recovery David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.