Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144408370
D15268.id42070.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D15268.id42070.diff
View Options
Index: head/sys/amd64/vmm/io/ppt.c
===================================================================
--- head/sys/amd64/vmm/io/ppt.c
+++ head/sys/amd64/vmm/io/ppt.c
@@ -353,6 +353,30 @@
return (FALSE);
}
+static void
+ppt_pci_reset(device_t dev)
+{
+ int ps;
+
+ if (pcie_flr(dev,
+ max(pcie_get_max_completion_timeout(dev) / 1000, 10),
+ true))
+ return;
+
+ /*
+ * If FLR fails, attempt a power-management reset by cycling
+ * the device in/out of D3 state.
+ * PCI spec says we can only go into D3 state from D0 state.
+ * Transition from D[12] into D0 before going to D3 state.
+ */
+ ps = pci_get_powerstate(dev);
+ if (ps != PCI_POWERSTATE_D0 && ps != PCI_POWERSTATE_D3)
+ pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+ if (pci_get_powerstate(dev) != PCI_POWERSTATE_D3)
+ pci_set_powerstate(dev, PCI_POWERSTATE_D3);
+ pci_set_powerstate(dev, ps);
+}
+
int
ppt_assign_device(struct vm *vm, int bus, int slot, int func)
{
@@ -368,9 +392,7 @@
return (EBUSY);
pci_save_state(ppt->dev);
- pcie_flr(ppt->dev,
- max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10),
- true);
+ ppt_pci_reset(ppt->dev);
pci_restore_state(ppt->dev);
ppt->vm = vm;
iommu_add_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev));
@@ -393,9 +415,7 @@
return (EBUSY);
pci_save_state(ppt->dev);
- pcie_flr(ppt->dev,
- max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10),
- true);
+ ppt_pci_reset(ppt->dev);
pci_restore_state(ppt->dev);
ppt_unmap_mmio(vm, ppt);
ppt_teardown_msi(ppt);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 9, 7:11 AM (41 m, 29 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28551383
Default Alt Text
D15268.id42070.diff (1 KB)
Attached To
Mode
D15268: Use PCI power-mgmt to reset a device if FLR fails.
Attached
Detach File
Event Timeline
Log In to Comment