From: David Gibson <david@gibson.dropbear.id.au>
To: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: mdroth@linux.vnet.ibm.com, sursingh@redhat.com, groug@kaod.org,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/6] spapr: Make DRC reset force DRC into known state
Date: Wed, 21 Jun 2017 15:24:55 +0800 [thread overview]
Message-ID: <20170621072455.GA12089@umbus> (raw)
In-Reply-To: <20170620082328.GA15438@in.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 8663 bytes --]
On Tue, Jun 20, 2017 at 01:53:28PM +0530, Bharata B Rao wrote:
> On Thu, Jun 08, 2017 at 03:09:28PM +1000, David Gibson wrote:
> > The reset handler for DRCs attempts several state transitions which are
> > subject to various checks and restrictions. But at reset time we know
> > there is no guest, so we can ignore most of the usual sequencing rules and
> > just set the DRC back to a known state. In fact, it's safer to do so.
> >
> > The existing code also has several redundant checks for
> > drc->awaiting_release inside a block which has already tested that. This
> > patch removes those and sets the DRC to a fixed initial state based only
> > on whether a device is currently plugged or not.
> >
> > With DRCs correctly reset to a state based on device presence, we don't
> > need to force state transitions as cold plugged devices are processed.
> > This allows us to remove all the callers of the set_*_state() methods from
> > outside spapr_drc.c.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > hw/ppc/spapr.c | 15 ---------------
> > hw/ppc/spapr_drc.c | 28 ++++++++--------------------
> > 2 files changed, 8 insertions(+), 35 deletions(-)
> >
> > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > index 01dda9e..c988e38 100644
> > --- a/hw/ppc/spapr.c
> > +++ b/hw/ppc/spapr.c
> > @@ -2545,12 +2545,6 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
> >
> > spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp);
> > addr += SPAPR_MEMORY_BLOCK_SIZE;
> > - if (!dev->hotplugged) {
> > - sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
> > - /* guests expect coldplugged LMBs to be pre-allocated */
> > - drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE);
> > - drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOLATED);
> > - }
> > }
> > /* send hotplug notification to the
> > * guest only in case of hotplugged memory
> > @@ -2901,15 +2895,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> > * of hotplugged CPUs.
> > */
> > spapr_hotplug_req_add_by_index(drc);
> > - } else {
> > - /*
> > - * Set the right DRC states for cold plugged CPU.
> > - */
> > - if (drc) {
> > - sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
> > - drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE);
> > - drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOLATED);
>
> So here you are removing the initial state setting for cold plugged CPUs and ...
>
> > - }
> > }
> > core_slot->cpu = OBJECT(dev);
> > }
> > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> > index dc4ac77..7e17f34 100644
> > --- a/hw/ppc/spapr_drc.c
> > +++ b/hw/ppc/spapr_drc.c
> > @@ -393,7 +393,6 @@ static bool release_pending(sPAPRDRConnector *drc)
> > static void reset(DeviceState *d)
> > {
> > sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
> > - sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
> >
> > trace_spapr_drc_reset(spapr_drc_index(drc));
> >
> > @@ -401,28 +400,17 @@ static void reset(DeviceState *d)
> > drc->ccs = NULL;
> >
> > /* immediately upon reset we can safely assume DRCs whose devices
> > - * are pending removal can be safely removed, and that they will
> > - * subsequently be left in an ISOLATED state. move the DRC to this
> > - * state in these cases (which will in turn complete any pending
> > - * device removals)
> > + * are pending removal can be safely removed.
> > */
> > if (drc->awaiting_release) {
> > - drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_ISOLATED);
> > - /* generally this should also finalize the removal, but if the device
> > - * hasn't yet been configured we normally defer removal under the
> > - * assumption that this transition is taking place as part of device
> > - * configuration. so check if we're still waiting after this, and
> > - * force removal if we are
> > - */
> > - if (drc->awaiting_release) {
> > - spapr_drc_detach(drc, DEVICE(drc->dev), NULL);
> > - }
> > + spapr_drc_release(drc);
> > + }
> >
> > - /* non-PCI devices may be awaiting a transition to UNUSABLE */
> > - if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI &&
> > - drc->awaiting_release) {
> > - drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_UNUSABLE);
> > - }
> > + drc->isolation_state = drc->dev ? SPAPR_DR_ISOLATION_STATE_UNISOLATED
> > + : SPAPR_DR_ISOLATION_STATE_ISOLATED;
> > + if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
> > + drc->allocation_state = drc->dev ? SPAPR_DR_ALLOCATION_STATE_USABLE
> > + : SPAPR_DR_ALLOCATION_STATE_UNUSABLE;
> > }
>
> ... adding it via reset. However you are setting drc->isolation_state and
> drc->allocation_state directly rather than going via
> drck->set_isolation_state() and drck->set_allocation_state() routines.
Yes, this is deliberate. At reset we *should not* be performing the
same checks on transitions that we do at other times. It is not only
easier, but also safer to set the new state directly.
> This results in awaiting_allocation not geting cleared for cold plugged
> CPUs. So the effect after this commit is that we can't remove the
> CPUs that are specified on cmdline using -device.
Ok, so I should be clearing awaiting_allocation as well (I have
another patch to post soon which gets rid of awaiting_allocation, but
we do want to avoid breaking bisect where possible).
I will fold a change to do that into ppc-for-2.10.
> The following fixes the issue for me:
>
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index fd9e07d..da6979a 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -450,13 +450,13 @@ static void reset(DeviceState *d)
> /* A device present at reset is coldplugged */
> drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
> if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
> - drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
> + drc_set_usable(drc);
> }
> } else {
> /* Otherwise device is absent, but might be hotplugged */
> drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
> if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
> - drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_UNUSABLE;
> + drc_set_unusable(drc);
> }
> }
> }
>
> However I thought this will restore the previous behaviour completely:
>
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index fd9e07d..b7726ef 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -433,6 +433,7 @@ static bool release_pending(sPAPRDRConnector *drc)
> static void reset(DeviceState *d)
> {
> sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
> + sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
>
> trace_spapr_drc_reset(spapr_drc_index(drc));
>
> @@ -448,15 +449,15 @@ static void reset(DeviceState *d)
>
> if (drc->dev) {
> /* A device present at reset is coldplugged */
> - drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
> + drck->unisolate(drc);
> if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
> - drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
> + drc_set_usable(drc);
> }
> } else {
> /* Otherwise device is absent, but might be hotplugged */
> - drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
> + drck->isolate(drc);
> if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
> - drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_UNUSABLE;
> + drc_set_unusable(drc);
> }
> }
> }
As noted above using the normal state transition functions misses the
point of this patch.
--
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 --]
next prev parent reply other threads:[~2017-06-21 8:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 5:09 [Qemu-devel] [PATCH 0/6] spapr: DRC cleanups (part IV) David Gibson
2017-06-08 5:09 ` [Qemu-devel] [PATCH 1/6] spapr: Start hotplugged PCI devices in ISOLATED state David Gibson
2017-06-19 10:11 ` Greg Kurz
2017-06-08 5:09 ` [Qemu-devel] [PATCH 2/6] spapr: Eliminate DRC 'signalled' state variable David Gibson
2017-06-19 10:12 ` Greg Kurz
2017-06-08 5:09 ` [Qemu-devel] [PATCH 3/6] spapr: Split DRC release from DRC detach David Gibson
2017-06-19 10:14 ` Greg Kurz
2017-06-08 5:09 ` [Qemu-devel] [PATCH 4/6] spapr: Make DRC reset force DRC into known state David Gibson
2017-06-19 10:25 ` Greg Kurz
2017-06-20 8:23 ` Bharata B Rao
2017-06-21 7:24 ` David Gibson [this message]
2017-06-08 5:09 ` [Qemu-devel] [PATCH 5/6] spapr: Clean up DRC set_allocation_state path David Gibson
2017-06-19 12:09 ` Greg Kurz
2017-06-08 5:09 ` [Qemu-devel] [PATCH 6/6] spapr: Clean up DRC set_isolation_state() path David Gibson
2017-06-19 13:16 ` Greg Kurz
2017-06-19 22:52 ` Michael Roth
2017-06-20 1:12 ` David Gibson
2017-06-15 17:10 ` [Qemu-devel] [PATCH 0/6] spapr: DRC cleanups (part IV) Laurent Vivier
2017-06-16 4:00 ` David Gibson
2017-06-16 7:57 ` Alexey Kardashevskiy
2017-06-19 19:51 ` David Gibson
2017-06-19 22:52 ` Michael Roth
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=20170621072455.GA12089@umbus \
--to=david@gibson.dropbear.id.au \
--cc=bharata@linux.vnet.ibm.com \
--cc=groug@kaod.org \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sursingh@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.