[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-6.0 5/9] spapr: Simplify error path of spapr_core_plug()
From: |
Greg Kurz |
Subject: |
Re: [PATCH for-6.0 5/9] spapr: Simplify error path of spapr_core_plug() |
Date: |
Tue, 24 Nov 2020 14:07:27 +0100 |
On Mon, 23 Nov 2020 16:13:18 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Sat, Nov 21, 2020 at 12:42:04AM +0100, Greg Kurz wrote:
> > 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>
>
> Applied to ppc-for-6.0, thanks.
>
This patch depends on the previous one.
> > ---
> > 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 da7586f548df..cfca033c7b14 100644
> > --- a/hw/ppc/spapr.c
> > +++ b/hw/ppc/spapr.c
> > @@ -3739,8 +3739,7 @@ int spapr_core_dt_populate(SpaprDrc *drc,
> > SpaprMachineState *spapr,
> > return 0;
> > }
> >
> > -static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> > - Error **errp)
../../hw/ppc/spapr.c: In function ‘spapr_core_plug’:
../../hw/ppc/spapr.c:3802:32: error: ‘errp’ undeclared (first use in this
function); did you mean ‘errno’?
errp) < 0) {
^~~~
errno
../../hw/ppc/spapr.c:3802:32: note: each undeclared identifier is reported only
once for each function it appears in
Please either drop it from ppc-for-6.0 or possibly adapt spapr_core_plug()
to handle errors from ppc_set_compat().
<my 2 cents>
Since I can't see how this could fail for a hotplugged CPU if it
succeeded for the boot CPU, I'd pass &error_abort despite this
being a hotplug path.
</my 2 cents>
> > +static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev)
> > {
> > SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
> > MachineClass *mc = MACHINE_GET_CLASS(spapr);
> > @@ -3755,20 +3754,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) {
> > /*
> > @@ -3981,7 +3980,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, errp);
> > } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) {
>
pgphiZ3bTEm7D.pgp
Description: OpenPGP digital signature
- [PATCH for-6.0 1/9] spapr: Do PCI device hotplug sanity checks at pre-plug only, (continued)
- [PATCH for-6.0 1/9] spapr: Do PCI device hotplug sanity checks at pre-plug only, Greg Kurz, 2020/11/20
- [PATCH for-6.0 2/9] spapr: Do NVDIMM/PC-DIMM device hotplug sanity checks at pre-plug only, Greg Kurz, 2020/11/20
- [PATCH for-6.0 3/9] spapr: Fix pre-2.10 dummy ICP hack, Greg Kurz, 2020/11/20
- [PATCH for-6.0 6/9] spapr: Make PHB placement functions and spapr_pre_plug_phb() return status, Greg Kurz, 2020/11/20
- [PATCH for-6.0 5/9] spapr: Simplify error path of spapr_core_plug(), Greg Kurz, 2020/11/20
- [PATCH for-6.0 7/9] spapr: Do PHB hoplug sanity check at pre-plug, Greg Kurz, 2020/11/20
- [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), Greg Kurz, 2020/11/20
- Re: [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), David Gibson, 2020/11/23
- Re: [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), Greg Kurz, 2020/11/23
- Re: [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), David Gibson, 2020/11/24
- Re: [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), Greg Kurz, 2020/11/25
- Re: [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), David Gibson, 2020/11/25
- Re: [PATCH for-6.0 4/9] spapr: Set compat mode in spapr_reset_vcpu(), Greg Kurz, 2020/11/26