Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/io/ppt.c
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
ppt_attach(device_t dev) | ppt_attach(device_t dev) | ||||
{ | { | ||||
struct pptdev *ppt; | struct pptdev *ppt; | ||||
ppt = device_get_softc(dev); | ppt = device_get_softc(dev); | ||||
iommu_remove_device(iommu_host_domain(), pci_get_rid(dev)); | |||||
num_pptdevs++; | num_pptdevs++; | ||||
TAILQ_INSERT_TAIL(&pptdev_list, ppt, next); | TAILQ_INSERT_TAIL(&pptdev_list, ppt, next); | ||||
ppt->dev = dev; | ppt->dev = dev; | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, "attached\n"); | device_printf(dev, "attached\n"); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
ppt_detach(device_t dev) | ppt_detach(device_t dev) | ||||
{ | { | ||||
struct pptdev *ppt; | struct pptdev *ppt; | ||||
ppt = device_get_softc(dev); | ppt = device_get_softc(dev); | ||||
if (ppt->vm != NULL) | if (ppt->vm != NULL) | ||||
return (EBUSY); | return (EBUSY); | ||||
num_pptdevs--; | num_pptdevs--; | ||||
TAILQ_REMOVE(&pptdev_list, ppt, next); | TAILQ_REMOVE(&pptdev_list, ppt, next); | ||||
pci_disable_busmaster(dev); | |||||
iommu_add_device(iommu_host_domain(), pci_get_rid(dev)); | |||||
return (0); | return (0); | ||||
} | } | ||||
static device_method_t ppt_methods[] = { | static device_method_t ppt_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, ppt_probe), | DEVMETHOD(device_probe, ppt_probe), | ||||
DEVMETHOD(device_attach, ppt_attach), | DEVMETHOD(device_attach, ppt_attach), | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | if (ppt->vm != NULL && ppt->vm != vm) | ||||
return (EBUSY); | return (EBUSY); | ||||
pci_save_state(ppt->dev); | pci_save_state(ppt->dev); | ||||
pcie_flr(ppt->dev, | pcie_flr(ppt->dev, | ||||
max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10), | max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10), | ||||
true); | true); | ||||
pci_restore_state(ppt->dev); | pci_restore_state(ppt->dev); | ||||
ppt->vm = vm; | 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)); | iommu_add_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev)); | ||||
return (0); | return (0); | ||||
} | } | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
int | int | ||||
ppt_unassign_device(struct vm *vm, int bus, int slot, int func) | ppt_unassign_device(struct vm *vm, int bus, int slot, int func) | ||||
Show All 12 Lines | if (ppt != NULL) { | ||||
pcie_flr(ppt->dev, | pcie_flr(ppt->dev, | ||||
max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10), | max(pcie_get_max_completion_timeout(ppt->dev) / 1000, 10), | ||||
true); | true); | ||||
pci_restore_state(ppt->dev); | pci_restore_state(ppt->dev); | ||||
ppt_unmap_mmio(vm, ppt); | ppt_unmap_mmio(vm, ppt); | ||||
ppt_teardown_msi(ppt); | ppt_teardown_msi(ppt); | ||||
ppt_teardown_msix(ppt); | ppt_teardown_msix(ppt); | ||||
iommu_remove_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev)); | iommu_remove_device(vm_iommu_domain(vm), pci_get_rid(ppt->dev)); | ||||
iommu_add_device(iommu_host_domain(), pci_get_rid(ppt->dev)); | |||||
ppt->vm = NULL; | ppt->vm = NULL; | ||||
return (0); | return (0); | ||||
} | } | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
int | int | ||||
ppt_unassign_all(struct vm *vm) | ppt_unassign_all(struct vm *vm) | ||||
▲ Show 20 Lines • Show All 262 Lines • Show Last 20 Lines |