From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjKDA-0007rl-SO for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:41:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjKD3-0004GK-HV for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:41:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjKD3-0004Ez-92 for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:41:37 -0500 From: Igor Mammedov Date: Thu, 21 Nov 2013 03:38:43 +0100 Message-Id: <1385001528-12003-23-git-send-email-imammedo@redhat.com> In-Reply-To: <1385001528-12003-1-git-send-email-imammedo@redhat.com> References: <1385001528-12003-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 22/27] pc: add memory hotplug Q35 machine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, stefanha@redhat.com, mst@redhat.com, chegu_vinod@hp.com, stefanb@linux.vnet.ibm.com, mjt@tls.msk.ru, mdroth@linux.vnet.ibm.com, armbru@redhat.com, vasilis.liaskovitis@profitbricks.com, quintela@redhat.com, kraxel@redhat.com, aliguori@amazon.com, hutao@cn.fujitsu.com, pbonzini@redhat.com, marcel.a@redhat.com, lcapitulino@redhat.com, afaerber@suse.de Add DimmBus to q35 machine, initialize memory hotplug window and plumb in ACPI callback (ich9_pm) for communicating hotplug event to guest. Signed-off-by: Igor Mammedov --- hw/i386/pc_q35.c | 3 +++ hw/pci-host/q35.c | 18 +++++++++++++++++- include/hw/pci-host/q35.h | 1 + 3 files changed, 21 insertions(+), 1 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 5525465..59887db 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -167,6 +167,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args) ICH9_LPC_NB_PIRQS); pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq); isa_bus = ich9_lpc->isa_bus; + pc_acpi_dev_memory_hotplug_init(&q35_host->mch.hotplug_mem_bus, + ich9_mem_hotplug, OBJECT(ich9_lpc)); /*end early*/ isa_bus_irqs(isa_bus, gsi); @@ -234,6 +236,7 @@ static void pc_compat_1_7(QEMUMachineInitArgs *args) { smbios_type1_defaults = false; pc_pci_as_mapping_init = pc_pci_as_mapping_init_1_7; + pc_hotplug_memory_init = pc_hotplug_memory_init_compat_1_7; } static void pc_compat_1_6(QEMUMachineInitArgs *args) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 6e28418..ead982b 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -356,11 +356,16 @@ static int mch_init(PCIDevice *d) { int i; MCHPCIState *mch = MCH_PCI_DEVICE(d); + ram_addr_t high_memory_end = 0x100000000ULL + mch->above_4g_mem_size; + + pc_hotplug_memory_init(OBJECT(mch), mch->system_memory, + mch->below_4g_mem_size, mch->pci_info.w32.begin, + &mch->hotplug_mem_bus, &high_memory_end); /* setup pci memory mapping */ pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory, mch->pci_address_space, - 0x100000000ULL + mch->above_4g_mem_size); + high_memory_end); /* smram */ cpu_smm_register(&mch_set_smm, mch); @@ -389,6 +394,16 @@ uint64_t mch_mcfg_base(void) return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT; } +static void mch_initfn(Object *obj) +{ + MCHPCIState *mch = MCH_PCI_DEVICE(obj); + + qbus_create_inplace(&mch->hotplug_mem_bus, + sizeof(mch->hotplug_mem_bus), + TYPE_DIMM_BUS, DEVICE(mch), + "hotplug-membus"); +} + static void mch_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); @@ -410,6 +425,7 @@ static const TypeInfo mch_info = { .name = TYPE_MCH_PCI_DEVICE, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(MCHPCIState), + .instance_init = mch_initfn, .class_init = mch_class_init, }; diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h index d0355b7..c9aa790 100644 --- a/include/hw/pci-host/q35.h +++ b/include/hw/pci-host/q35.h @@ -47,6 +47,7 @@ typedef struct MCHPCIState { PCIDevice parent_obj; /*< public >*/ + DimmBus hotplug_mem_bus; MemoryRegion *ram_memory; MemoryRegion *pci_address_space; MemoryRegion *system_memory; -- 1.7.1