Allow PCI VGA devices to be detached.

GPUs often have a VGA PCI class code and are probed/attached
by the VGA driver. Allow them to be detached so they can
be presented as passthru devices to VM guests.

Submitted by:	mmacy
Reviewed by:	jhb, imp, rgrimes
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D15269
This commit is contained in:
Peter Grehan 2018-05-03 22:51:44 +00:00
parent d5effb01f1
commit 598b1345d9

View File

@ -282,6 +282,17 @@ vga_pci_suspend(device_t dev)
return (bus_generic_suspend(dev));
}
static int
vga_pci_detach(device_t dev)
{
int error;
error = bus_generic_detach(dev);
if (error == 0)
error = device_delete_children(dev);
return (error);
}
static int
vga_pci_resume(device_t dev)
{
@ -620,6 +631,7 @@ static device_method_t vga_pci_methods[] = {
DEVMETHOD(device_attach, vga_pci_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, vga_pci_suspend),
DEVMETHOD(device_detach, vga_pci_detach),
DEVMETHOD(device_resume, vga_pci_resume),
/* Bus interface */