Re: [Qemu-devel] [PATCH RFC 6/6] hw/ich9: enable acpi pci hotplug
On Fri, Jun 30, 2017 at 12:56:02AM +0300, Aleksandr Bezzubikov wrote: > Signed-off-by: Aleksandr BezzubikovThis commit log is where you describe what works and what doesn't so people can figure it out from git log. > --- > hw/acpi/ich9.c | 31 +++ > hw/isa/lpc_ich9.c | 12 > include/hw/acpi/ich9.h | 4 > include/hw/i386/pc.h | 7 ++- > 4 files changed, 53 insertions(+), 1 deletion(-) > > diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c > index 5c279bb..25339eb 100644 > --- a/hw/acpi/ich9.c > +++ b/hw/acpi/ich9.c > @@ -258,6 +258,7 @@ static void pm_reset(void *opaque) > } > pm->smi_en_wmask = ~0; > > +acpi_pcihp_reset(>acpi_pci_hotplug); > acpi_update_sci(>acpi_regs, pm->irq); > } > > @@ -301,6 +302,10 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, > pm->powerdown_notifier.notify = pm_powerdown_req; > qemu_register_powerdown_notifier(>powerdown_notifier); > > +acpi_pcihp_init(OBJECT(lpc_pci), >acpi_pci_hotplug, lpc_pci->bus, > +pci_address_space_io(lpc_pci), > +pm->use_acpi_pci_hotplug); > + > legacy_acpi_cpu_hotplug_init(pci_address_space_io(lpc_pci), > OBJECT(lpc_pci), >gpe_cpu, ICH9_CPU_HOTPLUG_IO_BASE); > > @@ -335,6 +340,21 @@ static void ich9_pm_set_memory_hotplug_support(Object > *obj, bool value, > s->pm.acpi_memory_hotplug.is_enabled = value; > } > > +static bool ich9_pm_get_acpi_pci_hotplug_support(Object *obj, Error **errp) > +{ > +ICH9LPCState *s = ICH9_LPC_DEVICE(obj); > + > +return s->pm.use_acpi_pci_hotplug; > +} > + > +static void ich9_pm_set_acpi_pci_hotplug_support(Object *obj, bool value, > + Error **errp) > +{ > +ICH9LPCState *s = ICH9_LPC_DEVICE(obj); > + > +s->pm.use_acpi_pci_hotplug = value; > +} > + > static bool ich9_pm_get_cpu_hotplug_legacy(Object *obj, Error **errp) > { > ICH9LPCState *s = ICH9_LPC_DEVICE(obj); > @@ -446,6 +466,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs > *pm, Error **errp) > { > static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN; > pm->acpi_memory_hotplug.is_enabled = true; > +pm->use_acpi_pci_hotplug = true; > pm->cpu_hotplug_legacy = true; > pm->disable_s3 = 0; > pm->disable_s4 = 0; > @@ -462,6 +483,10 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs > *pm, Error **errp) > ich9_pm_get_memory_hotplug_support, > ich9_pm_set_memory_hotplug_support, > NULL); > +object_property_add_bool(obj, "acpi-pci-hotplug-with-bridge-support", > + ich9_pm_get_acpi_pci_hotplug_support, > + ich9_pm_set_acpi_pci_hotplug_support, > + NULL); > object_property_add_bool(obj, "cpu-hotplug-legacy", > ich9_pm_get_cpu_hotplug_legacy, > ich9_pm_set_cpu_hotplug_legacy, > @@ -497,6 +522,9 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, > DeviceState *dev, > acpi_memory_plug_cb(hotplug_dev, >pm.acpi_memory_hotplug, > dev, errp); > } > +} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { > +acpi_pcihp_device_plug_cb(hotplug_dev, >pm.acpi_pci_hotplug, > + dev, errp); > } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { > if (lpc->pm.cpu_hotplug_legacy) { > legacy_acpi_cpu_plug_cb(hotplug_dev, >pm.gpe_cpu, dev, > errp); > @@ -519,6 +547,9 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler > *hotplug_dev, > acpi_memory_unplug_request_cb(hotplug_dev, >>pm.acpi_memory_hotplug, dev, >errp); > +} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { > +acpi_pcihp_device_unplug_cb(hotplug_dev, >pm.acpi_pci_hotplug, > +dev, errp); > } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && > !lpc->pm.cpu_hotplug_legacy) { > acpi_cpu_unplug_request_cb(hotplug_dev, >pm.cpuhp_state, > diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c > index e2215dc..13574d0 100644 > --- a/hw/isa/lpc_ich9.c > +++ b/hw/isa/lpc_ich9.c > @@ -33,6 +33,7 @@ > #include "hw/hw.h" > #include "qapi/visitor.h" > #include "qemu/range.h" > +#include "qapi/error.h" > #include "hw/isa/isa.h" > #include "hw/sysbus.h" > #include "hw/i386/pc.h" > @@ -574,6 +575,15 @@ static const MemoryRegionOps rcrb_mmio_ops = { > .endianness = DEVICE_LITTLE_ENDIAN, > }; > > +static void ich9_update_bus_hotplug(PCIBus *pci_bus, void *opaque) > +{ > +ICH9LPCState *s = opaque; > + > +if (!pci_bus_is_express(pci_bus)) { > +
[Qemu-devel] [PATCH RFC 6/6] hw/ich9: enable acpi pci hotplug
Signed-off-by: Aleksandr Bezzubikov--- hw/acpi/ich9.c | 31 +++ hw/isa/lpc_ich9.c | 12 include/hw/acpi/ich9.h | 4 include/hw/i386/pc.h | 7 ++- 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 5c279bb..25339eb 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -258,6 +258,7 @@ static void pm_reset(void *opaque) } pm->smi_en_wmask = ~0; +acpi_pcihp_reset(>acpi_pci_hotplug); acpi_update_sci(>acpi_regs, pm->irq); } @@ -301,6 +302,10 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, pm->powerdown_notifier.notify = pm_powerdown_req; qemu_register_powerdown_notifier(>powerdown_notifier); +acpi_pcihp_init(OBJECT(lpc_pci), >acpi_pci_hotplug, lpc_pci->bus, +pci_address_space_io(lpc_pci), +pm->use_acpi_pci_hotplug); + legacy_acpi_cpu_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci), >gpe_cpu, ICH9_CPU_HOTPLUG_IO_BASE); @@ -335,6 +340,21 @@ static void ich9_pm_set_memory_hotplug_support(Object *obj, bool value, s->pm.acpi_memory_hotplug.is_enabled = value; } +static bool ich9_pm_get_acpi_pci_hotplug_support(Object *obj, Error **errp) +{ +ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + +return s->pm.use_acpi_pci_hotplug; +} + +static void ich9_pm_set_acpi_pci_hotplug_support(Object *obj, bool value, + Error **errp) +{ +ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + +s->pm.use_acpi_pci_hotplug = value; +} + static bool ich9_pm_get_cpu_hotplug_legacy(Object *obj, Error **errp) { ICH9LPCState *s = ICH9_LPC_DEVICE(obj); @@ -446,6 +466,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) { static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN; pm->acpi_memory_hotplug.is_enabled = true; +pm->use_acpi_pci_hotplug = true; pm->cpu_hotplug_legacy = true; pm->disable_s3 = 0; pm->disable_s4 = 0; @@ -462,6 +483,10 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) ich9_pm_get_memory_hotplug_support, ich9_pm_set_memory_hotplug_support, NULL); +object_property_add_bool(obj, "acpi-pci-hotplug-with-bridge-support", + ich9_pm_get_acpi_pci_hotplug_support, + ich9_pm_set_acpi_pci_hotplug_support, + NULL); object_property_add_bool(obj, "cpu-hotplug-legacy", ich9_pm_get_cpu_hotplug_legacy, ich9_pm_set_cpu_hotplug_legacy, @@ -497,6 +522,9 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, acpi_memory_plug_cb(hotplug_dev, >pm.acpi_memory_hotplug, dev, errp); } +} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { +acpi_pcihp_device_plug_cb(hotplug_dev, >pm.acpi_pci_hotplug, + dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (lpc->pm.cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, >pm.gpe_cpu, dev, errp); @@ -519,6 +547,9 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, acpi_memory_unplug_request_cb(hotplug_dev, >pm.acpi_memory_hotplug, dev, errp); +} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { +acpi_pcihp_device_unplug_cb(hotplug_dev, >pm.acpi_pci_hotplug, +dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && !lpc->pm.cpu_hotplug_legacy) { acpi_cpu_unplug_request_cb(hotplug_dev, >pm.cpuhp_state, diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index e2215dc..13574d0 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -33,6 +33,7 @@ #include "hw/hw.h" #include "qapi/visitor.h" #include "qemu/range.h" +#include "qapi/error.h" #include "hw/isa/isa.h" #include "hw/sysbus.h" #include "hw/i386/pc.h" @@ -574,6 +575,15 @@ static const MemoryRegionOps rcrb_mmio_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +static void ich9_update_bus_hotplug(PCIBus *pci_bus, void *opaque) +{ +ICH9LPCState *s = opaque; + +if (!pci_bus_is_express(pci_bus)) { +qbus_set_hotplug_handler(BUS(pci_bus), DEVICE(s), _abort); +} +} + static void ich9_lpc_machine_ready(Notifier *n, void *opaque) { ICH9LPCState *s = container_of(n, ICH9LPCState, machine_ready); @@ -597,6 +607,8 @@ static void ich9_lpc_machine_ready(Notifier *n, void *opaque) /* floppy */ pci_conf[0x82] |= 0x08; } + +pci_for_each_bus(s->d.bus, ich9_update_bus_hotplug, s); }