[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 06/21] spapr: Simplify unplug path
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 06/21] spapr: Simplify unplug path |
Date: |
Mon, 17 Jul 2017 16:56:06 +1000 |
spapr_lmb_release() and spapr_core_release() call hotplug_handler_unplug()
which after a bunch of indirection calls spapr_memory_unplug() or
spapr_core_unplug(). But we already know which is the appropriate thing
to call here, so we can just fold it directly into the release function.
Once that's done, there's no need for an hc->unplug method in the spapr
machine at all: since we also have an hc->unplug_request method, the
hotplug core will never use ->unplug.
Signed-off-by: David Gibson <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
Tested-by: Daniel Barboza <address@hidden>
---
hw/ppc/spapr.c | 56 ++++++++------------------------------------------------
1 file changed, 8 insertions(+), 48 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index cb61d3d36b..8818647e1a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2816,8 +2816,10 @@ static sPAPRDIMMState
*spapr_recover_pending_dimm_state(sPAPRMachineState *ms,
/* Callback to be called during DRC release. */
void spapr_lmb_release(DeviceState *dev)
{
- HotplugHandler *hotplug_ctrl = qdev_get_hotplug_handler(dev);
- sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_ctrl);
+ 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);
sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
/* This information will get lost if a migration occurs
@@ -2838,18 +2840,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.
*/
- hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort);
-}
-
-static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
- Error **errp)
-{
- sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev);
- PCDIMMDevice *dimm = PC_DIMM(dev);
- PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
- MemoryRegion *mr = ddc->get_memory_region(dimm);
-
- pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr);
+ pc_dimm_memory_unplug(dev, &spapr->hotplug_memory, mr);
object_unparent(OBJECT(dev));
}
@@ -2918,10 +2909,10 @@ static void *spapr_populate_hotplug_cpu_dt(CPUState
*cs, int *fdt_offset,
return fdt;
}
-static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
- Error **errp)
+/* Callback to be called during DRC release. */
+void spapr_core_release(DeviceState *dev)
{
- MachineState *ms = MACHINE(qdev_get_machine());
+ MachineState *ms = MACHINE(qdev_get_hotplug_handler(dev));
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(ms);
CPUCore *cc = CPU_CORE(dev);
CPUArchId *core_slot = spapr_find_cpu_slot(ms, cc->core_id, NULL);
@@ -2945,15 +2936,6 @@ static void spapr_core_unplug(HotplugHandler
*hotplug_dev, DeviceState *dev,
object_unparent(OBJECT(dev));
}
-/* Callback to be called during DRC release. */
-void spapr_core_release(DeviceState *dev)
-{
- HotplugHandler *hotplug_ctrl;
-
- hotplug_ctrl = qdev_get_hotplug_handler(dev);
- hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort);
-}
-
static
void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
@@ -3159,27 +3141,6 @@ static void spapr_machine_device_plug(HotplugHandler
*hotplug_dev,
}
}
-static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
- DeviceState *dev, Error **errp)
-{
- sPAPRMachineState *sms = SPAPR_MACHINE(qdev_get_machine());
- MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
-
- if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
- if (spapr_ovec_test(sms->ov5_cas, OV5_HP_EVT)) {
- spapr_memory_unplug(hotplug_dev, dev, errp);
- } else {
- error_setg(errp, "Memory hot unplug not supported for this guest");
- }
- } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
- if (!mc->has_hotpluggable_cpus) {
- error_setg(errp, "CPU hot unplug not supported on this machine");
- return;
- }
- spapr_core_unplug(hotplug_dev, dev, errp);
- }
-}
-
static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
@@ -3397,7 +3358,6 @@ static void spapr_machine_class_init(ObjectClass *oc,
void *data)
mc->get_hotplug_handler = spapr_get_hotplug_handler;
hc->pre_plug = spapr_machine_device_pre_plug;
hc->plug = spapr_machine_device_plug;
- hc->unplug = spapr_machine_device_unplug;
mc->cpu_index_to_instance_props = spapr_cpu_index_to_props;
mc->possible_cpu_arch_ids = spapr_possible_cpu_arch_ids;
hc->unplug_request = spapr_machine_device_unplug_request;
--
2.13.3
- [Qemu-ppc] [PULL 00/21] ppc-for-2.10 queue 20170717, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 04/21] spapr: Treat devices added before inbound migration as coldplugged, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 20/21] spapr: fix memory leak in spapr_core_pre_plug(), David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 07/21] spapr: Abort on delete failure in spapr_drc_release(), David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 05/21] spapr: Remove 'awaiting_allocation' DRC flag, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 01/21] spapr: Remove unnecessary instance_size specifications from DRC subtypes, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 09/21] spapr: Cleanups relating to DRC awaiting_release field, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 12/21] spapr: Implement DR-indicator for physical DRCs only, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 19/21] pseries: Allow HPT resizing with KVM, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 06/21] spapr: Simplify unplug path,
David Gibson <=
- [Qemu-ppc] [PULL 02/21] spapr: migrate pending_events of spapr state, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 08/21] spapr: Refactor spapr_drc_detach(), David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 03/21] spapr: Minor cleanups to events handling, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 17/21] pseries: Enable HPT resizing for 2.10, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 13/21] spapr: fix potential memory leak in spapr_core_plug(), David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 21/21] target/ppc: fix CPU hotplug when radix is enabled (TCG), David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 10/21] spapr: Consolidate DRC state variables, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 14/21] ppc/pnv: Remove unused XICSState reference, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 18/21] pseries: Use smaller default hash page tables when guest can resize, David Gibson, 2017/07/17
- [Qemu-ppc] [PULL 11/21] spapr: Remove sPAPRConfigureConnectorState sub-structure, David Gibson, 2017/07/17