From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, qemu-devel@nongnu.org,
agraf@suse.de, qemu-ppc@nongnu.org,
Bharata B Rao <bharata@linux.vnet.ibm.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 04/25] spapr: Add LMB DR connectors
Date: Thu, 3 Sep 2015 14:27:55 +1000 [thread overview]
Message-ID: <1441254496-16174-5-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1441254496-16174-1-git-send-email-david@gibson.dropbear.id.au>
Enable memory hotplug for pseries 2.4 and add LMB DR connectors.
With memory hotplug, enforce RAM size, 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]
[since this missed the 2.4 cutoff, changing to only enable for 2.5]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr.h | 1 +
2 files changed, 88 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 3b692ec..185151d 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -60,6 +60,7 @@
#include "hw/nmi.h"
#include "hw/compat.h"
+#include "qemu-common.h"
#include <libfdt.h>
@@ -1439,10 +1440,84 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu)
qemu_register_reset(spapr_cpu_reset, cpu);
}
+/*
+ * Reset routine for LMB DR devices.
+ *
+ * Unlike PCI DR devices, LMB DR devices explicitly register this reset
+ * routine. Reset for PCI DR devices will be handled by PHB reset routine
+ * when it walks all its children devices. LMB devices reset occurs
+ * as part of spapr_ppc_reset().
+ */
+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(spapr);
+ 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->hotplug_memory.base;
+ }
+ drc = spapr_dr_connector_new(OBJECT(spapr), SPAPR_DR_CONNECTOR_TYPE_LMB,
+ addr/lmb_size);
+ qemu_register_reset(spapr_drc_reset, drc);
+ }
+}
+
+/*
+ * If RAM size, maxmem size and individual node mem sizes aren't aligned
+ * to SPAPR_MEMORY_BLOCK_SIZE(256MB), then refuse to start the guest
+ * since we can't support such unaligned sizes with DRCONF_MEMORY.
+ */
+static void spapr_validate_node_memory(MachineState *machine)
+{
+ int i;
+
+ if (machine->maxram_size % SPAPR_MEMORY_BLOCK_SIZE ||
+ machine->ram_size % SPAPR_MEMORY_BLOCK_SIZE) {
+ error_report("Can't support memory configuration where RAM size "
+ "0x" RAM_ADDR_FMT " or maxmem size "
+ "0x" RAM_ADDR_FMT " isn't aligned to %llu MB",
+ machine->ram_size, machine->maxram_size,
+ SPAPR_MEMORY_BLOCK_SIZE/M_BYTE);
+ exit(EXIT_FAILURE);
+ }
+
+ for (i = 0; i < nb_numa_nodes; i++) {
+ if (numa_info[i].node_mem % SPAPR_MEMORY_BLOCK_SIZE) {
+ error_report("Can't support memory configuration where memory size"
+ " %" PRIx64 " of node %d isn't aligned to %llu MB",
+ numa_info[i].node_mem, 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;
@@ -1521,6 +1596,10 @@ static void ppc_spapr_init(MachineState *machine)
smp_threads),
XICS_IRQS);
+ if (smc->dr_lmb_enabled) {
+ spapr_validate_node_memory(machine);
+ }
+
/* init CPUs */
if (machine->cpu_model == NULL) {
machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
@@ -1570,6 +1649,10 @@ static void ppc_spapr_init(MachineState *machine)
&spapr->hotplug_memory.mr);
}
+ if (smc->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");
@@ -1843,6 +1926,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);
@@ -1857,6 +1941,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
mc->has_dynamic_sysbus = true;
mc->pci_allow_0_address = true;
+ smc->dr_lmb_enabled = false;
fwc->get_dev_path = spapr_get_fw_dev_path;
nc->nmi_monitor_handler = spapr_nmi;
}
@@ -2010,11 +2095,13 @@ static const TypeInfo spapr_machine_2_4_info = {
static void spapr_machine_2_5_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
+ sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(oc);
mc->name = "pseries-2.5";
mc->desc = "pSeries Logical Partition (PAPR compliant) v2.5";
mc->alias = "pseries";
mc->is_default = 1;
+ smc->dr_lmb_enabled = true;
}
static const TypeInfo spapr_machine_2_5_info = {
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 8a1929b..a142e91 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 */
};
/**
--
2.4.3
next prev parent reply other threads:[~2015-09-03 4:28 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-03 4:27 [Qemu-devel] [PATCH 00/25] sPAPR (pseries) patch backlog 2015-00-03 David Gibson
2015-09-03 4:27 ` [Qemu-devel] [PATCH 01/25] spapr: Provide an error message when migration fails due to htab_shift mismatch David Gibson
2015-09-03 4:27 ` [Qemu-devel] [PATCH 02/25] spapr: Create pseries-2.5 machine David Gibson
2015-09-03 4:27 ` [Qemu-devel] [PATCH 03/25] spapr: Initialize hotplug memory address space David Gibson
2015-09-03 4:27 ` David Gibson [this message]
2015-09-03 4:27 ` [Qemu-devel] [PATCH 05/25] spapr: Support ibm, dynamic-reconfiguration-memory David Gibson
2015-09-03 4:27 ` [Qemu-devel] [PATCH 06/25] spapr: Make hash table size a factor of maxram_size David Gibson
2015-09-03 4:27 ` [Qemu-devel] [PATCH 07/25] spapr: Memory hotplug support David Gibson
2015-09-03 4:27 ` [Qemu-devel] [PATCH 08/25] spapr: Don't allow memory hotplug to memory less nodes David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 09/25] spapr: Add /ibm,partition-name David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 10/25] spapr: Add /rtas/ibm, change-msix-capable David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 11/25] spapr: Make ibm, change-msi respect 3 return values David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 12/25] spapr: SPLPAR Characteristics David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 13/25] spapr_drc: Fix potential undefined behaviour David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 14/25] spapr: add dumpdtb support David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 15/25] ppc/spapr: Use qemu_log_mask() for hcall_dprintf() David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 16/25] spapr: Use QEMU limit for maximum CPUs number David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 17/25] spapr: Provide better error message when slots exceed max allowed David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 18/25] spapr: Populate ibm, associativity-lookup-arrays correctly for non-NUMA David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 19/25] spapr: Revert to memory@XXXX representation for non-hotplugged memory David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 20/25] spapr: Support hotplug by specifying DRC count David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 21/25] spapr: Move memory hotplug to RTAS_LOG_V6_HP_ID_DRC_COUNT type David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 22/25] spapr_rtas: Prevent QEMU crash during hotplug without a prior device_add David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 23/25] sPAPR: Introduce rtas_ldq() David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 24/25] pseries: define coldplugged devices as "configured" David Gibson
2015-09-03 4:28 ` [Qemu-devel] [PATCH 25/25] pseries: Update SLOF firmware image to qemu-slof-20150813 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=1441254496-16174-5-git-send-email-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=bharata@linux.vnet.ibm.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).