[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v4 03/11] pc-dimm: no need to pass the memory region
From: |
David Hildenbrand |
Subject: |
[Qemu-ppc] [PATCH v4 03/11] pc-dimm: no need to pass the memory region |
Date: |
Mon, 23 Apr 2018 18:51:18 +0200 |
We can just query it ourselves. When unplugging, we should always be
able to the region (as it was previously plugged). E.g. PPC already
assumed that and used &error_abort.
Signed-off-by: David Hildenbrand <address@hidden>
---
hw/i386/pc.c | 13 ++-----------
hw/mem/pc-dimm.c | 12 +++++++++---
hw/ppc/spapr.c | 9 +++------
include/hw/mem/pc-dimm.h | 5 ++---
4 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 19af0733fd..c14dec492b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1715,8 +1715,7 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
goto out;
}
- pc_dimm_memory_plug(dev, MACHINE(pcms)->device_memory, mr, align,
- &local_err);
+ pc_dimm_memory_plug(dev, MACHINE(pcms)->device_memory, align, &local_err);
if (local_err) {
goto out;
}
@@ -1766,17 +1765,9 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
- PCDIMMDevice *dimm = PC_DIMM(dev);
- PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
- MemoryRegion *mr;
HotplugHandlerClass *hhc;
Error *local_err = NULL;
- mr = ddc->get_memory_region(dimm, &local_err);
- if (local_err) {
- goto out;
- }
-
hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
@@ -1784,7 +1775,7 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_dev,
goto out;
}
- pc_dimm_memory_unplug(dev, MACHINE(pcms)->device_memory, mr);
+ pc_dimm_memory_unplug(dev, MACHINE(pcms)->device_memory);
object_unparent(OBJECT(dev));
out:
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index ef330628c1..aeff369f6f 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -37,7 +37,7 @@ typedef struct pc_dimms_capacity {
} pc_dimms_capacity;
void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
- MemoryRegion *mr, uint64_t align, Error **errp)
+ uint64_t align, Error **errp)
{
int slot;
MachineState *machine = MACHINE(qdev_get_machine());
@@ -46,8 +46,14 @@ void pc_dimm_memory_plug(DeviceState *dev,
MemoryHotplugState *hpms,
MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
Error *local_err = NULL;
uint64_t existing_dimms_capacity = 0;
+ MemoryRegion *mr;
uint64_t addr;
+ mr = ddc->get_memory_region(dimm, &local_err);
+ if (local_err) {
+ goto out;
+ }
+
addr = object_property_get_uint(OBJECT(dimm),
PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
@@ -116,12 +122,12 @@ out:
error_propagate(errp, local_err);
}
-void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
- MemoryRegion *mr)
+void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms)
{
PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
+ MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
memory_region_del_subregion(&hpms->mr, mr);
vmstate_unregister_ram(vmstate_mr, dev);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 56d5e8201b..8c13d165b4 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3044,7 +3044,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, MACHINE(ms)->device_memory, mr, align,
&local_err);
+ pc_dimm_memory_plug(dev, MACHINE(ms)->device_memory, align, &local_err);
if (local_err) {
goto out;
}
@@ -3065,7 +3065,7 @@ static void spapr_memory_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
return;
out_unplug:
- pc_dimm_memory_unplug(dev, MACHINE(ms)->device_memory, mr);
+ pc_dimm_memory_unplug(dev, MACHINE(ms)->device_memory);
out:
error_propagate(errp, local_err);
}
@@ -3183,9 +3183,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
@@ -3205,7 +3202,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, MACHINE(spapr)->device_memory, mr);
+ pc_dimm_memory_unplug(dev, MACHINE(spapr)->device_memory);
object_unparent(OBJECT(dev));
spapr_pending_dimm_unplugs_remove(spapr, ds);
}
diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index 8bda37adab..1d26e13cef 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -85,7 +85,6 @@ int pc_dimm_get_free_slot(const int *hint, int max_slots,
Error **errp);
uint64_t pc_existing_dimms_capacity(Error **errp);
void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
- MemoryRegion *mr, uint64_t align, Error **errp);
-void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
- MemoryRegion *mr);
+ uint64_t align, Error **errp);
+void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms);
#endif
--
2.14.3
- [Qemu-ppc] [PATCH v4 00/11] pc-dimm: factor out MemoryDevice, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 03/11] pc-dimm: no need to pass the memory region,
David Hildenbrand <=
- [Qemu-ppc] [PATCH v4 04/11] pc-dimm: pass in the machine and to the MemoryHotplugState, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 02/11] machine: make MemoryHotplugState accessible via the machine, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 01/11] pc-dimm: factor out MemoryDevice interface, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 05/11] pc-dimm: factor out address search into MemoryDevice code, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 06/11] pc-dimm: factor out capacity and slot checks into MemoryDevice, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 07/11] pc-dimm: move actual plug/unplug of a memory region to MemoryDevice, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 08/11] machine: rename MemoryHotplugState to DeviceMemoryState, David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 09/11] pc: rename "hotplug memory" terminology to "device memory", David Hildenbrand, 2018/04/23
- [Qemu-ppc] [PATCH v4 10/11] spapr: rename "hotplug memory" terminology to "device memory", David Hildenbrand, 2018/04/23