From patchwork Fri Jul 1 22:42:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9210569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 635FA60752 for ; Fri, 1 Jul 2016 22:49:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E280286C0 for ; Fri, 1 Jul 2016 22:49:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F366286CD; Fri, 1 Jul 2016 22:49:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 80C72286C0 for ; Fri, 1 Jul 2016 22:49:47 +0000 (UTC) Received: from localhost ([::1]:36066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ7Fq-0001bg-46 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Jul 2016 18:49:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78j-0002eB-EF for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ78f-0003YP-CQ for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:25 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78f-0003YA-3p for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:21 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u61MccSu018529 for ; Fri, 1 Jul 2016 18:42:20 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 23w62yc06g-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 01 Jul 2016 18:42:20 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Jul 2016 16:42:19 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 Jul 2016 16:42:17 -0600 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 6E3A93E40030; Fri, 1 Jul 2016 16:42:16 -0600 (MDT) Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u61MgI2Q10027412; Fri, 1 Jul 2016 22:42:18 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4CE0AC01B; Fri, 1 Jul 2016 18:42:15 -0400 (EDT) Received: from bahia.lan (unknown [9.164.136.204]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id E5DA4AC048; Fri, 1 Jul 2016 18:42:13 -0400 (EDT) From: Greg Kurz To: David Gibson Date: Sat, 02 Jul 2016 00:42:12 +0200 In-Reply-To: <146741287399.948.15988269239450224065.stgit@bahia.lan> References: <146741287399.948.15988269239450224065.stgit@bahia.lan> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16070122-0008-0000-0000-000004F6B3C2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070122-0009-0000-0000-000038F1F421 Message-Id: <146741293285.948.2129430864564241483.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-01_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607010225 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 7/7] ppc: move the cpu_dt_id logic to machine code 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: qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Cedric Le Goater , Bharata B Rao , Scott Wood , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that every supported machine type is able to provide a cpu_index, we can safely move all the cpu_dt_id bits to the machine code. TODO: the cpu_dt_id logic remains the same wannabe generic one as before because of its target code background: machine types should provide their own cpu_dt_id logic (it is required by the future powernv machine type for example). Signed-off-by: Greg Kurz --- hw/ppc/ppc.c | 28 +++++++++++++++++++++++++++- target-ppc/translate_init.c | 30 ------------------------------ 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 12de255fb211..506b493bf43b 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1354,7 +1354,33 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) void ppc_set_vcpu_dt_id(PowerPCCPU *cpu, int cpu_index, Error **errp) { - ; + int max_smt = kvmppc_smt_threads(); + int vcpu_dt_id; + + if (smp_threads > max_smt) { + error_setg(errp, "Cannot support more than %d threads on PPC with %s", + max_smt, kvm_enabled() ? "KVM" : "TCG"); + return; + } + if (!is_power_of_2(smp_threads)) { + error_setg(errp, "Cannot support %d threads on PPC with %s, " + "threads count must be a power of 2.", + smp_threads, kvm_enabled() ? "KVM" : "TCG"); + return; + } + + vcpu_dt_id = (cpu_index / smp_threads) * max_smt + + (cpu_index % smp_threads); + + if (kvm_enabled() && !kvm_vcpu_id_is_valid(vcpu_dt_id)) { + error_setg(errp, "Can't create CPU with id %d in KVM", vcpu_dt_id); + error_append_hint(errp, "Adjust the number of cpus to %d " + "or try to raise the number of threads per core\n", + vcpu_dt_id * smp_threads / max_smt); + return; + } + + cpu->cpu_dt_id = vcpu_dt_id; } PowerPCCPU *ppc_cpu_init(const char *cpu_model, int cpu_index) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 6706787b41a1..a54845a5be8f 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -9515,23 +9515,6 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) PowerPCCPU *cpu = POWERPC_CPU(dev); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); Error *local_err = NULL; -#if !defined(CONFIG_USER_ONLY) - int max_smt = kvmppc_smt_threads(); -#endif - -#if !defined(CONFIG_USER_ONLY) - if (smp_threads > max_smt) { - error_setg(errp, "Cannot support more than %d threads on PPC with %s", - max_smt, kvm_enabled() ? "KVM" : "TCG"); - return; - } - if (!is_power_of_2(smp_threads)) { - error_setg(errp, "Cannot support %d threads on PPC with %s, " - "threads count must be a power of 2.", - smp_threads, kvm_enabled() ? "KVM" : "TCG"); - return; - } -#endif cpu_exec_init(cs, &local_err); if (local_err != NULL) { @@ -9539,19 +9522,6 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp) return; } -#if !defined(CONFIG_USER_ONLY) - cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt - + (cs->cpu_index % smp_threads); - - if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->cpu_dt_id)) { - error_setg(errp, "Can't create CPU with id %d in KVM", cpu->cpu_dt_id); - error_append_hint(errp, "Adjust the number of cpus to %d " - "or try to raise the number of threads per core\n", - cpu->cpu_dt_id * smp_threads / max_smt); - return; - } -#endif - if (tcg_enabled()) { if (ppc_fixup_cpu(cpu) != 0) { error_setg(errp, "Unable to emulate selected CPU with TCG");