From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bARZy-0002Rd-3s for qemu-devel@nongnu.org; Tue, 07 Jun 2016 20:42:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bARZn-000235-Re for qemu-devel@nongnu.org; Tue, 07 Jun 2016 20:42:41 -0400 Received: from e17.ny.us.ibm.com ([129.33.205.207]:50277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bARZn-000228-NH for qemu-devel@nongnu.org; Tue, 07 Jun 2016 20:42:31 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Jun 2016 20:42:27 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1465313980-31281-2-git-send-email-thuth@redhat.com> References: <1465313980-31281-1-git-send-email-thuth@redhat.com> <1465313980-31281-2-git-send-email-thuth@redhat.com> Message-ID: <20160608003341.713.70672@loki> Date: Tue, 07 Jun 2016 19:33:41 -0500 Subject: Re: [Qemu-devel] [PATCH 1/5] ppc/spapr: Refactor h_client_architecture_support() CPU parsing code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Cc: Alexey Kardashevskiy , agraf@suse.de, qemu-devel@nongnu.org Quoting Thomas Huth (2016-06-07 10:39:36) > The h_client_architecture_support() function has become quite big > and nested already. So factor out the code that takes care of the > sPAPR compatibility PVRs (which will be modified by the following > patches). > = > Signed-off-by: Thomas Huth Restructuring looks sane. Reviewed-by: Michael Roth > --- > hw/ppc/spapr_hcall.c | 61 +++++++++++++++++++++++++++++++---------------= ------ > 1 file changed, 36 insertions(+), 25 deletions(-) > = > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > index 9a3f4ec..bb8f4de 100644 > --- a/hw/ppc/spapr_hcall.c > +++ b/hw/ppc/spapr_hcall.c > @@ -922,6 +922,39 @@ static void do_set_compat(void *arg) > ((cpuver) =3D=3D CPU_POWERPC_LOGICAL_2_06_PLUS) ? 2061 : \ > ((cpuver) =3D=3D CPU_POWERPC_LOGICAL_2_07) ? 2070 : 0) > = > +static void cas_handle_compat_cpu(PowerPCCPUClass *pcc, uint32_t pvr, > + unsigned max_lvl, unsigned *compat_lvl, > + unsigned *cpu_version) > +{ > + unsigned lvl =3D get_compat_level(pvr); > + bool is205, is206; > + > + if (!lvl) { > + return; > + } > + > + /* If it is a logical PVR, try to determine the highest level */ > + is205 =3D (pcc->pcr_mask & PCR_COMPAT_2_05) && > + (lvl =3D=3D get_compat_level(CPU_POWERPC_LOGICAL_2_05)); > + is206 =3D (pcc->pcr_mask & PCR_COMPAT_2_06) && > + ((lvl =3D=3D get_compat_level(CPU_POWERPC_LOGICAL_2_06)) || > + (lvl =3D=3D get_compat_level(CPU_POWERPC_LOGICAL_2_06_PLUS)= )); > + > + if (is205 || is206) { > + if (!max_lvl) { > + /* User did not set the level, choose the highest */ > + if (*compat_lvl <=3D lvl) { > + *compat_lvl =3D lvl; > + *cpu_version =3D pvr; > + } > + } else if (max_lvl >=3D lvl) { > + /* User chose the level, don't set higher than this */ > + *compat_lvl =3D lvl; > + *cpu_version =3D pvr; > + } > + } > +} > + > #define OV5_DRCONF_MEMORY 0x20 > = > static target_ulong h_client_architecture_support(PowerPCCPU *cpu_, > @@ -931,7 +964,7 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu_, > { > target_ulong list =3D ppc64_phys_to_real(args[0]); > target_ulong ov_table, ov5; > - PowerPCCPUClass *pcc_ =3D POWERPC_CPU_GET_CLASS(cpu_); > + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu_); > CPUState *cs; > bool cpu_match =3D false, cpu_update =3D true, memory_update =3D fal= se; > unsigned old_cpu_version =3D cpu_->cpu_version; > @@ -958,29 +991,7 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu_, > cpu_match =3D true; > cpu_version =3D cpu_->cpu_version; > } else if (!cpu_match) { > - /* If it is a logical PVR, try to determine the highest leve= l */ > - unsigned lvl =3D get_compat_level(pvr); > - if (lvl) { > - bool is205 =3D (pcc_->pcr_mask & PCR_COMPAT_2_05) && > - (lvl =3D=3D get_compat_level(CPU_POWERPC_LOGICAL_2_= 05)); > - bool is206 =3D (pcc_->pcr_mask & PCR_COMPAT_2_06) && > - ((lvl =3D=3D get_compat_level(CPU_POWERPC_LOGICAL_2_= 06)) || > - (lvl =3D=3D get_compat_level(CPU_POWERPC_LOGICAL_2_0= 6_PLUS))); > - > - if (is205 || is206) { > - if (!max_lvl) { > - /* User did not set the level, choose the highes= t */ > - if (compat_lvl <=3D lvl) { > - compat_lvl =3D lvl; > - cpu_version =3D pvr; > - } > - } else if (max_lvl >=3D lvl) { > - /* User chose the level, don't set higher than t= his */ > - compat_lvl =3D lvl; > - cpu_version =3D pvr; > - } > - } > - } > + cas_handle_compat_cpu(pcc, pvr, max_lvl, &compat_lvl, &cpu_v= ersion); > } > /* Terminator record */ > if (~pvr_mask & pvr) { > @@ -990,7 +1001,7 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu_, > = > /* Parsing finished */ > trace_spapr_cas_pvr(cpu_->cpu_version, cpu_match, > - cpu_version, pcc_->pcr_mask); > + cpu_version, pcc->pcr_mask); > = > /* Update CPUs */ > if (old_cpu_version !=3D cpu_version) { > -- = > 1.8.3.1 > = >=20