From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Bharata B Rao <bharata.rao@gmail.com>
Cc: aik@ozlabs.ru, "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Alexander Graf <agraf@suse.de>,
ncmike@ncultra.org, "qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 09/12] spapr_pci: enable basic hotplug operations
Date: Thu, 04 Sep 2014 11:34:14 -0500 [thread overview]
Message-ID: <20140904163414.32021.85667@loki> (raw)
In-Reply-To: <20140904161215.32021.65613@loki>
Quoting Michael Roth (2014-09-04 11:12:15)
> Quoting Bharata B Rao (2014-09-04 10:08:20)
> > On Thu, Sep 4, 2014 at 4:33 AM, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> > >> > +static int spapr_device_hotplug_add(DeviceState *qdev, PCIDevice *dev)
> > >> > +{
> > >> > + sPAPRPHBState *phb = SPAPR_PCI_HOST_BRIDGE(qdev);
> > >> > + sPAPRDrcEntry *drc_entry, *drc_entry_slot;
> > >> > + sPAPRConfigureConnectorState *ccs;
> > >> > + int slot = PCI_SLOT(dev->devfn);
> > >> > + int offset, ret;
> > >> > + void *fdt_orig, *fdt;
> > >> > + char nodename[512];
> > >> > + uint32_t encoded = ENCODE_DRC_STATE(INDICATOR_ENTITY_SENSE_PRESENT,
> > >> > + INDICATOR_ENTITY_SENSE_MASK,
> > >> > + INDICATOR_ENTITY_SENSE_SHIFT);
> > >> > +
> > >>
> > >> I am building on this infrastructure of yours and adding CPU hotplug
> > >> support to sPAPR guests.
> > >>
> > >> So we start with dr state of UNUSABLE and change it to PRESENT like
> > >> above when performing hotplug operation. But after this, in case of
> > >> CPU hotplug, the CPU hotplug code in the kernel
> > >> (arch/powerpc/platforms/pseries/dlpar.c:dlpar_acquire_drc()) does
> > >> get-sensor-state rtas call and expects the dr state to be UNUSABLE. Is
> > >> the guest kernel right in expecting dr state to be in UNUSABLE state
> > >> like this ? I have in fact disabled this check in the guest kernel to
> > >> get a CPU hotplugged successfully, but wanted to understand the state
> > >> changes and the expectations from the guest kernel correctly.
> > >
> > > According to PAPR+ 2.7 13.5.3.3,
> > >
> > > PRESENT (1):
> > >
> > > Returned for logical and physical DR entities when the DR connector is
> > > allocated to the OS and the DR entity is present. For physical DR entities,
> > > this indicates that the DR connector actually has a DR entity plugged into
> > > it. For DR connectors of physical DR entities, the DR connector must be
> > > allocated to the OS to return this value, otherwise a status of -3, no such
> > > sensor implemented, will be returned from the get-sensor-state RTAS call. For
> > > DR connectors of logical DR entities, the DR connector must be allocated to
> > > the OS to return this value, otherwise a sensor value of 2 or 3 will be
> > > returned.
> > >
> > > UNUSABLE (2):
> > >
> > > Returned for logical DR entities when the DR entity is not currently
> > > available to the OS, but may possibly be made available to the OS by calling
> > > set-indicator with the allocation-state indicator, setting that indicator to
> > > usable.
> > >
> > > So it seems 'PRESENT' is in fact the right value immediately after PCI
> > > hotplug, but it doesn't seem clear from the documentation whether 'PRESENT'
> > > or 'UNUSABLE' is more correct immediately after CPU hotplug. What does
> > > seem clear as that UNUSABLE does not have any use in the case of PCI
> > > devices: just PRESENT/EMPTY(0).
> > >
> > > But we actually 0-initialize the sensor field for DRCEntrys corresponding
> > > to PCI devices, which corresponds to 'EMPTY' (0), so the handling seems
> > > correct for PCI devices...
> >
> > Thanks Michael for the above information on PRESENT and USABLE states.
> >
> > >
> > > And since we already initialize PHB sensors to UNUSABLE in the top-level
> > > DRC list, I'm not sure why adjacent CPU entries would be affected by what
> > > we do later for PCI devices?
> >
> > Sorry if I wasn't clear enough in my previous mail. CPU hotplug isn't
> > affected by what you do for PCI devices, but...
> >
> > > It seems like you'd just need to do the
> > > equivalent of what we do for PHBs during realize:
> >
> > when I try to do the same state changes for CPU hotplug, things don't
> > work as expected.
> >
> > >
> > > spapr_add_phb_to_drc_table(sphb->buid, 2 /* Unusable */);
> > >
> > > So I'm not sure where the need for guest kernel changes is coming from for
> > > CPU hotplug.
> >
> > When the resource is hotplugged, you change the state from UNUSABLE to
> > PRESENT in QEMU before signalling the guest (via check exception irq).
> > But the same state change in CPU hotplug case isn't as per guest
> > kernel's expectation.
> >
> > > Do you have a snippet of what the initialize/hot_add hooks
> > > like in your case?
> >
> > I am talking about this piece of code in the the kernel in
> > arch/powerpc/platforms/pseries/dlpar.c
> >
> > int dlpar_acquire_drc(u32 drc_index)
> > {
> > int dr_status, rc;
> >
> > rc = rtas_call(rtas_token("get-sensor-state"), 2, 2, &dr_status,
> > DR_ENTITY_SENSE, drc_index);
> > if (rc || dr_status != DR_ENTITY_UNUSABLE)
> > return -1;
> > ...
> > }
> >
> > I have circumvented this problem by not setting the state to PRESENT
> > in my current hotplug patch. You can refer to the same in
> > spapr_cpu_hotplug_add() routine that's part of my patch 14/15
> > (https://lists.gnu.org/archive/html/qemu-devel/2014-09/msg00757.html)
>
> Yah, that's what I was getting at: at least just to get things working
> for testing, just avoid the PRESENT bits in your hot_add_cpu hook rather
> than patching the guest. Unfortunately the documentation isn't particularly
> clear about which of these approaches is more correct as far as CPUs go. But
> looking at it again:
>
> UNUSABLE (2):
>
> Returned for logical DR entities when the DR entity is not currently
> available to the OS, but may possibly be made available to the OS by calling
> set-indicator with the allocation-state indicator, setting that indicator to
> usable.
>
> That 'usable' indicator setting is documented for set-indicator as (1), which
> happens to correspond to PRESENT (1). So my read would be that for 'physical'
> hotplug (like PCI), the firmware changes the indicator state to PRESENT/USABLE
> immediately after hotplug, whereas with 'logical' hotplug (like PHB/CPU), the
> guest OS signals this transition to USABLE through set-indicator calls for the
> 9003 sensor/allocation state after hotplug (which also seems to match up with
> the kernel code).
>
> This seems to correspond with the dlpar_acquire_drc() function, but I'm a
> little confused why that's not also called in the PHB path...I think maybe
> in that case it's handled by drmgr in userspace... will take another look
> to confirm.
Yah, here's the code from drmgr, same expectations:
int
acquire_drc(uint32_t drc_index)
{
int rc;
say(DEBUG, "Acquiring drc index 0x%x\n", drc_index);
rc = dr_entity_sense(drc_index);
if (rc != STATE_UNUSABLE) {
say(ERROR, "Entity sense failed for drc %x with %d\n%s\n",
drc_index, rc, entity_sense_error(rc));
return -1;
}
say(DEBUG, "Setting allocation state to 'alloc usable'\n");
rc = rtas_set_indicator(ALLOCATION_STATE, drc_index, ALLOC_USABLE);
if (rc) {
say(ERROR, "Allocation failed for drc %x with %d\n%s\n",
drc_index, rc, set_indicator_error(rc));
return -1;
}
say(DEBUG, "Setting indicator state to 'unisolate'\n");
rc = rtas_set_indicator(ISOLATION_STATE, drc_index, UNISOLATE);
if (rc) {
int ret;
rc = -1;
say(ERROR, "Unisolate failed for drc %x with %d\n%s\n",
drc_index, rc, set_indicator_error(rc));
ret = rtas_set_indicator(ALLOCATION_STATE, drc_index,
ALLOC_UNUSABLE);
if (ret) {
say(ERROR, "Failed recovery to unusable state after "
"unisolate failure for drc %x with %d\n%s\n",
drc_index, ret, set_indicator_error(ret));
}
}
return rc;
}
>
> >
> > Regards,
> > Bharata.
next prev parent reply other threads:[~2014-09-04 16:34 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-19 0:21 [Qemu-devel] [PATCH v3 00/12] spapr: add support for pci hotplug Michael Roth
2014-08-19 0:21 ` [Qemu-devel] [PATCH 01/12] spapr: populate DRC entries for root dt node Michael Roth
2014-08-26 7:55 ` Alexey Kardashevskiy
2014-08-26 8:24 ` Alexey Kardashevskiy
2014-08-26 15:25 ` Michael Roth
2014-08-26 15:41 ` Michael Roth
2014-08-29 18:27 ` Tyrel Datwyler
2014-08-29 23:15 ` Alexander Graf
2014-08-26 14:56 ` Michael Roth
2014-09-05 0:31 ` [Qemu-devel] [Qemu-ppc] " Tyrel Datwyler
2014-08-26 11:11 ` [Qemu-devel] " Alexander Graf
2014-08-26 16:47 ` Michael Roth
2014-08-26 17:16 ` Alexander Graf
2014-09-03 5:55 ` Bharata B Rao
2014-09-05 22:00 ` Tyrel Datwyler
2014-08-19 0:21 ` [Qemu-devel] [PATCH 02/12] spapr_pci: populate DRC dt entries for PHBs Michael Roth
2014-08-26 8:32 ` Alexey Kardashevskiy
2014-08-26 17:16 ` Michael Roth
2014-08-26 9:09 ` Alexey Kardashevskiy
2014-08-26 17:52 ` Michael Roth
2014-08-26 11:29 ` Alexander Graf
2014-08-26 18:30 ` Michael Roth
2014-08-19 0:21 ` [Qemu-devel] [PATCH 03/12] spapr: add helper to retrieve a PHB/device DrcEntry Michael Roth
2014-08-19 0:21 ` [Qemu-devel] [PATCH 04/12] spapr_pci: add set-indicator RTAS interface Michael Roth
2014-08-26 11:36 ` Alexander Graf
2014-09-05 2:55 ` Nathan Fontenot
2014-09-30 22:08 ` Michael Roth
2014-10-01 14:30 ` Alexander Graf
2014-11-26 4:51 ` Bharata B Rao
2014-11-26 4:54 ` Bharata B Rao
2014-11-26 6:27 ` Michael Roth
2014-12-01 4:57 ` Bharata B Rao
2014-12-23 15:12 ` Michael Roth
2015-01-01 6:35 ` Bharata B Rao
2014-08-19 0:21 ` [Qemu-devel] [PATCH 05/12] spapr_pci: add get/set-power-level RTAS interfaces Michael Roth
2014-08-19 0:21 ` [Qemu-devel] [PATCH 06/12] spapr_pci: add get-sensor-state RTAS interface Michael Roth
2014-09-05 0:34 ` Tyrel Datwyler
2014-08-19 0:21 ` [Qemu-devel] [PATCH 07/12] spapr_pci: add ibm, configure-connector " Michael Roth
2014-08-26 9:12 ` Alexey Kardashevskiy
2014-09-05 3:03 ` Nathan Fontenot
2014-08-26 11:39 ` Alexander Graf
2014-08-19 0:21 ` [Qemu-devel] [PATCH 08/12] pci: allow 0 address for PCI IO regions Michael Roth
2014-08-26 9:14 ` Alexey Kardashevskiy
2014-08-26 11:55 ` Peter Maydell
2014-08-26 18:34 ` Michael Roth
2014-08-26 11:41 ` Alexander Graf
2014-08-27 13:47 ` Michael S. Tsirkin
2014-08-28 21:21 ` Michael Roth
2014-08-28 21:33 ` Peter Maydell
2014-08-28 21:46 ` Michael S. Tsirkin
2014-08-19 0:21 ` [Qemu-devel] [PATCH 09/12] spapr_pci: enable basic hotplug operations Michael Roth
2014-08-26 9:40 ` Alexey Kardashevskiy
2014-08-26 12:30 ` Alexander Graf
2014-09-03 10:33 ` Bharata B Rao
2014-09-03 23:03 ` Michael Roth
2014-09-04 15:08 ` Bharata B Rao
2014-09-04 16:12 ` Michael Roth
2014-09-04 16:34 ` Michael Roth [this message]
2014-09-05 3:10 ` Nathan Fontenot
2014-09-05 17:17 ` [Qemu-devel] [Qemu-ppc] " Tyrel Datwyler
2014-08-19 0:21 ` [Qemu-devel] [PATCH 10/12] spapr_events: re-use EPOW event infrastructure for hotplug events Michael Roth
2014-08-26 9:28 ` Alexey Kardashevskiy
2014-08-19 0:21 ` [Qemu-devel] [PATCH 11/12] spapr_events: event-scan RTAS interface Michael Roth
2014-08-26 9:30 ` Alexey Kardashevskiy
2014-08-29 18:43 ` Tyrel Datwyler
2014-08-19 0:21 ` [Qemu-devel] [PATCH 12/12] spapr_pci: emit hotplug add/remove events during hotplug Michael Roth
2014-08-26 9:35 ` Alexey Kardashevskiy
2014-08-26 12:36 ` Alexander Graf
2014-08-26 9:24 ` [Qemu-devel] [PATCH v3 00/12] spapr: add support for pci hotplug Alexey Kardashevskiy
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=20140904163414.32021.85667@loki \
--to=mdroth@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=bharata.rao@gmail.com \
--cc=ncmike@ncultra.org \
--cc=nfont@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=tyreld@linux.vnet.ibm.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).