Skip to content

Commit efba018

Browse files
Michael Chandavem330
authored andcommitted
bnx2: Add workaround to handle missed MSI.
The bnx2 chips do not support per MSI vector masking. On 5706/5708, new MSI address/data are stored only when the MSI enable bit is toggled. As a result, SMP affinity no longer works in the latest kernel. A more serious problem is that the driver will no longer receive interrupts when the MSI receiving CPU goes offline. The workaround in this patch only addresses the problem of CPU going offline. When that happens, the driver's timer function will detect that it is making no forward progress on pending interrupt events and will recover from it. Eric Dumazet reported the problem. We also found that if an interrupt is internally asserted while MSI and INTA are disabled, the chip will end up in the same state after MSI is re-enabled. The same workaround is needed for this problem. Signed-off-by: Michael Chan <mchan@broadcom.com> Tested-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d5654ef commit efba018

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎drivers/net/bnx2.c‎

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,6 +3144,28 @@ bnx2_has_work(struct bnx2_napi *bnapi)
31443144
return 0;
31453145
}
31463146

3147+
static void
3148+
bnx2_chk_missed_msi(struct bnx2 *bp)
3149+
{
3150+
struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
3151+
u32 msi_ctrl;
3152+
3153+
if (bnx2_has_work(bnapi)) {
3154+
msi_ctrl = REG_RD(bp, BNX2_PCICFG_MSI_CONTROL);
3155+
if (!(msi_ctrl & BNX2_PCICFG_MSI_CONTROL_ENABLE))
3156+
return;
3157+
3158+
if (bnapi->last_status_idx == bp->idle_chk_status_idx) {
3159+
REG_WR(bp, BNX2_PCICFG_MSI_CONTROL, msi_ctrl &
3160+
~BNX2_PCICFG_MSI_CONTROL_ENABLE);
3161+
REG_WR(bp, BNX2_PCICFG_MSI_CONTROL, msi_ctrl);
3162+
bnx2_msi(bp->irq_tbl[0].vector, bnapi);
3163+
}
3164+
}
3165+
3166+
bp->idle_chk_status_idx = bnapi->last_status_idx;
3167+
}
3168+
31473169
static void bnx2_poll_link(struct bnx2 *bp, struct bnx2_napi *bnapi)
31483170
{
31493171
struct status_block *sblk = bnapi->status_blk.msi;
@@ -3218,14 +3240,15 @@ static int bnx2_poll(struct napi_struct *napi, int budget)
32183240

32193241
work_done = bnx2_poll_work(bp, bnapi, work_done, budget);
32203242

3221-
if (unlikely(work_done >= budget))
3222-
break;
3223-
32243243
/* bnapi->last_status_idx is used below to tell the hw how
32253244
* much work has been processed, so we must read it before
32263245
* checking for more work.
32273246
*/
32283247
bnapi->last_status_idx = sblk->status_idx;
3248+
3249+
if (unlikely(work_done >= budget))
3250+
break;
3251+
32293252
rmb();
32303253
if (likely(!bnx2_has_work(bnapi))) {
32313254
netif_rx_complete(bp->dev, napi);
@@ -4570,6 +4593,8 @@ bnx2_init_chip(struct bnx2 *bp)
45704593
for (i = 0; i < BNX2_MAX_MSIX_VEC; i++)
45714594
bp->bnx2_napi[i].last_status_idx = 0;
45724595

4596+
bp->idle_chk_status_idx = 0xffff;
4597+
45734598
bp->rx_mode = BNX2_EMAC_RX_MODE_SORT_MODE;
45744599

45754600
/* Set up how to generate a link change interrupt. */
@@ -5718,6 +5743,10 @@ bnx2_timer(unsigned long data)
57185743
if (atomic_read(&bp->intr_sem) != 0)
57195744
goto bnx2_restart_timer;
57205745

5746+
if ((bp->flags & (BNX2_FLAG_USING_MSI | BNX2_FLAG_ONE_SHOT_MSI)) ==
5747+
BNX2_FLAG_USING_MSI)
5748+
bnx2_chk_missed_msi(bp);
5749+
57215750
bnx2_send_heart_beat(bp);
57225751

57235752
bp->stats_blk->stat_FwRxDrop =

‎drivers/net/bnx2.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ struct l2_fhdr {
378378
* pci_config_l definition
379379
* offset: 0000
380380
*/
381+
#define BNX2_PCICFG_MSI_CONTROL 0x00000058
382+
#define BNX2_PCICFG_MSI_CONTROL_ENABLE (1L<<16)
383+
381384
#define BNX2_PCICFG_MISC_CONFIG 0x00000068
382385
#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2)
383386
#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3)
@@ -6863,6 +6866,9 @@ struct bnx2 {
68636866

68646867
u8 num_tx_rings;
68656868
u8 num_rx_rings;
6869+
6870+
u32 idle_chk_status_idx;
6871+
68666872
};
68676873

68686874
#define REG_RD(bp, offset) \

0 commit comments

Comments
 (0)