From patchwork Tue Jul 12 12:14:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9225179 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 9E29860868 for ; Tue, 12 Jul 2016 12:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D38E27569 for ; Tue, 12 Jul 2016 12:17:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 804DD27DCD; Tue, 12 Jul 2016 12:17:06 +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 AB29227569 for ; Tue, 12 Jul 2016 12:17:05 +0000 (UTC) Received: from localhost ([::1]:39992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMwca-0007Kw-QK for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Jul 2016 08:17:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMwZr-0004Yd-J8 for qemu-devel@nongnu.org; Tue, 12 Jul 2016 08:14:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMwZn-00063r-00 for qemu-devel@nongnu.org; Tue, 12 Jul 2016 08:14:15 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:61985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMwZm-00063M-O5 for qemu-devel@nongnu.org; Tue, 12 Jul 2016 08:14:10 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6CC3mNU066109 for ; Tue, 12 Jul 2016 08:14:10 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 242we1uykv-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 12 Jul 2016 08:14:09 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Jul 2016 06:14:08 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 12 Jul 2016 06:14:05 -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 78B9419D8045; Tue, 12 Jul 2016 06:13:41 -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 u6CCE7r812517864; Tue, 12 Jul 2016 12:14:07 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75E63112077; Tue, 12 Jul 2016 08:14:04 -0400 (EDT) Received: from bahia.lan (unknown [9.164.146.113]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 11508112073; Tue, 12 Jul 2016 08:14:02 -0400 (EDT) From: Greg Kurz To: David Gibson Date: Tue, 12 Jul 2016 14:14:01 +0200 In-Reply-To: <146832546271.14159.13423837073754447992.stgit@bahia.lan> References: <146832546271.14159.13423837073754447992.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: 16071212-0020-0000-0000-0000094D2B95 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16071212-0021-0000-0000-0000539C65E7 Message-Id: <146832562932.14159.12277315156922180749.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-12_06:, , 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-1607120112 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v4 4/5] ppc: each machine type to provide 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-ppc@nongnu.org, qemu-devel@nongnu.org, Bharata B Rao Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch switches machine types to provide device-tree cpu ids. We have three cases to handle: - pseries < 2.7 call ppc_cpu_init() and should compute the DT id as it is currently done in the target code. - pseries 2.7 don't call ppc_cpu_init() and compute the DT as the sum of the core DT id and the the thread index within the core - all other machine types don't support SMT and just need to provide a different index for each vcpu 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 | 5 ++++- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/ppc4xx_devs.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 5 ++++- hw/ppc/spapr_cpu_core.c | 7 +++++-- hw/ppc/virtex_ml507.c | 2 +- include/hw/ppc/ppc.h | 2 +- 11 files changed, 21 insertions(+), 12 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index b9221cc2c14a..513a42a3f952 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -823,7 +823,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 366089085844..9ef9504ff29c 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -194,7 +194,7 @@ static void ppc_core99_init(MachineState *machine) } ppc_cpu_parse_features(machine->cpu_model); 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 5c2dc53cb584..0b09a8da8bf2 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -114,7 +114,7 @@ static void ppc_heathrow_init(MachineState *machine) machine->cpu_model = "G3"; ppc_cpu_parse_features(machine->cpu_model); 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 f908772cd279..7c48f9e04a4f 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1353,7 +1353,7 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) return NULL; } -PowerPCCPU *ppc_cpu_init(const char *cpu_model) +PowerPCCPU *ppc_cpu_init(const char *cpu_model, unsigned vcpu_dt_id) { PowerPCCPU *cpu = NULL; ObjectClass *oc; @@ -1373,6 +1373,9 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model) } cpu = POWERPC_CPU(object_new(object_class_get_name(oc))); + + cpu->cpu_dt_id = vcpu_dt_id; + object_property_set_bool(OBJECT(cpu), true, "realized", &err); out: diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 709a779cba7e..9dbe87207304 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -187,7 +187,7 @@ static void bamboo_init(MachineState *machine) machine->cpu_model = "440EP"; } ppc_cpu_parse_features(machine->cpu_model); - 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/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index 8cbe50361e86..ac39202c0d1c 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -57,7 +57,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model, /* init CPUs */ ppc_cpu_parse_features(cpu_model); - cpu = ppc_cpu_init(cpu_model); + cpu = ppc_cpu_init(cpu_model, 0); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC %s CPU definition\n", cpu_model); diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 99409a09f0ef..9e8cf233d98d 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -510,7 +510,7 @@ static void ppc_prep_init(MachineState *machine) machine->cpu_model = "602"; ppc_cpu_parse_features(machine->cpu_model); 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 658ccee799c0..7bb23af17094 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1837,7 +1837,10 @@ 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); + unsigned core_index = i / smp_threads; + unsigned thread_index = i % smp_threads; + PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model, + core_index * smt + thread_index); if (cpu == NULL) { error_report("Unable to find PowerPC CPU definition"); exit(1); diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 70b6b0b5ee17..e3a3024baf32 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -259,13 +259,16 @@ out: error_propagate(errp, local_err); } -static void spapr_cpu_core_realize_child(Object *child, Error **errp) +static void spapr_cpu_core_realize_child(Object *child, unsigned vcpu_dt_id, + Error **errp) { Error *local_err = NULL; sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); CPUState *cs = CPU(child); PowerPCCPU *cpu = POWERPC_CPU(cs); + cpu->cpu_dt_id = vcpu_dt_id; + object_property_set_bool(child, true, "realized", &local_err); if (local_err) { error_propagate(errp, local_err); @@ -306,7 +309,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) for (j = 0; j < cc->nr_threads; j++) { obj = sc->threads + j * size; - spapr_cpu_core_realize_child(obj, &local_err); + spapr_cpu_core_realize_child(obj, cc->core_id + j, &local_err); if (local_err) { goto err; } diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index a19dd17addda..efbc58137df4 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -97,7 +97,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size, qemu_irq *irqs; ppc_cpu_parse_features(cpu_model); - cpu = ppc_cpu_init(cpu_model); + cpu = ppc_cpu_init(cpu_model, 0); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index 2ed063e09bec..379b2f5d8e3d 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -106,6 +106,6 @@ 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, unsigned vcpu_dt_id); void ppc_cpu_parse_features(const char *cpu_model); #endif