From nobody Sat Jul 12 15:49:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486015204989146.7174227881868; Wed, 1 Feb 2017 22:00:04 -0800 (PST) Received: from localhost ([::1]:54447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZAR8-0000vQ-PR for importer@patchew.org; Thu, 02 Feb 2017 01:00:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9jp-0007Ne-Sx for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9jk-0003hj-RG for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:17 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:44447) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9jk-0003d7-A3; Thu, 02 Feb 2017 00:15:12 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqP6hg1z9s7w; Thu, 2 Feb 2017 16:14:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486012497; bh=CL/imQpi33d81zzwifu6gGqJ72iyYNnTF6zglDz07lA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OEpoMrWXPFW+5u3ZvNcFJXgC3vIm7FnpRuYTAGln5L30h5Sh3QdqI2cd54jtxDTkA gOotoirkc4CEd1KDf6fFDcQYmYH/GXWccmlYR+QUWjUIx8f4/31p+hoLb1ZbnYS5/c S5JC4ds7cL62QoVjfEN6S/W9GKvQJaepXcNhim1g= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:13:33 +1100 Message-Id: <20170202051445.5735-36-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170202051445.5735-1-david@gibson.dropbear.id.au> References: <20170202051445.5735-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 035/107] ppc: Rewrite ppc_get_compat_smt_threads() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To continue consolidation of compatibility mode information, this rewrites the ppc_get_compat_smt_threads() function using the table of compatiblity modes in target-ppc/compat.c. It's not a direct replacement, the new ppc_compat_max_threads() function has simpler semantics - it just returns the number of threads the cpu model has, taking into account any compatiblity mode it is in. This no longer takes into account kvmppc_smt_threads() as the previous version did. That check wasn't useful because we check in ppc_cpu_realizefn() that CPUs aren't instantiated with more threads than kvm allows (or if we didn't things will already be broken and this won't make it any worse). Signed-off-by: David Gibson Reviewed-by: Alexey Kardashevskiy --- hw/ppc/spapr.c | 8 ++++---- target/ppc/compat.c | 18 ++++++++++++++++++ target/ppc/cpu.h | 2 +- target/ppc/translate_init.c | 20 -------------------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a175609..b71cd7a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -206,6 +206,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineSt= ate *spapr) PowerPCCPU *cpu =3D POWERPC_CPU(cs); DeviceClass *dc =3D DEVICE_GET_CLASS(cs); int index =3D ppc_get_vcpu_dt_id(cpu); + int compat_smt =3D MIN(smp_threads, ppc_compat_max_threads(cpu)); =20 if ((index % smt) !=3D 0) { continue; @@ -240,8 +241,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineSt= ate *spapr) return ret; } =20 - ret =3D spapr_fixup_cpu_smt_dt(fdt, offset, cpu, - ppc_get_compat_smt_threads(cpu)); + ret =3D spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt); if (ret < 0) { return ret; } @@ -407,6 +407,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *f= dt, int offset, size_t page_sizes_prop_size; uint32_t vcpus_per_socket =3D smp_threads * smp_cores; uint32_t pft_size_prop[] =3D {0, cpu_to_be32(spapr->htab_shift)}; + int compat_smt =3D MIN(smp_threads, ppc_compat_max_threads(cpu)); sPAPRDRConnector *drc; sPAPRDRConnectorClass *drck; int drc_index; @@ -494,8 +495,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *f= dt, int offset, =20 _FDT(spapr_fixup_cpu_numa_dt(fdt, offset, cs)); =20 - _FDT(spapr_fixup_cpu_smt_dt(fdt, offset, cpu, - ppc_get_compat_smt_threads(cpu))); + _FDT(spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt)); } =20 static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spap= r) diff --git a/target/ppc/compat.c b/target/ppc/compat.c index f3fd9c6..66529a6 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -28,6 +28,7 @@ typedef struct { uint32_t pvr; uint64_t pcr; + int max_threads; } CompatInfo; =20 static const CompatInfo compat_table[] =3D { @@ -35,18 +36,22 @@ static const CompatInfo compat_table[] =3D { .pvr =3D CPU_POWERPC_LOGICAL_2_05, .pcr =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05 | PCR_TM_DIS | PCR_VSX_DIS, + .max_threads =3D 2, }, { /* POWER7, ISA2.06 */ .pvr =3D CPU_POWERPC_LOGICAL_2_06, .pcr =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, + .max_threads =3D 4, }, { .pvr =3D CPU_POWERPC_LOGICAL_2_06_PLUS, .pcr =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, + .max_threads =3D 4, }, { /* POWER8, ISA2.07 */ .pvr =3D CPU_POWERPC_LOGICAL_2_07, .pcr =3D PCR_COMPAT_2_07, + .max_threads =3D 8, }, }; =20 @@ -89,3 +94,16 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr= , Error **errp) } } } + +int ppc_compat_max_threads(PowerPCCPU *cpu) +{ + const CompatInfo *compat =3D compat_by_pvr(cpu->compat_pvr); + int n_threads =3D CPU(cpu)->nr_threads; + + if (cpu->compat_pvr) { + g_assert(compat); + n_threads =3D MIN(n_threads, compat->max_threads); + } + + return n_threads; +} diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index c859547..cd76053 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1250,7 +1250,6 @@ void ppc_store_sdr1 (CPUPPCState *env, target_ulong v= alue); void ppc_store_msr (CPUPPCState *env, target_ulong value); =20 void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf); -int ppc_get_compat_smt_threads(PowerPCCPU *cpu); #if defined(TARGET_PPC64) #endif =20 @@ -1325,6 +1324,7 @@ static inline int cpu_mmu_index (CPUPPCState *env, bo= ol ifetch) /* Compatibility modes */ #if defined(TARGET_PPC64) void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp); +int ppc_compat_max_threads(PowerPCCPU *cpu); #endif /* defined(TARGET_PPC64) */ =20 #include "exec/cpu-all.h" diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index a34a0eb..388a3e8 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -9952,26 +9952,6 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, Er= ror **errp) } } =20 -int ppc_get_compat_smt_threads(PowerPCCPU *cpu) -{ - CPUState *cs =3D CPU(cpu); - int ret =3D MIN(cs->nr_threads, kvmppc_smt_threads()); - - switch (cpu->compat_pvr) { - case CPU_POWERPC_LOGICAL_2_05: - ret =3D MIN(ret, 2); - break; - case CPU_POWERPC_LOGICAL_2_06: - ret =3D MIN(ret, 4); - break; - case CPU_POWERPC_LOGICAL_2_07: - ret =3D MIN(ret, 8); - break; - } - - return ret; -} - static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b) { ObjectClass *oc =3D (ObjectClass *)a; --=20 2.9.3