qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH v2 15/21] acpi_piix4: _OST dimm support


From: Vasilis Liaskovitis
Subject: [Qemu-devel] [RFC PATCH v2 15/21] acpi_piix4: _OST dimm support
Date: Wed, 11 Jul 2012 12:32:00 +0200

This allows qemu to receive notifications from the guest OS on success or
failure of a memory hotplug request. The guest OS needs to implement the _OST
functionality for this to work (linux-next: http://lkml.org/lkml/2012/6/25/321)
Also add new _OST registers in docs/specs/acpi_hotplug.txt

Signed-off-by: Vasilis Liaskovitis <address@hidden>
---
 docs/specs/acpi_hotplug.txt |   24 ++++++++++++++++++++++++
 hw/acpi_piix4.c             |   15 +++++++++++++++
 hw/dimm.c                   |   18 ++++++++++++++++++
 hw/dimm.h                   |    1 +
 4 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/docs/specs/acpi_hotplug.txt b/docs/specs/acpi_hotplug.txt
index cf86242..2f6fd5f 100644
--- a/docs/specs/acpi_hotplug.txt
+++ b/docs/specs/acpi_hotplug.txt
@@ -20,3 +20,27 @@ ejected.
 
 Written by ACPI memory device _EJ0 method to notify qemu of successfull
 hot-removal.  Write-only.
+
+Memory Dimm ejection failure notification (IO port 0xafa1, 1-byte access):
+---------------------------------------------------------------
+Dimm hot-remove _OST failure notification. Byte value indicates Dimm slot for
+which ejection failed.
+
+Written by ACPI memory device _OST method to notify qemu of failed
+hot-removal.  Write-only.
+
+Memory Dimm insertion success notification (IO port 0xafa2, 1-byte access):
+---------------------------------------------------------------
+Dimm hot-add _OST success notification. Byte value indicates Dimm slot for 
which
+insertion succeeded.
+
+Written by ACPI memory device _OST method to notify qemu of failed
+hot-add.  Write-only.
+
+Memory Dimm insertion failure notification (IO port 0xafa3, 1-byte access):
+---------------------------------------------------------------
+Dimm hot-add _OST failure notification. Byte value indicates Dimm slot for 
which
+insertion failed.
+
+Written by ACPI memory device _OST method to notify qemu of failed
+hot-add.  Write-only.
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index b988597..d8e2c22 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -49,6 +49,9 @@
 #define PCI_RMV_BASE 0xae0c
 #define MEM_BASE 0xaf80
 #define MEM_EJ_BASE 0xafa0
+#define MEM_OST_REMOVE_FAIL 0xafa1
+#define MEM_OST_ADD_SUCCESS 0xafa2
+#define MEM_OST_ADD_FAIL 0xafa3
 
 #define PIIX4_MEM_HOTPLUG_STATUS 8
 #define PIIX4_PCI_HOTPLUG_STATUS 2
@@ -531,6 +534,15 @@ static void gpe_writeb(void *opaque, uint32_t addr, 
uint32_t val)
         case MEM_EJ_BASE:
             dimm_notify(val, DIMM_REMOVE_SUCCESS);
             break;
+        case MEM_OST_REMOVE_FAIL:
+            dimm_notify(val, DIMM_REMOVE_FAIL);
+            break;
+        case MEM_OST_ADD_SUCCESS:
+            dimm_notify(val, DIMM_ADD_SUCCESS);
+            break;
+        case MEM_OST_ADD_FAIL:
+            dimm_notify(val, DIMM_ADD_FAIL);
+            break;
         default:
             acpi_gpe_ioport_writeb(&s->ar, addr, val);
     }
@@ -604,6 +616,9 @@ static void piix4_acpi_system_hot_add_init(PCIBus *bus, 
PIIX4PMState *s)
 
     register_ioport_read(MEM_BASE, DIMM_BITMAP_BYTES, 1,  gpe_readb, s);
     register_ioport_write(MEM_EJ_BASE, 1, 1,  gpe_writeb, s);
+    register_ioport_write(MEM_OST_REMOVE_FAIL, 1, 1,  gpe_writeb, s);
+    register_ioport_write(MEM_OST_ADD_SUCCESS, 1, 1,  gpe_writeb, s);
+    register_ioport_write(MEM_OST_ADD_FAIL, 1, 1,  gpe_writeb, s);
 
     for(i = 0; i < DIMM_BITMAP_BYTES; i++) {
         s->gperegs.mems_sts[i] = 0;
diff --git a/hw/dimm.c b/hw/dimm.c
index 9b32386..ba104cc 100644
--- a/hw/dimm.c
+++ b/hw/dimm.c
@@ -89,12 +89,14 @@ void dimm_activate(DimmState *slot)
     dimm_populate(slot);
     if (dimm_hotplug)
         dimm_hotplug(dimm_hotplug_qdev, (SysBusDevice*)slot, 1);
+    slot->pending = true;
 }
 
 void dimm_deactivate(DimmState *slot)
 {
     if (dimm_hotplug)
         dimm_hotplug(dimm_hotplug_qdev, (SysBusDevice*)slot, 0);
+    slot->pending = true;
 }
 
 DimmState *dimm_find_from_name(char *id)
@@ -138,6 +140,10 @@ int dimm_do(Monitor *mon, const QDict *qdict, bool add)
                     __FUNCTION__, id);
             return 1;
         }
+        if (slot->pending) {
+            fprintf(stderr, "warning: %s slot %s hot-operation pending\n",
+                    __FUNCTION__, id);
+        }
         dimm_activate(slot);
     }
     else {
@@ -146,6 +152,10 @@ int dimm_do(Monitor *mon, const QDict *qdict, bool add)
                     __FUNCTION__, id);
             return 1;
         }
+        if (slot->pending) {
+            fprintf(stderr, "warning: %s slot %s hot-operation pending\n",
+                    __FUNCTION__, id);
+        }
         dimm_deactivate(slot);
     }
 
@@ -198,6 +208,13 @@ void dimm_notify(uint32_t idx, uint32_t event)
         case DIMM_REMOVE_SUCCESS:
             dimm_depopulate(s);
             QTAILQ_INSERT_TAIL(&dimm_hp_result_queue, result, next);
+            s->pending = false;
+            break;
+        case DIMM_REMOVE_FAIL:
+        case DIMM_ADD_SUCCESS:
+        case DIMM_ADD_FAIL:
+            QTAILQ_INSERT_TAIL(&dimm_hp_result_queue, result, next);
+            s->pending = false;
             break;
         default:
             g_free(result);
@@ -259,6 +276,7 @@ static int dimm_init(SysBusDevice *s)
     slot = DIMM(s);
     slot->mr = NULL;
     slot->populated = false;
+    slot->pending = false;
     return 0;
 }
 
diff --git a/hw/dimm.h b/hw/dimm.h
index 3e55ed3..0fa6137 100644
--- a/hw/dimm.h
+++ b/hw/dimm.h
@@ -35,6 +35,7 @@ typedef struct DimmState {
     MemoryRegion *mr; /* MemoryRegion for this slot. !NULL only if populated */
     bool populated; /* 1 means device has been hotplugged. Default is 0. */
     QTAILQ_ENTRY (DimmState) nextdimm;
+    bool pending; /* true means a hot operation is pending for this dimm */
 } DimmState;
 
 struct dimm_hp_result {
-- 
1.7.9




reply via email to

[Prev in Thread] Current Thread [Next in Thread]