From patchwork Fri Jul 1 22:41:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9210573 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 9CA2D60752 for ; Fri, 1 Jul 2016 22:53:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8537C24EE5 for ; Fri, 1 Jul 2016 22:53:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77EF228505; Fri, 1 Jul 2016 22:53:20 +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 D6CD124EE5 for ; Fri, 1 Jul 2016 22:53:19 +0000 (UTC) Received: from localhost ([::1]:36087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ7JG-0005vw-Ix for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Jul 2016 18:53:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78T-0002Pb-Uj for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ78O-0003VJ-TL for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:5427 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78O-0003V8-N6 for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:04 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u61Mcdt6071473 for ; Fri, 1 Jul 2016 18:42:04 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 23wbbc8cyt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 01 Jul 2016 18:42:04 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Jul 2016 16:42:03 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 Jul 2016 16:42:00 -0600 X-IBM-Helo: d03dlp03.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 d03dlp03.boulder.ibm.com (Postfix) with ESMTP id A580D19D801C; Fri, 1 Jul 2016 16:41:37 -0600 (MDT) Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u61Mg1Ed10879434; Fri, 1 Jul 2016 22:42:01 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AB5F5E003; Fri, 1 Jul 2016 18:41:59 -0400 (EDT) Received: from bahia.lan (unknown [9.164.136.204]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id B3B91112087; Fri, 1 Jul 2016 18:41:57 -0400 (EDT) From: Greg Kurz To: David Gibson Date: Sat, 02 Jul 2016 00:41:56 +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-0028-0000-0000-0000051588D7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070122-0029-0000-0000-00002D2D39B2 Message-Id: <146741291671.948.11796116593986458170.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=2 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.158.5 Subject: [Qemu-devel] [PATCH v2 5/7] ppc: introduce ppc_set_vcpu_dt_id() 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 This patch introduces the ppc_set_vcpu_dt_id() function. It is currently empty but it will be used to generate cpu_dt_id out of a cpu_index provided by the machine. It also changes the machine types to provide cpu_index. Since all of them keep the cpus in an array, cpu_index is simply the index in the array. The only exception is pseries-2.7 which supports hotplug of cpu cores and already open codes the cpu creation. Its case will be covered in follow-up patch. Suggested-by: Igor Mammedov Signed-off-by: Greg Kurz --- hw/ppc/e500.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/ppc.c | 12 +++++++++++- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 2 +- include/hw/ppc/ppc.h | 2 +- 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index ff5d92e48dd9..461dcdc031b0 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -821,7 +821,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) CPUState *cs; qemu_irq *input; - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 6ab675c498d0..888f448796e7 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -193,7 +193,7 @@ static void ppc_core99_init(MachineState *machine) #endif } for (i = 0; i < smp_cpus; i++) { - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 77fbdfffd4e2..ceb92f820dde 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -113,7 +113,7 @@ static void ppc_heathrow_init(MachineState *machine) if (machine->cpu_model == NULL) machine->cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 57f4ddd073d0..dbc8ac7b3a9b 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1352,7 +1352,12 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) return NULL; } -PowerPCCPU *ppc_cpu_init(const char *cpu_model) +static void ppc_set_vcpu_dt_id(PowerPCCPU *cpu, int cpu_index, Error **errp) +{ + ; +} + +PowerPCCPU *ppc_cpu_init(const char *cpu_model, int cpu_index) { PowerPCCPU *cpu; CPUClass *cc; @@ -1374,6 +1379,11 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model) cpu = POWERPC_CPU(object_new(object_class_get_name(oc))); + ppc_set_vcpu_dt_id(cpu, cpu_index, &err); + if (err != NULL) { + goto out; + } + cc = CPU_CLASS(oc); cc->parse_features(CPU(cpu), model_pieces[1], &err); g_strfreev(model_pieces); diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 7f22433c8e91..86c453542a94 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -186,7 +186,7 @@ static void bamboo_init(MachineState *machine) if (machine->cpu_model == NULL) { machine->cpu_model = "440EP"; } - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, 0); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index e62fe643f492..d81d0675255e 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -509,7 +509,7 @@ static void ppc_prep_init(MachineState *machine) if (machine->cpu_model == NULL) machine->cpu_model = "602"; for (i = 0; i < smp_cpus; i++) { - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 690ee486aa07..57dbac2106d2 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1828,7 +1828,7 @@ static void ppc_spapr_init(MachineState *machine) g_free(type); } else { for (i = 0; i < smp_cpus; i++) { - PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model); + PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { error_report("Unable to find PowerPC CPU definition"); exit(1); diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index a4db1db82e1b..647451c9b6ac 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -106,5 +106,5 @@ enum { /* ppc_booke.c */ void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags); -PowerPCCPU *ppc_cpu_init(const char *cpu_model); +PowerPCCPU *ppc_cpu_init(const char *cpu_model, int cpu_index); #endif