From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vasilis Liaskovitis Subject: [RFC PATCH v2 15/21] acpi_piix4: _OST dimm support Date: Wed, 11 Jul 2012 12:32:00 +0200 Message-ID: <1342002726-18258-16-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com> Cc: avi@redhat.com, anthony@codemonkey.ws, gleb@redhat.com, imammedo@redhat.com, kevin@koconnor.net, wency@cn.fujitsu.com, Vasilis Liaskovitis To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org Return-path: Received: from mail-bk0-f46.google.com ([209.85.214.46]:40424 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757170Ab2GKKcW (ORCPT ); Wed, 11 Jul 2012 06:32:22 -0400 Received: by mail-bk0-f46.google.com with SMTP id j10so891613bkw.19 for ; Wed, 11 Jul 2012 03:32:21 -0700 (PDT) In-Reply-To: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SouDe-0003cZ-5h for qemu-devel@nongnu.org; Wed, 11 Jul 2012 06:32:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SouDX-0005sh-4N for qemu-devel@nongnu.org; Wed, 11 Jul 2012 06:32:29 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:61756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SouDW-0005ow-OP for qemu-devel@nongnu.org; Wed, 11 Jul 2012 06:32:22 -0400 Received: by mail-bk0-f45.google.com with SMTP id ji1so712868bkc.4 for ; Wed, 11 Jul 2012 03:32:21 -0700 (PDT) From: Vasilis Liaskovitis Date: Wed, 11 Jul 2012 12:32:00 +0200 Message-Id: <1342002726-18258-16-git-send-email-vasilis.liaskovitis@profitbricks.com> In-Reply-To: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com> Subject: [Qemu-devel] [RFC PATCH v2 15/21] acpi_piix4: _OST dimm support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org Cc: gleb@redhat.com, Vasilis Liaskovitis , kevin@koconnor.net, avi@redhat.com, anthony@codemonkey.ws, imammedo@redhat.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 --- 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