All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
To: David Gibson <david@gibson.dropbear.id.au>,
	mdroth@linux.vnet.ibm.com, groug@kaod.org
Cc: lvivier@redhat.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	sjitindarsingh@gmail.com, bharata@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCHv2 8/8] spapr: Implement DR-indicator for physical DRCs only
Date: Wed, 12 Jul 2017 14:44:28 -0300	[thread overview]
Message-ID: <809fccd8-e9f8-9ff9-d706-59ce18a172b0@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170712055317.26225-9-david@gibson.dropbear.id.au>



On 07/12/2017 02:53 AM, David Gibson wrote:
> According to PAPR, the DR-indicator should only be valid for physical DRCs,
> not logical DRCs.  At the moment we implement it for all DRCs, so restrict
> it to physical ones only.
>
> We move the state to the physical DRC subclass, which means adding some
> QOM boilerplate to handle the newly distinct type.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>

> ---
>   hw/ppc/spapr_drc.c         | 68 ++++++++++++++++++++++++++++++++++++++++++----
>   include/hw/ppc/spapr_drc.h | 13 ++++++---
>   2 files changed, 72 insertions(+), 9 deletions(-)
>
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index 423db80..39b7cef 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -478,7 +478,6 @@ static const VMStateDescription vmstate_spapr_drc = {
>       .needed = spapr_drc_needed,
>       .fields  = (VMStateField []) {
>           VMSTATE_UINT32(state, sPAPRDRConnector),
> -        VMSTATE_UINT32(dr_indicator, sPAPRDRConnector),
>           VMSTATE_END_OF_LIST()
>       }
>   };
> @@ -575,10 +574,63 @@ static void spapr_dr_connector_class_init(ObjectClass *k, void *data)
>       dk->user_creatable = false;
>   }
>
> +static bool drc_physical_needed(void *opaque)
> +{
> +    sPAPRDRCPhysical *drcp = (sPAPRDRCPhysical *)opaque;
> +    sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(drcp);
> +
> +    if ((drc->dev && (drcp->dr_indicator == SPAPR_DR_INDICATOR_ACTIVE))
> +        || (!drc->dev && (drcp->dr_indicator == SPAPR_DR_INDICATOR_INACTIVE))) {
> +        return false;
> +    }
> +    return true;
> +}
> +
> +static const VMStateDescription vmstate_spapr_drc_physical = {
> +    .name = "spapr_drc",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .needed = drc_physical_needed,
> +    .fields  = (VMStateField []) {
> +        VMSTATE_UINT32(dr_indicator, sPAPRDRCPhysical),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
> +static void drc_physical_reset(void *opaque)
> +{
> +    sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(opaque);
> +    sPAPRDRCPhysical *drcp = SPAPR_DRC_PHYSICAL(drc);
> +
> +    if (drc->dev) {
> +        drcp->dr_indicator = SPAPR_DR_INDICATOR_ACTIVE;
> +    } else {
> +        drcp->dr_indicator = SPAPR_DR_INDICATOR_INACTIVE;
> +    }
> +}
> +
> +static void realize_physical(DeviceState *d, Error **errp)
> +{
> +    sPAPRDRCPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
> +    Error *local_err = NULL;
> +
> +    realize(d, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
> +
> +    vmstate_register(DEVICE(drcp), spapr_drc_index(SPAPR_DR_CONNECTOR(drcp)),
> +                     &vmstate_spapr_drc_physical, drcp);
> +    qemu_register_reset(drc_physical_reset, drcp);
> +}
> +
>   static void spapr_drc_physical_class_init(ObjectClass *k, void *data)
>   {
> +    DeviceClass *dk = DEVICE_CLASS(k);
>       sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
>
> +    dk->realize = realize_physical;
>       drck->dr_entity_sense = physical_entity_sense;
>       drck->isolate = drc_isolate_physical;
>       drck->unisolate = drc_unisolate_physical;
> @@ -640,7 +692,7 @@ static const TypeInfo spapr_dr_connector_info = {
>   static const TypeInfo spapr_drc_physical_info = {
>       .name          = TYPE_SPAPR_DRC_PHYSICAL,
>       .parent        = TYPE_SPAPR_DR_CONNECTOR,
> -    .instance_size = sizeof(sPAPRDRConnector),
> +    .instance_size = sizeof(sPAPRDRCPhysical),
>       .class_init    = spapr_drc_physical_class_init,
>       .abstract      = true,
>   };
> @@ -883,12 +935,18 @@ static uint32_t rtas_set_dr_indicator(uint32_t idx, uint32_t state)
>   {
>       sPAPRDRConnector *drc = spapr_drc_by_index(idx);
>
> -    if (!drc) {
> -        return RTAS_OUT_PARAM_ERROR;
> +    if (!drc || !object_dynamic_cast(OBJECT(drc), TYPE_SPAPR_DRC_PHYSICAL)) {
> +        return RTAS_OUT_NO_SUCH_INDICATOR;
> +    }
> +    if ((state != SPAPR_DR_INDICATOR_INACTIVE)
> +        && (state != SPAPR_DR_INDICATOR_ACTIVE)
> +        && (state != SPAPR_DR_INDICATOR_IDENTIFY)
> +        && (state != SPAPR_DR_INDICATOR_ACTION)) {
> +        return RTAS_OUT_PARAM_ERROR; /* bad state parameter */
>       }
>
>       trace_spapr_drc_set_dr_indicator(idx, state);
> -    drc->dr_indicator = state;
> +    SPAPR_DRC_PHYSICAL(drc)->dr_indicator = state;
>       return RTAS_OUT_SUCCESS;
>   }
>
> diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
> index 9d4fd41..a7958d0 100644
> --- a/include/hw/ppc/spapr_drc.h
> +++ b/include/hw/ppc/spapr_drc.h
> @@ -33,7 +33,7 @@
>   #define SPAPR_DRC_PHYSICAL_CLASS(klass) \
>           OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \
>                              TYPE_SPAPR_DRC_PHYSICAL)
> -#define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \
> +#define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(sPAPRDRCPhysical, (obj), \
>                                                TYPE_SPAPR_DRC_PHYSICAL)
>
>   #define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical"
> @@ -198,9 +198,6 @@ typedef struct sPAPRDRConnector {
>       uint32_t id;
>       Object *owner;
>
> -    /* DR-indicator */
> -    uint32_t dr_indicator;
> -
>       uint32_t state;
>
>       /* RTAS ibm,configure-connector state */
> @@ -232,6 +229,14 @@ typedef struct sPAPRDRConnectorClass {
>       void (*release)(DeviceState *dev);
>   } sPAPRDRConnectorClass;
>
> +typedef struct sPAPRDRCPhysical {
> +    /*< private >*/
> +    sPAPRDRConnector parent;
> +
> +    /* DR-indicator */
> +    uint32_t dr_indicator;
> +} sPAPRDRCPhysical;
> +
>   static inline bool spapr_drc_hotplugged(DeviceState *dev)
>   {
>       return dev->hotplugged && !runstate_check(RUN_STATE_INMIGRATE);

  reply	other threads:[~2017-07-12 17:44 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
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   ` Daniel Henrique Barboza [this message]
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=809fccd8-e9f8-9ff9-d706-59ce18a172b0@linux.vnet.ibm.com \
    --to=danielhb@linux.vnet.ibm.com \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --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 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.