Skip to content

Commit 173d26f

Browse files
committed
Merge branch 'bnxt_en-fixes'
Michael Chan says: ==================== 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. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents d110986 + 028de14 commit 173d26f

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,17 +2693,16 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)
26932693
req.ver_upd = DRV_VER_UPD;
26942694

26952695
if (BNXT_PF(bp)) {
2696-
unsigned long vf_req_snif_bmap[4];
2696+
DECLARE_BITMAP(vf_req_snif_bmap, 256);
26972697
u32 *data = (u32 *)vf_req_snif_bmap;
26982698

2699-
memset(vf_req_snif_bmap, 0, 32);
2699+
memset(vf_req_snif_bmap, 0, sizeof(vf_req_snif_bmap));
27002700
for (i = 0; i < ARRAY_SIZE(bnxt_vf_req_snif); i++)
27012701
__set_bit(bnxt_vf_req_snif[i], vf_req_snif_bmap);
27022702

2703-
for (i = 0; i < 8; i++) {
2704-
req.vf_req_fwd[i] = cpu_to_le32(*data);
2705-
data++;
2706-
}
2703+
for (i = 0; i < 8; i++)
2704+
req.vf_req_fwd[i] = cpu_to_le32(data[i]);
2705+
27072706
req.enables |=
27082707
cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_VF_REQ_FWD);
27092708
}
@@ -4603,7 +4602,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
46034602
bp->nge_port_cnt = 1;
46044603
}
46054604

4606-
bp->state = BNXT_STATE_OPEN;
4605+
set_bit(BNXT_STATE_OPEN, &bp->state);
46074606
bnxt_enable_int(bp);
46084607
/* Enable TX queues */
46094608
bnxt_tx_enable(bp);
@@ -4679,8 +4678,10 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
46794678
/* Change device state to avoid TX queue wake up's */
46804679
bnxt_tx_disable(bp);
46814680

4682-
bp->state = BNXT_STATE_CLOSED;
4683-
cancel_work_sync(&bp->sp_task);
4681+
clear_bit(BNXT_STATE_OPEN, &bp->state);
4682+
smp_mb__after_atomic();
4683+
while (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state))
4684+
msleep(20);
46844685

46854686
/* Flush rings before disabling interrupts */
46864687
bnxt_shutdown_nic(bp, irq_re_init);
@@ -5030,8 +5031,10 @@ static void bnxt_dbg_dump_states(struct bnxt *bp)
50305031
static void bnxt_reset_task(struct bnxt *bp)
50315032
{
50325033
bnxt_dbg_dump_states(bp);
5033-
if (netif_running(bp->dev))
5034-
bnxt_tx_disable(bp); /* prevent tx timout again */
5034+
if (netif_running(bp->dev)) {
5035+
bnxt_close_nic(bp, false, false);
5036+
bnxt_open_nic(bp, false, false);
5037+
}
50355038
}
50365039

50375040
static void bnxt_tx_timeout(struct net_device *dev)
@@ -5081,8 +5084,12 @@ static void bnxt_sp_task(struct work_struct *work)
50815084
struct bnxt *bp = container_of(work, struct bnxt, sp_task);
50825085
int rc;
50835086

5084-
if (bp->state != BNXT_STATE_OPEN)
5087+
set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
5088+
smp_mb__after_atomic();
5089+
if (!test_bit(BNXT_STATE_OPEN, &bp->state)) {
5090+
clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
50855091
return;
5092+
}
50865093

50875094
if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event))
50885095
bnxt_cfg_rx_mode(bp);
@@ -5106,8 +5113,19 @@ static void bnxt_sp_task(struct work_struct *work)
51065113
bnxt_hwrm_tunnel_dst_port_free(
51075114
bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_VXLAN);
51085115
}
5109-
if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))
5116+
if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) {
5117+
/* bnxt_reset_task() calls bnxt_close_nic() which waits
5118+
* for BNXT_STATE_IN_SP_TASK to clear.
5119+
*/
5120+
clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
5121+
rtnl_lock();
51105122
bnxt_reset_task(bp);
5123+
set_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
5124+
rtnl_unlock();
5125+
}
5126+
5127+
smp_mb__before_atomic();
5128+
clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
51115129
}
51125130

51135131
static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
@@ -5186,7 +5204,7 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
51865204
bp->timer.function = bnxt_timer;
51875205
bp->current_interval = BNXT_TIMER_INTERVAL;
51885206

5189-
bp->state = BNXT_STATE_CLOSED;
5207+
clear_bit(BNXT_STATE_OPEN, &bp->state);
51905208

51915209
return 0;
51925210

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -925,9 +925,9 @@ struct bnxt {
925925

926926
struct timer_list timer;
927927

928-
int state;
929-
#define BNXT_STATE_CLOSED 0
930-
#define BNXT_STATE_OPEN 1
928+
unsigned long state;
929+
#define BNXT_STATE_OPEN 0
930+
#define BNXT_STATE_IN_SP_TASK 1
931931

932932
struct bnxt_irq *irq_tbl;
933933
u8 mac_addr[ETH_ALEN];

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifdef CONFIG_BNXT_SRIOV
2222
static int bnxt_vf_ndo_prep(struct bnxt *bp, int vf_id)
2323
{
24-
if (bp->state != BNXT_STATE_OPEN) {
24+
if (!test_bit(BNXT_STATE_OPEN, &bp->state)) {
2525
netdev_err(bp->dev, "vf ndo called though PF is down\n");
2626
return -EINVAL;
2727
}

0 commit comments

Comments
 (0)