* [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
@ 2013-06-06 3:16 liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 1/8] acpi: add ACPI Embedded Controller support liguang
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:16 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
v2:
1.remove PIIX4_PROC_BASE operations for cpu hotplug
2.fix wrong description fo cpu-del
patch 1 adds ACPI Embedded Controller (EC),
refer-to:
ACPI SPEC v5 chapter 12
"ACPI Embedded Controller Interface Specification"
EC is a standard ACPI device, it plays flexible roles,
especially be event carrier, it can pass events between platform
and OS, so OS can execute _Qxx method which defined
by yourself and query EC's ACPI space which can be a buffer for
many purposes
here, I want to deliver CPU online/offline event between
OS and QEMU for CPU hotplug feature, then we will don't
need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
again after 'cpu-add' and also for offline to do real cpu
removal.
what I am trying to do is emulated physical addition/removal
(like described by linux kernel document for cpu hotplug --
linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
these RFC patches are sent for demo what I am trying to do.
the design process simply like following:
hotplug
qemu::ec::sci -> kernel::ec::gpe::notifier->
kernel::cpu_physic_hotplug::handler->kernel::cpu_up
unplug
kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
sorry, I should poll cpu-unplug cmd sent from kernel,
but, it's a little trivial, I want do it later.
for kernel patches:
http://comments.gmane.org/gmane.linux.kernel/1503460
Li Guang (8)
acpi: add ACPI Embedded Controller support
ich9: add notifer for ec to generate sci
ec: add operations for _Qxx events
piix4: add notifer for ec to generate sci
piix4: add events for cpu hotplug
qmp: add 'cpu-del' command
pc: add EC qdev init for piix & q35
cpu-hotplug: remove memory regison for cpu hotplug
default-configs/x86_64-softmmu.mak | 1 +
hw/acpi/Makefile.objs | 1 +
hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
hw/acpi/ich9.c | 15 +++++++++++++++
hw/acpi/piix4.c | 68 ++++++++++++++
hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
hw/i386/pc_piix.c | 7 +
hw/i386/pc_q35.c | 6 +
include/hw/acpi/ec.h | 44 ++++++
include/hw/acpi/ich9.h | 1 +
include/hw/boards.h | 5 +++--
include/hw/i386/pc.h | 1 +
qapi-schema.json | 13 +++++++++++++
qmp-commands.hx | 23 +++++++++++++++++++++++
qmp.c | 9 +++++++++
15 files changed, 411 insertions(+), 54 deletions(-)
create mode 100644 hw/acpi/ec.c
create mode 100644 include/hw/acpi/ec.h
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 1/8] acpi: add ACPI Embedded Controller support
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
@ 2013-06-06 3:16 ` liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 2/8] ich9: add notifer for ec to generate sci liguang
` (7 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:16 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
this work implemented Embedded Controller chip emulation
which was defined at ACPI SEPC v5 chapter 12:
"ACPI Embedded Controller Interface Specification"
commonly Embedded Controller will emulate keyboard,
mouse, handle ACPI defined operations and some
low-speed devices like SMbus.
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
default-configs/x86_64-softmmu.mak | 1 +
hw/acpi/Makefile.objs | 1 +
hw/acpi/ec.c | 193 ++++++++++++++++++++++++++++++++++++
include/hw/acpi/ec.h | 29 ++++++
4 files changed, 224 insertions(+), 0 deletions(-)
create mode 100644 hw/acpi/ec.c
create mode 100644 include/hw/acpi/ec.h
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index 599b630..c654ae9 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -46,3 +46,4 @@ CONFIG_APIC=y
CONFIG_IOAPIC=y
CONFIG_ICC_BUS=y
CONFIG_PVPANIC=y
+CONFIG_ACPI_EC=y
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index a0b63b5..0936f17 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,2 +1,3 @@
common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o
+common-obj-$(CONFIG_ACPI_EC) += ec.o
diff --git a/hw/acpi/ec.c b/hw/acpi/ec.c
new file mode 100644
index 0000000..da8525f
--- /dev/null
+++ b/hw/acpi/ec.c
@@ -0,0 +1,193 @@
+#include "hw/acpi/ec.h"
+#include "hw/hw.h"
+#include "hw/isa/isa.h"
+#include "sysemu/sysemu.h"
+
+#define TYPE_EC_DEV "ACPI Embedded Controller"
+#define EC_DEV(obj) \
+ OBJECT_CHECK(ECState, (obj), TYPE_EC_DEV)
+
+static uint8_t ec_acpi_space[EC_ACPI_SPACE_SIZE] = {0};
+static uint8_t sci_event;
+static bool ec_enabled = false;
+
+typedef struct ECState {
+ ISADevice parent_obj;
+
+ uint8_t cmd;
+ uint8_t status;
+ uint8_t data;
+ uint8_t buf;
+ qemu_irq irq;
+ MemoryRegion io[2];
+} ECState;
+
+static NotifierList ec_sci_notifiers =
+ NOTIFIER_LIST_INITIALIZER(ec_sci_notifiers);
+void qemu_register_ec_sci_notifier(Notifier *notifier)
+{
+ notifier_list_add(&ec_sci_notifiers, notifier);
+}
+
+bool qemu_ec_enabled(void)
+{
+ return ec_enabled;
+}
+
+void ec_dev_init(ISABus *isabus)
+{
+ isa_create_simple(isabus, TYPE_EC_DEV);
+}
+
+void ec_acpi_event(uint8_t evt)
+{
+ sci_event = evt;
+}
+
+static void ec_generate_sci(void)
+{
+ notifier_list_notify(&ec_sci_notifiers, NULL);
+}
+
+static void acpi_data_write(void *opaque, hwaddr addr, uint64_t val,
+ unsigned size)
+{
+ ECState *s = opaque;
+ uint8_t tmp = val & 0xff;
+
+ if (s->status & EC_ACPI_CMD) {
+ s->buf = tmp & 0xff;
+ s->status &= ~EC_ACPI_CMD;
+ } else {
+ switch (tmp) {
+ case EC_ACPI_CMD_READ:
+ if (tmp < EC_ACPI_SPACE_SIZE) {
+ s->data = ec_acpi_space[tmp];
+ }
+ s->status |= EC_ACPI_OBF;
+ break;
+ case EC_ACPI_CMD_WRITE:
+ if (tmp < EC_ACPI_SPACE_SIZE) {
+ ec_acpi_space[s->buf] = tmp;
+ }
+ break;
+ case EC_ACPI_CMD_QUERY:
+ s->data = sci_event;
+ default:
+ break;
+ }
+ }
+ ec_generate_sci();
+}
+
+static uint64_t acpi_data_read(void *opaque, hwaddr addr, unsigned size)
+{
+ ECState *s = opaque;
+
+ s->status &= ~(EC_ACPI_OBF | EC_ACPI_SCI);
+
+ return s->data;
+}
+
+static void acpi_cmd_write(void *opaque, hwaddr addr, uint64_t val,
+ unsigned size)
+{
+ ECState *s = opaque;
+ bool is_cmd = false;
+
+ s->status |= EC_ACPI_CMD;
+
+ switch (val & 0xff) {
+ case EC_ACPI_CMD_READ:
+ case EC_ACPI_CMD_WRITE:
+ is_cmd = true;
+ break;
+ case EC_ACPI_BURST_EN:
+ s->status |= EC_ACPI_BST;
+ s->data = 0x90;
+ is_cmd = true;
+ break;
+ case EC_ACPI_BURST_DN:
+ s->status &= ~EC_ACPI_BST;
+ is_cmd = true;
+ break;
+ case EC_ACPI_CMD_QUERY:
+ is_cmd = true;
+ default:
+ break;
+ }
+ if (is_cmd) {
+ s->cmd = val & 0xff;
+ ec_generate_sci();
+ s->status |= EC_ACPI_SCI;
+ } else {
+ s->cmd = 0;
+ }
+}
+
+static uint64_t acpi_status_read(void *opaque, hwaddr addr, unsigned size)
+{
+ ECState *s = opaque;
+
+ return s->status;
+}
+
+static const MemoryRegionOps io62_io_ops = {
+ .write = acpi_data_write,
+ .read = acpi_data_read,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 1,
+ },
+};
+
+static const MemoryRegionOps io66_io_ops = {
+ .write = acpi_cmd_write,
+ .read = acpi_status_read,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 1,
+ },
+};
+
+static int ec_dev_initfn(ISADevice *dev)
+{
+ ISADevice *isadev = dev;
+ ECState *s = EC_DEV(dev);
+
+/* isa_init_irq(isadev, &s->irq, 0xb); */
+
+ memory_region_init_io(s->io, &io62_io_ops, s, "ec-acpi-data", 1);
+ isa_register_ioport(isadev, s->io, 0x62);
+
+ memory_region_init_io(s->io + 1, &io66_io_ops, s, "ec-acpi-cmd", 1);
+ isa_register_ioport(isadev, s->io + 1, 0x66);
+
+ return 0;
+}
+
+static void ec_class_initfn(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+ ISADeviceClass *ic = ISA_DEVICE_CLASS(oc);
+
+ dc->no_user = 1;
+ ic->init = ec_dev_initfn;
+ ec_enabled = true;
+}
+
+static TypeInfo acpi_ec_info = {
+ .name = TYPE_EC_DEV,
+ .parent = TYPE_ISA_DEVICE,
+ .class_init = ec_class_initfn,
+ .instance_size = sizeof(ECState),
+};
+
+static void ec_register_type(void)
+{
+ type_register_static(&acpi_ec_info);
+}
+
+type_init(ec_register_type);
diff --git a/include/hw/acpi/ec.h b/include/hw/acpi/ec.h
new file mode 100644
index 0000000..3556acd
--- /dev/null
+++ b/include/hw/acpi/ec.h
@@ -0,0 +1,29 @@
+#ifndef __EC_H
+#define __EC_H
+
+#include "hw/i386/pc.h"
+#include "qemu/notify.h"
+
+#define EC_ACPI_SPACE_SIZE 0x80
+
+#define EC_ACPI_CMD_PORT 0x66
+#define EC_ACPI_DATA_PORT 0x62
+
+#define EC_ACPI_OBF 0x1
+#define EC_ACPI_IBF 0x2
+#define EC_ACPI_CMD 0x8
+#define EC_ACPI_BST 0x10
+#define EC_ACPI_SCI 0x20
+
+#define EC_ACPI_CMD_READ 0x80
+#define EC_ACPI_CMD_WRITE 0x81
+#define EC_ACPI_BURST_EN 0x82
+#define EC_ACPI_BURST_DN 0x83
+#define EC_ACPI_CMD_QUERY 0x84
+
+void qemu_register_ec_sci_notifier(Notifier *notifier);
+bool qemu_ec_enabled(void);
+void ec_dev_init(ISABus *isabus);
+void ec_acpi_event(uint8_t evt);
+
+#endif
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 2/8] ich9: add notifer for ec to generate sci
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 1/8] acpi: add ACPI Embedded Controller support liguang
@ 2013-06-06 3:16 ` liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 3/8] ec: add operations for _Qxx events liguang
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:16 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
hw/acpi/ich9.c | 15 +++++++++++++++
include/hw/acpi/ich9.h | 1 +
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 4a17f32..f1583ef 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -33,6 +33,7 @@
#include "exec/address-spaces.h"
#include "hw/i386/ich9.h"
+#include "hw/acpi/ec.h"
//#define DEBUG
@@ -43,6 +44,8 @@ do { printf("%s "fmt, __func__, ## __VA_ARGS__); } while (0)
#define ICH9_DEBUG(fmt, ...) do { } while (0)
#endif
+#define GPE_EC_SCI_STATUS 8
+
static void pm_update_sci(ICH9LPCPMRegs *pm)
{
int sci_level, pm1a_sts;
@@ -202,6 +205,15 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
acpi_pm1_evt_power_down(&pm->acpi_regs);
}
+static void pm_ec_sci_req(Notifier *n, void *opaque)
+{
+ ICH9LPCPMRegs *pm = container_of(n, ICH9LPCPMRegs, ec_sci_notifier);
+ ACPIGPE *gpe = &pm->acpi_regs.gpe;
+
+ *gpe->sts |= GPE_EC_SCI_STATUS;
+ pm_update_sci(pm);
+}
+
void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
qemu_irq sci_irq)
{
@@ -227,4 +239,7 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
qemu_register_reset(pm_reset, pm);
pm->powerdown_notifier.notify = pm_powerdown_req;
qemu_register_powerdown_notifier(&pm->powerdown_notifier);
+
+ pm->ec_sci_notifier.notify = pm_ec_sci_req;
+ qemu_register_ec_sci_notifier(&pm->ec_sci_notifier);
}
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index b1fe71f..f358deb 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -42,6 +42,7 @@ typedef struct ICH9LPCPMRegs {
uint32_t pm_io_base;
Notifier powerdown_notifier;
+ Notifier ec_sci_notifier;
} ICH9LPCPMRegs;
void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 3/8] ec: add operations for _Qxx events
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 1/8] acpi: add ACPI Embedded Controller support liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 2/8] ich9: add notifer for ec to generate sci liguang
@ 2013-06-06 3:16 ` liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 4/8] piix4: add notifer for ec to generate sci liguang
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:16 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
hw/acpi/ec.c | 32 ++++++++++++++++++++++++++++----
include/hw/acpi/ec.h | 10 ++++++++++
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/hw/acpi/ec.c b/hw/acpi/ec.c
index da8525f..fe82e9c 100644
--- a/hw/acpi/ec.c
+++ b/hw/acpi/ec.c
@@ -22,6 +22,9 @@ typedef struct ECState {
MemoryRegion io[2];
} ECState;
+static void ec_generate_sci(ECState *);
+static ECState *ecs;
+
static NotifierList ec_sci_notifiers =
NOTIFIER_LIST_INITIALIZER(ec_sci_notifiers);
void qemu_register_ec_sci_notifier(Notifier *notifier)
@@ -44,8 +47,26 @@ void ec_acpi_event(uint8_t evt)
sci_event = evt;
}
-static void ec_generate_sci(void)
+void ec_acpi_space_poke(uint8_t idx, uint8_t val)
+{
+ if (idx < EC_ACPI_SPACE_SIZE) {
+ ec_acpi_space[idx] = val;
+ ec_generate_sci(ecs);
+ }
+}
+
+uint8_t ec_acpi_space_peek(uint8_t idx)
{
+ if (idx < EC_ACPI_SPACE_SIZE) {
+ return ec_acpi_space[idx];
+ } else {
+ return 0;
+ }
+}
+
+static void ec_generate_sci(ECState *s)
+{
+ s->status |= EC_ACPI_SCI;
notifier_list_notify(&ec_sci_notifiers, NULL);
}
@@ -72,12 +93,11 @@ static void acpi_data_write(void *opaque, hwaddr addr, uint64_t val,
}
break;
case EC_ACPI_CMD_QUERY:
- s->data = sci_event;
default:
break;
}
}
- ec_generate_sci();
+ ec_generate_sci(s);
}
static uint64_t acpi_data_read(void *opaque, hwaddr addr, unsigned size)
@@ -112,13 +132,15 @@ static void acpi_cmd_write(void *opaque, hwaddr addr, uint64_t val,
is_cmd = true;
break;
case EC_ACPI_CMD_QUERY:
+ s->data = sci_event;
+ s->status |= EC_ACPI_OBF;
is_cmd = true;
default:
break;
}
if (is_cmd) {
s->cmd = val & 0xff;
- ec_generate_sci();
+ ec_generate_sci(s);
s->status |= EC_ACPI_SCI;
} else {
s->cmd = 0;
@@ -165,6 +187,8 @@ static int ec_dev_initfn(ISADevice *dev)
memory_region_init_io(s->io + 1, &io66_io_ops, s, "ec-acpi-cmd", 1);
isa_register_ioport(isadev, s->io + 1, 0x66);
+ ecs = s;
+
return 0;
}
diff --git a/include/hw/acpi/ec.h b/include/hw/acpi/ec.h
index 3556acd..276d62a 100644
--- a/include/hw/acpi/ec.h
+++ b/include/hw/acpi/ec.h
@@ -21,9 +21,19 @@
#define EC_ACPI_BURST_DN 0x83
#define EC_ACPI_CMD_QUERY 0x84
+/* event no. */
+#define EVENT_CPU_ONLINE 0x1
+#define EVENT_CPU_OFFLINE 0x2
+
+/* index of acpi space*/
+#define EC_ACPI_SPACE_CPUS 1
+#define EC_ACPI_SPACE_CPUN 2
+
void qemu_register_ec_sci_notifier(Notifier *notifier);
bool qemu_ec_enabled(void);
void ec_dev_init(ISABus *isabus);
void ec_acpi_event(uint8_t evt);
+void ec_acpi_space_poke(uint8_t idx, uint8_t val);
+uint8_t ec_acpi_space_peek(uint8_t idx);
#endif
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 4/8] piix4: add notifer for ec to generate sci
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
` (2 preceding siblings ...)
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 3/8] ec: add operations for _Qxx events liguang
@ 2013-06-06 3:16 ` liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 5/8] piix4: add events for cpu hotplug liguang
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:16 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
hw/acpi/piix4.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index e6525ac..aae1c88 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -29,6 +29,7 @@
#include "exec/ioport.h"
#include "hw/nvram/fw_cfg.h"
#include "exec/address-spaces.h"
+#include "hw/acpi/ec.h"
//#define DEBUG
@@ -53,6 +54,7 @@
#define PIIX4_PCI_HOTPLUG_STATUS 2
#define PIIX4_CPU_HOTPLUG_STATUS 4
+#define GPE_EC_SCI_STATUS 8
struct pci_status {
uint32_t up; /* deprecated, maintained for migration compatibility */
@@ -94,6 +96,7 @@ typedef struct PIIX4PMState {
CPUStatus gpe_cpu;
Notifier cpu_added_notifier;
+ Notifier ec_sci_notifier;
} PIIX4PMState;
static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
@@ -622,6 +625,15 @@ static const MemoryRegionOps cpu_hotplug_ops = {
},
};
+static void pm_ec_sci_req(Notifier *n, void *opaque)
+{
+ PIIX4PMState *s = container_of(n, PIIX4PMState, ec_sci_notifier);
+ ACPIGPE *gpe = &s->ar.gpe;
+
+ *gpe->sts |= GPE_EC_SCI_STATUS;
+ pm_update_sci(s);
+}
+
typedef enum {
PLUG,
UNPLUG,
@@ -686,6 +698,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
memory_region_add_subregion(parent, PIIX4_PROC_BASE, &s->io_cpu);
s->cpu_added_notifier.notify = piix4_cpu_added_req;
qemu_register_cpu_added_notifier(&s->cpu_added_notifier);
+ s->ec_sci_notifier.notify = pm_ec_sci_req;
+ qemu_register_ec_sci_notifier(&s->ec_sci_notifier);
}
static void enable_device(PIIX4PMState *s, int slot)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 5/8] piix4: add events for cpu hotplug
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
` (3 preceding siblings ...)
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 4/8] piix4: add notifer for ec to generate sci liguang
@ 2013-06-06 3:16 ` liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 6/8] qmp: add 'cpu-del' command liguang
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:16 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
hw/acpi/piix4.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index aae1c88..8c5b39a 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -657,6 +657,14 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu,
g->sts[cpu_id / 8] &= ~(1 << (cpu_id % 8));
}
pm_update_sci(s);
+
+ if (qemu_ec_enabled()) {
+ uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUS);
+
+ ec_acpi_event(EVENT_CPU_ONLINE);
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, 1 << cpu_id | cpu_sts);
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUN, cpu_id);
+ }
}
static void piix4_cpu_added_req(Notifier *n, void *opaque)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 6/8] qmp: add 'cpu-del' command
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
` (4 preceding siblings ...)
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 5/8] piix4: add events for cpu hotplug liguang
@ 2013-06-06 3:16 ` liguang
2013-06-06 3:17 ` [Qemu-devel] [PATCH RFC v2 7/8] pc: add EC qdev init for piix & q35 liguang
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:16 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
add 'cpu-del' as complementary of 'cpu-add',
cpu-del doesn't really delete a previous created
cpu for it depends on CPU-QOM which it's un-finished
yet to unrealize it.
cpu-del just records the cpu-id that guest want to
remove to keep status of ACPI cpu hot-remove process.
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
hw/i386/pc.c | 30 ++++++++++++++++++++++++++++--
hw/i386/pc_piix.c | 1 +
hw/i386/pc_q35.c | 1 +
include/hw/boards.h | 5 +++--
include/hw/i386/pc.h | 1 +
qapi-schema.json | 13 +++++++++++++
qmp-commands.hx | 23 +++++++++++++++++++++++
qmp.c | 9 +++++++++
8 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4844a6b..a239892 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -55,6 +55,7 @@
#include "hw/acpi/acpi.h"
#include "hw/cpu/icc_bus.h"
#include "hw/boards.h"
+#include "hw/acpi/ec.h"
/* debug PC/ISA interrupts */
//#define DEBUG_IRQ
@@ -926,10 +927,15 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
{
DeviceState *icc_bridge;
int64_t apic_id = x86_cpu_apic_id_from_index(id);
+ uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUS);
if (cpu_exists(apic_id)) {
- error_setg(errp, "Unable to add CPU: %" PRIi64
- ", it already exists", id);
+ if (cpu_sts & 1 << id) {
+ error_setg(errp, "Unable to add CPU: %" PRIi64
+ ", it already exists", id);
+ } else {
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, cpu_sts | 1 << id);
+ }
return;
}
@@ -939,11 +945,31 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
return;
}
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, cpu_sts | 1 << id);
icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
TYPE_ICC_BRIDGE, NULL));
pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);
}
+void pc_hot_del_cpu(const int64_t id, Error **errp)
+{
+ uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUS);
+
+ if (id >= max_cpus) {
+ error_setg(errp, "Unable to del CPU: %" PRIi64
+ ", max allowed: %d", id, max_cpus - 1);
+ return;
+ }
+
+ if (cpu_sts & 1 << id) {
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, cpu_sts & ~(1 << id));
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUN, id);
+ } else {
+ error_setg(errp, "Unable to del CPU: %" PRIi64
+ ", it was not added before.", id);
+ }
+}
+
void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
{
int i;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d618570..71ce2ff 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -333,6 +333,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = {
.desc = "Standard PC (i440FX + PIIX, 1996)",
.init = pc_init_pci,
.hot_add_cpu = pc_hot_add_cpu,
+ .hot_del_cpu = pc_hot_del_cpu,
.max_cpus = 255,
.is_default = 1,
DEFAULT_MACHINE_OPTIONS,
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 7888dfe..f171ed3 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -221,6 +221,7 @@ static QEMUMachine pc_q35_machine_v1_5 = {
.desc = "Standard PC (Q35 + ICH9, 2009)",
.init = pc_q35_init,
.hot_add_cpu = pc_hot_add_cpu,
+ .hot_del_cpu = pc_hot_del_cpu,
.max_cpus = 255,
DEFAULT_MACHINE_OPTIONS,
};
diff --git a/include/hw/boards.h b/include/hw/boards.h
index fb7c6f1..fc6368a 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -22,7 +22,7 @@ typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args);
typedef void QEMUMachineResetFunc(void);
-typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp);
+typedef void QEMUMachineHotAddDelCPUFunc(const int64_t id, Error **errp);
typedef struct QEMUMachine {
const char *name;
@@ -30,7 +30,8 @@ typedef struct QEMUMachine {
const char *desc;
QEMUMachineInitFunc *init;
QEMUMachineResetFunc *reset;
- QEMUMachineHotAddCPUFunc *hot_add_cpu;
+ QEMUMachineHotAddDelCPUFunc *hot_add_cpu;
+ QEMUMachineHotAddDelCPUFunc *hot_del_cpu;
BlockInterfaceType block_default_type;
int max_cpus;
unsigned int no_serial:1,
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 6154058..89435f3 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -82,6 +82,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge);
void pc_hot_add_cpu(const int64_t id, Error **errp);
+void pc_hot_del_cpu(const int64_t id, Error **errp);
void pc_acpi_init(const char *default_dsdt);
FWCfgState *pc_memory_init(MemoryRegion *system_memory,
const char *kernel_filename,
diff --git a/qapi-schema.json b/qapi-schema.json
index ef1f657..d11e43b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1403,6 +1403,19 @@
{ 'command': 'cpu-add', 'data': {'id': 'int'} }
##
+# @cpu-del
+#
+# Deletes CPU with specified ID
+#
+# @id: ID of CPU to be deleted, valid values [0..max_cpus)
+#
+# Returns: Nothing on success
+#
+# Since 1.6
+##
+{ 'command': 'cpu-del', 'data': {'id': 'int'} }
+
+##
# @memsave:
#
# Save a portion of guest memory to a file.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index ffd130e..c4e77b4 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -408,6 +408,29 @@ Example:
EQMP
{
+ .name = "cpu-del",
+ .args_type = "id:i",
+ .mhandler.cmd_new = qmp_marshal_input_cpu_del,
+ },
+
+SQMP
+cpu-del
+-------
+
+Deletes virtual cpu
+
+Arguments:
+
+- "id": cpu id (json-int)
+
+Example:
+
+-> { "execute": "cpu-del", "arguments": { "id": 2 } }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "memsave",
.args_type = "val:l,size:i,filename:s,cpu:i?",
.mhandler.cmd_new = qmp_marshal_input_memsave,
diff --git a/qmp.c b/qmp.c
index 4c149b3..84dc873 100644
--- a/qmp.c
+++ b/qmp.c
@@ -118,6 +118,15 @@ void qmp_cpu_add(int64_t id, Error **errp)
}
}
+void qmp_cpu_del(int64_t id, Error **errp)
+{
+ if (current_machine->hot_del_cpu) {
+ current_machine->hot_del_cpu(id, errp);
+ } else {
+ error_setg(errp, "Not supported");
+ }
+}
+
#ifndef CONFIG_VNC
/* If VNC support is enabled, the "true" query-vnc command is
defined in the VNC subsystem */
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 7/8] pc: add EC qdev init for piix & q35
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
` (5 preceding siblings ...)
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 6/8] qmp: add 'cpu-del' command liguang
@ 2013-06-06 3:17 ` liguang
2013-06-06 3:17 ` [Qemu-devel] [PATCH RFC v2 8/8] cpu-hotplug: remove memory regison for cpu hotplug liguang
2013-06-06 8:13 ` [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC Michael S. Tsirkin
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:17 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
hw/i386/pc_piix.c | 6 ++++++
hw/i386/pc_q35.c | 5 +++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 71ce2ff..378c980 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -46,6 +46,8 @@
#include "exec/address-spaces.h"
#include "hw/acpi/acpi.h"
#include "cpu.h"
+#include "hw/acpi/ec.h"
+
#ifdef CONFIG_XEN
# include <xen/hvm/hvm_info_table.h>
#endif
@@ -229,6 +231,10 @@ static void pc_init1(MemoryRegion *system_memory,
if (has_pvpanic) {
pvpanic_init(isa_bus);
}
+
+ if (qemu_ec_enabled()) {
+ ec_dev_init(isa_bus);
+ }
}
static void pc_init_pci(QEMUMachineInitArgs *args)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index f171ed3..9c2d3b1 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -42,6 +42,7 @@
#include "hw/ide/ahci.h"
#include "hw/usb.h"
#include "hw/cpu/icc_bus.h"
+#include "hw/acpi/ec.h"
/* ICH9 AHCI has 6 ports */
#define MAX_SATA_PORTS 6
@@ -206,6 +207,10 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
if (has_pvpanic) {
pvpanic_init(isa_bus);
}
+
+ if (qemu_ec_enabled()) {
+ ec_dev_init(isa_bus);
+ }
}
static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH RFC v2 8/8] cpu-hotplug: remove memory regison for cpu hotplug
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
` (6 preceding siblings ...)
2013-06-06 3:17 ` [Qemu-devel] [PATCH RFC v2 7/8] pc: add EC qdev init for piix & q35 liguang
@ 2013-06-06 3:17 ` liguang
2013-06-06 8:13 ` [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC Michael S. Tsirkin
8 siblings, 0 replies; 16+ messages in thread
From: liguang @ 2013-06-06 3:17 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, qemu-devel, Christian Borntraeger,
Markus Armbruster, Joel Schopp, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
operations of memory regison(PIIX4_PROC_BASE) for cpu hostplug
can be transfered to EC space naturally by adding EC support.
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
hw/acpi/piix4.c | 46 ++++++++++------------------------------------
hw/i386/pc.c | 16 ++++++++--------
include/hw/acpi/ec.h | 5 +++--
3 files changed, 21 insertions(+), 46 deletions(-)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 8c5b39a..44928e3 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -600,31 +600,6 @@ static const MemoryRegionOps piix4_pci_ops = {
},
};
-static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size)
-{
- PIIX4PMState *s = opaque;
- CPUStatus *cpus = &s->gpe_cpu;
- uint64_t val = cpus->sts[addr];
-
- return val;
-}
-
-static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data,
- unsigned int size)
-{
- /* TODO: implement VCPU removal on guest signal that CPU can be removed */
-}
-
-static const MemoryRegionOps cpu_hotplug_ops = {
- .read = cpu_status_read,
- .write = cpu_status_write,
- .endianness = DEVICE_LITTLE_ENDIAN,
- .valid = {
- .min_access_size = 1,
- .max_access_size = 1,
- },
-};
-
static void pm_ec_sci_req(Notifier *n, void *opaque)
{
PIIX4PMState *s = container_of(n, PIIX4PMState, ec_sci_notifier);
@@ -653,18 +628,20 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu,
cpu_id = k->get_arch_id(CPU(cpu));
if (action == PLUG) {
g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUM + cpu_id/8, 1 << (cpu_id%8));
+ if (qemu_ec_enabled()) {
+ ec_acpi_event(EVENT_CPU_ONLINE);
+ }
} else {
g->sts[cpu_id / 8] &= ~(1 << (cpu_id % 8));
+ if (qemu_ec_enabled()) {
+ uint8_t tmp;
+ tmp = ec_acpi_space_peek(EC_ACPI_SPACE_CPUM + cpu_id/8);
+ tmp &= ~(1 << (cpu_id%8));
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUM + cpu_id/8, tmp);
+ }
}
pm_update_sci(s);
-
- if (qemu_ec_enabled()) {
- uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUS);
-
- ec_acpi_event(EVENT_CPU_ONLINE);
- ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, 1 << cpu_id | cpu_sts);
- ec_acpi_space_poke(EC_ACPI_SPACE_CPUN, cpu_id);
- }
}
static void piix4_cpu_added_req(Notifier *n, void *opaque)
@@ -701,9 +678,6 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
pci_bus_hotplug(bus, piix4_device_hotplug, &s->dev.qdev);
qemu_for_each_cpu(piix4_init_cpu_status, &s->gpe_cpu);
- memory_region_init_io(&s->io_cpu, &cpu_hotplug_ops, s, "apci-cpu-hotplug",
- PIIX4_PROC_LEN);
- memory_region_add_subregion(parent, PIIX4_PROC_BASE, &s->io_cpu);
s->cpu_added_notifier.notify = piix4_cpu_added_req;
qemu_register_cpu_added_notifier(&s->cpu_added_notifier);
s->ec_sci_notifier.notify = pm_ec_sci_req;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index a239892..8e98705 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -927,14 +927,14 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
{
DeviceState *icc_bridge;
int64_t apic_id = x86_cpu_apic_id_from_index(id);
- uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUS);
+ uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUM + apic_id/8);
if (cpu_exists(apic_id)) {
- if (cpu_sts & 1 << id) {
+ if (cpu_sts & 1 << id%8) {
error_setg(errp, "Unable to add CPU: %" PRIi64
", it already exists", id);
} else {
- ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, cpu_sts | 1 << id);
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUM, cpu_sts | 1 << id%8);
}
return;
}
@@ -945,7 +945,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
return;
}
- ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, cpu_sts | 1 << id);
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUM, cpu_sts | 1 << id%8);
icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
TYPE_ICC_BRIDGE, NULL));
pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);
@@ -953,7 +953,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
void pc_hot_del_cpu(const int64_t id, Error **errp)
{
- uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUS);
+ uint8_t cpu_sts = ec_acpi_space_peek(EC_ACPI_SPACE_CPUM + id/8);
if (id >= max_cpus) {
error_setg(errp, "Unable to del CPU: %" PRIi64
@@ -961,9 +961,9 @@ void pc_hot_del_cpu(const int64_t id, Error **errp)
return;
}
- if (cpu_sts & 1 << id) {
- ec_acpi_space_poke(EC_ACPI_SPACE_CPUS, cpu_sts & ~(1 << id));
- ec_acpi_space_poke(EC_ACPI_SPACE_CPUN, id);
+ if (cpu_sts & 1 << id/8) {
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUM, cpu_sts & ~(1 << id%8));
+ ec_acpi_space_poke(EC_ACPI_SPACE_CPUI, id);
} else {
error_setg(errp, "Unable to del CPU: %" PRIi64
", it was not added before.", id);
diff --git a/include/hw/acpi/ec.h b/include/hw/acpi/ec.h
index 276d62a..8109e04 100644
--- a/include/hw/acpi/ec.h
+++ b/include/hw/acpi/ec.h
@@ -26,8 +26,9 @@
#define EVENT_CPU_OFFLINE 0x2
/* index of acpi space*/
-#define EC_ACPI_SPACE_CPUS 1
-#define EC_ACPI_SPACE_CPUN 2
+#define EC_ACPI_SPACE_CCMD 2
+#define EC_ACPI_SPACE_CPUI 3
+#define EC_ACPI_SPACE_CPUM 4
void qemu_register_ec_sci_notifier(Notifier *notifier);
bool qemu_ec_enabled(void);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
` (7 preceding siblings ...)
2013-06-06 3:17 ` [Qemu-devel] [PATCH RFC v2 8/8] cpu-hotplug: remove memory regison for cpu hotplug liguang
@ 2013-06-06 8:13 ` Michael S. Tsirkin
2013-06-06 8:33 ` li guang
2013-06-06 8:48 ` Igor Mammedov
8 siblings, 2 replies; 16+ messages in thread
From: Michael S. Tsirkin @ 2013-06-06 8:13 UTC (permalink / raw)
To: liguang
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
qemu-devel, Christian Borntraeger, Markus Armbruster, Joel Schopp,
Gerd Hoffmann, Paolo Bonzini, Igor Mammedov, Luiz Capitulino,
Laszlo Ersek, Andreas Färber, Isaku Yamahata
On Thu, Jun 06, 2013 at 11:16:53AM +0800, liguang wrote:
> v2:
> 1.remove PIIX4_PROC_BASE operations for cpu hotplug
> 2.fix wrong description fo cpu-del
>
> patch 1 adds ACPI Embedded Controller (EC),
> refer-to:
> ACPI SPEC v5 chapter 12
> "ACPI Embedded Controller Interface Specification"
>
> EC is a standard ACPI device, it plays flexible roles,
> especially be event carrier, it can pass events between platform
> and OS, so OS can execute _Qxx method which defined
> by yourself and query EC's ACPI space which can be a buffer for
> many purposes
>
> here, I want to deliver CPU online/offline event between
> OS and QEMU for CPU hotplug feature, then we will don't
> need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
> again after 'cpu-add' and also for offline to do real cpu
> removal.
So, it's another channel to the guest.
Can't qemu-ga do this in userspace, using the existing channel?
> what I am trying to do is emulated physical addition/removal
> (like described by linux kernel document for cpu hotplug --
> linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
>
> these RFC patches are sent for demo what I am trying to do.
>
> the design process simply like following:
>
> hotplug
> qemu::ec::sci -> kernel::ec::gpe::notifier->
> kernel::cpu_physic_hotplug::handler->kernel::cpu_up
>
> unplug
> kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
> kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
>
> sorry, I should poll cpu-unplug cmd sent from kernel,
> but, it's a little trivial, I want do it later.
>
> for kernel patches:
> http://comments.gmane.org/gmane.linux.kernel/1503460
>
>
> Li Guang (8)
> acpi: add ACPI Embedded Controller support
> ich9: add notifer for ec to generate sci
> ec: add operations for _Qxx events
> piix4: add notifer for ec to generate sci
> piix4: add events for cpu hotplug
> qmp: add 'cpu-del' command
> pc: add EC qdev init for piix & q35
> cpu-hotplug: remove memory regison for cpu hotplug
>
> default-configs/x86_64-softmmu.mak | 1 +
> hw/acpi/Makefile.objs | 1 +
> hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
> hw/acpi/ich9.c | 15 +++++++++++++++
> hw/acpi/piix4.c | 68 ++++++++++++++
> hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
> hw/i386/pc_piix.c | 7 +
> hw/i386/pc_q35.c | 6 +
> include/hw/acpi/ec.h | 44 ++++++
> include/hw/acpi/ich9.h | 1 +
> include/hw/boards.h | 5 +++--
> include/hw/i386/pc.h | 1 +
> qapi-schema.json | 13 +++++++++++++
> qmp-commands.hx | 23 +++++++++++++++++++++++
> qmp.c | 9 +++++++++
> 15 files changed, 411 insertions(+), 54 deletions(-)
> create mode 100644 hw/acpi/ec.c
> create mode 100644 include/hw/acpi/ec.h
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
2013-06-06 8:13 ` [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC Michael S. Tsirkin
@ 2013-06-06 8:33 ` li guang
2013-06-18 2:47 ` li guang
2013-06-06 8:48 ` Igor Mammedov
1 sibling, 1 reply; 16+ messages in thread
From: li guang @ 2013-06-06 8:33 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
qemu-devel, Christian Borntraeger, Markus Armbruster, Joel Schopp,
Gerd Hoffmann, Paolo Bonzini, Igor Mammedov, Luiz Capitulino,
Laszlo Ersek, Andreas Färber, Isaku Yamahata
在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
> On Thu, Jun 06, 2013 at 11:16:53AM +0800, liguang wrote:
> > v2:
> > 1.remove PIIX4_PROC_BASE operations for cpu hotplug
> > 2.fix wrong description fo cpu-del
> >
> > patch 1 adds ACPI Embedded Controller (EC),
> > refer-to:
> > ACPI SPEC v5 chapter 12
> > "ACPI Embedded Controller Interface Specification"
> >
> > EC is a standard ACPI device, it plays flexible roles,
> > especially be event carrier, it can pass events between platform
> > and OS, so OS can execute _Qxx method which defined
> > by yourself and query EC's ACPI space which can be a buffer for
> > many purposes
> >
> > here, I want to deliver CPU online/offline event between
> > OS and QEMU for CPU hotplug feature, then we will don't
> > need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
> > again after 'cpu-add' and also for offline to do real cpu
> > removal.
>
> So, it's another channel to the guest.
> Can't qemu-ga do this in userspace, using the existing channel?
Sorry, I'm not familiar with qemu-ga,
anyway, maybe we don't want to do things like
'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")'
in userspace.
BTW, Michael,
do you think if we use EC space to pass info between
platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and
something like it can bring some convenience?
for we can directly operate on EC space, we don't have to
register memory regions and ops for them any more, and also,
these regions are mostly not exist in real platforms,
this a motivation that I add this device.
>
> > what I am trying to do is emulated physical addition/removal
> > (like described by linux kernel document for cpu hotplug --
> > linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
> >
> > these RFC patches are sent for demo what I am trying to do.
> >
> > the design process simply like following:
> >
> > hotplug
> > qemu::ec::sci -> kernel::ec::gpe::notifier->
> > kernel::cpu_physic_hotplug::handler->kernel::cpu_up
> >
> > unplug
> > kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
> > kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
> >
> > sorry, I should poll cpu-unplug cmd sent from kernel,
> > but, it's a little trivial, I want do it later.
> >
> > for kernel patches:
> > http://comments.gmane.org/gmane.linux.kernel/1503460
> >
> >
> > Li Guang (8)
> > acpi: add ACPI Embedded Controller support
> > ich9: add notifer for ec to generate sci
> > ec: add operations for _Qxx events
> > piix4: add notifer for ec to generate sci
> > piix4: add events for cpu hotplug
> > qmp: add 'cpu-del' command
> > pc: add EC qdev init for piix & q35
> > cpu-hotplug: remove memory regison for cpu hotplug
> >
> > default-configs/x86_64-softmmu.mak | 1 +
> > hw/acpi/Makefile.objs | 1 +
> > hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
> > hw/acpi/ich9.c | 15 +++++++++++++++
> > hw/acpi/piix4.c | 68 ++++++++++++++
> > hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
> > hw/i386/pc_piix.c | 7 +
> > hw/i386/pc_q35.c | 6 +
> > include/hw/acpi/ec.h | 44 ++++++
> > include/hw/acpi/ich9.h | 1 +
> > include/hw/boards.h | 5 +++--
> > include/hw/i386/pc.h | 1 +
> > qapi-schema.json | 13 +++++++++++++
> > qmp-commands.hx | 23 +++++++++++++++++++++++
> > qmp.c | 9 +++++++++
> > 15 files changed, 411 insertions(+), 54 deletions(-)
> > create mode 100644 hw/acpi/ec.c
> > create mode 100644 include/hw/acpi/ec.h
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
2013-06-06 8:13 ` [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC Michael S. Tsirkin
2013-06-06 8:33 ` li guang
@ 2013-06-06 8:48 ` Igor Mammedov
2013-06-06 8:58 ` li guang
1 sibling, 1 reply; 16+ messages in thread
From: Igor Mammedov @ 2013-06-06 8:48 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kevin Wolf, Anthony Liguori, Stefan Berger, Joel Schopp,
Markus Armbruster, qemu-devel, Alexander Graf,
Christian Borntraeger, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber, liguang,
Isaku Yamahata
On Thu, 6 Jun 2013 11:13:29 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Thu, Jun 06, 2013 at 11:16:53AM +0800, liguang wrote:
> > v2:
> > 1.remove PIIX4_PROC_BASE operations for cpu hotplug
> > 2.fix wrong description fo cpu-del
> >
> > patch 1 adds ACPI Embedded Controller (EC),
> > refer-to:
> > ACPI SPEC v5 chapter 12
> > "ACPI Embedded Controller Interface Specification"
> >
> > EC is a standard ACPI device, it plays flexible roles,
> > especially be event carrier, it can pass events between platform
> > and OS, so OS can execute _Qxx method which defined
> > by yourself and query EC's ACPI space which can be a buffer for
> > many purposes
> >
> > here, I want to deliver CPU online/offline event between
> > OS and QEMU for CPU hotplug feature, then we will don't
> > need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
> > again after 'cpu-add' and also for offline to do real cpu
> > removal.
>
> So, it's another channel to the guest.
> Can't qemu-ga do this in userspace, using the existing channel?
I believe it does.
Trying to handle 1 guest OS specific concept by introducing
extra hardware and a new new linux driver to just online CPUs,
doesn't look righ.
Guest already gets a cpu hot-add notification and acts on it
by creating sysfs entry that can be used for onlining it. So
guest knows that CPU has been hotplugged and even notifies
userspace via UDEV about event. So why extra channel is needed
for event that was already delivered and handled.
One can use UDEV to perform automatic online task or qemu-ga
to make process less straightforward, or alternatively extend
the current ACPI CPU hotplug in kernel to support automatic
CPU onlining.
>
> > what I am trying to do is emulated physical addition/removal
> > (like described by linux kernel document for cpu hotplug --
> > linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
> >
> > these RFC patches are sent for demo what I am trying to do.
> >
> > the design process simply like following:
> >
> > hotplug
> > qemu::ec::sci -> kernel::ec::gpe::notifier->
> > kernel::cpu_physic_hotplug::handler->kernel::cpu_up
> >
> > unplug
> > kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
> > kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
> >
> > sorry, I should poll cpu-unplug cmd sent from kernel,
> > but, it's a little trivial, I want do it later.
> >
> > for kernel patches:
> > http://comments.gmane.org/gmane.linux.kernel/1503460
> >
> >
> > Li Guang (8)
> > acpi: add ACPI Embedded Controller support
> > ich9: add notifer for ec to generate sci
> > ec: add operations for _Qxx events
> > piix4: add notifer for ec to generate sci
> > piix4: add events for cpu hotplug
> > qmp: add 'cpu-del' command
> > pc: add EC qdev init for piix & q35
> > cpu-hotplug: remove memory regison for cpu hotplug
> >
> > default-configs/x86_64-softmmu.mak | 1 +
> > hw/acpi/Makefile.objs | 1 +
> > hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
> > hw/acpi/ich9.c | 15 +++++++++++++++
> > hw/acpi/piix4.c | 68 ++++++++++++++
> > hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
> > hw/i386/pc_piix.c | 7 +
> > hw/i386/pc_q35.c | 6 +
> > include/hw/acpi/ec.h | 44 ++++++
> > include/hw/acpi/ich9.h | 1 +
> > include/hw/boards.h | 5 +++--
> > include/hw/i386/pc.h | 1 +
> > qapi-schema.json | 13 +++++++++++++
> > qmp-commands.hx | 23 +++++++++++++++++++++++
> > qmp.c | 9 +++++++++
> > 15 files changed, 411 insertions(+), 54 deletions(-)
> > create mode 100644 hw/acpi/ec.c
> > create mode 100644 include/hw/acpi/ec.h
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
2013-06-06 8:48 ` Igor Mammedov
@ 2013-06-06 8:58 ` li guang
0 siblings, 0 replies; 16+ messages in thread
From: li guang @ 2013-06-06 8:58 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Anthony Liguori, Stefan Berger, Joel Schopp,
Markus Armbruster, Michael S. Tsirkin, qemu-devel, Alexander Graf,
Christian Borntraeger, Gerd Hoffmann, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Andreas Färber,
Isaku Yamahata
在 2013-06-06四的 10:48 +0200,Igor Mammedov写道:
> On Thu, 6 Jun 2013 11:13:29 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Thu, Jun 06, 2013 at 11:16:53AM +0800, liguang wrote:
> > > v2:
> > > 1.remove PIIX4_PROC_BASE operations for cpu hotplug
> > > 2.fix wrong description fo cpu-del
> > >
> > > patch 1 adds ACPI Embedded Controller (EC),
> > > refer-to:
> > > ACPI SPEC v5 chapter 12
> > > "ACPI Embedded Controller Interface Specification"
> > >
> > > EC is a standard ACPI device, it plays flexible roles,
> > > especially be event carrier, it can pass events between platform
> > > and OS, so OS can execute _Qxx method which defined
> > > by yourself and query EC's ACPI space which can be a buffer for
> > > many purposes
> > >
> > > here, I want to deliver CPU online/offline event between
> > > OS and QEMU for CPU hotplug feature, then we will don't
> > > need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
> > > again after 'cpu-add' and also for offline to do real cpu
> > > removal.
> >
> > So, it's another channel to the guest.
> > Can't qemu-ga do this in userspace, using the existing channel?
> I believe it does.
> Trying to handle 1 guest OS specific concept by introducing
> extra hardware and a new new linux driver to just online CPUs,
> doesn't look righ.
> Guest already gets a cpu hot-add notification and acts on it
> by creating sysfs entry that can be used for onlining it. So
> guest knows that CPU has been hotplugged and even notifies
> userspace via UDEV about event. So why extra channel is needed
> for event that was already delivered and handled.
actually, there's a case in my hand to do cpu online automatically
by udev, it works well.
I still can't figure out why kernel did not do cpu online directly
just like the cpu ejection.
I don't have strong opinion to do cpu online in kernel space,
but I think do it in user-space either by hand or script or
program just not natural, that it to say, obviously cpu online
is part of cpu hotplug conceptually, we'd better do the these
actions together, but separate them.
>
> One can use UDEV to perform automatic online task or qemu-ga
> to make process less straightforward, or alternatively extend
> the current ACPI CPU hotplug in kernel to support automatic
> CPU onlining.
>
>
> >
> > > what I am trying to do is emulated physical addition/removal
> > > (like described by linux kernel document for cpu hotplug --
> > > linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
> > >
> > > these RFC patches are sent for demo what I am trying to do.
> > >
> > > the design process simply like following:
> > >
> > > hotplug
> > > qemu::ec::sci -> kernel::ec::gpe::notifier->
> > > kernel::cpu_physic_hotplug::handler->kernel::cpu_up
> > >
> > > unplug
> > > kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
> > > kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
> > >
> > > sorry, I should poll cpu-unplug cmd sent from kernel,
> > > but, it's a little trivial, I want do it later.
> > >
> > > for kernel patches:
> > > http://comments.gmane.org/gmane.linux.kernel/1503460
> > >
> > >
> > > Li Guang (8)
> > > acpi: add ACPI Embedded Controller support
> > > ich9: add notifer for ec to generate sci
> > > ec: add operations for _Qxx events
> > > piix4: add notifer for ec to generate sci
> > > piix4: add events for cpu hotplug
> > > qmp: add 'cpu-del' command
> > > pc: add EC qdev init for piix & q35
> > > cpu-hotplug: remove memory regison for cpu hotplug
> > >
> > > default-configs/x86_64-softmmu.mak | 1 +
> > > hw/acpi/Makefile.objs | 1 +
> > > hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
> > > hw/acpi/ich9.c | 15 +++++++++++++++
> > > hw/acpi/piix4.c | 68 ++++++++++++++
> > > hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
> > > hw/i386/pc_piix.c | 7 +
> > > hw/i386/pc_q35.c | 6 +
> > > include/hw/acpi/ec.h | 44 ++++++
> > > include/hw/acpi/ich9.h | 1 +
> > > include/hw/boards.h | 5 +++--
> > > include/hw/i386/pc.h | 1 +
> > > qapi-schema.json | 13 +++++++++++++
> > > qmp-commands.hx | 23 +++++++++++++++++++++++
> > > qmp.c | 9 +++++++++
> > > 15 files changed, 411 insertions(+), 54 deletions(-)
> > > create mode 100644 hw/acpi/ec.c
> > > create mode 100644 include/hw/acpi/ec.h
> >
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
2013-06-06 8:33 ` li guang
@ 2013-06-18 2:47 ` li guang
2013-06-18 9:14 ` Igor Mammedov
0 siblings, 1 reply; 16+ messages in thread
From: li guang @ 2013-06-18 2:47 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kevin Wolf, Anthony Liguori, Stefan Berger, Joel Schopp,
Markus Armbruster, qemu-devel, Alexander Graf,
Christian Borntraeger, Gerd Hoffmann, Igor Mammedov,
Paolo Bonzini, Luiz Capitulino, Laszlo Ersek, Andreas Färber,
Isaku Yamahata
Hi, Igor and Micheal
在 2013-06-06四的 16:33 +0800,li guang写道:
> 在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
> > On Thu, Jun 06, 2013 at 11:16:53AM +0800, liguang wrote:
> > > v2:
> > > 1.remove PIIX4_PROC_BASE operations for cpu hotplug
> > > 2.fix wrong description fo cpu-del
> > >
> > > patch 1 adds ACPI Embedded Controller (EC),
> > > refer-to:
> > > ACPI SPEC v5 chapter 12
> > > "ACPI Embedded Controller Interface Specification"
> > >
> > > EC is a standard ACPI device, it plays flexible roles,
> > > especially be event carrier, it can pass events between platform
> > > and OS, so OS can execute _Qxx method which defined
> > > by yourself and query EC's ACPI space which can be a buffer for
> > > many purposes
> > >
> > > here, I want to deliver CPU online/offline event between
> > > OS and QEMU for CPU hotplug feature, then we will don't
> > > need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
> > > again after 'cpu-add' and also for offline to do real cpu
> > > removal.
> >
> > So, it's another channel to the guest.
> > Can't qemu-ga do this in userspace, using the existing channel?
>
> Sorry, I'm not familiar with qemu-ga,
> anyway, maybe we don't want to do things like
> 'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")'
> in userspace.
>
> BTW, Michael,
> do you think if we use EC space to pass info between
> platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and
> something like it can bring some convenience?
> for we can directly operate on EC space, we don't have to
> register memory regions and ops for them any more, and also,
> these regions are mostly not exist in real platforms,
> this a motivation that I add this device.
>
does this approach have some benefit?
> >
> > > what I am trying to do is emulated physical addition/removal
> > > (like described by linux kernel document for cpu hotplug --
> > > linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
> > >
> > > these RFC patches are sent for demo what I am trying to do.
> > >
> > > the design process simply like following:
> > >
> > > hotplug
> > > qemu::ec::sci -> kernel::ec::gpe::notifier->
> > > kernel::cpu_physic_hotplug::handler->kernel::cpu_up
> > >
> > > unplug
> > > kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
> > > kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
> > >
> > > sorry, I should poll cpu-unplug cmd sent from kernel,
> > > but, it's a little trivial, I want do it later.
> > >
> > > for kernel patches:
> > > http://comments.gmane.org/gmane.linux.kernel/1503460
> > >
> > >
> > > Li Guang (8)
> > > acpi: add ACPI Embedded Controller support
> > > ich9: add notifer for ec to generate sci
> > > ec: add operations for _Qxx events
> > > piix4: add notifer for ec to generate sci
> > > piix4: add events for cpu hotplug
> > > qmp: add 'cpu-del' command
> > > pc: add EC qdev init for piix & q35
> > > cpu-hotplug: remove memory regison for cpu hotplug
> > >
> > > default-configs/x86_64-softmmu.mak | 1 +
> > > hw/acpi/Makefile.objs | 1 +
> > > hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
> > > hw/acpi/ich9.c | 15 +++++++++++++++
> > > hw/acpi/piix4.c | 68 ++++++++++++++
> > > hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
> > > hw/i386/pc_piix.c | 7 +
> > > hw/i386/pc_q35.c | 6 +
> > > include/hw/acpi/ec.h | 44 ++++++
> > > include/hw/acpi/ich9.h | 1 +
> > > include/hw/boards.h | 5 +++--
> > > include/hw/i386/pc.h | 1 +
> > > qapi-schema.json | 13 +++++++++++++
> > > qmp-commands.hx | 23 +++++++++++++++++++++++
> > > qmp.c | 9 +++++++++
> > > 15 files changed, 411 insertions(+), 54 deletions(-)
> > > create mode 100644 hw/acpi/ec.c
> > > create mode 100644 include/hw/acpi/ec.h
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
2013-06-18 2:47 ` li guang
@ 2013-06-18 9:14 ` Igor Mammedov
2013-06-19 0:39 ` li guang
0 siblings, 1 reply; 16+ messages in thread
From: Igor Mammedov @ 2013-06-18 9:14 UTC (permalink / raw)
To: li guang
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, Markus Armbruster, qemu-devel, Joel Schopp,
Gerd Hoffmann, Andreas Färber, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Christian Borntraeger,
Isaku Yamahata
On Tue, 18 Jun 2013 10:47:15 +0800
li guang <lig.fnst@cn.fujitsu.com> wrote:
> Hi, Igor and Micheal
>
> 在 2013-06-06四的 16:33 +0800,li guang写道:
> > 在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
> > > On Thu, Jun 06, 2013 at 11:16:53AM +0800, liguang wrote:
> > > > v2:
> > > > 1.remove PIIX4_PROC_BASE operations for cpu hotplug
> > > > 2.fix wrong description fo cpu-del
> > > >
> > > > patch 1 adds ACPI Embedded Controller (EC),
> > > > refer-to:
> > > > ACPI SPEC v5 chapter 12
> > > > "ACPI Embedded Controller Interface Specification"
> > > >
> > > > EC is a standard ACPI device, it plays flexible roles,
> > > > especially be event carrier, it can pass events between platform
> > > > and OS, so OS can execute _Qxx method which defined
> > > > by yourself and query EC's ACPI space which can be a buffer for
> > > > many purposes
> > > >
> > > > here, I want to deliver CPU online/offline event between
> > > > OS and QEMU for CPU hotplug feature, then we will don't
> > > > need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
> > > > again after 'cpu-add' and also for offline to do real cpu
> > > > removal.
> > >
> > > So, it's another channel to the guest.
> > > Can't qemu-ga do this in userspace, using the existing channel?
> >
> > Sorry, I'm not familiar with qemu-ga,
> > anyway, maybe we don't want to do things like
> > 'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")'
> > in userspace.
> >
> > BTW, Michael,
> > do you think if we use EC space to pass info between
> > platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and
> > something like it can bring some convenience?
> > for we can directly operate on EC space, we don't have to
> > register memory regions and ops for them any more, and also,
> > these regions are mostly not exist in real platforms,
> > this a motivation that I add this device.
> >
>
> does this approach have some benefit?
Replacing CPUs bitmap with a select window as it's done in this series
could be done in PIIX4 in similar manner and would be much simpler
than introducing whole new device. That however would require introducing
locking in bios's ACPI code to avoid concurrent handler execution which
is not needed in case of bitmap.
>
> > >
> > > > what I am trying to do is emulated physical addition/removal
> > > > (like described by linux kernel document for cpu hotplug --
> > > > linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
> > > >
> > > > these RFC patches are sent for demo what I am trying to do.
> > > >
> > > > the design process simply like following:
> > > >
> > > > hotplug
> > > > qemu::ec::sci -> kernel::ec::gpe::notifier->
> > > > kernel::cpu_physic_hotplug::handler->kernel::cpu_up
> > > >
> > > > unplug
> > > > kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
> > > > kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
> > > >
> > > > sorry, I should poll cpu-unplug cmd sent from kernel,
> > > > but, it's a little trivial, I want do it later.
> > > >
> > > > for kernel patches:
> > > > http://comments.gmane.org/gmane.linux.kernel/1503460
> > > >
> > > >
> > > > Li Guang (8)
> > > > acpi: add ACPI Embedded Controller support
> > > > ich9: add notifer for ec to generate sci
> > > > ec: add operations for _Qxx events
> > > > piix4: add notifer for ec to generate sci
> > > > piix4: add events for cpu hotplug
> > > > qmp: add 'cpu-del' command
> > > > pc: add EC qdev init for piix & q35
> > > > cpu-hotplug: remove memory regison for cpu hotplug
> > > >
> > > > default-configs/x86_64-softmmu.mak | 1 +
> > > > hw/acpi/Makefile.objs | 1 +
> > > > hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
> > > > hw/acpi/ich9.c | 15 +++++++++++++++
> > > > hw/acpi/piix4.c | 68 ++++++++++++++
> > > > hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
> > > > hw/i386/pc_piix.c | 7 +
> > > > hw/i386/pc_q35.c | 6 +
> > > > include/hw/acpi/ec.h | 44 ++++++
> > > > include/hw/acpi/ich9.h | 1 +
> > > > include/hw/boards.h | 5 +++--
> > > > include/hw/i386/pc.h | 1 +
> > > > qapi-schema.json | 13 +++++++++++++
> > > > qmp-commands.hx | 23 +++++++++++++++++++++++
> > > > qmp.c | 9 +++++++++
> > > > 15 files changed, 411 insertions(+), 54 deletions(-)
> > > > create mode 100644 hw/acpi/ec.c
> > > > create mode 100644 include/hw/acpi/ec.h
> >
> >
> >
>
>
>
--
Regards,
Igor
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC
2013-06-18 9:14 ` Igor Mammedov
@ 2013-06-19 0:39 ` li guang
0 siblings, 0 replies; 16+ messages in thread
From: li guang @ 2013-06-19 0:39 UTC (permalink / raw)
To: Igor Mammedov
Cc: Kevin Wolf, Alexander Graf, Anthony Liguori, Stefan Berger,
Michael S. Tsirkin, Markus Armbruster, qemu-devel, Joel Schopp,
Gerd Hoffmann, Andreas Färber, Paolo Bonzini,
Luiz Capitulino, Laszlo Ersek, Christian Borntraeger,
Isaku Yamahata
在 2013-06-18二的 11:14 +0200,Igor Mammedov写道:
> On Tue, 18 Jun 2013 10:47:15 +0800
> li guang <lig.fnst@cn.fujitsu.com> wrote:
>
> > Hi, Igor and Micheal
> >
> > 在 2013-06-06四的 16:33 +0800,li guang写道:
> > > 在 2013-06-06四的 11:13 +0300,Michael S. Tsirkin写道:
> > > > On Thu, Jun 06, 2013 at 11:16:53AM +0800, liguang wrote:
> > > > > v2:
> > > > > 1.remove PIIX4_PROC_BASE operations for cpu hotplug
> > > > > 2.fix wrong description fo cpu-del
> > > > >
> > > > > patch 1 adds ACPI Embedded Controller (EC),
> > > > > refer-to:
> > > > > ACPI SPEC v5 chapter 12
> > > > > "ACPI Embedded Controller Interface Specification"
> > > > >
> > > > > EC is a standard ACPI device, it plays flexible roles,
> > > > > especially be event carrier, it can pass events between platform
> > > > > and OS, so OS can execute _Qxx method which defined
> > > > > by yourself and query EC's ACPI space which can be a buffer for
> > > > > many purposes
> > > > >
> > > > > here, I want to deliver CPU online/offline event between
> > > > > OS and QEMU for CPU hotplug feature, then we will don't
> > > > > need to "echo 1 > /sys/devices/system/cpu/cpu1/online"
> > > > > again after 'cpu-add' and also for offline to do real cpu
> > > > > removal.
> > > >
> > > > So, it's another channel to the guest.
> > > > Can't qemu-ga do this in userspace, using the existing channel?
> > >
> > > Sorry, I'm not familiar with qemu-ga,
> > > anyway, maybe we don't want to do things like
> > > 'exec("echo 1 > /sys/devices/system/cpu/cpu1/online")'
> > > in userspace.
> > >
> > > BTW, Michael,
> > > do you think if we use EC space to pass info between
> > > platform(QEMU) and OS(PM) instead of 'PIIX4_PROC_BASE' and
> > > something like it can bring some convenience?
> > > for we can directly operate on EC space, we don't have to
> > > register memory regions and ops for them any more, and also,
> > > these regions are mostly not exist in real platforms,
> > > this a motivation that I add this device.
> > >
> >
> > does this approach have some benefit?
>
> Replacing CPUs bitmap with a select window as it's done in this series
> could be done in PIIX4 in similar manner and would be much simpler
> than introducing whole new device.
Cool! but I can't figure out the way to do that now,
could you tell me a little details about this manner?
and also, as I stated before, this device is not only can be used
in our cpu hotplug case, it can also be used in many other cases
like pvpanic, by it, we can do pvpanic like things without introducing
pvpanic like devices, isn't it an important advantage?
> That however would require introducing
> locking in bios's ACPI code to avoid concurrent handler execution which
> is not needed in case of bitmap.
>
Sorry, did not consider the lock, but for real platform, we also
didn't do lock for this operation, so why it's required here?
> >
> > > >
> > > > > what I am trying to do is emulated physical addition/removal
> > > > > (like described by linux kernel document for cpu hotplug --
> > > > > linux-2.6/Documentation/cpu-hotplug.txt) for QEMU.
> > > > >
> > > > > these RFC patches are sent for demo what I am trying to do.
> > > > >
> > > > > the design process simply like following:
> > > > >
> > > > > hotplug
> > > > > qemu::ec::sci -> kernel::ec::gpe::notifier->
> > > > > kernel::cpu_physic_hotplug::handler->kernel::cpu_up
> > > > >
> > > > > unplug
> > > > > kernel::cpu_down::kernel::cpu_physic_hotplug::handler->
> > > > > kernel::ec::ec_write->qemu::ec::->qemu::cpu-unplug
> > > > >
> > > > > sorry, I should poll cpu-unplug cmd sent from kernel,
> > > > > but, it's a little trivial, I want do it later.
> > > > >
> > > > > for kernel patches:
> > > > > http://comments.gmane.org/gmane.linux.kernel/1503460
> > > > >
> > > > >
> > > > > Li Guang (8)
> > > > > acpi: add ACPI Embedded Controller support
> > > > > ich9: add notifer for ec to generate sci
> > > > > ec: add operations for _Qxx events
> > > > > piix4: add notifer for ec to generate sci
> > > > > piix4: add events for cpu hotplug
> > > > > qmp: add 'cpu-del' command
> > > > > pc: add EC qdev init for piix & q35
> > > > > cpu-hotplug: remove memory regison for cpu hotplug
> > > > >
> > > > > default-configs/x86_64-softmmu.mak | 1 +
> > > > > hw/acpi/Makefile.objs | 1 +
> > > > > hw/acpi/ec.c | 225 ++++++++++++++++++++++++++++++++++++
> > > > > hw/acpi/ich9.c | 15 +++++++++++++++
> > > > > hw/acpi/piix4.c | 68 ++++++++++++++
> > > > > hw/i386/pc.c | 46 ++++++++++++++++++++++++++++--
> > > > > hw/i386/pc_piix.c | 7 +
> > > > > hw/i386/pc_q35.c | 6 +
> > > > > include/hw/acpi/ec.h | 44 ++++++
> > > > > include/hw/acpi/ich9.h | 1 +
> > > > > include/hw/boards.h | 5 +++--
> > > > > include/hw/i386/pc.h | 1 +
> > > > > qapi-schema.json | 13 +++++++++++++
> > > > > qmp-commands.hx | 23 +++++++++++++++++++++++
> > > > > qmp.c | 9 +++++++++
> > > > > 15 files changed, 411 insertions(+), 54 deletions(-)
> > > > > create mode 100644 hw/acpi/ec.c
> > > > > create mode 100644 include/hw/acpi/ec.h
> > >
> > >
> > >
> >
> >
> >
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2013-06-19 0:42 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 3:16 [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 1/8] acpi: add ACPI Embedded Controller support liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 2/8] ich9: add notifer for ec to generate sci liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 3/8] ec: add operations for _Qxx events liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 4/8] piix4: add notifer for ec to generate sci liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 5/8] piix4: add events for cpu hotplug liguang
2013-06-06 3:16 ` [Qemu-devel] [PATCH RFC v2 6/8] qmp: add 'cpu-del' command liguang
2013-06-06 3:17 ` [Qemu-devel] [PATCH RFC v2 7/8] pc: add EC qdev init for piix & q35 liguang
2013-06-06 3:17 ` [Qemu-devel] [PATCH RFC v2 8/8] cpu-hotplug: remove memory regison for cpu hotplug liguang
2013-06-06 8:13 ` [Qemu-devel] [PATCH RFC v2 0/7] coordinate cpu hotplug/unplug bewteen QEMU and kernel by EC Michael S. Tsirkin
2013-06-06 8:33 ` li guang
2013-06-18 2:47 ` li guang
2013-06-18 9:14 ` Igor Mammedov
2013-06-19 0:39 ` li guang
2013-06-06 8:48 ` Igor Mammedov
2013-06-06 8:58 ` li guang
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).