From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byuPk-0007Sb-Pm for qemu-devel@nongnu.org; Tue, 25 Oct 2016 01:36:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byuPj-00088f-MX for qemu-devel@nongnu.org; Tue, 25 Oct 2016 01:36:44 -0400 Date: Tue, 25 Oct 2016 16:36:27 +1100 From: David Gibson Message-ID: <20161025053627.GC11052@umbus.fritz.box> References: <1477129610-31353-1-git-send-email-clg@kaod.org> <1477129610-31353-14-git-send-email-clg@kaod.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zKD0QXBepZ0ysD7Q" Content-Disposition: inline In-Reply-To: <1477129610-31353-14-git-send-email-clg@kaod.org> Subject: Re: [Qemu-devel] [PATCH v5 13/17] ppc/xics: add a xics_get_cpu_index_by_pir helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: qemu-ppc@nongnu.org, Benjamin Herrenschmidt , qemu-devel@nongnu.org, Alexander Graf --zKD0QXBepZ0ysD7Q Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 22, 2016 at 11:46:46AM +0200, C=E9dric Le Goater wrote: > We will need this helper to translate the server number of the XIVE > (which is a PIR) into an ICPState index number (which is a cpu index). >=20 > Signed-off-by: C=E9dric Le Goater Looks correct as far as it goes, but I wonder if this would be more generally useful as a machine level function that searches the cpu objects by PIR, returning a pointer. From that to the cpu_index is then trivial. > --- > hw/intc/xics_native.c | 19 +++++++++++++++++++ > include/hw/ppc/xics.h | 1 + > 2 files changed, 20 insertions(+) >=20 > diff --git a/hw/intc/xics_native.c b/hw/intc/xics_native.c > index bbdd786aeb50..6318862f53fc 100644 > --- a/hw/intc/xics_native.c > +++ b/hw/intc/xics_native.c > @@ -33,6 +33,25 @@ > =20 > #include > =20 > +int xics_get_cpu_index_by_pir(XICSState *xics, int pir) > +{ > + int i; > + > + for (i =3D 0; i < xics->nr_servers; i++) { > + ICPState *icp =3D &xics->ss[i]; > + if (icp->cs) { > + PowerPCCPU *cpu =3D POWERPC_CPU(icp->cs); > + CPUPPCState *env =3D &cpu->env; > + > + if (env->spr_cb[SPR_PIR].default_value =3D=3D pir) { > + return i; > + } > + } > + } > + > + return -1; > +} > + > static void xics_native_reset(void *opaque) > { > device_reset(DEVICE(opaque)); > diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h > index 911cdd5e549f..beb232e616c5 100644 > --- a/include/hw/ppc/xics.h > +++ b/include/hw/ppc/xics.h > @@ -214,6 +214,7 @@ void xics_set_nr_servers(XICSState *xics, uint32_t nr= _servers, > =20 > /* Internal XICS interfaces */ > int xics_get_cpu_index_by_dt_id(int cpu_dt_id); > +int xics_get_cpu_index_by_pir(XICSState *xics, int pir); > =20 > void icp_set_cppr(ICPState *icp, uint8_t cppr); > void icp_set_mfrr(ICPState *icp, uint8_t mfrr); --=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 --zKD0QXBepZ0ysD7Q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYDu9bAAoJEGw4ysog2bOSpQcP/1YovbAPrGIa5yT5rYu3KcZl TJA399PCvkIb56K7Ox48Tzs8Ezz6otibofMr5Uq52sqgBLBDHrp+w2D6NGJFbRxJ u48cXuvtkWyZ294Z7+PVOOn9O+MMpKaaDYKxOEi37LdAOheYdIELI18GYAcgt1Az bKNbjjioFUeG80xwAsiyW2YHKO4xGy+buX40ZEI3fNB//3iodC3VhpfERtZaFlSp YBULlAxr2pUJ6tNDAcEs5wKVIq+H9ngiBKzEX4Bd3l2lvR1sh6q8YNZ6q2NjGNYw mLUsTlR0yb3WV5WahkMso7Krqu5PaYdRzJh2UAMLNwuLskWgPtweKSzXt1bxhX4K CHX0eNiYl64KFfuTfPEhFLGNUEuzGBV7+1PCwulMDy1GAUlgByiK+edJkIPZSypy Rd6rhcA+uJ3iacVpB7VAXHBJ/2f0cpl0RjXvc/20uRD1hk+eUEFLHquKkb1EXaV6 lhDGPsedXRcAQ2XzqvUrHktmH8gvlQko4xBsKcTzmmT2hhcHlAUKH4/jgQk8n8k/ MHVEQT/ARVRnGxlVwT1IbRZf2idtuSRriU+j4Ya//De7sJphrZHk4i7+iaclFdcW Yd2d/3pIVNid4d6BwI7GrzPxX+7EUeqloyvhil7Wohp3cblPSYTwvQKw4uanT8Ke RGlKzQAIuB1LWD4GllWt =jntl -----END PGP SIGNATURE----- --zKD0QXBepZ0ysD7Q--