From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2gED-0000xV-3F for qemu-devel@nongnu.org; Tue, 17 May 2016 10:44:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2gEA-0006Sz-B0 for qemu-devel@nongnu.org; Tue, 17 May 2016 10:44:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2gEA-0006Sp-3U for qemu-devel@nongnu.org; Tue, 17 May 2016 10:44:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 A6FA86330F for ; Tue, 17 May 2016 14:44:05 +0000 (UTC) From: Igor Mammedov Date: Tue, 17 May 2016 16:43:13 +0200 Message-Id: <1463496205-251412-22-git-send-email-imammedo@redhat.com> In-Reply-To: <1463496205-251412-1-git-send-email-imammedo@redhat.com> References: <1463496205-251412-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 21/33] pc: piix4: initialize new CPU hotplug hw List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mst@redhat.com, rkrcmar@redhat.com, ehabkost@redhat.com, drjones@redhat.com, armbru@redhat.com, marcel@redhat.com add necessary wiring to init new CPU hotplug hardware if PIIX4_PM.cpu-hotplug-legacy is "off". Set PIIX4_PM.cpu-hotplug-legacy to "off" by default and switch legacy hotplug to enabled only for 2.6 and older machine types. Signed-off-by: Igor Mammedov v1: - drop PIIX4_PM.cpu-hotplug property --- hw/acpi/piix4.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++------ include/hw/compat.h | 5 +++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index d25479c..05ce725 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; +} + +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))); @@ -572,8 +604,19 @@ 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 { + MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); + + /* piix4 is also used by MIPS target, so make sure that + user provides possible_cpu_arch_ids callback before + trying to initialize CPU hotplug + */ + if (mc->possible_cpu_arch_ids) { + cpu_hotplug_hw_init(parent, OBJECT(s), &s->cpuhp.state, + PIIX4_CPU_HOTPLUG_IO_BASE); + } } if (s->acpi_memory_hotplug.is_enabled) { @@ -605,7 +648,7 @@ static Property piix4_pm_properties[] = { DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_BOOL("cpu-hotplug-legacy", PIIX4PMState, - cpu_hotplug_legacy, true), + cpu_hotplug_legacy, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/compat.h b/include/hw/compat.h index a65d9d2..862776e 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -7,6 +7,11 @@ .property = "cpu-hotplug-legacy",\ .value = "on",\ },\ + {\ + .driver = "PIIX4_PM",\ + .property = "cpu-hotplug-legacy",\ + .value = "on",\ + },\ #define HW_COMPAT_2_5 \ {\ -- 1.8.3.1