summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-09-30 18:47:34 +0000
committerjhb <jhb@FreeBSD.org>2016-09-30 18:47:34 +0000
commitc03db820416e89f29bd1f5cb8f59a221d4d11463 (patch)
tree40eebb193bc1f2f586b485b14d6c3d5b8aae938b /sys/amd64
parent104dee440cbe66dc016a95db087f320c15704226 (diff)
downloadFreeBSD-src-c03db820416e89f29bd1f5cb8f59a221d4d11463.zip
FreeBSD-src-c03db820416e89f29bd1f5cb8f59a221d4d11463.tar.gz
MFC 305502: Reset PCI pass through devices via PCI-e FLR during VM start/end.
Add routines to trigger a function level reset (FLR) of a PCI-express device via the PCI-express device control register. This also includes support routines to wait for pending transactions to complete as well as calculating the maximum completion timeout permitted by a device. Change the ppt(4) driver to reset pass through devices before attaching to a VM during startup and before detaching from a VM during shutdown. Sponsored by: Chelsio Communications
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/vmm/io/ppt.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/amd64/vmm/io/ppt.c b/sys/amd64/vmm/io/ppt.c
index 6541d7d..4c9ff47 100644
--- a/sys/amd64/vmm/io/ppt.c
+++ b/sys/amd64/vmm/io/ppt.c
@@ -362,6 +362,11 @@ ppt_assign_device(struct vm *vm, int bus, int slot, int func)
if (ppt->vm != NULL && ppt->vm != vm)
return (EBUSY);
+ pci_save_state(ppt->dev);
+ pcie_flr(ppt->dev,
+ max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10),
+ true);
+ pci_restore_state(ppt->dev);
ppt->vm = vm;
iommu_remove_device(iommu_host_domain(), pci_get_rid(ppt->dev));
iommu_add_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev));
@@ -382,6 +387,12 @@ ppt_unassign_device(struct vm *vm, int bus, int slot, int func)
*/
if (ppt->vm != vm)
return (EBUSY);
+
+ pci_save_state(ppt->dev);
+ pcie_flr(ppt->dev,
+ max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10),
+ true);
+ pci_restore_state(ppt->dev);
ppt_unmap_mmio(vm, ppt);
ppt_teardown_msi(ppt);
ppt_teardown_msix(ppt);
OpenPOWER on IntegriCloud