All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug.
  2014-10-22 10:00 Tang Chen
@ 2014-10-22 10:00 ` Tang Chen
  0 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-10-22 10:00 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: hutao, isimatu.yasuaki, zhugh.fnst, tangchen

This patch adds a new bit to memory hotplug IO port indicating that
memory device is be removed. And set MemStatus->is_removing to false
when the bit is written.

NOTE: MemStatus->is_removing is set to true in acpi_memory_unplug_cb()
when doing memory hot-remove with device_del command.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 docs/specs/acpi_mem_hotplug.txt |  8 ++++++--
 hw/acpi/memory_hotplug.c        | 14 +++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/docs/specs/acpi_mem_hotplug.txt b/docs/specs/acpi_mem_hotplug.txt
index 1290994..5524c30 100644
--- a/docs/specs/acpi_mem_hotplug.txt
+++ b/docs/specs/acpi_mem_hotplug.txt
@@ -19,7 +19,9 @@ Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access):
               1: Device insert event, used to distinguish device for which
                  no device check event to OSPM was issued.
                  It's valid only when bit 1 is set.
-              2-7: reserved and should be ignored by OSPM
+              2: Device remove event, used to indicate that device is being
+		 removed.
+              3-7: reserved and should be ignored by OSPM
       [0x15-0x17] reserved
 
   write access:
@@ -35,7 +37,9 @@ Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access):
               1: if set to 1 clears device insert event, set by OSPM
                  after it has emitted device check event for the
                  selected memory device
-              2-7: reserved, OSPM must clear them before writing to register
+              2: set by hardware after it has emitted devive eject event for
+		 selected memory device
+              3-7: reserved, OSPM must clear them before writing to register
 
 Selecting memory device slot beyond present range has no effect on platform:
    - write accesses to memory hot-plug registers not documented above are
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 01dea6c..a745bb0 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -75,6 +75,7 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
     case 0x14: /* pack and return is_* fields */
         val |= mdev->is_enabled   ? 1 : 0;
         val |= mdev->is_inserting ? 2 : 0;
+        val |= mdev->is_removing  ? 4 : 0;
         trace_mhp_acpi_read_flags(mem_st->selector, val);
         break;
     default:
@@ -121,21 +122,28 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
         mdev = &mem_st->devs[mem_st->selector];
         mdev->ost_status = data;
         trace_mhp_acpi_write_ost_status(mem_st->selector, mdev->ost_status);
-        /* TODO: implement memory removal on guest signal */
 
         info = acpi_memory_device_status(mem_st->selector, mdev);
         qapi_event_send_acpi_device_ost(info, &error_abort);
         qapi_free_ACPIOSTInfo(info);
         break;
-    case 0x14:
+    case 0x14: /* set is_* fields */
         mdev = &mem_st->devs[mem_st->selector];
+
         if (data & 2) { /* clear insert event */
             mdev->is_inserting  = false;
             trace_mhp_acpi_clear_insert_evt(mem_st->selector);
+        } else if (data & 4) { /* request removal of device */
+            mdev->is_enabled = false;
+            mdev->is_removing = false;
+            object_unparent(OBJECT(mdev->dimm));
+            mdev->dimm = NULL;
         }
+
+        break;
+    default:
         break;
     }
-
 }
 static const MemoryRegionOps acpi_memory_hotplug_ops = {
     .read = acpi_memory_hotplug_read,
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support.
@ 2014-11-05  5:49 Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 01/10] acpi, mem-hotplug: Use PC_DIMM_SLOT_PROP in acpi_memory_plug_cb() Tang Chen
                   ` (10 more replies)
  0 siblings, 11 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

This patch-set implements memory hot-remove for QEmu. 

Rebased on Igor's asynchronize hotplug framework (qemu v2.1.2, the latest).

Approach: QEmu sets GPE status bit, then triggers SCI to notify guest os.
Guest os checks device status, and free memory resource if possible,
then generate OST.

NOTE: In this version, memory hot-remove is independent from _OST, 
      following Igor's comments. Will implement _OST for memory hot-remove
      soon if this part is OK.

Change log v3 -> v4 (RESEND):
1. Add new patch 1 ~ 4, fix some small problems in coding.
2. In patch 9, make memory hot-remove independent from _OST.
3. In patch 9, add comment for is_removing flag to document.
4. In patch 10, use macro instead of number.
5. Remove original patch 8 and 12 to coincident with asynchronize
   hotplug framework.

Hu Tao (4):
  acpi, piix4: Add memory hot unplug support for piix4.
  pc: Add memory hot unplug support for pc machine.
  pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support.
  pc, acpi bios: Add memory hot unplug interface.

Tang Chen (6):
  acpi, mem-hotplug: Use PC_DIMM_SLOT_PROP in acpi_memory_plug_cb().
  acpi, mem-hotplug: Add acpi_memory_get_slot_status_descriptor() to get
    MemStatus.
  acpi, mem-hotplug: Add acpi_memory_hotplug_sci() to rise sci for
    memory hotplug.
  acpi, mem-hotplug: Add acpi_memory_unplug_cb() to implement memory
    unplug.
  acpi, ich9: Add memory hot unplug support for ich9.
  acpi: Add hardware implementation for memory hot unplug.

 docs/specs/acpi_mem_hotplug.txt  |  8 +++--
 hw/acpi/ich9.c                   | 12 +++++++
 hw/acpi/memory_hotplug.c         | 71 +++++++++++++++++++++++++++++++---------
 hw/acpi/piix4.c                  |  6 +++-
 hw/i386/pc.c                     | 31 ++++++++++++++++++
 hw/i386/ssdt-mem.dsl             |  5 +++
 hw/i386/ssdt-misc.dsl            | 13 +++++++-
 hw/isa/lpc_ich9.c                |  5 +--
 hw/mem/pc-dimm.c                 | 10 ++++++
 include/hw/acpi/ich9.h           |  2 ++
 include/hw/acpi/memory_hotplug.h |  3 ++
 include/hw/acpi/pc-hotplug.h     |  2 ++
 12 files changed, 146 insertions(+), 22 deletions(-)

-- 
1.8.4.2

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 01/10] acpi, mem-hotplug: Use PC_DIMM_SLOT_PROP in acpi_memory_plug_cb().
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 02/10] acpi, mem-hotplug: Add acpi_memory_get_slot_status_descriptor() to get MemStatus Tang Chen
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

Replace string "slot" in acpi_memory_plug_cb() with MACRO PC_DIMM_SLOT_PROP.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/acpi/memory_hotplug.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index ed39241..c6580da 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -168,7 +168,8 @@ void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
 {
     MemStatus *mdev;
     Error *local_err = NULL;
-    int slot = object_property_get_int(OBJECT(dev), "slot", &local_err);
+    int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
+                                       &local_err);
 
     if (local_err) {
         error_propagate(errp, local_err);
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 02/10] acpi, mem-hotplug: Add acpi_memory_get_slot_status_descriptor() to get MemStatus.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 01/10] acpi, mem-hotplug: Use PC_DIMM_SLOT_PROP in acpi_memory_plug_cb() Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 03/10] acpi, mem-hotplug: Add acpi_memory_hotplug_sci() to rise sci for memory hotplug Tang Chen
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

Add a new API named acpi_memory_get_slot_status_descriptor() to obtain
a single memory slot status. Doing this is because this procedure will
be used by other functions in the next coming patches.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/acpi/memory_hotplug.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index c6580da..ef56bf6 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -163,29 +163,40 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
     memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io);
 }
 
-void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
-                         DeviceState *dev, Error **errp)
+static MemStatus *
+acpi_memory_get_slot_status_descriptor(MemHotplugState *mem_st,
+                                       DeviceState *dev, Error **errp)
 {
-    MemStatus *mdev;
     Error *local_err = NULL;
     int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
                                        &local_err);
 
     if (local_err) {
         error_propagate(errp, local_err);
-        return;
+        return NULL;
     }
 
     if (slot >= mem_st->dev_count) {
         char *dev_path = object_get_canonical_path(OBJECT(dev));
-        error_setg(errp, "acpi_memory_plug_cb: "
+        error_setg(errp, "acpi_memory_get_slot_status_descriptor: "
                    "device [%s] returned invalid memory slot[%d]",
-                    dev_path, slot);
+                   dev_path, slot);
         g_free(dev_path);
-        return;
+        return NULL;
     }
 
-    mdev = &mem_st->devs[slot];
+    return &mem_st->devs[slot];
+}
+
+void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
+                         DeviceState *dev, Error **errp)
+{
+    MemStatus *mdev;
+
+    mdev = acpi_memory_get_slot_status_descriptor(mem_st, dev, errp);
+    if (!mdev)
+        return;
+
     mdev->dimm = dev;
     mdev->is_enabled = true;
     mdev->is_inserting = true;
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 03/10] acpi, mem-hotplug: Add acpi_memory_hotplug_sci() to rise sci for memory hotplug.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 01/10] acpi, mem-hotplug: Use PC_DIMM_SLOT_PROP in acpi_memory_plug_cb() Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 02/10] acpi, mem-hotplug: Add acpi_memory_get_slot_status_descriptor() to get MemStatus Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 04/10] acpi, mem-hotplug: Add acpi_memory_unplug_cb() to implement memory unplug Tang Chen
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

Add a new API named acpi_memory_hotplug_sci() to send memory hotplug SCI.
Doing this is because this procedure will be used by other functions in the
next coming patches.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/acpi/memory_hotplug.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index ef56bf6..9839963 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -188,6 +188,12 @@ acpi_memory_get_slot_status_descriptor(MemHotplugState *mem_st,
     return &mem_st->devs[slot];
 }
 
+static void acpi_memory_hotplug_sci(ACPIREGS *ar, qemu_irq irq)
+{
+    ar->gpe.sts[0] |= ACPI_MEMORY_HOTPLUG_STATUS;
+    acpi_update_sci(ar, irq);
+}
+
 void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
                          DeviceState *dev, Error **errp)
 {
@@ -201,10 +207,8 @@ void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
     mdev->is_enabled = true;
     mdev->is_inserting = true;
 
-    /* do ACPI magic */
-    ar->gpe.sts[0] |= ACPI_MEMORY_HOTPLUG_STATUS;
-    acpi_update_sci(ar, irq);
-    return;
+    /* Do ACPI magic */
+    acpi_memory_hotplug_sci(ar, irq);
 }
 
 static const VMStateDescription vmstate_memhp_sts = {
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 04/10] acpi, mem-hotplug: Add acpi_memory_unplug_cb() to implement memory unplug.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (2 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 03/10] acpi, mem-hotplug: Add acpi_memory_hotplug_sci() to rise sci for memory hotplug Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 05/10] acpi, piix4: Add memory hot unplug support for piix4 Tang Chen
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

Add a new bool member named is_removing to MemStatus indicating that
the memory solt is being removed. Set it to true in acpi_memory_unplug_cb(),
and send SCI to guest.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/acpi/memory_hotplug.c         | 15 +++++++++++++++
 include/hw/acpi/memory_hotplug.h |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 9839963..01dea6c 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -211,6 +211,21 @@ void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
     acpi_memory_hotplug_sci(ar, irq);
 }
 
+void acpi_memory_unplug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
+                           DeviceState *dev, Error **errp)
+{
+    MemStatus *mdev;
+
+    mdev = acpi_memory_get_slot_status_descriptor(mem_st, dev, errp);
+    if (!mdev)
+        return;
+
+    mdev->is_removing = true;
+
+    /* Do ACPI magic */
+    acpi_memory_hotplug_sci(ar, irq);
+}
+
 static const VMStateDescription vmstate_memhp_sts = {
     .name = "memory hotplug device state",
     .version_id = 1,
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 7bbf8a0..fe41268 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -11,6 +11,7 @@ typedef struct MemStatus {
     DeviceState *dimm;
     bool is_enabled;
     bool is_inserting;
+    bool is_removing;
     uint32_t ost_event;
     uint32_t ost_status;
 } MemStatus;
@@ -28,6 +29,8 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
 
 void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
                          DeviceState *dev, Error **errp);
+void acpi_memory_unplug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
+                           DeviceState *dev, Error **errp);
 
 extern const VMStateDescription vmstate_memory_hotplug;
 #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 05/10] acpi, piix4: Add memory hot unplug support for piix4.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (3 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 04/10] acpi, mem-hotplug: Add acpi_memory_unplug_cb() to implement memory unplug Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 06/10] acpi, ich9: Add memory hot unplug support for ich9 Tang Chen
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

From: Hu Tao <hutao@cn.fujitsu.com>

Implement acpi_memory_unplug_cb(), sending an sci to guest to trigger
memory hot-remove, and call it in piix4_device_unplug_cb().

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/acpi/piix4.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 78c0a6d..92b29b7 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -360,7 +360,11 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
 {
     PIIX4PMState *s = PIIX4_PM(hotplug_dev);
 
-    if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+    if (s->acpi_memory_hotplug.is_enabled &&
+        object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        acpi_memory_unplug_cb(&s->ar, s->irq, &s->acpi_memory_hotplug, dev,
+                              errp);
+    } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
         acpi_pcihp_device_unplug_cb(&s->ar, s->irq, &s->acpi_pci_hotplug, dev,
                                     errp);
     } else {
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 06/10] acpi, ich9: Add memory hot unplug support for ich9.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (4 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 05/10] acpi, piix4: Add memory hot unplug support for piix4 Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 07/10] pc: Add memory hot unplug support for pc machine Tang Chen
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

Implement ich9_pm_device_unplug_cb() to support memory hot-remove,
calling acpi_memory_unplug_cb(). And itself will be called in
ich9_device_unplug_cb().

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/acpi/ich9.c         | 12 ++++++++++++
 hw/isa/lpc_ich9.c      |  5 +++--
 include/hw/acpi/ich9.h |  2 ++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index ea991a3..68cc169 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -301,6 +301,18 @@ void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp)
     }
 }
 
+void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp)
+{
+    if (pm->acpi_memory_hotplug.is_enabled &&
+        object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        acpi_memory_unplug_cb(&pm->acpi_regs, pm->irq, &pm->acpi_memory_hotplug,
+                              dev, errp);
+    } else {
+        error_setg(errp, "acpi: device unplug request for not supported device"
+                   " type: %s", object_get_typename(OBJECT(dev)));
+    }
+}
+
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
 {
     ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 530b074..75f28d1 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -610,8 +610,9 @@ static void ich9_device_plug_cb(HotplugHandler *hotplug_dev,
 static void ich9_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                                           DeviceState *dev, Error **errp)
 {
-    error_setg(errp, "acpi: device unplug request for not supported device"
-               " type: %s", object_get_typename(OBJECT(dev)));
+    ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
+
+    ich9_pm_device_unplug_cb(&lpc->pm, dev, errp);
 }
 
 static bool ich9_rst_cnt_needed(void *opaque)
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index fe975e6..92f19de 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -59,6 +59,8 @@ extern const VMStateDescription vmstate_ich9_pm;
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp);
 
 void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp);
+void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev,
+                              Error **errp);
 
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
 #endif /* HW_ACPI_ICH9_H */
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 07/10] pc: Add memory hot unplug support for pc machine.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (5 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 06/10] acpi, ich9: Add memory hot unplug support for ich9 Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 08/10] pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support Tang Chen
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

From: Hu Tao <hutao@cn.fujitsu.com>

Implement device unplug callback for PCMachine. And it now only support
pc-dimm hot-remove. The callback will call piix4 or ich9 callbacks introduced
in previous patches.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/i386/pc.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 1205db8..2c26749 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -61,6 +61,8 @@
 #include "hw/mem/pc-dimm.h"
 #include "trace.h"
 #include "qapi/visitor.h"
+#include "hw/acpi/piix4.h"
+#include "hw/i386/ich9.h"
 
 /* debug PC/ISA interrupts */
 //#define DEBUG_IRQ
@@ -1637,6 +1639,26 @@ out:
     error_propagate(errp, local_err);
 }
 
+static void pc_dimm_unplug(HotplugHandler *hotplug_dev,
+                           DeviceState *dev, Error **errp)
+{
+    HotplugHandlerClass *hhc;
+    Error *local_err = NULL;
+    PCMachineState *pcms = PC_MACHINE(hotplug_dev);
+
+    if (!pcms->acpi_dev) {
+        error_setg(&local_err,
+                   "memory hotplug is not enabled: missing acpi device");
+	goto out;
+    }
+
+    hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
+    hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
+
+out:
+    error_propagate(errp, local_err);
+}
+
 static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp)
 {
@@ -1647,6 +1669,14 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
     }
 }
 
+static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev,
+                                        DeviceState *dev, Error **errp)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        pc_dimm_unplug(hotplug_dev, dev, errp);
+    }
+}
+
 static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
                                              DeviceState *dev)
 {
@@ -1753,6 +1783,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     pcmc->get_hotplug_handler = mc->get_hotplug_handler;
     mc->get_hotplug_handler = pc_get_hotpug_handler;
     hc->plug = pc_machine_device_plug_cb;
+    hc->unplug = pc_machine_device_unplug_cb;
 }
 
 static const TypeInfo pc_machine_info = {
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 08/10] pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (6 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 07/10] pc: Add memory hot unplug support for pc machine Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05 10:19   ` Igor Mammedov
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug Tang Chen
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

From: Hu Tao <hutao@cn.fujitsu.com>

Implement unrealize function for pc-dimm device. It remove subregion from
hotplug region, and delete ram address range from guest ram list.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/mem/pc-dimm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index ee802bb..b105871 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -270,12 +270,22 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm)
     return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
 }
 
+static void pc_dimm_unrealize(DeviceState *dev, Error **errp)
+{
+    PCDIMMDevice *dimm = PC_DIMM(dev);
+    MemoryRegion *mr = pc_dimm_get_memory_region(dimm);
+
+    memory_region_del_subregion(mr->container, mr);
+    vmstate_unregister_ram(mr, dev);
+}
+
 static void pc_dimm_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
 
     dc->realize = pc_dimm_realize;
+    dc->unrealize = pc_dimm_unrealize;
     dc->props = pc_dimm_properties;
 
     ddc->get_memory_region = pc_dimm_get_memory_region;
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (7 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 08/10] pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05  6:16   ` Hu Tao
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 10/10] pc, acpi bios: Add memory hot unplug interface Tang Chen
  2014-11-05 10:31 ` [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Igor Mammedov
  10 siblings, 1 reply; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

This patch adds a new bit to memory hotplug IO port indicating that
memory device is be removed. And set MemStatus->is_removing to false
when the bit is written.

NOTE: MemStatus->is_removing is set to true in acpi_memory_unplug_cb()
when doing memory hot-remove with device_del command.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 docs/specs/acpi_mem_hotplug.txt |  8 ++++++--
 hw/acpi/memory_hotplug.c        | 14 +++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/docs/specs/acpi_mem_hotplug.txt b/docs/specs/acpi_mem_hotplug.txt
index 1290994..5524c30 100644
--- a/docs/specs/acpi_mem_hotplug.txt
+++ b/docs/specs/acpi_mem_hotplug.txt
@@ -19,7 +19,9 @@ Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access):
               1: Device insert event, used to distinguish device for which
                  no device check event to OSPM was issued.
                  It's valid only when bit 1 is set.
-              2-7: reserved and should be ignored by OSPM
+              2: Device remove event, used to indicate that device is being
+		 removed.
+              3-7: reserved and should be ignored by OSPM
       [0x15-0x17] reserved
 
   write access:
@@ -35,7 +37,9 @@ Memory hot-plug interface (IO port 0xa00-0xa17, 1-4 byte access):
               1: if set to 1 clears device insert event, set by OSPM
                  after it has emitted device check event for the
                  selected memory device
-              2-7: reserved, OSPM must clear them before writing to register
+              2: set by hardware after it has emitted devive eject event for
+		 selected memory device
+              3-7: reserved, OSPM must clear them before writing to register
 
 Selecting memory device slot beyond present range has no effect on platform:
    - write accesses to memory hot-plug registers not documented above are
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 01dea6c..a745bb0 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -75,6 +75,7 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
     case 0x14: /* pack and return is_* fields */
         val |= mdev->is_enabled   ? 1 : 0;
         val |= mdev->is_inserting ? 2 : 0;
+        val |= mdev->is_removing  ? 4 : 0;
         trace_mhp_acpi_read_flags(mem_st->selector, val);
         break;
     default:
@@ -121,21 +122,28 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
         mdev = &mem_st->devs[mem_st->selector];
         mdev->ost_status = data;
         trace_mhp_acpi_write_ost_status(mem_st->selector, mdev->ost_status);
-        /* TODO: implement memory removal on guest signal */
 
         info = acpi_memory_device_status(mem_st->selector, mdev);
         qapi_event_send_acpi_device_ost(info, &error_abort);
         qapi_free_ACPIOSTInfo(info);
         break;
-    case 0x14:
+    case 0x14: /* set is_* fields */
         mdev = &mem_st->devs[mem_st->selector];
+
         if (data & 2) { /* clear insert event */
             mdev->is_inserting  = false;
             trace_mhp_acpi_clear_insert_evt(mem_st->selector);
+        } else if (data & 4) { /* request removal of device */
+            mdev->is_enabled = false;
+            mdev->is_removing = false;
+            object_unparent(OBJECT(mdev->dimm));
+            mdev->dimm = NULL;
         }
+
+        break;
+    default:
         break;
     }
-
 }
 static const MemoryRegionOps acpi_memory_hotplug_ops = {
     .read = acpi_memory_hotplug_read,
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [RESEND PATCH v4 10/10] pc, acpi bios: Add memory hot unplug interface.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (8 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug Tang Chen
@ 2014-11-05  5:49 ` Tang Chen
  2014-11-05 10:31 ` [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Igor Mammedov
  10 siblings, 0 replies; 15+ messages in thread
From: Tang Chen @ 2014-11-05  5:49 UTC (permalink / raw)
  To: qemu-devel, imammedo, mst, pbonzini
  Cc: guz.fnst, hutao, isimatu.yasuaki, zhugh.fnst, tangchen

From: Hu Tao <hutao@cn.fujitsu.com>

This patch implements MEMORY_SLOT_EJECT_METHOD according to ACPI spec.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
 hw/i386/ssdt-mem.dsl         |  5 +++++
 hw/i386/ssdt-misc.dsl        | 13 ++++++++++++-
 include/hw/acpi/pc-hotplug.h |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/hw/i386/ssdt-mem.dsl b/hw/i386/ssdt-mem.dsl
index 22ff5dd..1416639 100644
--- a/hw/i386/ssdt-mem.dsl
+++ b/hw/i386/ssdt-mem.dsl
@@ -43,6 +43,7 @@ DefinitionBlock ("ssdt-mem.aml", "SSDT", 0x02, "BXPC", "CSSDT", 0x1)
     External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_STATUS_METHOD, MethodObj)
     External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_OST_METHOD, MethodObj)
     External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_PROXIMITY_METHOD, MethodObj)
+    External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_EJECT_METHOD, MethodObj)
 
     Scope(\_SB) {
 /*  v------------------ DO NOT EDIT ------------------v */
@@ -72,6 +73,10 @@ DefinitionBlock ("ssdt-mem.aml", "SSDT", 0x02, "BXPC", "CSSDT", 0x1)
             Method(_OST, 3) {
                 \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_OST_METHOD(_UID, Arg0, Arg1, Arg2)
             }
+
+            Method(_EJ0, 1) {
+                \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_EJECT_METHOD(_UID, Arg0)
+            }
         }
     }
 }
diff --git a/hw/i386/ssdt-misc.dsl b/hw/i386/ssdt-misc.dsl
index 0fd4480..7b29539 100644
--- a/hw/i386/ssdt-misc.dsl
+++ b/hw/i386/ssdt-misc.dsl
@@ -156,6 +156,7 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
                 Offset(20),
                 MEMORY_SLOT_ENABLED,  1, // 1 if enabled, read only
                 MEMORY_SLOT_INSERT_EVENT, 1, // (read) 1 if has a insert event. (write) 1 to clear event
+                MEMORY_SLOT_REMOVE_EVENT, 1, // 1 if DIMM has a remove request, read only
             }
 
             Mutex (MEMORY_SLOT_LOCK, 0)
@@ -174,11 +175,14 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
                 while (LLess(Local0, MEMORY_SLOTS_NUMBER)) {
                     Store(Local0, MEMORY_SLOT_SLECTOR) // select Local0 DIMM
+
                     If (LEqual(MEMORY_SLOT_INSERT_EVENT, One)) { // Memory device needs check
                         MEMORY_SLOT_NOTIFY_METHOD(Local0, 1)
                         Store(1, MEMORY_SLOT_INSERT_EVENT)
+                    } Elseif (LEqual(MEMORY_SLOT_REMOVE_EVENT, One)) { // Ejection request
+                        MEMORY_SLOT_NOTIFY_METHOD(Local0, 3)
                     }
-                    // TODO: handle memory eject request
+
                     Add(Local0, One, Local0) // goto next DIMM
                 }
                 Release(MEMORY_SLOT_LOCK)
@@ -278,6 +282,13 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1)
                 Store(Arg2, MEMORY_SLOT_OST_STATUS)
                 Release(MEMORY_SLOT_LOCK)
             }
+
+            Method(MEMORY_SLOT_EJECT_METHOD, 2) {
+                Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
+                Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
+                Store(One, MEMORY_SLOT_REMOVE_EVENT)
+                Release(MEMORY_SLOT_LOCK)
+            }
         } // Device()
     } // Scope()
 }
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index b9db295..b61b6ea 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -42,6 +42,7 @@
 #define MEMORY_SLOT_PROXIMITY        MPX
 #define MEMORY_SLOT_ENABLED          MES
 #define MEMORY_SLOT_INSERT_EVENT     MINS
+#define MEMORY_SLOT_REMOVE_EVENT     MRMV
 #define MEMORY_SLOT_SLECTOR          MSEL
 #define MEMORY_SLOT_OST_EVENT        MOEV
 #define MEMORY_SLOT_OST_STATUS       MOSC
@@ -50,6 +51,7 @@
 #define MEMORY_SLOT_CRS_METHOD       MCRS
 #define MEMORY_SLOT_OST_METHOD       MOST
 #define MEMORY_SLOT_PROXIMITY_METHOD MPXM
+#define MEMORY_SLOT_EJECT_METHOD     MEJ0
 #define MEMORY_SLOT_NOTIFY_METHOD    MTFY
 #define MEMORY_SLOT_SCAN_METHOD      MSCN
 
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug.
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug Tang Chen
@ 2014-11-05  6:16   ` Hu Tao
  0 siblings, 0 replies; 15+ messages in thread
From: Hu Tao @ 2014-11-05  6:16 UTC (permalink / raw)
  To: Tang Chen
  Cc: zhugh.fnst, mst, qemu-devel, isimatu.yasuaki, pbonzini, guz.fnst,
	imammedo

On Wed, Nov 05, 2014 at 01:49:54PM +0800, Tang Chen wrote:

<...>

> -              2-7: reserved, OSPM must clear them before writing to register
> +              2: set by hardware after it has emitted devive eject event for

s/devive/device/

Regards,
Hu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [RESEND PATCH v4 08/10] pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support.
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 08/10] pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support Tang Chen
@ 2014-11-05 10:19   ` Igor Mammedov
  0 siblings, 0 replies; 15+ messages in thread
From: Igor Mammedov @ 2014-11-05 10:19 UTC (permalink / raw)
  To: Tang Chen
  Cc: zhugh.fnst, mst, hutao, qemu-devel, isimatu.yasuaki, guz.fnst,
	pbonzini

On Wed, 5 Nov 2014 13:49:53 +0800
Tang Chen <tangchen@cn.fujitsu.com> wrote:

> From: Hu Tao <hutao@cn.fujitsu.com>
> 
> Implement unrealize function for pc-dimm device. It remove subregion from
> hotplug region, and delete ram address range from guest ram list.
This still doesn't address comments made in V3

looks like there isn't any need for unrealize so far
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
> ---
>  hw/mem/pc-dimm.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index ee802bb..b105871 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -270,12 +270,22 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm)
>      return host_memory_backend_get_memory(dimm->hostmem, &error_abort);
>  }
>  
> +static void pc_dimm_unrealize(DeviceState *dev, Error **errp)
> +{
> +    PCDIMMDevice *dimm = PC_DIMM(dev);
> +    MemoryRegion *mr = pc_dimm_get_memory_region(dimm);
> +
> +    memory_region_del_subregion(mr->container, mr);
you wouldn't need to access fields if it's done in unplug handler
and you shouldn't access MemoryRegion fields directly in the first place

> +    vmstate_unregister_ram(mr, dev);


all above should be done unplug handler by pc-machine

> +}
> +
>  static void pc_dimm_class_init(ObjectClass *oc, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(oc);
>      PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc);
>  
>      dc->realize = pc_dimm_realize;
> +    dc->unrealize = pc_dimm_unrealize;
>      dc->props = pc_dimm_properties;
>  
>      ddc->get_memory_region = pc_dimm_get_memory_region;

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support.
  2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
                   ` (9 preceding siblings ...)
  2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 10/10] pc, acpi bios: Add memory hot unplug interface Tang Chen
@ 2014-11-05 10:31 ` Igor Mammedov
  10 siblings, 0 replies; 15+ messages in thread
From: Igor Mammedov @ 2014-11-05 10:31 UTC (permalink / raw)
  To: Tang Chen
  Cc: zhugh.fnst, mst, hutao, qemu-devel, isimatu.yasuaki, guz.fnst,
	pbonzini

On Wed, 5 Nov 2014 13:49:45 +0800
Tang Chen <tangchen@cn.fujitsu.com> wrote:

> This patch-set implements memory hot-remove for QEmu. 
> 
> Rebased on Igor's asynchronize hotplug framework (qemu v2.1.2, the latest).
As I've wrote before, there were hot-unplug patches merged last month,
see for reference http://lists.nongnu.org/archive/html/qemu-devel/2014-09/msg05195.html
and this series could benefit from them.

So please look take in account not addressed yet comments on V3
and rebase on current master instead of stable 2.1.2.

> 
> Approach: QEmu sets GPE status bit, then triggers SCI to notify guest os.
> Guest os checks device status, and free memory resource if possible,
> then generate OST.
> 
> NOTE: In this version, memory hot-remove is independent from _OST, 
>       following Igor's comments. Will implement _OST for memory hot-remove
>       soon if this part is OK.
> 
> Change log v3 -> v4 (RESEND):
> 1. Add new patch 1 ~ 4, fix some small problems in coding.
> 2. In patch 9, make memory hot-remove independent from _OST.
> 3. In patch 9, add comment for is_removing flag to document.
> 4. In patch 10, use macro instead of number.
> 5. Remove original patch 8 and 12 to coincident with asynchronize
>    hotplug framework.
> 
> Hu Tao (4):
>   acpi, piix4: Add memory hot unplug support for piix4.
>   pc: Add memory hot unplug support for pc machine.
>   pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support.
>   pc, acpi bios: Add memory hot unplug interface.
> 
> Tang Chen (6):
>   acpi, mem-hotplug: Use PC_DIMM_SLOT_PROP in acpi_memory_plug_cb().
>   acpi, mem-hotplug: Add acpi_memory_get_slot_status_descriptor() to get
>     MemStatus.
>   acpi, mem-hotplug: Add acpi_memory_hotplug_sci() to rise sci for
>     memory hotplug.
>   acpi, mem-hotplug: Add acpi_memory_unplug_cb() to implement memory
>     unplug.
>   acpi, ich9: Add memory hot unplug support for ich9.
>   acpi: Add hardware implementation for memory hot unplug.
> 
>  docs/specs/acpi_mem_hotplug.txt  |  8 +++--
>  hw/acpi/ich9.c                   | 12 +++++++
>  hw/acpi/memory_hotplug.c         | 71 +++++++++++++++++++++++++++++++---------
>  hw/acpi/piix4.c                  |  6 +++-
>  hw/i386/pc.c                     | 31 ++++++++++++++++++
>  hw/i386/ssdt-mem.dsl             |  5 +++
>  hw/i386/ssdt-misc.dsl            | 13 +++++++-
>  hw/isa/lpc_ich9.c                |  5 +--
>  hw/mem/pc-dimm.c                 | 10 ++++++
>  include/hw/acpi/ich9.h           |  2 ++
>  include/hw/acpi/memory_hotplug.h |  3 ++
>  include/hw/acpi/pc-hotplug.h     |  2 ++
>  12 files changed, 146 insertions(+), 22 deletions(-)
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-11-05 10:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05  5:49 [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 01/10] acpi, mem-hotplug: Use PC_DIMM_SLOT_PROP in acpi_memory_plug_cb() Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 02/10] acpi, mem-hotplug: Add acpi_memory_get_slot_status_descriptor() to get MemStatus Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 03/10] acpi, mem-hotplug: Add acpi_memory_hotplug_sci() to rise sci for memory hotplug Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 04/10] acpi, mem-hotplug: Add acpi_memory_unplug_cb() to implement memory unplug Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 05/10] acpi, piix4: Add memory hot unplug support for piix4 Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 06/10] acpi, ich9: Add memory hot unplug support for ich9 Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 07/10] pc: Add memory hot unplug support for pc machine Tang Chen
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 08/10] pc-dimm: Add pc_dimm_unrealize() for memory hot unplug support Tang Chen
2014-11-05 10:19   ` Igor Mammedov
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug Tang Chen
2014-11-05  6:16   ` Hu Tao
2014-11-05  5:49 ` [Qemu-devel] [RESEND PATCH v4 10/10] pc, acpi bios: Add memory hot unplug interface Tang Chen
2014-11-05 10:31 ` [Qemu-devel] [RESEND PATCH v4 00/10] QEmu memory hot unplug support Igor Mammedov
  -- strict thread matches above, loose matches on Subject: below --
2014-10-22 10:00 Tang Chen
2014-10-22 10:00 ` [Qemu-devel] [RESEND PATCH v4 09/10] acpi: Add hardware implementation for memory hot unplug Tang Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.