From patchwork Mon May 2 12:33:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8992111 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 5C0A6BF29F for ; Mon, 2 May 2016 12:46:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 86995201FE for ; Mon, 2 May 2016 12:46:16 +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 7C622201FA for ; Mon, 2 May 2016 12:46:15 +0000 (UTC) Received: from localhost ([::1]:36448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axDEp-00084W-Mn for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 May 2016 08:46:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD3u-0006dd-2E for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axD3h-0008Us-V4 for qemu-devel@nongnu.org; Mon, 02 May 2016 08:34:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD3h-0008RI-O4 for qemu-devel@nongnu.org; Mon, 02 May 2016 08:34:41 -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 A32558553B for ; Mon, 2 May 2016 12:34:30 +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 u42CXqc8000450; Mon, 2 May 2016 08:34:29 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 2 May 2016 14:33:30 +0200 Message-Id: <1462192431-146342-22-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 21/42] pc: q35: 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 add ICH9-LPC.cpu-hotplug property and necessary wiring to init new CPU hotplug hardware if ICH9-LPC.cpu-hotplug is "on", which is enabled if machine.cpu-hotplug is "on". Signed-off-by: Igor Mammedov --- hw/acpi/ich9.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++---- hw/i386/pc_q35.c | 7 +++--- include/hw/acpi/ich9.h | 6 ++++- 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 6ffa9bf..dd141eb 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -170,6 +170,24 @@ static const VMStateDescription vmstate_memhp_state = { } }; +static bool vmstate_test_use_cpuhp(void *opaque) +{ + ICH9LPCPMRegs *s = opaque; + return !s->cpu_hotplug_legacy && s->cpuhp.state.is_enabled; +} + +static const VMStateDescription vmstate_cpuhp_state = { + .name = "ich9_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, ICH9LPCPMRegs), + VMSTATE_END_OF_LIST() + } +}; + static bool vmstate_test_use_tco(void *opaque) { ICH9LPCPMRegs *s = opaque; @@ -209,6 +227,7 @@ const VMStateDescription vmstate_ich9_pm = { .subsections = (const VMStateDescription*[]) { &vmstate_memhp_state, &vmstate_tco_io_state, + &vmstate_cpuhp_state, NULL } }; @@ -275,7 +294,10 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, if (pm->cpu_hotplug_legacy) { legacy_acpi_cpu_hotplug_init(pci_address_space_io(lpc_pci), - OBJECT(lpc_pci), &pm->gpe_cpu, ICH9_CPU_HOTPLUG_IO_BASE); + OBJECT(lpc_pci), &pm->cpuhp.legacy, ICH9_CPU_HOTPLUG_IO_BASE); + } else if (pm->cpuhp.state.is_enabled) { + cpu_hotplug_hw_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci), + &pm->cpuhp.state, ICH9_CPU_HOTPLUG_IO_BASE); } if (pm->acpi_memory_hotplug.is_enabled) { @@ -323,6 +345,21 @@ static void ich9_pm_set_cpu_hotplug_legacy(Object *obj, bool value, s->pm.cpu_hotplug_legacy = value; } +static bool ich9_pm_get_cpu_hotplug_support(Object *obj, Error **errp) +{ + ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + + return !s->pm.cpu_hotplug_legacy && s->pm.cpuhp.state.is_enabled; +} + +static void ich9_pm_set_cpu_hotplug_support(Object *obj, bool value, + Error **errp) +{ + ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + + s->pm.cpuhp.state.is_enabled = value; +} + static void ich9_pm_get_disable_s3(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -433,6 +470,10 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) ich9_pm_get_cpu_hotplug_legacy, ich9_pm_set_cpu_hotplug_legacy, NULL); + object_property_add_bool(obj, "cpu-hotplug", + ich9_pm_get_cpu_hotplug_support, + ich9_pm_set_cpu_hotplug_support, + NULL); object_property_add(obj, ACPI_PM_PROP_S3_DISABLED, "uint8", ich9_pm_get_disable_s3, ich9_pm_set_disable_s3, @@ -460,9 +501,13 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { acpi_memory_plug_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); - } else if (lpc->pm.cpu_hotplug_legacy && - object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { - legacy_acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.gpe_cpu, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + if (lpc->pm.cpu_hotplug_legacy) { + legacy_acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.cpuhp.legacy, dev, + errp); + } else { + acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.cpuhp.state, dev, errp); + } } else { error_setg(errp, "acpi: device plug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -479,6 +524,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, acpi_memory_unplug_request_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && + !lpc->pm.cpu_hotplug_legacy) { + acpi_cpu_unplug_request_cb(hotplug_dev, &lpc->pm.cpuhp.state, + dev, errp); } else { error_setg(errp, "acpi: device unplug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -493,6 +542,9 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, if (lpc->pm.acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { acpi_memory_unplug_cb(&lpc->pm.acpi_memory_hotplug, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && + !lpc->pm.cpu_hotplug_legacy) { + acpi_cpu_unplug_cb(&lpc->pm.cpuhp.state, dev, errp); } else { error_setg(errp, "acpi: device unplug for not supported device" " type: %s", object_get_typename(OBJECT(dev))); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 4787df1..0dc4ed5 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -171,15 +171,16 @@ static void pc_q35_init(MachineState *machine) host_bus = phb->bus; pcms->bus = phb->bus; /* create ISA bus */ - lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV, - ICH9_LPC_FUNC), true, - TYPE_ICH9_LPC_DEVICE); + lpc = pci_create_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV, + ICH9_LPC_FUNC), true, TYPE_ICH9_LPC_DEVICE); + qdev_prop_set_bit(DEVICE(lpc), "cpu-hotplug", machine->cpu_hotplug); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, TYPE_HOTPLUG_HANDLER, (Object **)&pcms->acpi_dev, object_property_allow_set_link, OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); + qdev_init_nofail(DEVICE(lpc)); object_property_set_link(OBJECT(machine), OBJECT(lpc), PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index e29a856..198c017 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -23,6 +23,7 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" +#include "hw/acpi/cpu.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h" @@ -49,7 +50,10 @@ typedef struct ICH9LPCPMRegs { Notifier powerdown_notifier; bool cpu_hotplug_legacy; - AcpiCpuHotplug gpe_cpu; + union { + AcpiCpuHotplug legacy; /* used for keeping legacy state */ + CPUHotplugState state; + } cpuhp; MemHotplugState acpi_memory_hotplug;