qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Greg Kurz <groug@kaod.org>
Subject: Re: [Qemu-devel] [PATCH v2 1/5] ppc/xics: introduce a parent_realize in ICSStateClass
Date: Tue, 26 Jun 2018 12:18:21 +1000	[thread overview]
Message-ID: <20180626021821.GH22971@umbus.fritz.box> (raw)
In-Reply-To: <20180625091718.18544-2-clg@kaod.org>

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

On Mon, Jun 25, 2018 at 11:17:14AM +0200, Cédric Le Goater wrote:
> This makes possible to move the common ICSState code of the realize
> handlers in the ics-base class.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Applied to ppc-for-3.0, thanks.

> ---
>  include/hw/ppc/xics.h |  3 ++-
>  hw/intc/xics.c        | 37 ++++++++++++++++++++++---------------
>  hw/intc/xics_kvm.c    | 20 +++++++++++++++-----
>  3 files changed, 39 insertions(+), 21 deletions(-)
> 
> diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
> index 4b04b295a772..44e96e640070 100644
> --- a/include/hw/ppc/xics.h
> +++ b/include/hw/ppc/xics.h
> @@ -115,7 +115,8 @@ struct PnvICPState {
>  struct ICSStateClass {
>      DeviceClass parent_class;
>  
> -    void (*realize)(ICSState *s, Error **errp);
> +    DeviceRealize parent_realize;
> +
>      void (*pre_save)(ICSState *s);
>      int (*post_load)(ICSState *s, int version_id);
>      void (*reject)(ICSState *s, uint32_t irq);
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index 063491f38712..d6066d561fdc 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -618,30 +618,31 @@ static void ics_simple_initfn(Object *obj)
>      ics->offset = XICS_IRQ_BASE;
>  }
>  
> -static void ics_simple_realize(ICSState *ics, Error **errp)
> +static void ics_simple_realize(DeviceState *dev, Error **errp)
>  {
> -    if (!ics->nr_irqs) {
> -        error_setg(errp, "Number of interrupts needs to be greater 0");
> +    ICSState *ics = ICS_SIMPLE(dev);
> +    ICSStateClass *icsc = ICS_BASE_GET_CLASS(ics);
> +    Error *local_err = NULL;
> +
> +    icsc->parent_realize(dev, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
>          return;
>      }
> -    ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
> +
>      ics->qirqs = qemu_allocate_irqs(ics_simple_set_irq, ics, ics->nr_irqs);
>  
>      qemu_register_reset(ics_simple_reset, ics);
>  }
>  
> -static Property ics_simple_properties[] = {
> -    DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0),
> -    DEFINE_PROP_END_OF_LIST(),
> -};
> -
>  static void ics_simple_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
>      ICSStateClass *isc = ICS_BASE_CLASS(klass);
>  
> -    isc->realize = ics_simple_realize;
> -    dc->props = ics_simple_properties;
> +    device_class_set_parent_realize(dc, ics_simple_realize,
> +                                    &isc->parent_realize);
> +
>      dc->vmsd = &vmstate_ics_simple;
>      isc->reject = ics_simple_reject;
>      isc->resend = ics_simple_resend;
> @@ -659,7 +660,6 @@ static const TypeInfo ics_simple_info = {
>  
>  static void ics_base_realize(DeviceState *dev, Error **errp)
>  {
> -    ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
>      ICSState *ics = ICS_BASE(dev);
>      Object *obj;
>      Error *err = NULL;
> @@ -672,17 +672,24 @@ static void ics_base_realize(DeviceState *dev, Error **errp)
>      }
>      ics->xics = XICS_FABRIC(obj);
>  
> -
> -    if (icsc->realize) {
> -        icsc->realize(ics, errp);
> +    if (!ics->nr_irqs) {
> +        error_setg(errp, "Number of interrupts needs to be greater 0");
> +        return;
>      }
> +    ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
>  }
>  
> +static Property ics_base_properties[] = {
> +    DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
>  static void ics_base_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
>  
>      dc->realize = ics_base_realize;
> +    dc->props = ics_base_properties;
>  }
>  
>  static const TypeInfo ics_base_info = {
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index f511e50a8020..1f27eb497981 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -345,13 +345,17 @@ static void ics_kvm_reset(void *dev)
>      ics_set_kvm_state(ics, 1);
>  }
>  
> -static void ics_kvm_realize(ICSState *ics, Error **errp)
> +static void ics_kvm_realize(DeviceState *dev, Error **errp)
>  {
> -    if (!ics->nr_irqs) {
> -        error_setg(errp, "Number of interrupts needs to be greater 0");
> +    ICSState *ics = ICS_KVM(dev);
> +    ICSStateClass *icsc = ICS_BASE_GET_CLASS(ics);
> +    Error *local_err = NULL;
> +
> +    icsc->parent_realize(dev, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
>          return;
>      }
> -    ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
>      ics->qirqs = qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs);
>  
>      qemu_register_reset(ics_kvm_reset, ics);
> @@ -360,8 +364,14 @@ static void ics_kvm_realize(ICSState *ics, Error **errp)
>  static void ics_kvm_class_init(ObjectClass *klass, void *data)
>  {
>      ICSStateClass *icsc = ICS_BASE_CLASS(klass);
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> +
> +    /*
> +     * Use device_class_set_parent_realize() when ics-kvm inherits
> +     * directly from ics-base and not from ics-simple anymore.
> +     */
> +    dc->realize = ics_kvm_realize;
>  
> -    icsc->realize = ics_kvm_realize;
>      icsc->pre_save = ics_get_kvm_state;
>      icsc->post_load = ics_set_kvm_state;
>      icsc->synchronize_state = ics_synchronize_state;

-- 
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: 833 bytes --]

  reply	other threads:[~2018-06-26  2:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25  9:17 [Qemu-devel] [PATCH v2 0/5] rework the ICS classes inheritance tree Cédric Le Goater
2018-06-25  9:17 ` [Qemu-devel] [PATCH v2 1/5] ppc/xics: introduce a parent_realize in ICSStateClass Cédric Le Goater
2018-06-26  2:18   ` David Gibson [this message]
2018-06-25  9:17 ` [Qemu-devel] [PATCH v2 2/5] ppc/xics: move the instance_init handler under the ics-base class Cédric Le Goater
2018-06-26  2:21   ` David Gibson
2018-06-25  9:17 ` [Qemu-devel] [PATCH v2 3/5] ppx/xics: introduce a parent_reset in ICSStateClass Cédric Le Goater
2018-06-26  2:25   ` David Gibson
2018-06-25  9:17 ` [Qemu-devel] [PATCH v2 4/5] ppc/xics: move the vmstate structures under the ics-base class Cédric Le Goater
2018-06-26  2:30   ` David Gibson
2018-06-25  9:17 ` [Qemu-devel] [PATCH v2 5/5] ppc/xics: rework the ICS classes inheritance tree Cédric Le Goater
2018-06-26  3:21   ` David Gibson
2018-06-26 13:27 ` [Qemu-devel] [Qemu-ppc] [PATCH v2 0/5] " Greg Kurz
2018-06-26 16:37   ` Cédric Le Goater
2018-06-27  0:14     ` David Gibson
2018-06-27  6:34       ` Cédric Le Goater
2018-06-28  3:54         ` 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=20180626021821.GH22971@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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).