[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/30] spapr: Do PHB hoplug sanity check at pre-plug
From: |
David Gibson |
Subject: |
[PULL 06/30] spapr: Do PHB hoplug sanity check at pre-plug |
Date: |
Mon, 14 Dec 2020 15:57:43 +1100 |
From: Greg Kurz <groug@kaod.org>
We currently detect that a PHB index is already in use at plug time.
But this can be decteted at pre-plug in order to error out earlier.
This allows to pass &error_abort to spapr_drc_attach() and to end
up with a plug handler that doesn't need to report errors anymore.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20201120234208.683521-8-groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 28d266f7a7..ac115b0987 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3886,6 +3886,7 @@ static bool spapr_phb_pre_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(dev);
SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
const unsigned windows_supported = spapr_phb_windows_supported(sphb);
+ SpaprDrc *drc;
if (dev->hotplugged && !smc->dr_phb_enabled) {
error_setg(errp, "PHB hotplug not supported for this machine");
@@ -3897,6 +3898,12 @@ static bool spapr_phb_pre_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
return false;
}
+ drc = spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, sphb->index);
+ if (drc && drc->dev) {
+ error_setg(errp, "PHB %d already attached", sphb->index);
+ return false;
+ }
+
/*
* This will check that sphb->index doesn't exceed the maximum number of
* PHBs for the current machine type.
@@ -3910,8 +3917,7 @@ static bool spapr_phb_pre_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
errp);
}
-static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
- Error **errp)
+static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev)
{
SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
@@ -3927,9 +3933,8 @@ static void spapr_phb_plug(HotplugHandler *hotplug_dev,
DeviceState *dev,
/* hotplug hooks should check it's enabled before getting this far */
assert(drc);
- if (!spapr_drc_attach(drc, dev, errp)) {
- return;
- }
+ /* spapr_phb_pre_plug() already checked the DRC is attachable */
+ spapr_drc_attach(drc, dev, &error_abort);
if (hotplugged) {
spapr_hotplug_req_add_by_index(drc);
@@ -3997,7 +4002,7 @@ static void spapr_machine_device_plug(HotplugHandler
*hotplug_dev,
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
spapr_core_plug(hotplug_dev, dev, errp);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE)) {
- spapr_phb_plug(hotplug_dev, dev, errp);
+ spapr_phb_plug(hotplug_dev, dev);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) {
spapr_tpm_proxy_plug(hotplug_dev, dev, errp);
}
--
2.29.2
- [PULL 00/30] ppc-for-6.0 queue 20201214, David Gibson, 2020/12/13
- [PULL 01/30] spapr/xive: Turn some sanity checks into assertions, David Gibson, 2020/12/13
- [PULL 02/30] spapr/xics: Drop unused argument to xics_kvm_has_broken_disconnect(), David Gibson, 2020/12/13
- [PULL 05/30] spapr: Make PHB placement functions and spapr_pre_plug_phb() return status, David Gibson, 2020/12/13
- [PULL 03/30] spapr: Do PCI device hotplug sanity checks at pre-plug only, David Gibson, 2020/12/13
- [PULL 07/30] spapr: Do TPM proxy hotplug sanity checks at pre-plug, David Gibson, 2020/12/13
- [PULL 09/30] ppc: Add a missing break for PPC6xx_INPUT_TBEN, David Gibson, 2020/12/13
- [PULL 12/30] ppc/translate: Delay NaN checking after comparison, David Gibson, 2020/12/13
- [PULL 08/30] target/ppc: replaced the TODO with LOG_UNIMP and add break for silence warnings, David Gibson, 2020/12/13
- [PULL 04/30] spapr: Do NVDIMM/PC-DIMM device hotplug sanity checks at pre-plug only, David Gibson, 2020/12/13
- [PULL 06/30] spapr: Do PHB hoplug sanity check at pre-plug,
David Gibson <=
- [PULL 10/30] ppc/translate: Fix unordered f64/f128 comparisons, David Gibson, 2020/12/13
- [PULL 11/30] ppc/translate: Turn the helper macros into functions, David Gibson, 2020/12/13
- [PULL 13/30] ppc/translate: Raise exceptions after setting the cc, David Gibson, 2020/12/13
- [PULL 18/30] spapr: Abort if ppc_set_compat() fails for hot-plugged CPUs, David Gibson, 2020/12/13
- [PULL 15/30] hw/ppc/spapr_tpm_proxy: Fix hexadecimal format string specifier, David Gibson, 2020/12/13
- [PULL 14/30] ppc/translate: Rewrite gen_lxvdsx to use gvec primitives, David Gibson, 2020/12/13
- [PULL 19/30] spapr: Simplify error path of spapr_core_plug(), David Gibson, 2020/12/13
- [PULL 17/30] spapr: Fix pre-2.10 dummy ICP hack, David Gibson, 2020/12/13