From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXQsZ-0005Bv-Cu for qemu-devel@nongnu.org; Mon, 16 Mar 2015 05:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXQsY-0007Iq-98 for qemu-devel@nongnu.org; Mon, 16 Mar 2015 05:00:07 -0400 Received: from [59.151.112.132] (port=37810 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXQsX-000759-UP for qemu-devel@nongnu.org; Mon, 16 Mar 2015 05:00:06 -0400 From: Zhu Guihua Date: Mon, 16 Mar 2015 16:58:16 +0800 Message-ID: <25454ba4d411914abb12f764ddd82080e7916d70.1426494342.git.zhugh.fnst@cn.fujitsu.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RESEND PATCH v4 4/6] acpi, mem-hotplug: Add unplug cb for memory device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, imammedo@redhat.com, mst@redhat.com, pbonzini@redhat.com Cc: guz.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com, Zhu Guihua , tangchen@cn.fujitsu.com From: Tang Chen This patch adds unplug cb for memory device. It resets some memory status in acpi_memory_unplug_cb(). Signed-off-by: Tang Chen Signed-off-by: Zhu Guihua --- hw/acpi/ich9.c | 9 +++++++-- hw/acpi/memory_hotplug.c | 14 ++++++++++++++ hw/acpi/piix4.c | 10 ++++++++-- include/hw/acpi/memory_hotplug.h | 2 ++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index b85eed4..84e5bb8 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -413,8 +413,13 @@ void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev, void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) { - error_setg(errp, "acpi: device unplug for not supported device" - " type: %s", object_get_typename(OBJECT(dev))); + if (pm->acpi_memory_hotplug.is_enabled && + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + acpi_memory_unplug_cb(&pm->acpi_memory_hotplug, dev, errp); + } else { + error_setg(errp, "acpi: device unplug for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 2ef6a94..687b2f1 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -227,6 +227,20 @@ void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq, acpi_update_sci(ar, irq); } +void acpi_memory_unplug_cb(MemHotplugState *mem_st, + DeviceState *dev, Error **errp) +{ + MemStatus *mdev; + + mdev = acpi_memory_slot_status(mem_st, dev, errp); + if (!mdev) { + return; + } + + mdev->is_enabled = false; + mdev->dimm = NULL; +} + static const VMStateDescription vmstate_memhp_sts = { .name = "memory hotplug device state", .version_id = 1, diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index f716e91..781ad33 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -377,8 +377,14 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - error_setg(errp, "acpi: device unplug for not supported device" - " type: %s", object_get_typename(OBJECT(dev))); + PIIX4PMState *s = PIIX4_PM(hotplug_dev); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + acpi_memory_unplug_cb(&s->acpi_memory_hotplug, dev, errp); + } else { + error_setg(errp, "acpi: device unplug for not supported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } static void piix4_update_bus_hotplug(PCIBus *pci_bus, void *opaque) diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h index c437a85..15deae0 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -32,6 +32,8 @@ void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st, void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st, DeviceState *dev, Error **errp); +void acpi_memory_unplug_cb(MemHotplugState *mem_st, + DeviceState *dev, Error **errp); extern const VMStateDescription vmstate_memory_hotplug; #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \ -- 1.9.3