Page MenuHomeFreeBSD

D62451.1796510683.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D62451.1796510683.diff

diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -7512,7 +7512,15 @@
pci_reset_prepare(device_t dev, device_t child)
{
- if (dev == device_get_parent(child))
+ /*
+ * Skip saving if the child is already suspended or powered down;
+ * pci_suspend_child() and pci_child_detached()/pci_probe_nomatch()
+ * already saved D0 state, and saving again would overwrite it with
+ * post-suspend or D3 state.
+ */
+ if (dev == device_get_parent(child) &&
+ !device_is_suspended(child) &&
+ pci_get_powerstate(child) == PCI_POWERSTATE_D0)
pci_save_state(child);
return (0);
}
@@ -7530,17 +7538,33 @@
} else {
error = BUS_SUSPEND_CHILD(dev, child);
}
+ if (error != 0)
+ return (error);
+
+ error = BUS_RESET_PREPARE(dev, child);
if (error == 0) {
- if (!pcie_flr(child, 1000, false)) {
- error = BUS_RESET_PREPARE(dev, child);
- if (error == 0)
- pci_power_reset(child);
- BUS_RESET_POST(dev, child);
- }
- if ((flags & DEVF_RESET_DETACH) != 0)
- device_probe_and_attach(child);
- else
- BUS_RESUME_CHILD(dev, child);
+ /*
+ * Wake non-D0 devices before FLR so config space is accessible
+ * (D3cold reads return 0xffffffff) and PM state matches the
+ * post-reset D0 default.
+ */
+ if (pci_get_powerstate(child) != PCI_POWERSTATE_D0)
+ pci_set_powerstate(child, PCI_POWERSTATE_D0);
+ if (!pcie_flr(child, 1000, false))
+ pci_power_reset(child);
+ }
+ BUS_RESET_POST(dev, child);
+ if ((flags & DEVF_RESET_DETACH) != 0) {
+ device_probe_and_attach(child);
+ /*
+ * Match pci_resume_child(): re-apply hw.pci.do_power_nodriver
+ * if the device remains unattached after probe/attach.
+ */
+ if (!device_is_attached(child) &&
+ pci_get_powerstate(child) == PCI_POWERSTATE_D0)
+ pci_cfg_save(child, device_get_ivars(child), 1);
+ } else {
+ BUS_RESUME_CHILD(dev, child);
}
return (error);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 5, 10:44 PM (10 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42241186
Default Alt Text
D62451.1796510683.diff (1 KB)

Event Timeline