From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
qemu-ppc@nongnu.org, david@gibson.dropbear.id.au
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
agraf@suse.de, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] ppc/spapr: Refactor h_client_architecture_support() CPU parsing code
Date: Tue, 07 Jun 2016 19:33:41 -0500 [thread overview]
Message-ID: <20160608003341.713.70672@loki> (raw)
In-Reply-To: <1465313980-31281-2-git-send-email-thuth@redhat.com>
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 <thuth@redhat.com>
Restructuring looks sane.
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
> 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) == CPU_POWERPC_LOGICAL_2_06_PLUS) ? 2061 : \
> ((cpuver) == 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 = get_compat_level(pvr);
> + bool is205, is206;
> +
> + if (!lvl) {
> + return;
> + }
> +
> + /* If it is a logical PVR, try to determine the highest level */
> + is205 = (pcc->pcr_mask & PCR_COMPAT_2_05) &&
> + (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_05));
> + is206 = (pcc->pcr_mask & PCR_COMPAT_2_06) &&
> + ((lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06)) ||
> + (lvl == 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 <= lvl) {
> + *compat_lvl = lvl;
> + *cpu_version = pvr;
> + }
> + } else if (max_lvl >= lvl) {
> + /* User chose the level, don't set higher than this */
> + *compat_lvl = lvl;
> + *cpu_version = 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(PowerPCCPU *cpu_,
> {
> target_ulong list = ppc64_phys_to_real(args[0]);
> target_ulong ov_table, ov5;
> - PowerPCCPUClass *pcc_ = POWERPC_CPU_GET_CLASS(cpu_);
> + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu_);
> CPUState *cs;
> bool cpu_match = false, cpu_update = true, memory_update = false;
> unsigned old_cpu_version = cpu_->cpu_version;
> @@ -958,29 +991,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,
> cpu_match = true;
> cpu_version = cpu_->cpu_version;
> } else if (!cpu_match) {
> - /* If it is a logical PVR, try to determine the highest level */
> - unsigned lvl = get_compat_level(pvr);
> - if (lvl) {
> - bool is205 = (pcc_->pcr_mask & PCR_COMPAT_2_05) &&
> - (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_05));
> - bool is206 = (pcc_->pcr_mask & PCR_COMPAT_2_06) &&
> - ((lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06)) ||
> - (lvl == 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 <= lvl) {
> - compat_lvl = lvl;
> - cpu_version = pvr;
> - }
> - } else if (max_lvl >= lvl) {
> - /* User chose the level, don't set higher than this */
> - compat_lvl = lvl;
> - cpu_version = pvr;
> - }
> - }
> - }
> + cas_handle_compat_cpu(pcc, pvr, max_lvl, &compat_lvl, &cpu_version);
> }
> /* Terminator record */
> if (~pvr_mask & pvr) {
> @@ -990,7 +1001,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *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 != cpu_version) {
> --
> 1.8.3.1
>
>
next prev parent reply other threads:[~2016-06-08 0:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-07 15:39 [Qemu-devel] [PATCH 0/5] ppc: Improve sPAPR CPU compatibility mode settings Thomas Huth
2016-06-07 15:39 ` [Qemu-devel] [PATCH 1/5] ppc/spapr: Refactor h_client_architecture_support() CPU parsing code Thomas Huth
2016-06-08 0:33 ` Michael Roth [this message]
2016-06-07 15:39 ` [Qemu-devel] [PATCH 2/5] ppc: Split pcr_mask settings into supported bits and the register mask Thomas Huth
2016-06-08 0:34 ` Michael Roth
2016-06-07 15:39 ` [Qemu-devel] [PATCH 3/5] ppc: Provide function to get CPU class of the host CPU Thomas Huth
2016-06-08 0:38 ` Michael Roth
2016-06-07 15:39 ` [Qemu-devel] [PATCH 4/5] ppc: Improve PCR bit selection in ppc_set_compat() Thomas Huth
2016-06-08 1:12 ` David Gibson
2016-06-08 6:47 ` Thomas Huth
2016-06-08 5:44 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2016-06-08 6:59 ` Thomas Huth
2016-06-08 7:24 ` David Gibson
2016-06-08 7:37 ` Thomas Huth
2016-06-07 15:39 ` [Qemu-devel] [PATCH 5/5] ppc: Add PowerISA 2.07 compatibility mode Thomas Huth
2016-06-08 1:11 ` [Qemu-devel] [PATCH 0/5] ppc: Improve sPAPR CPU compatibility mode settings David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160608003341.713.70672@loki \
--to=mdroth@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.