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 1/4] xics: Link ICS_PROP_XICS property to ICSState::xics pointer
Date: Mon, 18 Nov 2019 09:03:01 +0100 [thread overview]
Message-ID: <19b058f8-f71f-a224-a9f2-d92caa0b844e@kaod.org> (raw)
In-Reply-To: <157403283596.409804.17347207690271971987.stgit@bahia.lan>
On 18/11/2019 00:20, Greg Kurz wrote:
> The ICS object has both a pointer and an ICS_PROP_XICS property pointing
> to the XICS fabric. Confusing bugs could arise if these ever go out of
> sync.
>
> Change the property definition so that it explicitely sets the pointer.
> 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 | 13 +++----------
> hw/ppc/pnv_psi.c | 3 +--
> hw/ppc/spapr_irq.c | 9 ++-------
> 3 files changed, 6 insertions(+), 19 deletions(-)
>
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index e7ac9ba618fa..f7a454808992 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -609,17 +609,8 @@ static void ics_reset_handler(void *dev)
> static void ics_realize(DeviceState *dev, Error **errp)
> {
> ICSState *ics = ICS(dev);
> - Error *local_err = NULL;
> - Object *obj;
>
> - obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &local_err);
> - if (!obj) {
> - error_propagate_prepend(errp, local_err,
> - "required link '" ICS_PROP_XICS
> - "' not found: ");
> - return;
> - }
> - ics->xics = XICS_FABRIC(obj);
> + assert(ics->xics);
>
> if (!ics->nr_irqs) {
> error_setg(errp, "Number of interrupts needs to be greater 0");
> @@ -699,6 +690,8 @@ static const VMStateDescription vmstate_ics = {
>
> static Property ics_properties[] = {
> DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0),
> + DEFINE_PROP_LINK(ICS_PROP_XICS, ICSState, xics, TYPE_XICS_FABRIC,
> + XICSFabric *),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
> index a360515a86f8..7e725aaf2bd5 100644
> --- a/hw/ppc/pnv_psi.c
> +++ b/hw/ppc/pnv_psi.c
> @@ -497,8 +497,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
> }
>
> /* Create PSI interrupt control source */
> - object_property_add_const_link(OBJECT(ics), ICS_PROP_XICS, obj,
> - &error_abort);
> + object_property_set_link(OBJECT(ics), obj, ICS_PROP_XICS, &error_abort);
> object_property_set_int(OBJECT(ics), PSI_NUM_INTERRUPTS, "nr-irqs", &err);
> if (err) {
> error_propagate(errp, err);
> diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
> index 168044be853a..487c8ceb35a3 100644
> --- a/hw/ppc/spapr_irq.c
> +++ b/hw/ppc/spapr_irq.c
> @@ -319,13 +319,8 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
> return;
> }
>
> - object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr),
> - &local_err);
> - if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> - }
> -
> + object_property_set_link(obj, OBJECT(spapr), ICS_PROP_XICS,
> + &error_abort);
> object_property_set_int(obj, smc->nr_xirqs, "nr-irqs", &local_err);
> if (local_err) {
> error_propagate(errp, local_err);
>
next prev parent reply other threads:[~2019-11-18 8:04 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 [this message]
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
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=19b058f8-f71f-a224-a9f2-d92caa0b844e@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).