qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Greg Kurz <groug@kaod.org>, David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH for-5.0 3/4] xics: Link ICP_PROP_CPU property to ICPState::cs pointer
Date: Mon, 18 Nov 2019 09:04:14 +0100	[thread overview]
Message-ID: <cf7b4c63-9e46-6e5c-e7e7-8996893a5374@kaod.org> (raw)
In-Reply-To: <157403284709.409804.16142099083325945141.stgit@bahia.lan>

On 18/11/2019 00:20, Greg Kurz wrote:
> The ICP object has both a pointer and an ICP_PROP_CPU property pointing
> to the cpu. Confusing bugs could arise if these ever go out of sync.
> 
> Change the property definition so that it explicitely sets the pointer.

 explicitly

> The property isn't optional : not being able to set the link is a bug
> and QEMU should rather abort than exit in this case.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>



Reviewed-by: Cédric Le Goater <clg@kaod.org>


> ---
>  hw/intc/xics.c |   21 ++++-----------------
>  1 file changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index 35dddb88670e..0b259a09c545 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -305,25 +305,13 @@ void icp_reset(ICPState *icp)
>  static void icp_realize(DeviceState *dev, Error **errp)
>  {
>      ICPState *icp = ICP(dev);
> -    PowerPCCPU *cpu;
>      CPUPPCState *env;
> -    Object *obj;
>      Error *err = NULL;
>  
>      assert(icp->xics);
> +    assert(icp->cs);
>  
> -    obj = object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err);
> -    if (!obj) {
> -        error_propagate_prepend(errp, err,
> -                                "required link '" ICP_PROP_CPU
> -                                "' not found: ");
> -        return;
> -    }
> -
> -    cpu = POWERPC_CPU(obj);
> -    icp->cs = CPU(obj);
> -
> -    env = &cpu->env;
> +    env = &POWERPC_CPU(icp->cs)->env;
>      switch (PPC_INPUT(env)) {
>      case PPC_FLAGS_INPUT_POWER7:
>          icp->output = env->irq_inputs[POWER7_INPUT_INT];
> @@ -363,6 +351,7 @@ static void icp_unrealize(DeviceState *dev, Error **errp)
>  static Property icp_properties[] = {
>      DEFINE_PROP_LINK(ICP_PROP_XICS, ICPState, xics, TYPE_XICS_FABRIC,
>                       XICSFabric *),
> +    DEFINE_PROP_LINK(ICP_PROP_CPU, ICPState, cs, TYPE_CPU, CPUState *),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>  
> @@ -397,8 +386,7 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
>      object_property_add_child(cpu, type, obj, &error_abort);
>      object_unref(obj);
>      object_property_set_link(obj, OBJECT(xi), ICP_PROP_XICS, &error_abort);
> -    object_ref(cpu);
> -    object_property_add_const_link(obj, ICP_PROP_CPU, cpu, &error_abort);
> +    object_property_set_link(obj, cpu, ICP_PROP_CPU, &error_abort);
>      object_property_set_bool(obj, true, "realized", &local_err);
>      if (local_err) {
>          object_unparent(obj);
> @@ -413,7 +401,6 @@ void icp_destroy(ICPState *icp)
>  {
>      Object *obj = OBJECT(icp);
>  
> -    object_unref(object_property_get_link(obj, ICP_PROP_CPU, &error_abort));
>      object_unparent(obj);
>  }
>  
> 



  reply	other threads:[~2019-11-18  8:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-17 23:20 [PATCH for-5.0 0/4] ppc: Some more QOM cleanup for XICS Greg Kurz
2019-11-17 23:20 ` [PATCH for-5.0 1/4] xics: Link ICS_PROP_XICS property to ICSState::xics pointer Greg Kurz
2019-11-18  8:03   ` Cédric Le Goater
2019-11-17 23:20 ` [PATCH for-5.0 2/4] xics: Link ICP_PROP_XICS property to ICPState::xics pointer Greg Kurz
2019-11-18  8:03   ` Cédric Le Goater
2019-11-17 23:20 ` [PATCH for-5.0 3/4] xics: Link ICP_PROP_CPU property to ICPState::cs pointer Greg Kurz
2019-11-18  8:04   ` Cédric Le Goater [this message]
2019-11-17 23:20 ` [PATCH for-5.0 4/4] spapr: Abort if XICS interrupt controller cannot be initialized Greg Kurz
2019-11-18  8:07   ` Cédric Le Goater
2019-11-19  0:37 ` [PATCH for-5.0 0/4] ppc: Some more QOM cleanup for XICS 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=cf7b4c63-9e46-6e5c-e7e7-8996893a5374@kaod.org \
    --to=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --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).