aboutsummaryrefslogtreecommitdiff
path: root/hw/ppc
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-05-08 15:25:17 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-05-08 15:25:17 +0100
commitcc8f8ba754bba17eea9791d67b572eb26e30b4ce (patch)
tree2fab5dc102c3c704e2f1377ffedaf981e1b520d3 /hw/ppc
parentd01beac177d44491d7db8747b79d94e1b53d173b (diff)
parentb40dffdec60c2dbe54806576faa5cb85227586d1 (diff)
downloadqemu-cc8f8ba754bba17eea9791d67b572eb26e30b4ce.zip
qemu-cc8f8ba754bba17eea9791d67b572eb26e30b4ce.tar.gz
qemu-cc8f8ba754bba17eea9791d67b572eb26e30b4ce.tar.bz2
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
Machine queue, 2018-05-07 * pc-dimm: factor out MemoryDevice (virtio-pmem and virtio-mem will make use of the new abstraction later) * scripts/device-crash-test: Removed fixed CAN entries # gpg: Signature made Mon 07 May 2018 18:01:42 BST # gpg: using RSA key 2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/machine-next-pull-request: scripts/device-crash-test: Removed fixed CAN entries vl: allow 'maxmem' without 'slot' spapr: rename "hotplug memory" terminology to "device memory" pc: rename "hotplug memory" terminology to "device memory" machine: rename MemoryHotplugState to DeviceMemoryState pc-dimm: move actual plug/unplug of a memory region to MemoryDevice pc-dimm: factor out capacity and slot checks into MemoryDevice pc-dimm: factor out address search into MemoryDevice code pc-dimm: pass in the machine and to the MemoryHotplugState pc-dimm: no need to pass the memory region machine: make MemoryHotplugState accessible via the machine pc-dimm: factor out MemoryDevice interface Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/ppc')
-rw-r--r--hw/ppc/spapr.c71
-rw-r--r--hw/ppc/spapr_hcall.c7
-rw-r--r--hw/ppc/spapr_rtas_ddw.c5
3 files changed, 43 insertions, 40 deletions
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 32ab3c4..a1abcba 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -74,6 +74,7 @@
#include "hw/compat.h"
#include "qemu/cutils.h"
#include "hw/ppc/spapr_cpu_core.h"
+#include "hw/mem/memory-device.h"
#include <libfdt.h>
@@ -702,13 +703,14 @@ spapr_get_drconf_cell(uint32_t seq_lmbs, uint64_t base_addr,
static int spapr_populate_drmem_v2(sPAPRMachineState *spapr, void *fdt,
int offset, MemoryDeviceInfoList *dimms)
{
+ MachineState *machine = MACHINE(spapr);
uint8_t *int_buf, *cur_index, buf_len;
int ret;
uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
uint64_t addr, cur_addr, size;
- uint32_t nr_boot_lmbs = (spapr->hotplug_memory.base / lmb_size);
- uint64_t mem_end = spapr->hotplug_memory.base +
- memory_region_size(&spapr->hotplug_memory.mr);
+ uint32_t nr_boot_lmbs = (machine->device_memory->base / lmb_size);
+ uint64_t mem_end = machine->device_memory->base +
+ memory_region_size(&machine->device_memory->mr);
uint32_t node, nr_entries = 0;
sPAPRDRConnector *drc;
DrconfCellQueue *elem, *next;
@@ -723,7 +725,7 @@ static int spapr_populate_drmem_v2(sPAPRMachineState *spapr, void *fdt,
QSIMPLEQ_INSERT_TAIL(&drconf_queue, elem, entry);
nr_entries++;
- cur_addr = spapr->hotplug_memory.base;
+ cur_addr = machine->device_memory->base;
for (info = dimms; info; info = info->next) {
PCDIMMDeviceInfo *di = info->value->u.dimm.data;
@@ -786,11 +788,12 @@ static int spapr_populate_drmem_v2(sPAPRMachineState *spapr, void *fdt,
static int spapr_populate_drmem_v1(sPAPRMachineState *spapr, void *fdt,
int offset, MemoryDeviceInfoList *dimms)
{
+ MachineState *machine = MACHINE(spapr);
int i, ret;
uint64_t lmb_size = SPAPR_MEMORY_BLOCK_SIZE;
- uint32_t hotplug_lmb_start = spapr->hotplug_memory.base / lmb_size;
- uint32_t nr_lmbs = (spapr->hotplug_memory.base +
- memory_region_size(&spapr->hotplug_memory.mr)) /
+ uint32_t device_lmb_start = machine->device_memory->base / lmb_size;
+ uint32_t nr_lmbs = (machine->device_memory->base +
+ memory_region_size(&machine->device_memory->mr)) /
lmb_size;
uint32_t *int_buf, *cur_index, buf_len;
@@ -805,7 +808,7 @@ static int spapr_populate_drmem_v1(sPAPRMachineState *spapr, void *fdt,
uint64_t addr = i * lmb_size;
uint32_t *dynamic_memory = cur_index;
- if (i >= hotplug_lmb_start) {
+ if (i >= device_lmb_start) {
sPAPRDRConnector *drc;
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, i);
@@ -824,7 +827,7 @@ static int spapr_populate_drmem_v1(sPAPRMachineState *spapr, void *fdt,
} else {
/*
* LMB information for RMA, boot time RAM and gap b/n RAM and
- * hotplug memory region -- all these are marked as reserved
+ * device memory region -- all these are marked as reserved
* and as having no valid DRC.
*/
dynamic_memory[0] = cpu_to_be32(addr >> 32);
@@ -862,7 +865,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt)
MemoryDeviceInfoList *dimms = NULL;
/*
- * Don't create the node if there is no hotpluggable memory
+ * Don't create the node if there is no device memory
*/
if (machine->ram_size == machine->maxram_size) {
return 0;
@@ -887,7 +890,7 @@ static int spapr_populate_drconf_memory(sPAPRMachineState *spapr, void *fdt)
}
/* ibm,dynamic-memory or ibm,dynamic-memory-v2 */
- dimms = qmp_pc_dimm_device_list();
+ dimms = qmp_memory_device_list();
if (spapr_ovec_test(spapr->ov5_cas, OV5_DRMEM_V2)) {
ret = spapr_populate_drmem_v2(spapr, fdt, offset, dimms);
} else {
@@ -1033,11 +1036,11 @@ static void spapr_dt_rtas(sPAPRMachineState *spapr, void *fdt)
GString *hypertas = g_string_sized_new(256);
GString *qemu_hypertas = g_string_sized_new(256);
uint32_t refpoints[] = { cpu_to_be32(0x4), cpu_to_be32(0x4) };
- uint64_t max_hotplug_addr = spapr->hotplug_memory.base +
- memory_region_size(&spapr->hotplug_memory.mr);
+ uint64_t max_device_addr = MACHINE(spapr)->device_memory->base +
+ memory_region_size(&MACHINE(spapr)->device_memory->mr);
uint32_t lrdr_capacity[] = {
- cpu_to_be32(max_hotplug_addr >> 32),
- cpu_to_be32(max_hotplug_addr & 0xffffffff),
+ cpu_to_be32(max_device_addr >> 32),
+ cpu_to_be32(max_device_addr & 0xffffffff),
0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE),
cpu_to_be32(max_cpus / smp_threads),
};
@@ -2296,7 +2299,7 @@ static void spapr_create_lmb_dr_connectors(sPAPRMachineState *spapr)
for (i = 0; i < nr_lmbs; i++) {
uint64_t addr;
- addr = i * lmb_size + spapr->hotplug_memory.base;
+ addr = i * lmb_size + machine->device_memory->base;
spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_LMB,
addr / lmb_size);
}
@@ -2633,9 +2636,12 @@ static void spapr_machine_init(MachineState *machine)
machine->ram_size);
memory_region_add_subregion(sysmem, 0, ram);
+ /* always allocate the device memory information */
+ machine->device_memory = g_malloc0(sizeof(*machine->device_memory));
+
/* initialize hotplug memory address space */
if (machine->ram_size < machine->maxram_size) {
- ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+ ram_addr_t device_mem_size = machine->maxram_size - machine->ram_size;
/*
* Limit the number of hotpluggable memory slots to half the number
* slots that KVM supports, leaving the other half for PCI and other
@@ -2654,12 +2660,12 @@ static void spapr_machine_init(MachineState *machine)
exit(1);
}
- spapr->hotplug_memory.base = ROUND_UP(machine->ram_size,
- SPAPR_HOTPLUG_MEM_ALIGN);
- memory_region_init(&spapr->hotplug_memory.mr, OBJECT(spapr),
- "hotplug-memory", hotplug_mem_size);
- memory_region_add_subregion(sysmem, spapr->hotplug_memory.base,
- &spapr->hotplug_memory.mr);
+ machine->device_memory->base = ROUND_UP(machine->ram_size,
+ SPAPR_DEVICE_MEM_ALIGN);
+ memory_region_init(&machine->device_memory->mr, OBJECT(spapr),
+ "device-memory", device_mem_size);
+ memory_region_add_subregion(sysmem, machine->device_memory->base,
+ &machine->device_memory->mr);
}
if (smc->dr_lmb_enabled) {
@@ -3147,7 +3153,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
align = memory_region_get_alignment(mr);
size = memory_region_size(mr);
- pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err);
+ pc_dimm_memory_plug(dev, MACHINE(ms), align, &local_err);
if (local_err) {
goto out;
}
@@ -3168,7 +3174,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
return;
out_unplug:
- pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr);
+ pc_dimm_memory_unplug(dev, MACHINE(ms));
out:
error_propagate(errp, local_err);
}
@@ -3286,9 +3292,6 @@ static sPAPRDIMMState *spapr_recover_pending_dimm_state(sPAPRMachineState *ms,
void spapr_lmb_release(DeviceState *dev)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_hotplug_handler(dev));
- PCDIMMDevice *dimm = PC_DIMM(dev);
- PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
- MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
/* This information will get lost if a migration occurs
@@ -3308,7 +3311,7 @@ void spapr_lmb_release(DeviceState *dev)
* Now that all the LMBs have been removed by the guest, call the
* pc-dimm unplug handler to cleanup up the pc-dimm device.
*/
- pc_dimm_memory_unplug(dev, &spapr->hotplug_memory, mr);
+ pc_dimm_memory_unplug(dev, MACHINE(spapr));
object_unparent(OBJECT(dev));
spapr_pending_dimm_unplugs_remove(spapr, ds);
}
@@ -4259,13 +4262,13 @@ static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index,
hwaddr phb0_base, phb_base;
int i;
- /* Do we have hotpluggable memory? */
+ /* Do we have device memory? */
if (MACHINE(spapr)->maxram_size > ram_top) {
/* Can't just use maxram_size, because there may be an
- * alignment gap between normal and hotpluggable memory
- * regions */
- ram_top = spapr->hotplug_memory.base +
- memory_region_size(&spapr->hotplug_memory.mr);
+ * alignment gap between normal and device memory regions
+ */
+ ram_top = MACHINE(spapr)->device_memory->base +
+ memory_region_size(&MACHINE(spapr)->device_memory->mr);
}
phb0_base = QEMU_ALIGN_UP(ram_top, phb0_alignment);
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index ca9702e..022f6d8 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -14,6 +14,7 @@
#include "kvm_ppc.h"
#include "hw/ppc/spapr_ovec.h"
#include "mmu-book3s-v3.h"
+#include "hw/mem/memory-device.h"
struct LPCRSyncState {
target_ulong value;
@@ -66,13 +67,13 @@ static inline bool valid_ptex(PowerPCCPU *cpu, target_ulong ptex)
static bool is_ram_address(sPAPRMachineState *spapr, hwaddr addr)
{
MachineState *machine = MACHINE(spapr);
- MemoryHotplugState *hpms = &spapr->hotplug_memory;
+ DeviceMemoryState *dms = machine->device_memory;
if (addr < machine->ram_size) {
return true;
}
- if ((addr >= hpms->base)
- && ((addr - hpms->base) < memory_region_size(&hpms->mr))) {
+ if ((addr >= dms->base)
+ && ((addr - dms->base) < memory_region_size(&dms->mr))) {
return true;
}
diff --git a/hw/ppc/spapr_rtas_ddw.c b/hw/ppc/spapr_rtas_ddw.c
index 177dcff..329feb1 100644
--- a/hw/ppc/spapr_rtas_ddw.c
+++ b/hw/ppc/spapr_rtas_ddw.c
@@ -122,9 +122,8 @@ static void rtas_ibm_query_pe_dma_window(PowerPCCPU *cpu,
if (machine->ram_size == machine->maxram_size) {
max_window_size = machine->ram_size;
} else {
- MemoryHotplugState *hpms = &spapr->hotplug_memory;
-
- max_window_size = hpms->base + memory_region_size(&hpms->mr);
+ max_window_size = machine->device_memory->base +
+ memory_region_size(&machine->device_memory->mr);
}
avail = SPAPR_PCI_DMA_MAX_WINDOWS - spapr_phb_get_active_win_num(sphb);