From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: lcapitulino@redhat.com, pkrempa@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH v2 3/5] acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices
Date: Mon, 16 Jun 2014 19:12:27 +0200 [thread overview]
Message-ID: <1402938749-13371-4-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1402938749-13371-1-git-send-email-imammedo@redhat.com>
... using TYPE_ACPI_DEVICE_IF interface.
Which provides status reporting of ACPI declared memory devices
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
v2:
- set slot-type to DIMM
- take into account that 'device' field could be optional
---
hw/acpi/ich9.c | 7 +++++++
hw/acpi/memory_hotplug.c | 31 +++++++++++++++++++++++++++++++
hw/acpi/piix4.c | 11 +++++++++++
hw/isa/lpc_ich9.c | 3 +++
include/hw/acpi/ich9.h | 3 +++
include/hw/acpi/memory_hotplug.h | 1 +
6 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 2f66524..b9ebf63 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -310,3 +310,10 @@ void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp)
" type: %s", object_get_typename(OBJECT(dev)));
}
}
+
+void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
+{
+ ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
+
+ acpi_memory_ospm_status(&s->pm.acpi_memory_hotplug, list);
+}
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 71c7a5e..e7009bc 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -4,6 +4,37 @@
#include "hw/boards.h"
#include "trace.h"
+static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
+{
+ ACPIOSTInfo *info = g_new0(ACPIOSTInfo, 1);
+
+ info->slot_type = ACPI_SLOT_TYPE_DIMM;
+ info->slot = g_strdup_printf("%d", slot);
+ info->source = mdev->ost_event;
+ info->status = mdev->ost_status;
+ if (mdev->dimm) {
+ DeviceState *dev = DEVICE(mdev->dimm);
+ if (dev->id) {
+ info->device = g_strdup(dev->id);
+ info->has_device = true;
+ }
+ }
+ return info;
+}
+
+void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list)
+{
+ int i;
+
+ for (i = 0; i < mem_st->dev_count; i++) {
+ ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
+ elem->value = acpi_memory_device_status(i, &mem_st->devs[i]);
+ elem->next = NULL;
+ **list = elem;
+ *list = &elem->next;
+ }
+}
+
static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
unsigned int size)
{
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 7473485..6e2587f 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -35,6 +35,7 @@
#include "hw/hotplug.h"
#include "hw/mem/pc-dimm.h"
#include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/acpi_dev_interface.h"
//#define DEBUG
@@ -574,6 +575,13 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
}
}
+static void piix4_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
+{
+ PIIX4PMState *s = PIIX4_PM(adev);
+
+ acpi_memory_ospm_status(&s->acpi_memory_hotplug, list);
+}
+
static Property piix4_pm_properties[] = {
DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
@@ -591,6 +599,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
+ AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass);
k->init = piix4_pm_initfn;
k->config_write = pm_write_config;
@@ -609,6 +618,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
dc->hotpluggable = false;
hc->plug = piix4_device_plug_cb;
hc->unplug = piix4_device_unplug_cb;
+ adevc->ospm_status = piix4_ospm_status;
}
static const TypeInfo piix4_pm_info = {
@@ -618,6 +628,7 @@ static const TypeInfo piix4_pm_info = {
.class_init = piix4_pm_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_HOTPLUG_HANDLER },
+ { TYPE_ACPI_DEVICE_IF },
{ }
}
};
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 01ca071..a2b87ea 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -659,6 +659,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
+ AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass);
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
dc->reset = ich9_lpc_reset;
@@ -677,6 +678,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
dc->cannot_instantiate_with_device_add_yet = true;
hc->plug = ich9_device_plug_cb;
hc->unplug = ich9_device_unplug_cb;
+ adevc->ospm_status = ich9_pm_ospm_status;
}
static const TypeInfo ich9_lpc_info = {
@@ -687,6 +689,7 @@ static const TypeInfo ich9_lpc_info = {
.class_init = ich9_lpc_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_HOTPLUG_HANDLER },
+ { TYPE_ACPI_DEVICE_IF },
{ }
}
};
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 1977f1b..7e42448 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -24,6 +24,7 @@
#include "hw/acpi/acpi.h"
#include "hw/acpi/cpu_hotplug.h"
#include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/acpi_dev_interface.h"
typedef struct ICH9LPCPMRegs {
/*
@@ -59,4 +60,6 @@ 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_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
#endif /* HW_ACPI_ICH9_H */
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 4588459..7bbf8a0 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -34,4 +34,5 @@ extern const VMStateDescription vmstate_memory_hotplug;
VMSTATE_STRUCT(memhp, state, 1, \
vmstate_memory_hotplug, MemHotplugState)
+void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
#endif
--
1.7.1
next prev parent reply other threads:[~2014-06-16 17:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 1/5] qmp: add query-memory-devices command Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 2/5] acpi: introduce TYPE_ACPI_DEVICE_IF interface Igor Mammedov
2014-06-16 17:12 ` Igor Mammedov [this message]
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 4/5] qmp: add query-acpi-ospm-status command Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 5/5] qmp: add ACPI_DEVICE_OST event handling Igor Mammedov
2014-06-17 11:25 ` [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Michael S. Tsirkin
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=1402938749-13371-4-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mst@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-devel@nongnu.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).