From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLL7D-0004vA-9n for qemu-devel@nongnu.org; Thu, 07 Jul 2016 22:02:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLL7A-0005Ts-3I for qemu-devel@nongnu.org; Thu, 07 Jul 2016 22:02:03 -0400 Date: Fri, 8 Jul 2016 11:57:07 +1000 From: David Gibson Message-ID: <20160708015707.GW14675@voom.fritz.box> References: <146780713904.26232.12351310667258006783.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <146780727293.26232.15003585063698606874.stgit@bahia.lab.toulouse-stg.fr.ibm.com> <20160707020151.GK14675@voom.fritz.box> <20160707105502.4f3aa6fa@bahia.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JkgDhDyNm4zanevS" Content-Disposition: inline In-Reply-To: <20160707105502.4f3aa6fa@bahia.lan> Subject: Re: [Qemu-devel] [PATCH v3 5/7] ppc: each machine type to provide vcpu_dt_id List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: Eduardo Habkost , Benjamin Herrenschmidt , qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Cedric Le Goater , Bharata B Rao , Scott Wood , Igor Mammedov --JkgDhDyNm4zanevS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 07, 2016 at 10:55:02AM +0200, Greg Kurz wrote: > On Thu, 7 Jul 2016 12:01:51 +1000 > David Gibson wrote: >=20 > > On Wed, Jul 06, 2016 at 02:14:36PM +0200, Greg Kurz wrote: > > > This patch switches machine types to provide device-tree cpu ids. > > >=20 > > > We have three cases to handle: > > >=20 > > > - pseries < 2.7 call ppc_cpu_init() and should compute the DT id as i= t is > > > currently done in the target code. > > >=20 > > > - pseries 2.7 don't call ppc_cpu_init() and compute the DT as the sum= of > > > the core DT id and the the thread index within the core > > >=20 > > > - all other machine types don't support SMT and just need to provide a > > > different index for each vcpu =20 > >=20 > > Would it instead make sense to expose the dt_id as a vcpu property and > > have the machine type set it if it wants to override? > >=20 >=20 > And the default would be cs->cpu_index I guess, correct ? That was my intention. However Bharata has since pointed out that this doesn't work, because the cpu_index is only computed at realize time. > > dt_id is probably not a good name though, since there's no guarantee > > the machine type actually uses a dt, which is part of the point of > > this series. > >=20 >=20 > machine_cpu_index ? >=20 > > >=20 > > > Signed-off-by: Greg Kurz > > > --- > > > hw/ppc/e500.c | 2 +- > > > hw/ppc/mac_newworld.c | 2 +- > > > hw/ppc/mac_oldworld.c | 2 +- > > > hw/ppc/ppc.c | 5 ++++- > > > hw/ppc/ppc440_bamboo.c | 2 +- > > > hw/ppc/ppc4xx_devs.c | 2 +- > > > hw/ppc/prep.c | 2 +- > > > hw/ppc/spapr.c | 5 ++++- > > > hw/ppc/spapr_cpu_core.c | 7 +++++-- > > > hw/ppc/virtex_ml507.c | 2 +- > > > include/hw/ppc/ppc.h | 2 +- > > > 11 files changed, 21 insertions(+), 12 deletions(-) > > >=20 > > > diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c > > > index b9221cc2c14a..513a42a3f952 100644 > > > --- a/hw/ppc/e500.c > > > +++ b/hw/ppc/e500.c > > > @@ -823,7 +823,7 @@ void ppce500_init(MachineState *machine, PPCE500P= arams *params) > > > CPUState *cs; > > > qemu_irq *input; > > > =20 > > > - cpu =3D ppc_cpu_init(machine->cpu_model); > > > + cpu =3D ppc_cpu_init(machine->cpu_model, i); > > > if (cpu =3D=3D NULL) { > > > fprintf(stderr, "Unable to initialize CPU!\n"); > > > exit(1); > > > diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c > > > index 366089085844..9ef9504ff29c 100644 > > > --- a/hw/ppc/mac_newworld.c > > > +++ b/hw/ppc/mac_newworld.c > > > @@ -194,7 +194,7 @@ static void ppc_core99_init(MachineState *machine) > > > } > > > ppc_cpu_parse_features(machine->cpu_model); > > > for (i =3D 0; i < smp_cpus; i++) { > > > - cpu =3D ppc_cpu_init(machine->cpu_model); > > > + cpu =3D ppc_cpu_init(machine->cpu_model, i); > > > if (cpu =3D=3D NULL) { > > > fprintf(stderr, "Unable to find PowerPC CPU definition\n= "); > > > exit(1); > > > diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c > > > index 5c2dc53cb584..0b09a8da8bf2 100644 > > > --- a/hw/ppc/mac_oldworld.c > > > +++ b/hw/ppc/mac_oldworld.c > > > @@ -114,7 +114,7 @@ static void ppc_heathrow_init(MachineState *machi= ne) > > > machine->cpu_model =3D "G3"; > > > ppc_cpu_parse_features(machine->cpu_model); > > > for (i =3D 0; i < smp_cpus; i++) { > > > - cpu =3D ppc_cpu_init(machine->cpu_model); > > > + cpu =3D ppc_cpu_init(machine->cpu_model, i); > > > if (cpu =3D=3D NULL) { > > > fprintf(stderr, "Unable to find PowerPC CPU definition\n= "); > > > exit(1); > > > diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c > > > index 0df32a9b3965..3d7739b9540e 100644 > > > --- a/hw/ppc/ppc.c > > > +++ b/hw/ppc/ppc.c > > > @@ -1353,7 +1353,7 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) > > > return NULL; > > > } > > > =20 > > > -PowerPCCPU *ppc_cpu_init(const char *cpu_model) > > > +PowerPCCPU *ppc_cpu_init(const char *cpu_model, unsigned vcpu_dt_id) > > > { > > > PowerPCCPU *cpu; > > > ObjectClass *oc; > > > @@ -1373,6 +1373,9 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model) > > > } > > > =20 > > > cpu =3D POWERPC_CPU(object_new(object_class_get_name(oc))); > > > + > > > + cpu->cpu_dt_id =3D vcpu_dt_id; > > > + > > > object_property_set_bool(OBJECT(cpu), true, "realized", &err); > > > =20 > > > out: > > > diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c > > > index 709a779cba7e..9dbe87207304 100644 > > > --- a/hw/ppc/ppc440_bamboo.c > > > +++ b/hw/ppc/ppc440_bamboo.c > > > @@ -187,7 +187,7 @@ static void bamboo_init(MachineState *machine) > > > machine->cpu_model =3D "440EP"; > > > } > > > ppc_cpu_parse_features(machine->cpu_model); > > > - cpu =3D ppc_cpu_init(machine->cpu_model); > > > + cpu =3D ppc_cpu_init(machine->cpu_model, 0); > > > if (cpu =3D=3D NULL) { > > > fprintf(stderr, "Unable to initialize CPU!\n"); > > > exit(1); > > > diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c > > > index 8cbe50361e86..ac39202c0d1c 100644 > > > --- a/hw/ppc/ppc4xx_devs.c > > > +++ b/hw/ppc/ppc4xx_devs.c > > > @@ -57,7 +57,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model, > > > =20 > > > /* init CPUs */ > > > ppc_cpu_parse_features(cpu_model); > > > - cpu =3D ppc_cpu_init(cpu_model); > > > + cpu =3D ppc_cpu_init(cpu_model, 0); > > > if (cpu =3D=3D NULL) { > > > fprintf(stderr, "Unable to find PowerPC %s CPU definition\n", > > > cpu_model); > > > diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c > > > index 99409a09f0ef..9e8cf233d98d 100644 > > > --- a/hw/ppc/prep.c > > > +++ b/hw/ppc/prep.c > > > @@ -510,7 +510,7 @@ static void ppc_prep_init(MachineState *machine) > > > machine->cpu_model =3D "602"; > > > ppc_cpu_parse_features(machine->cpu_model); > > > for (i =3D 0; i < smp_cpus; i++) { > > > - cpu =3D ppc_cpu_init(machine->cpu_model); > > > + cpu =3D ppc_cpu_init(machine->cpu_model, i); > > > if (cpu =3D=3D NULL) { > > > fprintf(stderr, "Unable to find PowerPC CPU definition\n= "); > > > exit(1); > > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > > index 8ca80812f16a..baefc7bd279c 100644 > > > --- a/hw/ppc/spapr.c > > > +++ b/hw/ppc/spapr.c > > > @@ -1849,7 +1849,10 @@ static void ppc_spapr_init(MachineState *machi= ne) > > > g_free(type); > > > } else { > > > for (i =3D 0; i < smp_cpus; i++) { > > > - PowerPCCPU *cpu =3D ppc_cpu_init(machine->cpu_model); > > > + unsigned core_index =3D i / smp_threads; > > > + unsigned thread_index =3D i % smp_threads; > > > + PowerPCCPU *cpu =3D ppc_cpu_init(machine->cpu_model, > > > + core_index * smt + thread= _index); > > > if (cpu =3D=3D NULL) { > > > error_report("Unable to find PowerPC CPU definition"= ); > > > exit(1); > > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > > > index 70b6b0b5ee17..e3a3024baf32 100644 > > > --- a/hw/ppc/spapr_cpu_core.c > > > +++ b/hw/ppc/spapr_cpu_core.c > > > @@ -259,13 +259,16 @@ out: > > > error_propagate(errp, local_err); > > > } > > > =20 > > > -static void spapr_cpu_core_realize_child(Object *child, Error **errp) > > > +static void spapr_cpu_core_realize_child(Object *child, unsigned vcp= u_dt_id, > > > + Error **errp) > > > { > > > Error *local_err =3D NULL; > > > sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); > > > CPUState *cs =3D CPU(child); > > > PowerPCCPU *cpu =3D POWERPC_CPU(cs); > > > =20 > > > + cpu->cpu_dt_id =3D vcpu_dt_id; > > > + > > > object_property_set_bool(child, true, "realized", &local_err); > > > if (local_err) { > > > error_propagate(errp, local_err); > > > @@ -306,7 +309,7 @@ static void spapr_cpu_core_realize(DeviceState *d= ev, Error **errp) > > > for (j =3D 0; j < cc->nr_threads; j++) { > > > obj =3D sc->threads + j * size; > > > =20 > > > - spapr_cpu_core_realize_child(obj, &local_err); > > > + spapr_cpu_core_realize_child(obj, cc->core_id + j, &local_er= r); > > > if (local_err) { > > > goto err; > > > } > > > diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c > > > index a19dd17addda..efbc58137df4 100644 > > > --- a/hw/ppc/virtex_ml507.c > > > +++ b/hw/ppc/virtex_ml507.c > > > @@ -97,7 +97,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *r= am_size, > > > qemu_irq *irqs; > > > =20 > > > ppc_cpu_parse_features(cpu_model); > > > - cpu =3D ppc_cpu_init(cpu_model); > > > + cpu =3D ppc_cpu_init(cpu_model, 0); > > > if (cpu =3D=3D NULL) { > > > fprintf(stderr, "Unable to initialize CPU!\n"); > > > exit(1); > > > diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h > > > index 2ed063e09bec..379b2f5d8e3d 100644 > > > --- a/include/hw/ppc/ppc.h > > > +++ b/include/hw/ppc/ppc.h > > > @@ -106,6 +106,6 @@ enum { > > > /* ppc_booke.c */ > > > void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t = flags); > > > =20 > > > -PowerPCCPU *ppc_cpu_init(const char *cpu_model); > > > +PowerPCCPU *ppc_cpu_init(const char *cpu_model, unsigned vcpu_dt_id); > > > void ppc_cpu_parse_features(const char *cpu_model); > > > #endif > > > =20 > >=20 >=20 --=20 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 --JkgDhDyNm4zanevS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXfwhzAAoJEGw4ysog2bOSP3EP/RZBs2Z45UbU3rWLGpCxYsmL fTyko8w0Vbs3UAe7xzATuGyQfykjmWICSMYGDdLGri/9oAPE8KoltxhV8jhFCVWm gdesaCchF47aYiUfwPbtUxHznNn5eSE+mc9ZFevG5EByek367zu/2s0RSzmEW2gG TYOSq45iYdO0LghINfQ/Gp1iyS8ibQgtIJ+fA/0o85TbhpQRXGuURNCpyuS+DkAT bHrI1PHH2e35cmGhC4jKcCLhCwpNBs+DreNvtRngBCYZiJdPnMj865sSbKxfjQ/N VdehD874lcETmDvguwzNd0qYd87JCkZz0WF8lZUpS4btJ6IwpUspo4KRGIvpn9Lk 0KWxAslMBNzGFG4Q8agbrZN2WTKOQzAc6UT5l8C0u6bT/tgAM4A8rGy6OuqBg5yy 9N4F6S8SCPtLlKU/afikDxdqf3F3KSwSCzirf0lbLIDhq4qBOhDgrRv7gBFEEW4b 38K6+JqzjGHi+zlbsO1flt7KKhd4BfofKQRnHXNtW/Vm8mmFTi4g87LGGXC+tWiY r4nyDzXQcJFfNkf7aD/bZKJ1djxFfaWC7EOXcMzi3gjI8d5+IzmvtAHFrHQQtxc+ H5aEptE9rTJSBg0nq+VoGHFP/0Y5lRKMS5vSHwJKd8ep8D5ZcNL2/HeJHU+4eCyn 9eVgHWz99lPk5WCnneya =P5TV -----END PGP SIGNATURE----- --JkgDhDyNm4zanevS--