From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEnze-0003IG-Kd for qemu-devel@nongnu.org; Sun, 19 Jun 2016 21:27:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEnzd-0005Wl-35 for qemu-devel@nongnu.org; Sun, 19 Jun 2016 21:27:14 -0400 Date: Mon, 20 Jun 2016 11:23:02 +1000 From: David Gibson Message-ID: <20160620012302.GA6858@voom.fritz.box> References: <1466375313-7562-1-git-send-email-sergey.fedorov@linaro.org> <1466375313-7562-2-git-send-email-sergey.fedorov@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline In-Reply-To: <1466375313-7562-2-git-send-email-sergey.fedorov@linaro.org> Subject: Re: [Qemu-devel] [RFC 1/8] cpus: pass CPUState to run_on_cpu helpers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: qemu-devel@nongnu.org, patches@linaro.org, Alex =?iso-8859-1?Q?Benn=E9e?= , Paolo Bonzini , Peter Crosthwaite , Richard Henderson , "Michael S. Tsirkin" , Eduardo Habkost , Alexander Graf , Marcelo Tosatti , qemu-ppc@nongnu.org, kvm@vger.kernel.org --jRHKVT23PllUwdXP Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 20, 2016 at 01:28:26AM +0300, Sergey Fedorov wrote: > From: Alex Benn=E9e >=20 > CPUState is a fairly common pointer to pass to these helpers. This means > if you need other arguments for the async_run_on_cpu case you end up > having to do a g_malloc to stuff additional data into the routine. For > the current users this isn't a massive deal but for MTTCG this gets > cumbersome when the only other parameter is often an address. >=20 > This adds the typedef run_on_cpu_func for helper functions which has an > explicit CPUState * passed as the first parameter. All the users of > run_on_cpu and async_run_on_cpu have had their helpers updated to use > CPUState where available. >=20 > Signed-off-by: Alex Benn=E9e > Signed-off-by: Sergey Fedorov [snip] > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 778fa255a946..a427492c0310 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2159,10 +2159,8 @@ static void spapr_machine_finalizefn(Object *obj) > g_free(spapr->kvm_type); > } > =20 > -static void ppc_cpu_do_nmi_on_cpu(void *arg) > +static void ppc_cpu_do_nmi_on_cpu(CPUState *cs, void *arg) > { > - CPUState *cs =3D arg; > - > cpu_synchronize_state(cs); > ppc_cpu_do_system_reset(cs); > } > @@ -2172,7 +2170,7 @@ static void spapr_nmi(NMIState *n, int cpu_index, E= rror **errp) > CPUState *cs; > =20 > CPU_FOREACH(cs) { > - async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, cs); > + async_run_on_cpu(cs, ppc_cpu_do_nmi_on_cpu, NULL); > } > } > =20 > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > index 2ba5cbdb194a..22d57469b8a5 100644 > --- a/hw/ppc/spapr_hcall.c > +++ b/hw/ppc/spapr_hcall.c > @@ -13,19 +13,18 @@ > #include "kvm_ppc.h" > =20 > struct SPRSyncState { > - CPUState *cs; > int spr; > target_ulong value; > target_ulong mask; > }; > =20 > -static void do_spr_sync(void *arg) > +static void do_spr_sync(CPUState *cs, void *arg) > { > struct SPRSyncState *s =3D arg; > - PowerPCCPU *cpu =3D POWERPC_CPU(s->cs); > + PowerPCCPU *cpu =3D POWERPC_CPU(cs); > CPUPPCState *env =3D &cpu->env; > =20 > - cpu_synchronize_state(s->cs); > + cpu_synchronize_state(cs); > env->spr[s->spr] &=3D ~s->mask; > env->spr[s->spr] |=3D s->value; > } > @@ -34,7 +33,6 @@ static void set_spr(CPUState *cs, int spr, target_ulong= value, > target_ulong mask) > { > struct SPRSyncState s =3D { > - .cs =3D cs, > .spr =3D spr, > .value =3D value, > .mask =3D mask > @@ -908,11 +906,11 @@ typedef struct { > Error *err; > } SetCompatState; You've missed the opportunity here to remove the cpu field from SetCompatState, as you did with SPRSyncState. > =20 > -static void do_set_compat(void *arg) > +static void do_set_compat(CPUState *cs, void *arg) > { > SetCompatState *s =3D arg; > =20 > - cpu_synchronize_state(CPU(s->cpu)); > + cpu_synchronize_state(cs); > ppc_set_compat(s->cpu, s->cpu_version, &s->err); > } --=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 --jRHKVT23PllUwdXP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXZ0V2AAoJEGw4ysog2bOS5i4QAMmP93JO0wvEIhDcrfPIhalS mVWFWOUfbZJ9yBAoHFQR+BsAokFx8N2k2Z2lcz8Iy/FdYqI2uGa2P/gLHgF9SXfz FaaFDKVmTSGIpwSL9t6lNBoSkGXON+8zgklGS3u5KdZAf+opR9x0IIlOUUb2OWIw CkiSHooogZJfW2Vmiiyf70B/Xwu8HcToIs5WVz/0rP0n3sjRgi9rRHEpU6r7oUR0 /2IdULw6tY75LcXwF6vzuFQP9rUqRB9OmeN7L4Ym7jFT6rIrdy03N+c+4SdnxNgL v/kpUIzvgVpiI9A3bs34n+rjyvNNvrX6NGbSm528JpAttrDO4X1TVG0ovj1ulP5p VTM0pRKdKoRyYj2S+LG/0CcdqnKQOSGlG8+9JTUKe4UghdAH8qgi1NCiryY3+eCK dhhO+kLm/khgk8bVzmLYzP0lNFjxWrCJNMmHLqdR1rFQ5VV4Vrw2/RmWf+I5iKon bjv162jGqAOkCpPirQbdelTaFT1ZU0DAHhHJnUdKBeAapBr5LSoN9JQ8zscyT1xS IajVzFP6sQ3jxm+c4Z56MAciQjbLVbpnndUSBRTTKpp9kzw0uJBD+wEtRPjE+jU8 nANJp3iQ07niPt7kOrWu1/t4TAvRW2lPN3Url4OPHkUrCMp3N9mMJPK9J9aj39RS OAp18dxaFgJcTuC5LMmT =HLC1 -----END PGP SIGNATURE----- --jRHKVT23PllUwdXP--