From patchwork Mon May 2 12:33:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8992151 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9321DBF29F for ; Mon, 2 May 2016 12:48:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BABC1201FE for ; Mon, 2 May 2016 12:48:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1DCE201FA for ; Mon, 2 May 2016 12:48:35 +0000 (UTC) Received: from localhost ([::1]:36464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axDH5-0003g9-Kf for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 May 2016 08:48:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD3v-0006h1-KE for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axD3j-0008VV-J3 for qemu-devel@nongnu.org; Mon, 02 May 2016 08:34:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD3j-0008Rw-C8 for qemu-devel@nongnu.org; Mon, 02 May 2016 08:34:43 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48A64477 for ; Mon, 2 May 2016 12:34:32 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u42CXqc9000450; Mon, 2 May 2016 08:34:30 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 2 May 2016 14:33:31 +0200 Message-Id: <1462192431-146342-23-git-send-email-imammedo@redhat.com> In-Reply-To: <1462192431-146342-1-git-send-email-imammedo@redhat.com> References: <1462192431-146342-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 22/42] pc: piix4: initialize new CPU hotplug hw X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, ehabkost@redhat.com, mst@redhat.com, armbru@redhat.com, marcel@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Igor Mammedov --- hw/acpi/piix4.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------ hw/i386/pc_piix.c | 2 +- hw/mips/mips_malta.c | 2 +- include/hw/i386/pc.h | 3 ++- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 8f53b30..2246c65 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -34,6 +34,7 @@ #include "hw/acpi/piix4.h" #include "hw/acpi/pcihp.h" #include "hw/acpi/cpu_hotplug.h" +#include "hw/acpi/cpu.h" #include "hw/hotplug.h" #include "hw/mem/pc-dimm.h" #include "hw/acpi/memory_hotplug.h" @@ -86,7 +87,10 @@ typedef struct PIIX4PMState { uint8_t s4_val; bool cpu_hotplug_legacy; - AcpiCpuHotplug gpe_cpu; + union { + AcpiCpuHotplug legacy; /* used for keeping legacy state */ + CPUHotplugState state; + } cpuhp; MemHotplugState acpi_memory_hotplug; } PIIX4PMState; @@ -273,6 +277,24 @@ static const VMStateDescription vmstate_memhp_state = { } }; +static bool vmstate_test_use_cpuhp(void *opaque) +{ + PIIX4PMState *s = opaque; + return !s->cpu_hotplug_legacy && s->cpuhp.state.is_enabled; +} + +static const VMStateDescription vmstate_cpuhp_state = { + .name = "piix4_pm/cpuhp", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .needed = vmstate_test_use_cpuhp, + .fields = (VMStateField[]) { + VMSTATE_CPU_HOTPLUG(cpuhp.state, PIIX4PMState), + VMSTATE_END_OF_LIST() + } +}; + /* qemu-kvm 1.2 uses version 3 but advertised as 2 * To support incoming qemu-kvm 1.2 migration, change version_id * and minimum_version_id to 2 below (which breaks migration from @@ -307,6 +329,7 @@ static const VMStateDescription vmstate_acpi = { }, .subsections = (const VMStateDescription*[]) { &vmstate_memhp_state, + &vmstate_cpuhp_state, NULL } }; @@ -351,9 +374,12 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, acpi_memory_plug_cb(hotplug_dev, &s->acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp); - } else if (s->cpu_hotplug_legacy && - object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { - legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + if (s->cpu_hotplug_legacy) { + legacy_acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp.legacy, dev, errp); + } else { + acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp.state, dev, errp); + } } else { error_setg(errp, "acpi: device plug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -372,6 +398,9 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && + !s->cpu_hotplug_legacy) { + acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp.state, dev, errp); } else { error_setg(errp, "acpi: device unplug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -386,6 +415,9 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, if (s->acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { acpi_memory_unplug_cb(&s->acpi_memory_hotplug, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && + !s->cpu_hotplug_legacy) { + acpi_cpu_unplug_cb(&s->cpuhp.state, dev, errp); } else { error_setg(errp, "acpi: device unplug for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -507,13 +539,15 @@ Object *piix4_pm_find(void) I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq smi_irq, - int smm_enabled, DeviceState **piix4_pm) + int smm_enabled, DeviceState **piix4_pm, + bool cpuhp_enabled) { DeviceState *dev; PIIX4PMState *s; dev = DEVICE(pci_create(bus, devfn, TYPE_PIIX4_PM)); qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base); + qdev_prop_set_bit(dev, "cpu-hotplug", cpuhp_enabled); if (piix4_pm) { *piix4_pm = dev; } @@ -572,8 +606,11 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, s->use_acpi_pci_hotplug); if (s->cpu_hotplug_legacy) { - legacy_acpi_cpu_hotplug_init(parent, OBJECT(s), &s->gpe_cpu, + legacy_acpi_cpu_hotplug_init(parent, OBJECT(s), &s->cpuhp.legacy, PIIX4_CPU_HOTPLUG_IO_BASE); + } else if (s->cpuhp.state.is_enabled) { + cpu_hotplug_hw_init(parent, OBJECT(s), &s->cpuhp.state, + PIIX4_CPU_HOTPLUG_IO_BASE); } if (s->acpi_memory_hotplug.is_enabled) { @@ -606,6 +643,8 @@ static Property piix4_pm_properties[] = { acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_BOOL("cpu-hotplug-legacy", PIIX4PMState, cpu_hotplug_legacy, false), + DEFINE_PROP_BOOL("cpu-hotplug", PIIX4PMState, + cpuhp.state.is_enabled, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index cdbdd69..860a83d 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -259,7 +259,7 @@ static void pc_init1(MachineState *machine, smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, gsi[9], smi_irq, pc_machine_is_smm_enabled(pcms), - &piix4_pm); + &piix4_pm, machine->cpu_hotplug); smbus_eeprom_init(smbus, 8, NULL, 0); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index fa769e5..3f61e38 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -1208,7 +1208,7 @@ void mips_malta_init(MachineState *machine) pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci"); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, - isa_get_irq(NULL, 9), NULL, 0, NULL); + isa_get_irq(NULL, 9), NULL, 0, NULL, NULL); smbus_eeprom_init(smbus, 8, smbus_eeprom_buf, smbus_eeprom_size); g_free(smbus_eeprom_buf); pit = pit_init(isa_bus, 0x40, 0, NULL); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f1e40ae..43aeebb 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -275,7 +275,8 @@ int cmos_get_fd_drive_type(FloppyDriveType fd0); I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq smi_irq, - int smm_enabled, DeviceState **piix4_pm); + int smm_enabled, DeviceState **piix4_pm, + bool cpuhp_enabled); void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr); /* hpet.c */