From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzcFH-0008JO-OG for qemu-devel@nongnu.org; Thu, 27 Oct 2016 00:24:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzcFF-0007FI-TE for qemu-devel@nongnu.org; Thu, 27 Oct 2016 00:24:51 -0400 Date: Thu, 27 Oct 2016 14:12:42 +1100 From: David Gibson Message-ID: <20161027031242.GH19918@umbus.fritz.box> References: <1477129610-31353-1-git-send-email-clg@kaod.org> <1477129610-31353-14-git-send-email-clg@kaod.org> <20161025053627.GC11052@umbus.fritz.box> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aF3LVLvitz/VQU3c" Content-Disposition: inline In-Reply-To: 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 --aF3LVLvitz/VQU3c Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 25, 2016 at 12:58:11PM +0200, C=E9dric Le Goater wrote: > On 10/25/2016 07:36 AM, David Gibson wrote: > > 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). > >> > >> Signed-off-by: C=E9dric Le Goater > >=20 > > 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. >=20 > Well I guess so. The XICSState argument reduces the scope in case of=20 > multichip but as this routine is used to initialize the xive registers,= =20 > it does not need to be fast. Ahh.. I was thinking of the top-level xics object as global, rather than per-chip. Except.. does having it per-chip work anyway? The server numbers are globally unique, aren't they? What happens if you put a server number =66rom one chip as the target for an ICE on another chip? The xics object is a bit weird, in that it doesn't represent a real device in a sense, but is rather something to co-ordinate global addressing between ICS and ICP units. Well, I suppose in that sense it represent the interrupt propagation fabric. > So you rather have, something like: >=20 > PowerPCCPU *ppc_get_vcpu_by_pir(int pir); >=20 > similar to : >=20 > PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id); >=20 >=20 > Thanks, >=20 > C.=20 >=20 > >> --- > >> hw/intc/xics_native.c | 19 +++++++++++++++++++ > >> include/hw/ppc/xics.h | 1 + > >> 2 files changed, 20 insertions(+) > >> > >> 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 >=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 --aF3LVLvitz/VQU3c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYEXCqAAoJEGw4ysog2bOSKgoP/ivXHBin+6luGZyppUVNP7hA SltqS+S5ejVW4LfLZfWFO/0VvOdZxvRK0nBXj1eZOYqTsUkQIOApm4CAZpAnBRn0 UwuylUpL2OjNk3fNSgkCJT1RROzyHfTYGR6FEfalQcPkJtaG8bpHO3JAomfkHBjA q50WRQVcgc1lD90PBiMfRu6+ZvA9/+3RJOFYU2N3yocT4Ph9EhpqSJUBDsTATUBp 83hzzKWkuOI0T9uoi27nD7YR5Gqmmo09RQ1QYUGw+VN9qK0wfmVkBMDtpb/gjp2B MM0LjlkG3QIN8FNQm9YBmauQSqgLqlt09o90ZJKdIeMYbLXqF1o0nXk+AE1Xg8CH 2cD4XtUfiF/zDsEaT5NGxZvJYUiEY8TULnsofJt1uF+19P0xcLYJ8tpuzEqkM2Wq kLCOeEKbYBtQkcvKBFibC6D3jNJ4sg7NOJd0Z1qCc31YvAvxIvZvbaFCjGbGMxso z+97bmVMXKtaguIxESFjmLm1CFNPc5QfZ2zA1wPPKHp7CBZjDrPfYNyj/DfjG/So o9iE99C3U1QsUtGlTQe1wduON6/RoUXa+YQITVhN45VzWmSSM28Qv5WGYbRx4UQm MB4Sx9pPRrbULAmxconM+gmZdZU3soFpnhV0wU16EE0PBQQR6qXGLPoiDmCwFemQ AZEztyRCSKX50CIASe7E =XzqK -----END PGP SIGNATURE----- --aF3LVLvitz/VQU3c--