Skip to content

Commit 5c5b875

Browse files
committed
Merge branch 'pci/err'
- For drivers using PCI legacy suspend, save config state at suspend so that state (not any earlier state from enumeration, probe, or error recovery) will be restored when resuming (Lukas Wunner) - For devices with no driver or a driver that lacks PM, save config state at hibernate so that state (not any earlier state from enumeration, probe, or error recovery) will be restored when resuming (Lukas Wunner) - Save device config space on device addition, before driver binding, so error recovery works more reliably (Lukas Wunner) - Drop pci_save_state() from several drivers that no longer need it since the PCI core always does it and pci_restore_state() no longer invalidates the saved state (Lukas Wunner) - Document use of pci_save_state() by drivers to capture the state they want restored during error recovery (Lukas Wunner) * pci/err: Documentation: PCI: Amend error recovery doc with pci_save_state() rules treewide: Drop pci_save_state() after pci_restore_state() PCI/ERR: Ensure error recoverability at all times PCI/PM: Stop needlessly clearing state_saved on enumeration and thaw PCI/PM: Reinstate clearing state_saved in legacy and !PM codepaths
2 parents e0910b3 + 5e09895 commit 5c5b875

35 files changed

Lines changed: 22 additions & 64 deletions

File tree

Documentation/PCI/pci-error-recovery.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,21 @@ be recovered, there is nothing more that can be done; the platform
326326
will typically report a "permanent failure" in such a case. The
327327
device will be considered "dead" in this case.
328328

329+
Drivers typically need to call pci_restore_state() after reset to
330+
re-initialize the device's config space registers and thereby
331+
bring it from D0\ :sub:`uninitialized` into D0\ :sub:`active` state
332+
(PCIe r7.0 sec 5.3.1.1). The PCI core invokes pci_save_state()
333+
on enumeration after initializing config space to ensure that a
334+
saved state is available for subsequent error recovery.
335+
Drivers which modify config space on probe may need to invoke
336+
pci_save_state() afterwards to record those changes for later
337+
error recovery. When going into system suspend, pci_save_state()
338+
is called for every PCI device and that state will be restored
339+
not only on resume, but also on any subsequent error recovery.
340+
In the unlikely event that the saved state recorded on suspend
341+
is unsuitable for error recovery, drivers should call
342+
pci_save_state() on resume.
343+
329344
Drivers for multi-function cards will need to coordinate among
330345
themselves as to which driver instance will perform any "one-shot"
331346
or global device initialization. For example, the Symbios sym53cxx2

drivers/crypto/intel/qat/qat_common/adf_aer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ void adf_dev_restore(struct adf_accel_dev *accel_dev)
105105
accel_dev->accel_id);
106106
hw_device->reset_device(accel_dev);
107107
pci_restore_state(pdev);
108-
pci_save_state(pdev);
109108
}
110109
}
111110

@@ -204,7 +203,6 @@ static pci_ers_result_t adf_slot_reset(struct pci_dev *pdev)
204203
if (!pdev->is_busmaster)
205204
pci_set_master(pdev);
206205
pci_restore_state(pdev);
207-
pci_save_state(pdev);
208206
res = adf_dev_up(accel_dev, false);
209207
if (res && res != -EALREADY)
210208
return PCI_ERS_RESULT_DISCONNECT;

drivers/dma/ioat/init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,6 @@ static pci_ers_result_t ioat_pcie_error_slot_reset(struct pci_dev *pdev)
12861286
} else {
12871287
pci_set_master(pdev);
12881288
pci_restore_state(pdev);
1289-
pci_save_state(pdev);
12901289
pci_wake_from_d3(pdev, false);
12911290
}
12921291

drivers/net/ethernet/broadcom/bnx2.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6444,7 +6444,6 @@ bnx2_reset_task(struct work_struct *work)
64446444
if (!(pcicmd & PCI_COMMAND_MEMORY)) {
64456445
/* in case PCI block has reset */
64466446
pci_restore_state(bp->pdev);
6447-
pci_save_state(bp->pdev);
64486447
}
64496448
rc = bnx2_init_nic(bp, 1);
64506449
if (rc) {
@@ -8718,7 +8717,6 @@ static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
87188717
} else {
87198718
pci_set_master(pdev);
87208719
pci_restore_state(pdev);
8721-
pci_save_state(pdev);
87228720

87238721
if (netif_running(dev))
87248722
err = bnx2_init_nic(bp, 1);

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14216,7 +14216,6 @@ static pci_ers_result_t bnx2x_io_slot_reset(struct pci_dev *pdev)
1421614216

1421714217
pci_set_master(pdev);
1421814218
pci_restore_state(pdev);
14219-
pci_save_state(pdev);
1422014219

1422114220
if (netif_running(dev))
1422214221
bnx2x_set_power_state(bp, PCI_D0);

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18352,7 +18352,6 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
1835218352

1835318353
pci_set_master(pdev);
1835418354
pci_restore_state(pdev);
18355-
pci_save_state(pdev);
1835618355

1835718356
if (!netdev || !netif_running(netdev)) {
1835818357
rc = PCI_ERS_RESULT_RECOVERED;

drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2933,7 +2933,6 @@ static int t3_reenable_adapter(struct adapter *adapter)
29332933
}
29342934
pci_set_master(adapter->pdev);
29352935
pci_restore_state(adapter->pdev);
2936-
pci_save_state(adapter->pdev);
29372936

29382937
/* Free sge resources */
29392938
t3_free_sge_resources(adapter);

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5456,7 +5456,6 @@ static pci_ers_result_t eeh_slot_reset(struct pci_dev *pdev)
54565456

54575457
if (!adap) {
54585458
pci_restore_state(pdev);
5459-
pci_save_state(pdev);
54605459
return PCI_ERS_RESULT_RECOVERED;
54615460
}
54625461

@@ -5471,7 +5470,6 @@ static pci_ers_result_t eeh_slot_reset(struct pci_dev *pdev)
54715470

54725471
pci_set_master(pdev);
54735472
pci_restore_state(pdev);
5474-
pci_save_state(pdev);
54755473

54765474
if (t4_wait_dev_ready(adap->regs) < 0)
54775475
return PCI_ERS_RESULT_DISCONNECT;

drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ static pci_ers_result_t hbg_pci_err_slot_reset(struct pci_dev *pdev)
158158

159159
pci_set_master(pdev);
160160
pci_restore_state(pdev);
161-
pci_save_state(pdev);
162161

163162
hbg_err_reset(priv);
164163
return PCI_ERS_RESULT_RECOVERED;

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7195,7 +7195,6 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
71957195
"Cannot re-enable PCI device after reset.\n");
71967196
result = PCI_ERS_RESULT_DISCONNECT;
71977197
} else {
7198-
pdev->state_saved = true;
71997198
pci_restore_state(pdev);
72007199
pci_set_master(pdev);
72017200

0 commit comments

Comments
 (0)