[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/30] spapr: Simplify error path of spapr_core_plug()
From: |
David Gibson |
Subject: |
[PULL 19/30] spapr: Simplify error path of spapr_core_plug() |
Date: |
Fri, 11 Dec 2020 15:14:56 +1100 |
From: Greg Kurz <groug@kaod.org>
spapr_core_pre_plug() already guarantees that the slot for the given core
ID is available. It is thus safe to assume that spapr_find_cpu_slot()
returns a slot during plug. Turn the error path into an assertion.
It is also safe to assume that no device is attached to the corresponding
DRC and that spapr_drc_attach() shouldn't fail.
Pass &error_abort to spapr_drc_attach() and simplify error handling.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20201201113728.885700-4-groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 583ec93e83..9dd8deb8c8 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3741,8 +3741,7 @@ int spapr_core_dt_populate(SpaprDrc *drc,
SpaprMachineState *spapr,
return 0;
}
-static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
- Error **errp)
+static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev)
{
SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
MachineClass *mc = MACHINE_GET_CLASS(spapr);
@@ -3757,20 +3756,20 @@ static void spapr_core_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
int i;
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
- if (!core_slot) {
- error_setg(errp, "Unable to find CPU core with core-id: %d",
- cc->core_id);
- return;
- }
+ g_assert(core_slot); /* Already checked in spapr_core_pre_plug() */
+
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU,
spapr_vcpu_id(spapr, cc->core_id));
g_assert(drc || !mc->has_hotpluggable_cpus);
if (drc) {
- if (!spapr_drc_attach(drc, dev, errp)) {
- return;
- }
+ /*
+ * spapr_core_pre_plug() already buys us this is a brand new
+ * core being plugged into a free slot. Nothing should already
+ * be attached to the corresponding DRC.
+ */
+ spapr_drc_attach(drc, dev, &error_abort);
if (hotplugged) {
/*
@@ -4012,7 +4011,7 @@ static void spapr_machine_device_plug(HotplugHandler
*hotplug_dev,
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
spapr_memory_plug(hotplug_dev, dev);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
- spapr_core_plug(hotplug_dev, dev, errp);
+ spapr_core_plug(hotplug_dev, dev);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE)) {
spapr_phb_plug(hotplug_dev, dev);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) {
--
2.29.2
- [PULL 11/30] ppc/translate: Turn the helper macros into functions, (continued)
- [PULL 11/30] ppc/translate: Turn the helper macros into functions, David Gibson, 2020/12/10
- [PULL 07/30] spapr: Do TPM proxy hotplug sanity checks at pre-plug, David Gibson, 2020/12/10
- [PULL 06/30] spapr: Do PHB hoplug sanity check at pre-plug, David Gibson, 2020/12/10
- [PULL 15/30] hw/ppc/spapr_tpm_proxy: Fix hexadecimal format string specifier, David Gibson, 2020/12/10
- [PULL 16/30] xive: Add trace events, David Gibson, 2020/12/10
- [PULL 10/30] ppc/translate: Fix unordered f64/f128 comparisons, David Gibson, 2020/12/10
- [PULL 08/30] target/ppc: replaced the TODO with LOG_UNIMP and add break for silence warnings, David Gibson, 2020/12/10
- [PULL 14/30] ppc/translate: Rewrite gen_lxvdsx to use gvec primitives, David Gibson, 2020/12/10
- [PULL 12/30] ppc/translate: Delay NaN checking after comparison, David Gibson, 2020/12/10
- [PULL 13/30] ppc/translate: Raise exceptions after setting the cc, David Gibson, 2020/12/10
- [PULL 19/30] spapr: Simplify error path of spapr_core_plug(),
David Gibson <=
- [PULL 23/30] MAINTAINERS: Add Greg Kurz as co-maintainer for ppc, David Gibson, 2020/12/10
- [PULL 21/30] target/ppc: Remove "compat" property of server class POWER CPUs, David Gibson, 2020/12/10
- [PULL 30/30] spapr.c: set a 'kvm-type' default value instead of relying on NULL, David Gibson, 2020/12/10
- [PULL 18/30] spapr: Abort if ppc_set_compat() fails for hot-plugged CPUs, David Gibson, 2020/12/10
- [PULL 17/30] spapr: Fix pre-2.10 dummy ICP hack, David Gibson, 2020/12/10
- [PULL 27/30] spapr: Pass sPAPR machine state down to spapr_pci_switch_vga(), David Gibson, 2020/12/10
- [PULL 25/30] ppc/translate: Use POWERPC_MMU_64 to detect 64-bit MMU models, David Gibson, 2020/12/10
- [PULL 29/30] spapr: Pass sPAPR machine state to some RTAS events handling functions, David Gibson, 2020/12/10
- [PULL 28/30] spapr: Don't use qdev_get_machine() in spapr_msi_write(), David Gibson, 2020/12/10
- [PULL 26/30] target/ppc: Introduce an mmu_is_64bit() helper, David Gibson, 2020/12/10