From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aik@ozlabs.ru, Bharata B Rao <bharata@linux.vnet.ibm.com>,
mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org,
tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com,
imammedo@redhat.com, david@gibson.dropbear.id.au
Subject: [Qemu-devel] [RFC PATCH v4 2/5] spapr: Add LMB DR connectors
Date: Fri, 19 Jun 2015 15:47:54 +0530 [thread overview]
Message-ID: <1434709077-17491-3-git-send-email-bharata@linux.vnet.ibm.com> (raw)
In-Reply-To: <1434709077-17491-1-git-send-email-bharata@linux.vnet.ibm.com>
Enable memory hotplug for pseries 2.4 and add LMB DR connectors.
With memory hotplug, enforce NUMA node memory size and maxmem to be
a multiple of SPAPR_MEMORY_BLOCK_SIZE (256M) since that's the granularity
in which LMBs are represented and hot-added.
LMB DR connectors will be used by the memory hotplug code.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
[spapr_drc_reset implementation]
---
hw/ppc/spapr.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr.h | 2 ++
2 files changed, 80 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 87a29dc..f9af89b 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -59,6 +59,7 @@
#include "hw/nmi.h"
#include "hw/compat.h"
+#include "qemu-common.h"
#include <libfdt.h>
@@ -1436,10 +1437,76 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu)
qemu_register_reset(spapr_cpu_reset, cpu);
}
+static void spapr_drc_reset(void *opaque)
+{
+ sPAPRDRConnector *drc = opaque;
+ DeviceState *d = DEVICE(drc);
+
+ if (d) {
+ device_reset(d);
+ }
+}
+
+static void spapr_create_lmb_dr_connectors(sPAPRMachineState *spapr)
+{
+ MachineState *machine = MACHINE(qdev_get_machine());
+ uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
+ uint32_t nr_rma_lmbs = spapr->rma_size/lmb_size;
+ uint32_t nr_lmbs = machine->maxram_size/lmb_size - nr_rma_lmbs;
+ uint32_t nr_assigned_lmbs = machine->ram_size/lmb_size - nr_rma_lmbs;
+ int i;
+
+ for (i = 0; i < nr_lmbs; i++) {
+ sPAPRDRConnector *drc;
+ uint64_t addr;
+
+ if (i < nr_assigned_lmbs) {
+ addr = (i + nr_rma_lmbs) * lmb_size;
+ } else {
+ addr = (i - nr_assigned_lmbs) * lmb_size +
+ SPAPR_MACHINE(qdev_get_machine())->hotplug_memory.base;
+ }
+
+ drc = spapr_dr_connector_new(qdev_get_machine(),
+ SPAPR_DR_CONNECTOR_TYPE_LMB, addr/lmb_size);
+ qemu_register_reset(spapr_drc_reset, drc);
+ }
+}
+
+/*
+ * If LMB DR is enabled node memory size and max memory size should
+ * be a multiple of SPAPR_MEMORY_BLOCK_SIZE (256M).
+ */
+static void spapr_validate_node_memory(sPAPRMachineState *spapr)
+{
+ int i;
+ MachineState *machine = MACHINE(qdev_get_machine());
+
+ if (!spapr->dr_lmb_enabled) {
+ return;
+ }
+
+ if (machine->maxram_size % SPAPR_MEMORY_BLOCK_SIZE) {
+ error_report("maxmem should be a multiple of %lld MB",
+ SPAPR_MEMORY_BLOCK_SIZE/M_BYTE);
+ exit(EXIT_FAILURE);
+ }
+
+ for (i = 0; i < nb_numa_nodes; i++) {
+ if (numa_info[i].node_mem &&
+ numa_info[i].node_mem % SPAPR_MEMORY_BLOCK_SIZE) {
+ error_report("Memory size on node %d should be a multiple "
+ "of %lld MB", i, SPAPR_MEMORY_BLOCK_SIZE/M_BYTE);
+ exit(EXIT_FAILURE);
+ }
+ }
+}
+
/* pSeries LPAR / sPAPR hardware init */
static void ppc_spapr_init(MachineState *machine)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
+ sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
@@ -1518,6 +1585,9 @@ static void ppc_spapr_init(MachineState *machine)
smp_threads),
XICS_IRQS);
+ spapr->dr_lmb_enabled = smc->dr_lmb_enabled;
+ spapr_validate_node_memory(spapr);
+
/* init CPUs */
if (machine->cpu_model == NULL) {
machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
@@ -1577,6 +1647,10 @@ static void ppc_spapr_init(MachineState *machine)
&spapr->hotplug_memory.mr);
}
+ if (spapr->dr_lmb_enabled) {
+ spapr_create_lmb_dr_connectors(spapr);
+ }
+
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin");
if (!filename) {
error_report("Could not find LPAR rtas '%s'", "spapr-rtas.bin");
@@ -1850,6 +1924,7 @@ static void spapr_nmi(NMIState *n, int cpu_index, Error **errp)
static void spapr_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(oc);
FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
NMIClass *nc = NMI_CLASS(oc);
@@ -1863,6 +1938,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
mc->kvm_type = spapr_kvm_type;
mc->has_dynamic_sysbus = true;
+ smc->dr_lmb_enabled = false;
fwc->get_dev_path = spapr_get_fw_dev_path;
nc->nmi_monitor_handler = spapr_nmi;
}
@@ -1998,11 +2074,13 @@ static const TypeInfo spapr_machine_2_3_info = {
static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(oc);
mc->name = "pseries-2.4";
mc->desc = "pSeries Logical Partition (PAPR compliant) v2.4";
mc->alias = "pseries";
mc->is_default = 1;
+ smc->dr_lmb_enabled = true;
}
static const TypeInfo spapr_machine_2_4_info = {
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 8a1929b..b3fba76 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -35,6 +35,7 @@ struct sPAPRMachineClass {
MachineClass parent_class;
/*< public >*/
+ bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs */
};
/**
@@ -74,6 +75,7 @@ struct sPAPRMachineState {
/* RTAS state */
QTAILQ_HEAD(, sPAPRConfigureConnectorState) ccs_list;
+ bool dr_lmb_enabled; /* hotplug / dynamic-reconfiguration of LMBs */
/*< public >*/
char *kvm_type;
--
2.1.0
next prev parent reply other threads:[~2015-06-19 10:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 10:17 [Qemu-devel] [RFC PATCH v4 0/5] Memory hotplug for PowerPC sPAPR guests Bharata B Rao
2015-06-19 10:17 ` [Qemu-devel] [RFC PATCH v4 1/5] spapr: Initialize hotplug memory address space Bharata B Rao
2015-06-23 1:33 ` David Gibson
2015-06-24 2:14 ` Bharata B Rao
2015-06-19 10:17 ` Bharata B Rao [this message]
2015-06-23 1:32 ` [Qemu-devel] [RFC PATCH v4 2/5] spapr: Add LMB DR connectors David Gibson
2015-06-24 2:19 ` Bharata B Rao
2015-06-24 3:24 ` Bharata B Rao
2015-06-24 5:51 ` David Gibson
2015-06-25 12:56 ` Michael Roth
2015-06-19 10:17 ` [Qemu-devel] [RFC PATCH v4 3/5] spapr: Support ibm, dynamic-reconfiguration-memory Bharata B Rao
2015-06-23 1:54 ` David Gibson
2015-06-24 2:25 ` Bharata B Rao
2015-06-24 5:55 ` David Gibson
2015-06-25 6:17 ` Bharata B Rao
2015-06-19 10:17 ` [Qemu-devel] [RFC PATCH v4 4/5] spapr: Make hash table size a factor of maxram_size Bharata B Rao
2015-06-23 2:08 ` David Gibson
2015-06-19 10:17 ` [Qemu-devel] [RFC PATCH v4 5/5] spapr: Memory hotplug support Bharata B Rao
2015-06-23 2:29 ` David Gibson
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=1434709077-17491-3-git-send-email-bharata@linux.vnet.ibm.com \
--to=bharata@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=imammedo@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=nfont@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=tyreld@linux.vnet.ibm.com \
/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).