bnxt_en: Bug fix and add tx timeout recovery.
v2 cover bnxt_en: Bug fix and add tx timeout recovery.
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(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/4 bnxt_en: Fix bitmap declaration to work on 32-bit arches.
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.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -6
@@ -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 ); }
Signature · 1 line
1.8.3.1
PATCH v2 2/4 bnxt_en: Change bp->state to bitmap.
In reply to Michael ChanThis allows multiple independent bits to be set for various states. Subsequent patches to implement tx timeout reset will require this.
--- 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(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -4
@@ -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 ;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -3
@@ -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 0struct bnxt_irq *irq_tbl;u8 mac_addr[ETH_ALEN ];
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +1 -1
@@ -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 ; }
Signature · 1 line
1.8.3.1
PATCH v2 3/4 bnxt_en: Don't cancel sp_task from bnxt_close_nic().
In reply to Michael ChanWhen 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.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +11 -2
@@ -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)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -927,6 +927,7 @@ struct bnxt {unsigned long state;#define BNXT_STATE_OPEN 0 +#define BNXT_STATE_IN_SP_TASK 1struct bnxt_irq *irq_tbl;u8 mac_addr[ETH_ALEN ];
Signature · 1 line
1.8.3.1
PATCH v2 4/4 bnxt_en: Implement missing tx timeout reset logic.
In reply to Michael ChanThe 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.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +14 -4
@@ -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);
Signature · 1 line
1.8.3.1
David Miller
maintainerFrom: Michael Chan <[email protected]>
Date: Wed, 9 Dec 2015 19:35:40 -0500
Quoted 3 lines
Fix a bitmap declaration bug and add missing tx timeout recovery.
v2: Fixed white space error. Thanks Dave.
Series applied, thanks Michael.