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,
Nathan Fontenot <nfont@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v4 02/17] spapr_drc: initial implementation of sPAPRDRConnector device
Date: Sun, 25 Jan 2015 22:56:06 -0600 [thread overview]
Message-ID: <20150126045606.23721.1241@loki> (raw)
In-Reply-To: <CAGZKiBoudRtCcUioosMYCo8aH2533m=6YkGXxfsNi_vKWOtsZg@mail.gmail.com>
Quoting Bharata B Rao (2015-01-02 04:32:58)
> On Tue, Dec 23, 2014 at 6:00 PM, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> > This device emulates a firmware abstraction used by pSeries guests to
> > manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
> > memory, and CPUs. It is conceptually similar to an SHPC device,
> > complete with LED indicators to identify individual slots to physical
> > physical users and indicate when it is safe to remove a device. In
> > some cases it is also used to manage virtualized resources, such a
> > memory, CPUs, and physical-host bridges, which in the case of pSeries
> > guests are virtualized resources where the physical components are
> > managed by the host.
> >
> > Guests communicate with these DR Connectors using RTAS calls,
> > generally by addressing the unique DRC index associated with a
> > particular connector for a particular resource. For introspection
> > purposes we expose this state initially as QOM properties, and
> > in subsequent patches will introduce the RTAS calls that make use of
> > it. This constitutes to the 'guest' interface.
> >
> > On the QEMU side we provide an attach/detach interface to associate
> > or cleanup a DeviceState with a particular sPAPRDRConnector in
> > response to hotplug/unplug, respectively. This constitutes the
> > 'physical' interface to the DR Connector.
> >
> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > ---
> > hw/ppc/Makefile.objs | 2 +-
> > hw/ppc/spapr_drc.c | 503 +++++++++++++++++++++++++++++++++++++++++++++
> > include/hw/ppc/spapr_drc.h | 201 ++++++++++++++++++
> > 3 files changed, 705 insertions(+), 1 deletion(-)
> > create mode 100644 hw/ppc/spapr_drc.c
> > create mode 100644 include/hw/ppc/spapr_drc.h
> >
> > diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
> > index 19d9920..ea010fd 100644
> > --- a/hw/ppc/Makefile.objs
> > +++ b/hw/ppc/Makefile.objs
> > @@ -3,7 +3,7 @@ obj-y += ppc.o ppc_booke.o
> > # IBM pSeries (sPAPR)
> > obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
> > obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
> > -obj-$(CONFIG_PSERIES) += spapr_pci.o
> > +obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_drc.o
> > ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
> > obj-y += spapr_pci_vfio.o
> > endif
> > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> > new file mode 100644
> > index 0000000..f81c6d1
> > --- /dev/null
> > +++ b/hw/ppc/spapr_drc.c
> > @@ -0,0 +1,503 @@
> > +/*
> > + * QEMU SPAPR Dynamic Reconfiguration Connector Implementation
> > + *
> > + * Copyright IBM Corp. 2014
> > + *
> > + * Authors:
> > + * Michael Roth <mdroth@linux.vnet.ibm.com>
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> > + * See the COPYING file in the top-level directory.
> > + */
> > +
> > +#include "hw/ppc/spapr_drc.h"
> > +#include "qom/object.h"
> > +#include "hw/qdev.h"
> > +#include "qapi/visitor.h"
> > +#include "qemu/error-report.h"
> > +
> > +/* #define DEBUG_SPAPR_DRC */
> > +
> > +#ifdef DEBUG_SPAPR_DRC
> > +#define DPRINTF(fmt, ...) \
> > + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
> > +#define DPRINTFN(fmt, ...) \
> > + do { DPRINTF(fmt, ## __VA_ARGS__); fprintf(stderr, "\n"); } while (0)
> > +#else
> > +#define DPRINTF(fmt, ...) \
> > + do { } while (0)
> > +#define DPRINTFN(fmt, ...) \
> > + do { } while (0)
> > +#endif
> > +
> > +#define DRC_CONTAINER_PATH "/dr-connector"
> > +#define DRC_INDEX_TYPE_SHIFT 28
> > +#define DRC_INDEX_ID_MASK ~(~0 << DRC_INDEX_TYPE_SHIFT)
> > +
> > +static int set_isolation_state(sPAPRDRConnector *drc,
> > + sPAPRDRIsolationState state)
> > +{
> > + sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
> > +
> > + DPRINTFN("set_isolation_state: %x", state);
> > + drc->isolation_state = state;
> > + if (drc->awaiting_release &&
> > + drc->isolation_state == SPAPR_DR_ISOLATION_STATE_ISOLATED) {
> > + drck->detach(drc, DEVICE(drc->dev), drc->detach_cb,
> > + drc->detach_cb_opaque);
> > + }
> > + return 0;
> > +}
> > +
> > +static int set_indicator_state(sPAPRDRConnector *drc,
> > + sPAPRDRIndicatorState state)
> > +{
> > + DPRINTFN("set_indicator_state: %x", state);
> > + drc->indicator_state = state;
> > + return 0;
> > +}
> > +
> > +static int set_allocation_state(sPAPRDRConnector *drc,
> > + sPAPRDRAllocationState state)
> > +{
> > + DPRINTFN("set_allocation_state: %x", state);
> > + drc->indicator_state = state;
> > + return 0;
> > +}
> > +
> > +static uint32_t get_id(sPAPRDRConnector *drc)
> > +{
> > + /* this value is unique for DRCs of a particular type, but may
> > + * overlap with the id's of other DRCs. the value is used both
> > + * to calculate a unique (across all DRC types) index, as well
> > + * as generating the ibm,drc-names OFDT property that describes
> > + * DRCs
> > + */
> > + return drc->id;
> > +}
> > +
> > +static sPAPRDRConnectorTypeShift get_type_shift(sPAPRDRConnectorType type)
> > +{
> > + uint32_t shift = 0;
> > +
> > + g_assert(type != SPAPR_DR_CONNECTOR_TYPE_ANY);
> > + while (type != (1 << shift)) {
> > + shift++;
> > + }
> > + return shift;
> > +}
> > +
> > +static uint32_t get_index(sPAPRDRConnector *drc)
> > +{
> > + /* no set format for a drc index: it only needs to be globally
> > + * unique. this is how we encode the DRC type on bare-metal
> > + * however, so might as well do that here
> > + */
> > + return (get_type_shift(drc->type) << DRC_INDEX_TYPE_SHIFT) |
> > + (drc->id & DRC_INDEX_ID_MASK);
> > +}
> > +
> > +static uint32_t get_type(sPAPRDRConnector *drc)
> > +{
> > + return drc->type;
> > +}
> > +
> > +/*
> > + * dr-entity-sense sensor value
> > + * returned via get-sensor-state RTAS calls
> > + * as expected by state diagram in PAPR+ 2.7, 13.4
> > + * based on the current allocation/indicator/power states
> > + * for the DR connector.
> > + */
> > +static sPAPRDREntitySense entity_sense(sPAPRDRConnector *drc)
> > +{
> > + if (drc->dev) {
> > + /* this assumes all PCI devices are assigned to
> > + * a 'live insertion' power domain, where QEMU
> > + * manages power state automatically as opposed
> > + * to the guest. present, non-PCI resources are
> > + * unaffected by power state.
> > + */
> > + return SPAPR_DR_ENTITY_SENSE_PRESENT;
> > + }
>
> Hotplugged CPU comes with drc->dev set (set during
> sPAPRDRConnectorClass->attach()) and hence ends up returning PRESENT
> but kernel expects UNUSABLE during get-sensor-state rtas call.
That does seem to be in agreement with the state machine in PAPR+ 13.4.
I've updated the check to return UNUSABLE/EMPTY if the allocation
state is UNUSABLE when dealing with logical DR devices. For PCI we
transition to PRESENT have plug/power-on regardless of allocation
state.
>
> > +
> > + if (drc->type == SPAPR_DR_CONNECTOR_TYPE_PCI) {
> > + /* PCI devices, and only PCI devices, use PRESENT
> > + * in cases where we'd otherwise use UNUSABLE
> > + */
> > + return SPAPR_DR_ENTITY_SENSE_EMPTY;
> > + }
> > + return SPAPR_DR_ENTITY_SENSE_UNUSABLE;
> > +}
next prev parent reply other threads:[~2015-01-26 21:33 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-23 12:30 [Qemu-devel] [PATCH v4 00/17] spapr: add support for pci hotplug Michael Roth
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 01/17] docs: add sPAPR hotplug/dynamic-reconfiguration documentation Michael Roth
2015-01-16 5:28 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 02/17] spapr_drc: initial implementation of sPAPRDRConnector device Michael Roth
2015-01-02 10:32 ` Bharata B Rao
2015-01-26 4:56 ` Michael Roth [this message]
2015-01-16 6:19 ` David Gibson
2015-01-26 4:01 ` Michael Roth
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 03/17] spapr_rtas: add get/set-power-level RTAS interfaces Michael Roth
2015-01-16 6:21 ` David Gibson
2015-01-26 5:21 ` Michael Roth
2015-01-27 5:24 ` David Gibson
2015-01-27 21:36 ` Michael Roth
2015-01-27 22:05 ` Tyrel Datwyler
2015-01-28 0:42 ` Michael Roth
2015-02-09 16:29 ` Nathan Fontenot
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 04/17] spapr_rtas: add set-indicator RTAS interface Michael Roth
2015-01-16 6:25 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 05/17] spapr_rtas: add get-sensor-state " Michael Roth
2015-01-16 6:28 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 06/17] spapr: add rtas_st_buffer_direct() helper Michael Roth
2015-01-19 3:25 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 07/17] spapr_rtas: add ibm, configure-connector RTAS interface Michael Roth
2015-01-19 3:44 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 08/17] spapr_events: re-use EPOW event infrastructure for hotplug events Michael Roth
2015-01-19 4:31 ` David Gibson
2015-01-26 16:56 ` Michael Roth
2015-01-27 5:27 ` David Gibson
2015-01-28 3:56 ` Bharata B Rao
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 09/17] spapr_events: event-scan RTAS interface Michael Roth
2015-01-19 4:34 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 10/17] spapr_drc: add spapr_drc_populate_dt() Michael Roth
2015-01-19 5:15 ` David Gibson
2015-01-26 20:35 ` Michael Roth
2015-01-27 5:30 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 11/17] spapr: introduce pseries-2.3 machine type Michael Roth
2015-01-19 5:16 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 12/17] spapr_pci: add dynamic-reconfiguration option for spapr-pci-host-bridge Michael Roth
2015-01-19 5:18 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 13/17] spapr_pci: create DRConnectors for each PCI slot during PHB realize Michael Roth
2015-01-19 5:20 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 14/17] spapr_pci: populate DRC dt entries for PHBs Michael Roth
2015-01-19 5:22 ` David Gibson
2015-01-26 20:44 ` Michael Roth
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 15/17] pci: make pci_bar useable outside pci.c Michael Roth
2015-01-19 5:24 ` David Gibson
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 16/17] spapr_pci: enable basic hotplug operations Michael Roth
2015-01-19 5:58 ` David Gibson
2015-01-26 21:17 ` Michael Roth
2015-01-27 5:37 ` David Gibson
2015-01-23 5:17 ` Alexey Kardashevskiy
2015-01-26 21:20 ` Michael Roth
2014-12-23 12:30 ` [Qemu-devel] [PATCH v4 17/17] spapr_pci: emit hotplug add/remove events during hotplug Michael Roth
2015-01-19 6:00 ` David Gibson
2015-01-26 21:32 ` 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=20150126045606.23721.1241@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).