Leave ppt devices in the host domain when they are not attached to a VM.

This allows a pass through device to be reset to a normal device driver
on the host and reused on the host.  ppt devices are now always active in
some I/O MMU domain when the I/O MMU is active, either the host domain
or the domain of a VM they are attached to.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7666
This commit is contained in:
John Baldwin 2016-09-06 18:53:17 +00:00
parent d945328992
commit 5fb03c3780
2 changed files with 3 additions and 7 deletions

View file

@ -158,7 +158,6 @@ iommu_init(void)
{
int error, bus, slot, func;
vm_paddr_t maxaddr;
const char *name;
device_t dev;
if (!iommu_enable)
@ -203,12 +202,7 @@ iommu_init(void)
if (dev == NULL)
continue;
/* skip passthrough devices */
name = device_get_name(dev);
if (name != NULL && strcmp(name, "ppt") == 0)
continue;
/* everything else belongs to the host domain */
/* Everything belongs to the host domain. */
iommu_add_device(host_domain,
pci_get_rid(dev));
}

View file

@ -363,6 +363,7 @@ ppt_assign_device(struct vm *vm, int bus, int slot, int func)
return (EBUSY);
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));
return (0);
}
@ -385,6 +386,7 @@ ppt_unassign_device(struct vm *vm, int bus, int slot, int func)
ppt_teardown_msi(ppt);
ppt_teardown_msix(ppt);
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;
return (0);
}