From: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org
Cc: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>,
gleb@redhat.com, blauwirbel@gmail.com, kevin@koconnor.net,
avi@redhat.com, anthony@codemonkey.ws, imammedo@redhat.com,
eblake@redhat.com, kraxel@redhat.com
Subject: [Qemu-devel] [RFC PATCH v3 15/19] Add _OST dimm support
Date: Fri, 21 Sep 2012 13:17:31 +0200 [thread overview]
Message-ID: <1348226255-4226-16-git-send-email-vasilis.liaskovitis@profitbricks.com> (raw)
In-Reply-To: <1348226255-4226-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)
This patch also updates dimm bitmap state and hot-remove pending flag
on hot-remove fail. This allows failed hot operations to be retried at
anytime. This only works for guests that use _OST notification.
Also adds new _OST registers in docs/specs/acpi_hotplug.txt
Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
---
docs/specs/acpi_hotplug.txt | 25 +++++++++++++++++++++++++
hw/acpi_piix4.c | 35 ++++++++++++++++++++++++++++++++++-
hw/dimm.c | 28 +++++++++++++++++++++++++++-
hw/dimm.h | 10 +++++++++-
4 files changed, 95 insertions(+), 3 deletions(-)
diff --git a/docs/specs/acpi_hotplug.txt b/docs/specs/acpi_hotplug.txt
index cf86242..536da16 100644
--- a/docs/specs/acpi_hotplug.txt
+++ b/docs/specs/acpi_hotplug.txt
@@ -20,3 +20,28 @@ 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 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-remove _OST 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-remove _OST 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 8776669..f7220d4 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
@@ -87,6 +90,7 @@ typedef struct PIIX4PMState {
uint8_t s4_val;
} PIIX4PMState;
+static int piix4_dimm_revert(DeviceState *qdev, DimmDevice *dev, int add);
static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s);
#define ACPI_ENABLE 0xf1
@@ -531,6 +535,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,13 +617,16 @@ 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;
}
pci_bus_hotplug(bus, piix4_device_hotplug, &s->dev.qdev);
- dimm_bus_hotplug(piix4_dimm_hotplug, &s->dev.qdev);
+ dimm_bus_hotplug(piix4_dimm_hotplug, piix4_dimm_revert, &s->dev.qdev);
}
static void enable_device(PIIX4PMState *s, int slot)
@@ -656,6 +672,23 @@ static int piix4_dimm_hotplug(DeviceState *qdev, DimmDevice *dev, int
return 0;
}
+static int piix4_dimm_revert(DeviceState *qdev, DimmDevice *dev, int add)
+{
+ PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, qdev);
+ PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, pci_dev);
+ struct gpe_regs *g = &s->gperegs;
+ DimmDevice *slot = DIMM(dev);
+ int idx = slot->idx;
+
+ if (add) {
+ g->mems_sts[idx/8] &= ~(1 << (idx%8));
+ }
+ else {
+ g->mems_sts[idx/8] |= (1 << (idx%8));
+ }
+ return 0;
+}
+
static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
PCIHotplugState state)
{
diff --git a/hw/dimm.c b/hw/dimm.c
index 21626f6..1521462 100644
--- a/hw/dimm.c
+++ b/hw/dimm.c
@@ -126,12 +126,14 @@ void dimm_config_create(char *id, uint64_t size, uint64_t node, uint32_t
QTAILQ_INSERT_TAIL(&dimmconfig_list, dimm_cfg, nextdimmcfg);
}
-void dimm_bus_hotplug(dimm_hotplug_fn hotplug, DeviceState *qdev)
+void dimm_bus_hotplug(dimm_hotplug_fn hotplug, dimm_hotplug_fn revert,
+ DeviceState *qdev)
{
DimmBus *bus = main_memory_bus;
bus->qbus.allow_hotplug = 1;
bus->dimm_hotplug_qdev = qdev;
bus->dimm_hotplug = hotplug;
+ bus->dimm_revert = revert;
}
static void dimm_plug_device(DimmDevice *slot)
@@ -141,6 +143,7 @@ static void dimm_plug_device(DimmDevice *slot)
dimm_populate(slot);
if (bus->dimm_hotplug)
bus->dimm_hotplug(bus->dimm_hotplug_qdev, slot, 1);
+ slot->pending = DIMM_ADD_PENDING;
}
static int dimm_unplug_device(DeviceState *qdev)
@@ -149,6 +152,7 @@ static int dimm_unplug_device(DeviceState *qdev)
if (bus->dimm_hotplug)
bus->dimm_hotplug(bus->dimm_hotplug_qdev, DIMM(qdev), 0);
+ DIMM(qdev)->pending = DIMM_REMOVE_PENDING;
return 1;
}
@@ -266,12 +270,33 @@ void dimm_notify(uint32_t idx, uint32_t event)
result = g_malloc0(sizeof(*result));
slotcfg = dimmcfg_find_from_name(DEVICE(s)->id);
result->dimmname = slotcfg->name;
+ result->ret = event;
switch(event) {
case DIMM_REMOVE_SUCCESS:
dimm_depopulate(s);
QTAILQ_REMOVE(&bus->dimmlist, s, nextdimm);
qdev_simple_unplug_cb((DeviceState*)s);
+ s->pending = DIMM_NO_PENDING;
+ QTAILQ_INSERT_TAIL(&bus->dimm_hp_result_queue, result, next);
+ break;
+ case DIMM_REMOVE_FAIL:
+ s->pending = DIMM_NO_PENDING;
+ if (bus->dimm_revert)
+ bus->dimm_revert(bus->dimm_hotplug_qdev, s, 0);
+ QTAILQ_INSERT_TAIL(&bus->dimm_hp_result_queue, result, next);
+ break;
+ case DIMM_ADD_SUCCESS:
+ s->pending = DIMM_NO_PENDING;
+ QTAILQ_INSERT_TAIL(&bus->dimm_hp_result_queue, result, next);
+ break;
+ case DIMM_ADD_FAIL:
+ dimm_depopulate(s);
+ s->pending = DIMM_NO_PENDING;
+ if (bus->dimm_revert)
+ bus->dimm_revert(bus->dimm_hotplug_qdev, s, 1);
+ QTAILQ_REMOVE(&bus->dimmlist, s, nextdimm);
+ qdev_simple_unplug_cb((DeviceState*)s);
QTAILQ_INSERT_TAIL(&bus->dimm_hp_result_queue, result, next);
break;
default:
@@ -352,6 +377,7 @@ static int dimm_init(DeviceState *s)
slot->start = slotcfg->start;
slot->size = slotcfg->size;
slot->node = slotcfg->node;
+ slot->pending = DIMM_NO_PENDING;
QTAILQ_INSERT_TAIL(&bus->dimmlist, slot, nextdimm);
dimm_plug_device(slot);
diff --git a/hw/dimm.h b/hw/dimm.h
index 21225be..4f696d8 100644
--- a/hw/dimm.h
+++ b/hw/dimm.h
@@ -18,6 +18,12 @@ typedef enum {
DIMM_ADD_FAIL = 3
} dimm_hp_result_code;
+typedef enum {
+ DIMM_NO_PENDING = 0,
+ DIMM_ADD_PENDING = 1,
+ DIMM_REMOVE_PENDING = 2,
+} dimm_hp_pending_code;
+
#define TYPE_DIMM "dimm"
#define DIMM(obj) \
OBJECT_CHECK(DimmDevice, (obj), TYPE_DIMM)
@@ -42,6 +48,7 @@ typedef struct DimmDevice {
ram_addr_t size;
uint32_t node; /* numa node proximity */
MemoryRegion *mr; /* MemoryRegion for this slot. !NULL only if populated */
+ dimm_hp_pending_code pending; /* indicates if a hot operation is pending for this dimm */
QTAILQ_ENTRY (DimmDevice) nextdimm;
} DimmDevice;
@@ -66,6 +73,7 @@ typedef struct DimmBus {
BusState qbus;
DeviceState *dimm_hotplug_qdev;
dimm_hotplug_fn dimm_hotplug;
+ dimm_hotplug_fn dimm_revert;
dimm_calcoffset_fn dimm_calcoffset;
DimmConfiglist dimmconfig_list;
QTAILQ_HEAD(Dimmlist, DimmDevice) dimmlist;
@@ -80,7 +88,7 @@ struct dimm_hp_result {
void dimm_calc_offsets(dimm_calcoffset_fn calcfn);
void dimm_notify(uint32_t idx, uint32_t event);
-void dimm_bus_hotplug(dimm_hotplug_fn hotplug, DeviceState *qdev);
+void dimm_bus_hotplug(dimm_hotplug_fn hotplug, dimm_hotplug_fn revert, DeviceState *qdev);
void setup_fwcfg_hp_dimms(uint64_t *fw_cfg_slots);
int dimm_add(char *id);
void main_memory_bus_create(Object *parent);
--
1.7.9
next prev parent reply other threads:[~2012-09-21 11:18 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-21 11:17 [Qemu-devel] [RFC PATCH v3 00/19] ACPI memory hotplug Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 01/19][SeaBIOS] Add ACPI_EXTRACT_DEVICE* macros Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 02/19][SeaBIOS] Add SSDT memory device support Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 03/19][SeaBIOS] acpi-dsdt: Implement functions for memory hotplug Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 04/19][SeaBIOS] acpi: generate hotplug memory devices Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 05/19] Implement dimm device abstraction Vasilis Liaskovitis
2012-09-24 6:02 ` Wen Congyang
2012-10-23 12:25 ` Stefan Hajnoczi
2012-10-24 8:06 ` liu ping fan
2012-10-24 10:15 ` Stefan Hajnoczi
2012-10-24 17:16 ` Vasilis Liaskovitis
2012-10-25 8:00 ` liu ping fan
2012-10-31 11:15 ` Avi Kivity
2012-10-31 12:18 ` Stefan Hajnoczi
2012-10-31 12:34 ` Avi Kivity
2012-10-31 12:34 ` Stefan Hajnoczi
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 06/19] Implement "-dimm" command line option Vasilis Liaskovitis
2012-09-22 13:46 ` Blue Swirl
2012-09-24 10:42 ` Vasilis Liaskovitis
2012-09-29 11:13 ` Blue Swirl
2012-10-09 17:04 ` Vasilis Liaskovitis
2012-10-13 8:57 ` Blue Swirl
2012-10-17 9:19 ` Vasilis Liaskovitis
2012-10-17 10:03 ` Avi Kivity
2012-10-18 9:27 ` Vasilis Liaskovitis
2012-10-18 12:33 ` Avi Kivity
2012-10-19 17:48 ` Blue Swirl
2012-10-22 10:55 ` Avi Kivity
2012-10-22 8:39 ` Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 07/19] acpi_piix4: Implement memory device hotplug registers Vasilis Liaskovitis
2012-09-22 13:49 ` Blue Swirl
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 08/19] pc: calculate dimm physical addresses and adjust memory map Vasilis Liaskovitis
2012-09-22 14:15 ` Blue Swirl
2012-09-24 15:27 ` Vasilis Liaskovitis
2012-09-29 11:27 ` Blue Swirl
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 09/19] pc: Add dimm paravirt SRAT info Vasilis Liaskovitis
2012-09-27 3:55 ` Wen Congyang
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 10/19] fix live-migration when "populated=on" is missing Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 11/19] Implement qmp and hmp commands for notification lists Vasilis Liaskovitis
2012-09-21 22:03 ` Eric Blake
2012-09-24 14:45 ` Vasilis Liaskovitis
2012-10-23 12:15 ` Stefan Hajnoczi
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 12/19] Implement "info memory-total" and "query-memory-total" Vasilis Liaskovitis
2012-09-21 22:36 ` Eric Blake
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 13/19] balloon: update with hotplugged memory Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 14/19][SeaBIOS] Add _OST dimm method Vasilis Liaskovitis
2012-09-21 11:17 ` Vasilis Liaskovitis [this message]
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 16/19] Update dimm state on reset Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 17/19][SeaBIOS] Implement _PS3 method for memory device Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 18/19] Implement _PS3 for dimm Vasilis Liaskovitis
2012-09-21 11:17 ` [Qemu-devel] [RFC PATCH v3 19/19][SeaBIOS] Calculate pcimem_start and pcimem64_start from SRAT entries Vasilis Liaskovitis
2012-09-21 11:19 ` [Qemu-devel] [RFC PATCH v3 19/19] alternative: Introduce paravirt interface QEMU_CFG_PCI_WINDOW Vasilis Liaskovitis
2012-09-21 11:20 ` [Qemu-devel] [RFC PATCH v3 20/19][SeaBIOS] alternative: Use paravirt interface for pci windows Vasilis Liaskovitis
2012-09-24 6:35 ` Wen Congyang
2012-09-24 10:46 ` Vasilis Liaskovitis
2012-09-24 6:51 ` [Qemu-devel] [RFC PATCH v3 19/19][SeaBIOS] Calculate pcimem_start and pcimem64_start from SRAT entries Wen Congyang
2012-09-22 14:17 ` [Qemu-devel] [RFC PATCH v3 00/19] ACPI memory hotplug Blue Swirl
2012-10-31 10:58 ` Stefan Hajnoczi
2012-10-31 11:16 ` Avi Kivity
2012-11-01 9:01 ` Vasilis Liaskovitis
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=1348226255-4226-16-git-send-email-vasilis.liaskovitis@profitbricks.com \
--to=vasilis.liaskovitis@profitbricks.com \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=eblake@redhat.com \
--cc=gleb@redhat.com \
--cc=imammedo@redhat.com \
--cc=kevin@koconnor.net \
--cc=kraxel@redhat.com \
--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).