[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v5 04/16] pc-dimm: pass PCDIMMDevice to pc_dimm_.*plug
From: |
David Hildenbrand |
Subject: |
[Qemu-ppc] [PATCH v5 04/16] pc-dimm: pass PCDIMMDevice to pc_dimm_.*plug |
Date: |
Fri, 5 Oct 2018 11:20:12 +0200 |
We're plugging/unplugging a PCDIMMDevice, so directly pass this type
instead of a more generic DeviceState.
Reviewed-by: David Gibson <address@hidden>
Acked-by: David Gibson <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Reviewed-by: Eric Auger <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
---
hw/i386/pc.c | 6 +++---
hw/mem/pc-dimm.c | 24 +++++++++++-------------
hw/ppc/spapr.c | 8 ++++----
include/hw/mem/pc-dimm.h | 6 +++---
4 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 03148450c8..86c16f9aaf 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1699,7 +1699,7 @@ static void pc_memory_pre_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
return;
}
- pc_dimm_pre_plug(dev, MACHINE(hotplug_dev),
+ pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev),
pcmc->enforce_aligned_dimm ? NULL : &legacy_align, errp);
}
@@ -1711,7 +1711,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_dev,
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
- pc_dimm_plug(dev, MACHINE(pcms), &local_err);
+ pc_dimm_plug(PC_DIMM(dev), MACHINE(pcms), &local_err);
if (local_err) {
goto out;
}
@@ -1771,7 +1771,7 @@ static void pc_memory_unplug(HotplugHandler *hotplug_dev,
goto out;
}
- pc_dimm_unplug(dev, MACHINE(pcms));
+ pc_dimm_unplug(PC_DIMM(dev), MACHINE(pcms));
object_unparent(OBJECT(dev));
out:
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index fb6bcaedc4..f46fb7ada2 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -29,24 +29,24 @@
static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
-void pc_dimm_pre_plug(DeviceState *dev, MachineState *machine,
+void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
const uint64_t *legacy_align, Error **errp)
{
- PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
Error *local_err = NULL;
MemoryRegion *mr;
uint64_t addr, align;
int slot;
- slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
+ slot = object_property_get_int(OBJECT(dimm), PC_DIMM_SLOT_PROP,
&error_abort);
slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL :
&slot,
machine->ram_slots, &local_err);
if (local_err) {
goto out;
}
- object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP,
&error_abort);
+ object_property_set_int(OBJECT(dimm), slot, PC_DIMM_SLOT_PROP,
+ &error_abort);
trace_mhp_pc_dimm_assigned_slot(slot);
mr = ddc->get_memory_region(dimm, &local_err);
@@ -55,7 +55,7 @@ void pc_dimm_pre_plug(DeviceState *dev, MachineState *machine,
}
align = legacy_align ? *legacy_align : memory_region_get_alignment(mr);
- addr = object_property_get_uint(OBJECT(dev), PC_DIMM_ADDR_PROP,
+ addr = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
&error_abort);
addr = memory_device_get_free_addr(machine, !addr ? NULL : &addr, align,
memory_region_size(mr), &local_err);
@@ -63,38 +63,36 @@ void pc_dimm_pre_plug(DeviceState *dev, MachineState
*machine,
goto out;
}
trace_mhp_pc_dimm_assigned_address(addr);
- object_property_set_uint(OBJECT(dev), addr, PC_DIMM_ADDR_PROP,
+ object_property_set_uint(OBJECT(dimm), addr, PC_DIMM_ADDR_PROP,
&error_abort);
out:
error_propagate(errp, local_err);
}
-void pc_dimm_plug(DeviceState *dev, MachineState *machine, Error **errp)
+void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine, Error **errp)
{
- PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm,
&error_abort);
MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
uint64_t addr;
- addr = object_property_get_uint(OBJECT(dev), PC_DIMM_ADDR_PROP,
+ addr = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
&error_abort);
memory_device_plug_region(machine, mr, addr);
- vmstate_register_ram(vmstate_mr, dev);
+ vmstate_register_ram(vmstate_mr, DEVICE(dimm));
}
-void pc_dimm_unplug(DeviceState *dev, MachineState *machine)
+void pc_dimm_unplug(PCDIMMDevice *dimm, MachineState *machine)
{
- PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm,
&error_abort);
MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
memory_device_unplug_region(machine, mr);
- vmstate_unregister_ram(vmstate_mr, dev);
+ vmstate_unregister_ram(vmstate_mr, DEVICE(dimm));
}
static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 98868d893a..c078347b66 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3135,7 +3135,7 @@ static void spapr_memory_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
size = memory_region_size(mr);
- pc_dimm_plug(dev, MACHINE(ms), &local_err);
+ pc_dimm_plug(dimm, MACHINE(ms), &local_err);
if (local_err) {
goto out;
}
@@ -3158,7 +3158,7 @@ static void spapr_memory_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
return;
out_unplug:
- pc_dimm_unplug(dev, MACHINE(ms));
+ pc_dimm_unplug(dimm, MACHINE(ms));
out:
error_propagate(errp, local_err);
}
@@ -3202,7 +3202,7 @@ static void spapr_memory_pre_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
return;
}
- pc_dimm_pre_plug(dev, MACHINE(hotplug_dev), NULL, errp);
+ pc_dimm_pre_plug(dimm, MACHINE(hotplug_dev), NULL, errp);
}
struct sPAPRDIMMState {
@@ -3314,7 +3314,7 @@ static void spapr_memory_unplug(HotplugHandler
*hotplug_dev, DeviceState *dev)
sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_dev);
sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
- pc_dimm_unplug(dev, MACHINE(hotplug_dev));
+ pc_dimm_unplug(PC_DIMM(dev), MACHINE(hotplug_dev));
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 b382eb4303..99cbd54de7 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -79,8 +79,8 @@ typedef struct PCDIMMDeviceClass {
Error **errp);
} PCDIMMDeviceClass;
-void pc_dimm_pre_plug(DeviceState *dev, MachineState *machine,
+void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,
const uint64_t *legacy_align, Error **errp);
-void pc_dimm_plug(DeviceState *dev, MachineState *machine, Error **errp);
-void pc_dimm_unplug(DeviceState *dev, MachineState *machine);
+void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine, Error **errp);
+void pc_dimm_unplug(PCDIMMDevice *dimm, MachineState *machine);
#endif
--
2.17.1
- [Qemu-ppc] [PATCH v5 00/16] memory-device: complete refactoring, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 16/16] memory-device: trace when pre_plugging/plugging/unplugging, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 15/16] memory-device: complete factoring out unplug handling, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 14/16] memory-device: complete factoring out plug handling, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 12/16] memory-device: add device class function set_addr(), David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 10/16] memory-device: factor out get_memory_region() from pc-dimm, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 11/16] memory-device: drop get_region_size(), David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 13/16] memory-device: complete factoring out pre_plug handling, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 08/16] memory-device: document MemoryDeviceClass, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 09/16] memory-device: add and use memory_device_get_region_size(), David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 04/16] pc-dimm: pass PCDIMMDevice to pc_dimm_.*plug,
David Hildenbrand <=
- [Qemu-ppc] [PATCH v5 02/16] memory-device: fix error message when hinted address is too small, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 03/16] memory-device: improve "range conflicts" error message, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 07/16] memory-device: forward errors in get_region_size()/get_plugged_size(), David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 05/16] memory-device: use memory device terminology in error messages, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 06/16] memory-device: introduce separate config option, David Hildenbrand, 2018/10/05
- [Qemu-ppc] [PATCH v5 01/16] memory-device: fix alignment error message, David Hildenbrand, 2018/10/05
- Re: [Qemu-ppc] [PATCH v5 00/16] memory-device: complete refactoring, David Hildenbrand, 2018/10/09