qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org
Cc: gleb@redhat.com,
	Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>,
	kevin@koconnor.net, avi@redhat.com, anthony@codemonkey.ws,
	imammedo@redhat.com
Subject: [Qemu-devel] [RFC PATCH v2 15/21] acpi_piix4: _OST dimm support
Date: Wed, 11 Jul 2012 12:32:00 +0200	[thread overview]
Message-ID: <1342002726-18258-16-git-send-email-vasilis.liaskovitis@profitbricks.com> (raw)
In-Reply-To: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com>

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 <vasilis.liaskovitis@profitbricks.com>
---
 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

  parent reply	other threads:[~2012-07-11 10:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 10:31 [Qemu-devel] [RFC PATCH v2 00/21] ACPI memory hotplug Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 01/21][SeaBIOS] Add ACPI_EXTRACT_DEVICE* macros Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 02/21][SeaBIOS] Add SSDT memory device support Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 03/21][SeaBIOS] acpi-dsdt: Implement functions for memory hotplug Vasilis Liaskovitis
2012-07-17  7:23   ` Wen Congyang
2012-07-20  8:48     ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 04/21][SeaBIOS] acpi: generate hotplug memory devices Vasilis Liaskovitis
2012-07-11 10:48   ` Wen Congyang
2012-07-11 16:39     ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 05/21][SeaBIOS] pciinit: Fix pcimem_start value Vasilis Liaskovitis
2012-07-11 11:56   ` Gerd Hoffmann
2012-07-11 16:45     ` Vasilis Liaskovitis
2012-07-12  7:22       ` Gerd Hoffmann
2012-07-12  9:09         ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 06/21] dimm: Implement memory device abstraction Vasilis Liaskovitis
2012-07-12 19:55   ` Blue Swirl
2012-07-13 17:39     ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 07/21] acpi_piix4: Implement memory device hotplug registers Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 08/21] pc: calculate dimm physical addresses and adjust memory map Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 09/21] pc: Add dimm paravirt SRAT info Vasilis Liaskovitis
2012-07-12 19:48   ` Blue Swirl
2012-07-13 17:40     ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 10/21] Implement "-dimm" command line option Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 11/21] Implement dimm_add and dimm_del hmp/qmp commands Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 12/21] fix live-migration when "populated=on" is missing Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 13/21] Implement memory hotplug notification lists Vasilis Liaskovitis
2012-07-11 14:59   ` Eric Blake
2012-07-11 16:47     ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 14/21][SeaBIOS] acpi_dsdt: Support _OST dimm method Vasilis Liaskovitis
2012-07-11 10:32 ` Vasilis Liaskovitis [this message]
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 16/21] acpi_piix4: Update dimm state on VM reboot Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 17/21][SeaBIOS] acpi_dsdt: Revert internal dimm state on _OST failure Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 18/21] acpi_piix4: Update dimm bitmap state on hot-remove fail Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 19/21] Implement "info memtotal" and "query-memtotal" Vasilis Liaskovitis
2012-07-11 15:14   ` Eric Blake
2012-07-11 16:55     ` Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 20/21] Implement -dimms, -dimmspop command line options Vasilis Liaskovitis
2012-07-11 14:55   ` Avi Kivity
2012-07-11 16:57     ` Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 21/21] Implement mem_increase, mem_decrease hmp/qmp commands Vasilis Liaskovitis
2012-07-12 20:04 ` [Qemu-devel] [RFC PATCH v2 00/21] ACPI memory hotplug Blue Swirl
2012-07-13 17:49   ` Vasilis Liaskovitis
2012-07-14  9:08     ` Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342002726-18258-16-git-send-email-vasilis.liaskovitis@profitbricks.com \
    --to=vasilis.liaskovitis@profitbricks.com \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).