qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: mdroth@linux.vnet.ibm.com, danielhb@linux.vnet.ibm.com,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org, lvivier@redhat.com,
	sjitindarsingh@gmail.com, bharata@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCHv2 4/8] spapr: Refactor spapr_drc_detach()
Date: Thu, 13 Jul 2017 10:53:38 +1000	[thread overview]
Message-ID: <20170713005338.GQ4083@umbus.fritz.box> (raw)
In-Reply-To: <20170712134715.46aec1e0@bahia.lan>

[-- Attachment #1: Type: text/plain, Size: 7587 bytes --]

On Wed, Jul 12, 2017 at 01:47:15PM +0200, Greg Kurz wrote:
> On Wed, 12 Jul 2017 15:53:13 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > This function has two unused parameters - remove them.
> > 
> > It also sets awaiting_release on all paths, except one.  On that path
> > setting it is harmless, since it will be immediately cleared by
> > spapr_drc_release().  So factor it out of the if statements.
> > 
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> 
> Patch 3 drops the hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort)
> lines that could be called below spapr_drc_detach(), but we still have:
> 
> spapr_drc_detach()
>  spapr_drc_release()
>   object_property_del(OBJECT(drc), "device", NULL);
>                                               ^^
> Should this be &error_abort or should we pass an Error ** down to here ?
> (which, would require to add an errp argument to both spapr_drc_release()
>  and spapr_drc_reset())
> 
> I would favor &error_abort since a failure in object_property_del() would
> mean we're calling spapr_drc_detach() on a DRC that wasn't attached to a
> device... ie, a bug. In this case:

Done, although as a separate patch, since it's not really tied to the
changes here.

> 
> Reviewed-by: Greg Kurz <groug@kaod.org>
> 
> >  hw/ppc/spapr.c             | 11 +++--------
> >  hw/ppc/spapr_drc.c         | 12 ++++++------
> >  hw/ppc/spapr_pci.c         |  7 +------
> >  include/hw/ppc/spapr_drc.h |  2 +-
> >  4 files changed, 11 insertions(+), 21 deletions(-)
> > 
> > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > index ff2aa6b..5c528e2 100644
> > --- a/hw/ppc/spapr.c
> > +++ b/hw/ppc/spapr.c
> > @@ -2654,7 +2654,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
> >                  addr -= SPAPR_MEMORY_BLOCK_SIZE;
> >                  drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
> >                                        addr / SPAPR_MEMORY_BLOCK_SIZE);
> > -                spapr_drc_detach(drc, dev, NULL);
> > +                spapr_drc_detach(drc);
> >              }
> >              g_free(fdt);
> >              error_propagate(errp, local_err);
> > @@ -2877,7 +2877,7 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
> >                                addr / SPAPR_MEMORY_BLOCK_SIZE);
> >          g_assert(drc);
> >  
> > -        spapr_drc_detach(drc, dev, errp);
> > +        spapr_drc_detach(drc);
> >          addr += SPAPR_MEMORY_BLOCK_SIZE;
> >      }
> >  
> > @@ -2944,7 +2944,6 @@ void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,
> >  {
> >      int index;
> >      sPAPRDRConnector *drc;
> > -    Error *local_err = NULL;
> >      CPUCore *cc = CPU_CORE(dev);
> >      int smt = kvmppc_smt_threads();
> >  
> > @@ -2961,11 +2960,7 @@ void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev,
> >      drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * smt);
> >      g_assert(drc);
> >  
> > -    spapr_drc_detach(drc, dev, &local_err);
> > -    if (local_err) {
> > -        error_propagate(errp, local_err);
> > -        return;
> > -    }
> > +    spapr_drc_detach(drc);
> >  
> >      spapr_hotplug_req_remove_by_index(drc);
> >  }
> > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> > index 89ba3d6..08fc715 100644
> > --- a/hw/ppc/spapr_drc.c
> > +++ b/hw/ppc/spapr_drc.c
> > @@ -70,7 +70,7 @@ static uint32_t drc_isolate_physical(sPAPRDRConnector *drc)
> >          uint32_t drc_index = spapr_drc_index(drc);
> >          if (drc->configured) {
> >              trace_spapr_drc_set_isolation_state_finalizing(drc_index);
> > -            spapr_drc_detach(drc, DEVICE(drc->dev), NULL);
> > +            spapr_drc_detach(drc);
> >          } else {
> >              trace_spapr_drc_set_isolation_state_deferring(drc_index);
> >          }
> > @@ -134,7 +134,7 @@ static uint32_t drc_isolate_logical(sPAPRDRConnector *drc)
> >          uint32_t drc_index = spapr_drc_index(drc);
> >          if (drc->configured) {
> >              trace_spapr_drc_set_isolation_state_finalizing(drc_index);
> > -            spapr_drc_detach(drc, DEVICE(drc->dev), NULL);
> > +            spapr_drc_detach(drc);
> >          } else {
> >              trace_spapr_drc_set_isolation_state_deferring(drc_index);
> >          }
> > @@ -187,7 +187,7 @@ static uint32_t drc_set_unusable(sPAPRDRConnector *drc)
> >      if (drc->awaiting_release) {
> >          uint32_t drc_index = spapr_drc_index(drc);
> >          trace_spapr_drc_set_allocation_state_finalizing(drc_index);
> > -        spapr_drc_detach(drc, DEVICE(drc->dev), NULL);
> > +        spapr_drc_detach(drc);
> >      }
> >  
> >      return RTAS_OUT_SUCCESS;
> > @@ -371,20 +371,20 @@ static void spapr_drc_release(sPAPRDRConnector *drc)
> >      drc->dev = NULL;
> >  }
> >  
> > -void spapr_drc_detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp)
> > +void spapr_drc_detach(sPAPRDRConnector *drc)
> >  {
> >      trace_spapr_drc_detach(spapr_drc_index(drc));
> >  
> > +    drc->awaiting_release = true;
> > +
> >      if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
> >          trace_spapr_drc_awaiting_isolated(spapr_drc_index(drc));
> > -        drc->awaiting_release = true;
> >          return;
> >      }
> >  
> >      if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI &&
> >          drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
> >          trace_spapr_drc_awaiting_unusable(spapr_drc_index(drc));
> > -        drc->awaiting_release = true;
> >          return;
> >      }
> >  
> > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> > index 1e84c55..092a2f5 100644
> > --- a/hw/ppc/spapr_pci.c
> > +++ b/hw/ppc/spapr_pci.c
> > @@ -1478,7 +1478,6 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler,
> >      PCIDevice *pdev = PCI_DEVICE(plugged_dev);
> >      sPAPRDRConnectorClass *drck;
> >      sPAPRDRConnector *drc = spapr_phb_get_pci_drc(phb, pdev);
> > -    Error *local_err = NULL;
> >  
> >      if (!phb->dr_enabled) {
> >          error_setg(errp, QERR_BUS_NO_HOTPLUG,
> > @@ -1516,11 +1515,7 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler,
> >              }
> >          }
> >  
> > -        spapr_drc_detach(drc, DEVICE(pdev), &local_err);
> > -        if (local_err) {
> > -            error_propagate(errp, local_err);
> > -            return;
> > -        }
> > +        spapr_drc_detach(drc);
> >  
> >          /* if this isn't func 0, defer unplug event. otherwise signal removal
> >           * for all present functions
> > diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
> > index 18a196e..fc8b721 100644
> > --- a/include/hw/ppc/spapr_drc.h
> > +++ b/include/hw/ppc/spapr_drc.h
> > @@ -242,6 +242,6 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
> >  
> >  void spapr_drc_attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt,
> >                        int fdt_start_offset, Error **errp);
> > -void spapr_drc_detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp);
> > +void spapr_drc_detach(sPAPRDRConnector *drc);
> >  
> >  #endif /* HW_SPAPR_DRC_H */
> 



-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2017-07-13  0:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12  5:53 [Qemu-devel] [PATCHv2 0/8] spapr: DRC cleanups (part VI) David Gibson
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 1/8] spapr: Treat devices added before inbound migration as coldplugged David Gibson
2017-07-12  8:41   ` Greg Kurz
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 2/8] spapr: Remove 'awaiting_allocation' DRC flag David Gibson
2017-07-12  9:38   ` Laurent Vivier
2017-07-12 10:00   ` Greg Kurz
2017-07-12 11:05     ` David Gibson
2017-07-12 11:27       ` Greg Kurz
2017-07-12 17:04         ` Greg Kurz
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 3/8] spapr: Simplify unplug path David Gibson
2017-07-12 10:04   ` Greg Kurz
2017-07-12 10:31     ` Greg Kurz
2017-07-13  0:30       ` David Gibson
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 4/8] spapr: Refactor spapr_drc_detach() David Gibson
2017-07-12 11:47   ` Greg Kurz
2017-07-13  0:53     ` David Gibson [this message]
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 5/8] spapr: Cleanups relating to DRC awaiting_release field David Gibson
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 6/8] spapr: Consolidate DRC state variables David Gibson
2017-07-12 17:36   ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 7/8] spapr: Remove sPAPRConfigureConnectorState sub-structure David Gibson
2017-07-12 17:40   ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-07-12  5:53 ` [Qemu-devel] [PATCHv2 8/8] spapr: Implement DR-indicator for physical DRCs only David Gibson
2017-07-12 17:44   ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-07-12 13:48 ` [Qemu-devel] [Qemu-ppc] [PATCHv2 0/8] spapr: DRC cleanups (part VI) Daniel Henrique Barboza
2017-07-13  0:57   ` David Gibson
2017-07-13 10:13     ` Daniel Henrique Barboza
2017-07-14  6:53       ` David Gibson
2017-07-14 13:50         ` Daniel Henrique Barboza
2017-07-15  2:42           ` David Gibson
2017-07-13  1:09 ` [Qemu-devel] " David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170713005338.GQ4083@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=danielhb@linux.vnet.ibm.com \
    --cc=groug@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=sjitindarsingh@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).