[PATCH 6/8] hw/acpi/ich9: Support forced PCI unplug
Dongli Zhang <[email protected]>
| Newsgroups | org.nongnu.qemu-devel,org.xenproject.lists.xen-devel |
|---|---|
| Message-ID | <[email protected]> |
Support forced PCI unplug for ICH9. This enables forced removal for ACPI PCI hotplug on q35 machines while rejecting non-PCI devices. Signed-off-by: Dongli Zhang <[email protected]> --- hw/acpi/ich9.c | 15 +++++++++++++++ hw/isa/lpc_ich9.c | 1 + include/hw/acpi/ich9.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 5e8f8a7eaf..4bcaf3858b 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -528,6 +528,21 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, } } +void ich9_pm_device_force_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_force_unplug_cb(hotplug_dev, + &lpc->pm.acpi_pci_hotplug, + dev, errp); + } else { + error_setg(errp, "acpi: forced device unplug for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } +} + bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bus) { ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev); diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index edf9783ec8..6d734ffc47 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -908,6 +908,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data) hc->plug = ich9_pm_device_plug_cb; hc->unplug_request = ich9_pm_device_unplug_request_cb; hc->unplug = ich9_pm_device_unplug_cb; + hc->force_unplug = ich9_pm_device_force_unplug_cb; hc->is_hotpluggable_bus = ich9_pm_is_hotpluggable_bus; adevc->ospm_status = ich9_pm_ospm_status; adevc->send_event = ich9_send_gpe; diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 30990fcef5..cc9f50a60f 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -93,6 +93,8 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); +void ich9_pm_device_force_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp); bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bus); void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); -- 2.43.5