From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4bzT-0005tC-Ai for qemu-devel@nongnu.org; Wed, 31 Jul 2013 15:23:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4bzM-00075L-Bs for qemu-devel@nongnu.org; Wed, 31 Jul 2013 15:23:19 -0400 Message-ID: <51F96413.2090808@suse.de> Date: Wed, 31 Jul 2013 21:22:59 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1374043057-27208-1-git-send-email-aik@ozlabs.ru> <1374043057-27208-4-git-send-email-aik@ozlabs.ru> In-Reply-To: <1374043057-27208-4-git-send-email-aik@ozlabs.ru> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/4] xics: rework initialization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Anthony Liguori , qemu-devel@nongnu.org, Alexander Graf , Paul Mackerras , qemu-ppc@nongnu.org, David Gibson Am 17.07.2013 08:37, schrieb Alexey Kardashevskiy: > Currently RTAS and hypercalls are registered in the XICS class init > function. The upcoming XICS-KVM will inherit from XICS but will use > another API to register RTAS tokens with KVM so registration has > to move from the class init function (common for both XICS and > XICS-KVM) to the _realize function (specific to the controller). This sounds sensible, but the reason is definitely not that there is only class_init when you have two classes, but that registration of global state belongs into realize. > This moves ICS creation to _realize as there is no point to create > some child devices in initfn() (ICS) and some in realize() (ICPs). >=20 > As initfn is no more needed, this removes it. >=20 > Signed-off-by: Alexey Kardashevskiy > --- > hw/intc/xics.c | 35 +++++++++++++++-------------------- > 1 file changed, 15 insertions(+), 20 deletions(-) >=20 > diff --git a/hw/intc/xics.c b/hw/intc/xics.c > index 283c2dd..a359f52 100644 > --- a/hw/intc/xics.c > +++ b/hw/intc/xics.c > @@ -689,9 +689,23 @@ static void xics_cpu_setup(XICSState *icp, PowerPC= CPU *cpu) > static void xics_realize(DeviceState *dev, Error **errp) > { > XICSState *icp =3D XICS(dev); > - ICSState *ics =3D icp->ics; > + ICSState *ics; > int i; > =20 > + spapr_rtas_register("ibm,set-xive", rtas_set_xive); > + spapr_rtas_register("ibm,get-xive", rtas_get_xive); > + spapr_rtas_register("ibm,int-off", rtas_int_off); > + spapr_rtas_register("ibm,int-on", rtas_int_on); > + > + spapr_register_hypercall(H_CPPR, h_cppr); > + spapr_register_hypercall(H_IPI, h_ipi); > + spapr_register_hypercall(H_XIRR, h_xirr); > + spapr_register_hypercall(H_EOI, h_eoi); > + > + icp->ics =3D ICS(object_new(TYPE_ICS)); > + ics =3D icp->ics; > + object_property_add_child(OBJECT(icp), "ics", OBJECT(icp->ics), NU= LL); > + > ics->nr_irqs =3D icp->nr_irqs; > ics->offset =3D XICS_IRQ_BASE; > ics->icp =3D icp; > @@ -707,14 +721,6 @@ static void xics_realize(DeviceState *dev, Error *= *errp) > } > } > =20 > -static void xics_initfn(Object *obj) > -{ > - XICSState *xics =3D XICS(obj); > - > - xics->ics =3D ICS(object_new(TYPE_ICS)); > - object_property_add_child(obj, "ics", OBJECT(xics->ics), NULL); > -} > - > static Property xics_properties[] =3D { > DEFINE_PROP_UINT32("nr_servers", XICSState, nr_servers, -1), > DEFINE_PROP_UINT32("nr_irqs", XICSState, nr_irqs, -1), This looks wrong, both before and after. It should be both created using object_initialize() and added as child property in instance_init. If TYPE_ICS is a device, then in realize it should get realized. Regards, Andreas > @@ -730,16 +736,6 @@ static void xics_class_init(ObjectClass *oc, void = *data) > dc->props =3D xics_properties; > dc->reset =3D xics_reset; > k->cpu_setup =3D xics_cpu_setup; > - > - spapr_rtas_register("ibm,set-xive", rtas_set_xive); > - spapr_rtas_register("ibm,get-xive", rtas_get_xive); > - spapr_rtas_register("ibm,int-off", rtas_int_off); > - spapr_rtas_register("ibm,int-on", rtas_int_on); > - > - spapr_register_hypercall(H_CPPR, h_cppr); > - spapr_register_hypercall(H_IPI, h_ipi); > - spapr_register_hypercall(H_XIRR, h_xirr); > - spapr_register_hypercall(H_EOI, h_eoi); > } > =20 > static const TypeInfo xics_info =3D { > @@ -748,7 +744,6 @@ static const TypeInfo xics_info =3D { > .instance_size =3D sizeof(XICSState), > .class_size =3D sizeof(XICSStateClass), > .class_init =3D xics_class_init, > - .instance_init =3D xics_initfn, > }; > =20 > static void xics_register_types(void) --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg