Skip to content

Commit c32f632

Browse files
Vasundhara Volamgregkh
authored andcommitted
bnxt_en: Re-write PCI BARs after PCI fatal error.
[ Upstream commit f75d9a0 ] When a PCIe fatal error occurs, the internal latched BAR addresses in the chip get reset even though the BAR register values in config space are retained. pci_restore_state() will not rewrite the BAR addresses if the BAR address values are valid, causing the chip's internal BAR addresses to stay invalid. So we need to zero the BAR registers during PCIe fatal error to force pci_restore_state() to restore the BAR addresses. These write cycles to the BAR registers will cause the proper BAR addresses to latch internally. Fixes: 6316ea6 ("bnxt_en: Enable AER support.") Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0123694 commit c32f632

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12530,6 +12530,9 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
1253012530
return PCI_ERS_RESULT_DISCONNECT;
1253112531
}
1253212532

12533+
if (state == pci_channel_io_frozen)
12534+
set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state);
12535+
1253312536
if (netif_running(netdev))
1253412537
bnxt_close(netdev);
1253512538

@@ -12556,7 +12559,7 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
1255612559
{
1255712560
struct net_device *netdev = pci_get_drvdata(pdev);
1255812561
struct bnxt *bp = netdev_priv(netdev);
12559-
int err = 0;
12562+
int err = 0, off;
1256012563
pci_ers_result_t result = PCI_ERS_RESULT_DISCONNECT;
1256112564

1256212565
netdev_info(bp->dev, "PCI Slot Reset\n");
@@ -12568,6 +12571,20 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
1256812571
"Cannot re-enable PCI device after reset.\n");
1256912572
} else {
1257012573
pci_set_master(pdev);
12574+
/* Upon fatal error, our device internal logic that latches to
12575+
* BAR value is getting reset and will restore only upon
12576+
* rewritting the BARs.
12577+
*
12578+
* As pci_restore_state() does not re-write the BARs if the
12579+
* value is same as saved value earlier, driver needs to
12580+
* write the BARs to 0 to force restore, in case of fatal error.
12581+
*/
12582+
if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN,
12583+
&bp->state)) {
12584+
for (off = PCI_BASE_ADDRESS_0;
12585+
off <= PCI_BASE_ADDRESS_5; off += 4)
12586+
pci_write_config_dword(bp->pdev, off, 0);
12587+
}
1257112588
pci_restore_state(pdev);
1257212589
pci_save_state(pdev);
1257312590

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,7 @@ struct bnxt {
17361736
#define BNXT_STATE_ABORT_ERR 5
17371737
#define BNXT_STATE_FW_FATAL_COND 6
17381738
#define BNXT_STATE_DRV_REGISTERED 7
1739+
#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8
17391740

17401741
#define BNXT_NO_FW_ACCESS(bp) \
17411742
(test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \

0 commit comments

Comments
 (0)