From patchwork Thu Oct 5 16:24:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7J6P1W5yz9sRm for ; Fri, 6 Oct 2017 03:25:49 +1100 (AEDT) Received: from localhost ([::1]:40759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08y3-0002nC-5q for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:25:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xH-0002my-5Q for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:24:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xE-0003Ay-Tk for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:24:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36394) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xE-0003A2-NM; Thu, 05 Oct 2017 12:24:56 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C70B781E04; Thu, 5 Oct 2017 16:24:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C70B781E04 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CA1C5C552; Thu, 5 Oct 2017 16:24:54 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:28 +0200 Message-Id: <1507220690-265042-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Oct 2017 16:24:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/23] qom: update doc comment for type_register[_static]() 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" type_register()/type_register_static() functions in current impl. can't fail returning 0, also none of the users check for error so update doc comment to reflect current behaviour. Suggested-by: Eduardo Habkost Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost Reviewed-by: David Gibson --- include/qom/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index e0d9824..a707b67 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -773,7 +773,7 @@ const char *object_get_typename(const Object *obj); * @info and all of the strings it points to should exist for the life time * that the type is registered. * - * Returns: 0 on failure, the new #Type on success. + * Returns: the new #Type. */ Type type_register_static(const TypeInfo *info); @@ -784,7 +784,7 @@ Type type_register_static(const TypeInfo *info); * Unlike type_register_static(), this call does not require @info or its * string members to continue to exist after the call returns. * - * Returns: 0 on failure, the new #Type on success. + * Returns: the new #Type. */ Type type_register(const TypeInfo *info); From patchwork Thu Oct 5 16:24:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7J6R1vKmz9sRm for ; Fri, 6 Oct 2017 03:25:51 +1100 (AEDT) Received: from localhost ([::1]:40761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08y5-0002o9-9O for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:25:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xH-0002mz-I9 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xG-0003Bm-HM for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:24:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55092) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xG-0003BM-AZ; Thu, 05 Oct 2017 12:24:58 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6575F78EBE; Thu, 5 Oct 2017 16:24:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6575F78EBE Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B5F95C54B; Thu, 5 Oct 2017 16:24:55 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:29 +0200 Message-Id: <1507220690-265042-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Oct 2017 16:24:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 02/23] qom: introduce type_register_static_array() 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" it will help to remove code duplication of registration static types in places that have open coded loop to perform batch type registering. Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: David Gibson --- include/qom/object.h | 10 ++++++++++ qom/object.c | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index a707b67..9a2369c 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -789,6 +789,16 @@ Type type_register_static(const TypeInfo *info); Type type_register(const TypeInfo *info); /** + * type_register_static_array: + * @infos: The array of the new type #TypeInfo structures. + * @nr_infos: number of entries in @infos + * + * @infos and all of the strings it points to should exist for the life time + * that the type is registered. + */ +void type_register_static_array(const TypeInfo *infos, int nr_infos); + +/** * object_class_dynamic_cast_assert: * @klass: The #ObjectClass to attempt to cast. * @typename: The QOM typename of the class to cast to. diff --git a/qom/object.c b/qom/object.c index 6a7bd92..c58c52d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -151,6 +151,15 @@ TypeImpl *type_register_static(const TypeInfo *info) return type_register(info); } +void type_register_static_array(const TypeInfo *infos, int nr_infos) +{ + int i; + + for (i = 0; i < nr_infos; i++) { + type_register_static(&infos[i]); + } +} + static TypeImpl *type_get_by_name(const char *name) { if (name == NULL) { From patchwork Thu Oct 5 16:24:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7J6T0SzGz9sRm for ; Fri, 6 Oct 2017 03:25:52 +1100 (AEDT) Received: from localhost ([::1]:40763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08y6-0002pE-VU for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:25:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xJ-0002nT-LP for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xI-0003DM-Ma for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35428) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xI-0003Ch-AV; Thu, 05 Oct 2017 12:25:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6091D820F7; Thu, 5 Oct 2017 16:24:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6091D820F7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADD165C54B; Thu, 5 Oct 2017 16:24:57 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:30 +0200 Message-Id: <1507220690-265042-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 05 Oct 2017 16:24:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 03/23] qom: add helper macro DEFINE_TYPES() 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" DEFINE_TYPES() will help to simplify following routine patterns: static void foo_register_types(void) { type_register_static(&foo1_type_info); type_register_static(&foo2_type_info); ... } type_init(foo_register_types) or static void foo_register_types(void) { int i; for (i = 0; i < ARRAY_SIZE(type_infos); i++) { type_register_static(&type_infos[i]); } } type_init(foo_register_types) with a single line DEFINE_TYPES(type_infos) where types have static definition which could be consolidated in a single array of TypeInfo structures. It saves us ~6-10LOC per use case and would help to replace imperative foo_register_types() there with declarative style of type registration. Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: David Gibson --- include/qom/object.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 9a2369c..dc73d59 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -79,6 +79,28 @@ typedef struct InterfaceInfo InterfaceInfo; * #TypeInfo describes information about the type including what it inherits * from, the instance and class size, and constructor/destructor hooks. * + * Alternatively several static types could be registered using helper macro + * DEFINE_TYPES() + * + * + * + * static const TypeInfo device_types_info[] = { + * { + * .name = TYPE_MY_DEVICE_A, + * .parent = TYPE_DEVICE, + * .instance_size = sizeof(MyDeviceA), + * }, + * { + * .name = TYPE_MY_DEVICE_B, + * .parent = TYPE_DEVICE, + * .instance_size = sizeof(MyDeviceB), + * }, + * }; + * + * DEFINE_TYPES(device_types_info) + * + * + * * Every type has an #ObjectClass associated with it. #ObjectClass derivatives * are instantiated dynamically but there is only ever one instance for any * given type. The #ObjectClass typically holds a table of function pointers @@ -799,6 +821,20 @@ Type type_register(const TypeInfo *info); void type_register_static_array(const TypeInfo *infos, int nr_infos); /** + * DEFINE_TYPES: + * @type_array: The array containing #TypeInfo structures to register + * + * @type_array should be static constant that exists for the life time + * that the type is registered. + */ +#define DEFINE_TYPES(type_array) \ +static void do_qemu_init_ ## type_array(void) \ +{ \ + type_register_static_array(type_array, ARRAY_SIZE(type_array)); \ +} \ +type_init(do_qemu_init_ ## type_array) + +/** * object_class_dynamic_cast_assert: * @klass: The #ObjectClass to attempt to cast. * @typename: The QOM typename of the class to cast to. From patchwork Thu Oct 5 16:24:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7J9t3VQbz9t1G for ; Fri, 6 Oct 2017 03:28:50 +1100 (AEDT) Received: from localhost ([::1]:40780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e090y-0005ax-FT for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:28:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xK-0002oS-Op for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xJ-0003Ee-Lm for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xJ-0003Dg-Gy; Thu, 05 Oct 2017 12:25:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98676641DC; Thu, 5 Oct 2017 16:25:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 98676641DC Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D8F25E1A4; Thu, 5 Oct 2017 16:24:59 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:31 +0200 Message-Id: <1507220690-265042-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 05 Oct 2017 16:25:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/23] ppc: mpc8544ds/e500plat: use generic cpu_model parsing 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/e500.c | 8 +------- hw/ppc/e500plat.c | 1 + hw/ppc/mpc8544ds.c | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index db0e49a..9178e70 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -803,11 +803,6 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) SysBusDevice *s; PPCE500CCSRState *ccsr; - /* Setup CPUs */ - if (machine->cpu_model == NULL) { - machine->cpu_model = "e500v2_v30"; - } - irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB); for (i = 0; i < smp_cpus; i++) { @@ -815,8 +810,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) CPUState *cs; qemu_irq *input; - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, - machine->cpu_model)); + cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); env = &cpu->env; cs = CPU(cpu); diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 94b4545..e59e80f 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -64,6 +64,7 @@ static void e500plat_machine_init(MachineClass *mc) mc->init = e500plat_init; mc->max_cpus = 32; mc->has_dynamic_sysbus = true; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); } DEFINE_MACHINE("ppce500", e500plat_machine_init) diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c index 27b8289..1717953 100644 --- a/hw/ppc/mpc8544ds.c +++ b/hw/ppc/mpc8544ds.c @@ -16,6 +16,7 @@ #include "sysemu/device_tree.h" #include "hw/ppc/openpic.h" #include "qemu/error-report.h" +#include "cpu.h" static void mpc8544ds_fixup_devtree(PPCE500Params *params, void *fdt) { @@ -55,6 +56,7 @@ static void ppce500_machine_init(MachineClass *mc) mc->desc = "mpc8544ds"; mc->init = mpc8544ds_init; mc->max_cpus = 15; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("e500v2_v30"); } DEFINE_MACHINE("mpc8544ds", ppce500_machine_init) From patchwork Thu Oct 5 16:24:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7J9t1DS9z9t16 for ; Fri, 6 Oct 2017 03:28:50 +1100 (AEDT) Received: from localhost ([::1]:40779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e090y-0005ah-7R for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:28:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xQ-0002t5-Ul for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xL-0003GJ-BL for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36634) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xL-0003FJ-64; Thu, 05 Oct 2017 12:25:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3ACE57AEA3; Thu, 5 Oct 2017 16:25:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3ACE57AEA3 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id E031A4DA3C; Thu, 5 Oct 2017 16:25:00 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:32 +0200 Message-Id: <1507220690-265042-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Oct 2017 16:25:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/23] ppc: mac_newworld: use generic cpu_model parsing 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/mac_newworld.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 6d0ace2..3fa7c42 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -174,16 +174,8 @@ static void ppc_core99_init(MachineState *machine) linux_boot = (kernel_filename != NULL); /* init CPUs */ - if (machine->cpu_model == NULL) { -#ifdef TARGET_PPC64 - machine->cpu_model = "970fx"; -#else - machine->cpu_model = "G4"; -#endif - } for (i = 0; i < smp_cpus; i++) { - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, - machine->cpu_model)); + cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); env = &cpu->env; /* Set time-base frequency to 100 Mhz */ @@ -520,6 +512,11 @@ static void core99_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus = MAX_CPUS; mc->default_boot_order = "cd"; mc->kvm_type = core99_kvm_type; +#ifdef TARGET_PPC64 + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("970fx_v3.1"); +#else + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7400_v2.9"); +#endif } static const TypeInfo core99_machine_info = { From patchwork Thu Oct 5 16:24:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JB94np4z9t2m for ; Fri, 6 Oct 2017 03:29:05 +1100 (AEDT) Received: from localhost ([::1]:40782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e091D-0005ri-O2 for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:29:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xQ-0002sb-Gy for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xN-0003HT-Dr for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xN-0003H7-7X; Thu, 05 Oct 2017 12:25:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFC958123E; Thu, 5 Oct 2017 16:25:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DFC958123E Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F32A4DA3C; Thu, 5 Oct 2017 16:25:02 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:33 +0200 Message-Id: <1507220690-265042-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Oct 2017 16:25:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 06/23] ppc: mac_oldworld: use generic cpu_model parsing 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/mac_oldworld.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index bc7c8b7..010ea36 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -108,11 +108,8 @@ static void ppc_heathrow_init(MachineState *machine) linux_boot = (kernel_filename != NULL); /* init CPUs */ - if (machine->cpu_model == NULL) - machine->cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, - machine->cpu_model)); + cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); env = &cpu->env; /* Set time-base frequency to 16.6 Mhz */ @@ -385,6 +382,7 @@ static void heathrow_class_init(ObjectClass *oc, void *data) /* TOFIX "cad" when Mac floppy is implemented */ mc->default_boot_order = "cd"; mc->kvm_type = heathrow_kvm_type; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("750_v3.1"); } static const TypeInfo ppc_heathrow_machine_info = { From patchwork Thu Oct 5 16:24:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JDq5LBRz9sRm for ; Fri, 6 Oct 2017 03:31:23 +1100 (AEDT) Received: from localhost ([::1]:40793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e093R-0007xF-Hm for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:31:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xU-0002wd-Ep for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xO-0003Hv-H9 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56632) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xO-0003Hg-Bn; Thu, 05 Oct 2017 12:25:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 69830C047B74; Thu, 5 Oct 2017 16:25:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 69830C047B74 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F0D861789; Thu, 5 Oct 2017 16:25:03 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:34 +0200 Message-Id: <1507220690-265042-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 05 Oct 2017 16:25:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 07/23] ppc: bamboo: use generic cpu_model parsing 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/ppc440_bamboo.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index f92d47f..693c215 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -182,11 +182,7 @@ static void bamboo_init(MachineState *machine) int success; int i; - /* Setup CPU. */ - if (machine->cpu_model == NULL) { - machine->cpu_model = "440EP"; - } - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model)); + cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); env = &cpu->env; if (env->mmu_model != POWERPC_MMU_BOOKE) { @@ -297,6 +293,7 @@ static void bamboo_machine_init(MachineClass *mc) { mc->desc = "bamboo"; mc->init = bamboo_init; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("440epb"); } DEFINE_MACHINE("bamboo", bamboo_machine_init) From patchwork Thu Oct 5 16:24:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JDs107vz9sRm for ; Fri, 6 Oct 2017 03:31:25 +1100 (AEDT) Received: from localhost ([::1]:40794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e093T-0007zh-4I for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:31:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xU-0002wV-AJ for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xQ-0003J7-9H for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55578) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xQ-0003Ib-3p; Thu, 05 Oct 2017 12:25:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15B9678EB0; Thu, 5 Oct 2017 16:25:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15B9678EB0 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id B27A65C54B; Thu, 5 Oct 2017 16:25:05 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:35 +0200 Message-Id: <1507220690-265042-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Oct 2017 16:25:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 08/23] ppc: replace cpu_model with cpu_type on ref405ep, taihu boards 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/ppc405_uc.c | 6 ++++-- hw/ppc/ppc4xx_devs.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c index 8e58065..205ebce 100644 --- a/hw/ppc/ppc405_uc.c +++ b/hw/ppc/ppc405_uc.c @@ -1629,7 +1629,8 @@ CPUPPCState *ppc405cr_init(MemoryRegion *address_space_mem, qemu_irq *pic, *irqs; memset(clk_setup, 0, sizeof(clk_setup)); - cpu = ppc4xx_init("405cr", &clk_setup[PPC405CR_CPU_CLK], + cpu = ppc4xx_init(POWERPC_CPU_TYPE_NAME("405crc"), + &clk_setup[PPC405CR_CPU_CLK], &clk_setup[PPC405CR_TMR_CLK], sysclk); env = &cpu->env; /* Memory mapped devices registers */ @@ -1981,7 +1982,8 @@ CPUPPCState *ppc405ep_init(MemoryRegion *address_space_mem, memset(clk_setup, 0, sizeof(clk_setup)); /* init CPUs */ - cpu = ppc4xx_init("405ep", &clk_setup[PPC405EP_CPU_CLK], + cpu = ppc4xx_init(POWERPC_CPU_TYPE_NAME("405ep"), + &clk_setup[PPC405EP_CPU_CLK], &tlb_clk_setup, sysclk); env = &cpu->env; clk_setup[PPC405EP_CPU_CLK].cb = tlb_clk_setup.cb; diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index 6d7f785..2e96389 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -48,7 +48,7 @@ static void ppc4xx_reset(void *opaque) /*****************************************************************************/ /* Generic PowerPC 4xx processor instantiation */ -PowerPCCPU *ppc4xx_init(const char *cpu_model, +PowerPCCPU *ppc4xx_init(const char *cpu_type, clk_setup_t *cpu_clk, clk_setup_t *tb_clk, uint32_t sysclk) { @@ -56,7 +56,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model, CPUPPCState *env; /* init CPUs */ - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); + cpu = POWERPC_CPU(cpu_create(cpu_type)); env = &cpu->env; cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */ From patchwork Thu Oct 5 16:24:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JMP0mdhz9rvt for ; Fri, 6 Oct 2017 03:37:05 +1100 (AEDT) Received: from localhost ([::1]:40823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e098x-0004GT-4o for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:37:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xW-0002yP-3q for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xR-0003Jy-Pm for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35930) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xR-0003Jg-Jd; Thu, 05 Oct 2017 12:25:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE6378210E; Thu, 5 Oct 2017 16:25:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE6378210E Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 523265E1A4; Thu, 5 Oct 2017 16:25:07 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:36 +0200 Message-Id: <1507220690-265042-10-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 05 Oct 2017 16:25:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 09/23] ppc: virtex-ml507: replace cpu_model with cpu_type 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/virtex_ml507.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index ed9b406..5ac4f76 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -89,14 +89,14 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env, static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size, int do_init, - const char *cpu_model, + const char *cpu_type, uint32_t sysclk) { PowerPCCPU *cpu; CPUPPCState *env; qemu_irq *irqs; - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); + cpu = POWERPC_CPU(cpu_create(cpu_type)); env = &cpu->env; ppc_booke_timers_init(cpu, sysclk, 0/* no flags */); @@ -211,11 +211,7 @@ static void virtex_init(MachineState *machine) int i; /* init CPUs */ - if (machine->cpu_model == NULL) { - machine->cpu_model = "440-Xilinx"; - } - - cpu = ppc440_init_xilinx(&ram_size, 1, machine->cpu_model, 400000000); + cpu = ppc440_init_xilinx(&ram_size, 1, machine->cpu_type, 400000000); env = &cpu->env; if (env->mmu_model != POWERPC_MMU_BOOKE) { @@ -307,6 +303,7 @@ static void virtex_machine_init(MachineClass *mc) { mc->desc = "Xilinx Virtex ML507 reference design"; mc->init = virtex_init; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("440-xilinx"); } DEFINE_MACHINE("virtex-ml507", virtex_machine_init) From patchwork Thu Oct 5 16:24:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JRg2zQ5z9t16 for ; Fri, 6 Oct 2017 03:40:47 +1100 (AEDT) Received: from localhost ([::1]:40842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09CX-0007N3-Gk for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:40:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xU-0002we-FP for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xT-0003Kz-DP for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xT-0003KL-75; Thu, 05 Oct 2017 12:25:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4029A9D502; Thu, 5 Oct 2017 16:25:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4029A9D502 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id E88335C54B; Thu, 5 Oct 2017 16:25:08 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:37 +0200 Message-Id: <1507220690-265042-11-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 05 Oct 2017 16:25:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/23] ppc: 40p/prep: replace cpu_model with cpu_type 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/prep.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 94138a4..6f8accc 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -517,11 +517,8 @@ static void ppc_prep_init(MachineState *machine) linux_boot = (kernel_filename != NULL); /* init CPUs */ - if (machine->cpu_model == NULL) - machine->cpu_model = "602"; for (i = 0; i < smp_cpus; i++) { - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, - machine->cpu_model)); + cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); env = &cpu->env; if (env->flags & POWERPC_FLAG_RTC_CLK) { @@ -684,6 +681,7 @@ static void prep_machine_init(MachineClass *mc) mc->block_default_type = IF_IDE; mc->max_cpus = MAX_CPUS; mc->default_boot_order = "cad"; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("602"); } static int prep_set_cmos_checksum(DeviceState *dev, void *opaque) @@ -718,10 +716,7 @@ static void ibm_40p_init(MachineState *machine) char boot_device; /* init CPU */ - if (!machine->cpu_model) { - machine->cpu_model = "604"; - } - cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model)); + cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); env = &cpu->env; if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { error_report("only 6xx bus is supported on this machine"); @@ -894,6 +889,7 @@ static void ibm_40p_machine_init(MachineClass *mc) mc->default_ram_size = 128 * M_BYTE; mc->block_default_type = IF_SCSI; mc->default_boot_order = "c"; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("604"); } DEFINE_MACHINE("40p", ibm_40p_machine_init) From patchwork Thu Oct 5 16:24:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JJD4lzSz9t16 for ; Fri, 6 Oct 2017 03:34:20 +1100 (AEDT) Received: from localhost ([::1]:40806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e096I-0001rL-OG for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:34:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xW-0002yY-3o for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xV-0003Mh-4R for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36060) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xU-0003Ln-S5; Thu, 05 Oct 2017 12:25:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D477682111; Thu, 5 Oct 2017 16:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D477682111 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 887195C552; Thu, 5 Oct 2017 16:25:10 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:38 +0200 Message-Id: <1507220690-265042-12-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 05 Oct 2017 16:25:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 11/23] ppc: spapr: replace ppc_cpu_parse_features() with cpu_parse_cpu_model() 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" ppc_cpu_parse_features() is doing practically the same thing as generic cpu_parse_cpu_model(). So remove duplicated impl. and reuse generic one. Signed-off-by: Igor Mammedov Reviewed-by: Greg Kurz Acked-by: David Gibson --- include/hw/ppc/ppc.h | 2 -- hw/ppc/ppc.c | 25 ------------------------- hw/ppc/spapr_cpu_core.c | 9 ++++----- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index 4e7fe11..ff0ac30 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -105,6 +105,4 @@ enum { /* ppc_booke.c */ void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags); - -void ppc_cpu_parse_features(const char *cpu_model); #endif diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 05da316..7ec35de 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1359,28 +1359,3 @@ void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val) break; } } - -void ppc_cpu_parse_features(const char *cpu_model) -{ - CPUClass *cc; - ObjectClass *oc; - const char *typename; - gchar **model_pieces; - - model_pieces = g_strsplit(cpu_model, ",", 2); - if (!model_pieces[0]) { - error_report("Invalid/empty CPU model name"); - exit(1); - } - - oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]); - if (oc == NULL) { - error_report("Unable to find CPU definition: %s", model_pieces[0]); - exit(1); - } - - typename = object_class_get_name(oc); - cc = CPU_CLASS(oc); - cc->parse_features(typename, model_pieces[1], &error_fatal); - g_strfreev(model_pieces); -} diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 3e20b1d..3dea5ff 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -34,6 +34,7 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr) * before passing it on to the cpu level parser. */ gchar **inpieces; + gchar *newprops; int i, j; gchar *compat_str = NULL; @@ -58,17 +59,15 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr) if (compat_str) { char *val = compat_str + strlen("compat="); - gchar *newprops = g_strjoinv(",", inpieces); object_property_set_str(OBJECT(spapr), val, "max-cpu-compat", &error_fatal); - ppc_cpu_parse_features(newprops); - g_free(newprops); - } else { - ppc_cpu_parse_features(MACHINE(spapr)->cpu_model); } + newprops = g_strjoinv(",", inpieces); + cpu_parse_cpu_model(TYPE_POWERPC_CPU, newprops); + g_free(newprops); g_strfreev(inpieces); } From patchwork Thu Oct 5 16:24:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JFC4ZWYz9sRm for ; Fri, 6 Oct 2017 03:31:43 +1100 (AEDT) Received: from localhost ([::1]:40796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e093l-0008BR-FZ for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:31:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xZ-00036B-Js for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xW-0003QO-Ps for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56928) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xW-0003Nh-DT; Thu, 05 Oct 2017 12:25:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73963C04AC4E; Thu, 5 Oct 2017 16:25:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73963C04AC4E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 288715C552; Thu, 5 Oct 2017 16:25:12 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:39 +0200 Message-Id: <1507220690-265042-13-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 05 Oct 2017 16:25:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 12/23] ppc: move '-cpu foo, compat=xxx' parsing into ppc_cpu_parse_featurestr() 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" there is a dedicated callback CPUClass::parse_features which purpose is to convert -cpu features into a set of global properties AND deal with compat/legacy features that couldn't be directly translated into CPU's properties. Create ppc variant of it (ppc_cpu_parse_featurestr) and move 'compat=val' handling from spapr_cpu_core.c into it. That removes a dependency of board/core code on cpu_model parsing and would let to reuse common -cpu parsing introduced by 6063d4c0 Signed-off-by: Igor Mammedov --- include/hw/ppc/spapr.h | 1 - target/ppc/cpu-qom.h | 1 + hw/ppc/spapr.c | 2 +- hw/ppc/spapr_cpu_core.c | 50 -------------------------------------- target/ppc/translate_init.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 52 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index c1b365f..8ca4f94 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -659,7 +659,6 @@ void spapr_hotplug_req_add_by_count_indexed(sPAPRDRConnectorType drc_type, uint32_t count, uint32_t index); void spapr_hotplug_req_remove_by_count_indexed(sPAPRDRConnectorType drc_type, uint32_t count, uint32_t index); -void spapr_cpu_parse_features(sPAPRMachineState *spapr); int spapr_hpt_shift_for_ramsize(uint64_t ramsize); void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift, Error **errp); diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index d0cf6ca..429b47f 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -181,6 +181,7 @@ typedef struct PowerPCCPUClass { DeviceRealize parent_realize; DeviceUnrealize parent_unrealize; void (*parent_reset)(CPUState *cpu); + void (*parent_parse_features)(const char *type, char *str, Error **errp); uint32_t pvr; bool (*pvr_match)(struct PowerPCCPUClass *pcc, uint32_t pvr); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ff87f15..01b3012 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2366,7 +2366,7 @@ static void ppc_spapr_init(MachineState *machine) machine->cpu_model = kvm_enabled() ? "host" : smc->tcg_default_cpu; } - spapr_cpu_parse_features(spapr); + cpu_parse_cpu_model(TYPE_POWERPC_CPU, machine->cpu_model); spapr_set_vsmt_mode(spapr, &error_fatal); diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 3dea5ff..427d47f 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -21,56 +21,6 @@ #include "sysemu/hw_accel.h" #include "qemu/error-report.h" -void spapr_cpu_parse_features(sPAPRMachineState *spapr) -{ - /* - * Backwards compatibility hack: - * - * CPUs had a "compat=" property which didn't make sense for - * anything except pseries. It was replaced by "max-cpu-compat" - * machine option. This supports old command lines like - * -cpu POWER8,compat=power7 - * By stripping the compat option and applying it to the machine - * before passing it on to the cpu level parser. - */ - gchar **inpieces; - gchar *newprops; - int i, j; - gchar *compat_str = NULL; - - inpieces = g_strsplit(MACHINE(spapr)->cpu_model, ",", 0); - - /* inpieces[0] is the actual model string */ - i = 1; - j = 1; - while (inpieces[i]) { - if (g_str_has_prefix(inpieces[i], "compat=")) { - /* in case of multiple compat= options */ - g_free(compat_str); - compat_str = inpieces[i]; - } else { - j++; - } - - i++; - /* Excise compat options from list */ - inpieces[j] = inpieces[i]; - } - - if (compat_str) { - char *val = compat_str + strlen("compat="); - - object_property_set_str(OBJECT(spapr), val, "max-cpu-compat", - &error_fatal); - - } - - newprops = g_strjoinv(",", inpieces); - cpu_parse_cpu_model(TYPE_POWERPC_CPU, newprops); - g_free(newprops); - g_strfreev(inpieces); -} - static void spapr_cpu_reset(void *opaque) { PowerPCCPU *cpu = opaque; diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index c6399a3..5ee91e8 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10313,6 +10313,62 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name) return NULL; } +static void ppc_cpu_parse_featurestr(const char *typename, char *features, + Error **errp) +{ + const PowerPCCPUClass *pcc; + char *compat_str = NULL; + char *s = features; + char **inpieces; + Error *local_err = NULL; + int i; + + if (!features) { + return; + } + + /* + * Backwards compatibility hack: + * + * CPUs had a "compat=" property which didn't make sense for + * anything except pseries. It was replaced by "max-cpu-compat" + * machine option. This supports old command lines like + * -cpu POWER8,compat=power7 + * By stripping the compat option and applying it to the machine + * before passing it on to the cpu level parser. + */ + inpieces = g_strsplit(features, ",", 0); + *s = '\0'; + for (i = 0; inpieces[i]; i++) { + if (g_str_has_prefix(inpieces[i], "compat=")) { + compat_str = inpieces[i]; + continue; + } + if ((i != 0) && (s != features)) { + s = g_stpcpy(s, ","); + } + s = g_stpcpy(s, inpieces[i]); + } + + if (compat_str) { + Object *machine = qdev_get_machine(); + if (machine) { + char *v = compat_str + strlen("compat="); + object_property_set_str(machine, v, "max-cpu-compat", &local_err); + } else { + error_setg(&local_err, "Not supported property: %s", compat_str); + } + } + g_strfreev(inpieces); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + /* do property processing with generic handler */ + pcc = POWERPC_CPU_CLASS(object_class_by_name(typename)); + pcc->parent_parse_features(typename, features, errp); +} const char *ppc_cpu_lookup_alias(const char *alias) { @@ -10706,6 +10762,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->reset = ppc_cpu_reset; cc->class_by_name = ppc_cpu_class_by_name; + pcc->parent_parse_features = cc->parse_features; + cc->parse_features = ppc_cpu_parse_featurestr; cc->has_work = ppc_cpu_has_work; cc->do_interrupt = ppc_cpu_do_interrupt; cc->cpu_exec_interrupt = ppc_cpu_exec_interrupt; From patchwork Thu Oct 5 16:24:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JJB3jwNz9rvt for ; Fri, 6 Oct 2017 03:34:18 +1100 (AEDT) Received: from localhost ([::1]:40805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e096G-0001pH-CN for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:34:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xZ-00036C-KX for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xY-0003T1-H2 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xY-0003RF-25; Thu, 05 Oct 2017 12:25:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 142A278ECB; Thu, 5 Oct 2017 16:25:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 142A278ECB Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBC545C54B; Thu, 5 Oct 2017 16:25:13 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:40 +0200 Message-Id: <1507220690-265042-14-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Oct 2017 16:25:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 13/23] ppc: spapr: define core types statically 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" spapr core type definition doesn't have any fields that require it to be defined at runtime. So replace code that fills in TypeInfo at runtime with static TypeInfo array that does the same at complie time. Signed-off-by: Igor Mammedov Reviewed-by: Greg Kurz Acked-by: David Gibson --- include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 85 +++++++++++++---------------------------- 2 files changed, 29 insertions(+), 58 deletions(-) diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_core.h index 93051e9..66dcf52 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -21,6 +21,8 @@ #define SPAPR_CPU_CORE_GET_CLASS(obj) \ OBJECT_GET_CLASS(sPAPRCPUCoreClass, (obj), TYPE_SPAPR_CPU_CORE) +#define SPAPR_CPU_CORE_TYPE_NAME(model) model "-" TYPE_SPAPR_CPU_CORE + typedef struct sPAPRCPUCore { /*< private >*/ CPUCore parent_obj; diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 427d47f..01f4ec8 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -217,36 +217,6 @@ err: error_propagate(errp, local_err); } -static const char *spapr_core_models[] = { - /* 970 */ - "970_v2.2", - - /* 970MP variants */ - "970mp_v1.0", - "970mp_v1.1", - - /* POWER5+ */ - "power5+_v2.1", - - /* POWER7 */ - "power7_v2.3", - - /* POWER7+ */ - "power7+_v2.1", - - /* POWER8 */ - "power8_v2.0", - - /* POWER8E */ - "power8e_v2.1", - - /* POWER8NVL */ - "power8nvl_v1.0", - - /* POWER9 */ - "power9_v1.0", -}; - static Property spapr_cpu_core_properties[] = { DEFINE_PROP_INT32("node-id", sPAPRCPUCore, node_id, CPU_UNSET_NUMA_NODE_ID), DEFINE_PROP_END_OF_LIST() @@ -264,33 +234,32 @@ void spapr_cpu_core_class_init(ObjectClass *oc, void *data) g_assert(scc->cpu_class); } -static const TypeInfo spapr_cpu_core_type_info = { - .name = TYPE_SPAPR_CPU_CORE, - .parent = TYPE_CPU_CORE, - .abstract = true, - .instance_size = sizeof(sPAPRCPUCore), - .class_size = sizeof(sPAPRCPUCoreClass), -}; - -static void spapr_cpu_core_register_types(void) -{ - int i; - - type_register_static(&spapr_cpu_core_type_info); - - for (i = 0; i < ARRAY_SIZE(spapr_core_models); i++) { - TypeInfo type_info = { - .parent = TYPE_SPAPR_CPU_CORE, - .instance_size = sizeof(sPAPRCPUCore), - .class_init = spapr_cpu_core_class_init, - .class_data = (void *) spapr_core_models[i], - }; - - type_info.name = g_strdup_printf("%s-" TYPE_SPAPR_CPU_CORE, - spapr_core_models[i]); - type_register(&type_info); - g_free((void *)type_info.name); +#define DEFINE_SPAPR_CPU_CORE_TYPE(cpu_model) \ + { \ + .parent = TYPE_SPAPR_CPU_CORE, \ + .class_data = (void *) cpu_model, \ + .class_init = spapr_cpu_core_class_init, \ + .name = SPAPR_CPU_CORE_TYPE_NAME(cpu_model), \ } -} -type_init(spapr_cpu_core_register_types) +static const TypeInfo spapr_cpu_core_type_infos[] = { + { + .name = TYPE_SPAPR_CPU_CORE, + .parent = TYPE_CPU_CORE, + .abstract = true, + .instance_size = sizeof(sPAPRCPUCore), + .class_size = sizeof(sPAPRCPUCoreClass), + }, + DEFINE_SPAPR_CPU_CORE_TYPE("970_v2.2"), + DEFINE_SPAPR_CPU_CORE_TYPE("970mp_v1.0"), + DEFINE_SPAPR_CPU_CORE_TYPE("970mp_v1.1"), + DEFINE_SPAPR_CPU_CORE_TYPE("power5+_v2.1"), + DEFINE_SPAPR_CPU_CORE_TYPE("power7_v2.3"), + DEFINE_SPAPR_CPU_CORE_TYPE("power7+_v2.1"), + DEFINE_SPAPR_CPU_CORE_TYPE("power8_v2.0"), + DEFINE_SPAPR_CPU_CORE_TYPE("power8e_v2.1"), + DEFINE_SPAPR_CPU_CORE_TYPE("power8nvl_v1.0"), + DEFINE_SPAPR_CPU_CORE_TYPE("power9_v1.0"), +}; + +DEFINE_TYPES(spapr_cpu_core_type_infos) From patchwork Thu Oct 5 16:24:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821937 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JML5G5dz9rvt for ; Fri, 6 Oct 2017 03:37:02 +1100 (AEDT) Received: from localhost ([::1]:40822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e098u-0004Dj-Py for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:37:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xb-00038R-9b for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xZ-0003V4-Ua for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xZ-0003Tf-KZ; Thu, 05 Oct 2017 12:25:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A53B178EC2; Thu, 5 Oct 2017 16:25:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A53B178EC2 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B70C5C54B; Thu, 5 Oct 2017 16:25:15 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:41 +0200 Message-Id: <1507220690-265042-15-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Oct 2017 16:25:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 14/23] ppc: spapr: use cpu type name directly 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" replace sPAPRCPUCoreClass::cpu_class with cpu type name since it were needed just to get that at points it were accessed. Signed-off-by: Igor Mammedov Reviewed-by: Greg Kurz Acked-by: David Gibson --- include/hw/ppc/spapr_cpu_core.h | 2 +- hw/ppc/spapr.c | 6 ++---- hw/ppc/spapr_cpu_core.c | 13 +++++-------- target/ppc/kvm.c | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_core.h index 66dcf52..264ce68 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -34,7 +34,7 @@ typedef struct sPAPRCPUCore { typedef struct sPAPRCPUCoreClass { DeviceClass parent_class; - ObjectClass *cpu_class; + const char *cpu_type; } sPAPRCPUCoreClass; char *spapr_get_cpu_core_type(const char *model); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 01b3012..ad7afd6 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3142,8 +3142,7 @@ void spapr_core_release(DeviceState *dev) if (smc->pre_2_10_has_unused_icps) { sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc)); - const char *typename = object_class_get_name(scc->cpu_class); - size_t size = object_type_get_instance_size(typename); + size_t size = object_type_get_instance_size(scc->cpu_type); int i; for (i = 0; i < cc->nr_threads; i++) { @@ -3239,8 +3238,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, if (smc->pre_2_10_has_unused_icps) { sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(cc)); - const char *typename = object_class_get_name(scc->cpu_class); - size_t size = object_type_get_instance_size(typename); + size_t size = object_type_get_instance_size(scc->cpu_type); int i; for (i = 0; i < cc->nr_threads; i++) { diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 01f4ec8..8e13e52 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -90,8 +90,7 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp) { sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); - const char *typename = object_class_get_name(scc->cpu_class); - size_t size = object_type_get_instance_size(typename); + size_t size = object_type_get_instance_size(scc->cpu_type); CPUCore *cc = CPU_CORE(dev); int i; @@ -152,8 +151,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); CPUCore *cc = CPU_CORE(OBJECT(dev)); - const char *typename = object_class_get_name(scc->cpu_class); - size_t size = object_type_get_instance_size(typename); + size_t size = object_type_get_instance_size(scc->cpu_type); Error *local_err = NULL; void *obj; int i, j; @@ -172,7 +170,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) obj = sc->threads + i * size; - object_initialize(obj, size, typename); + object_initialize(obj, size, scc->cpu_type); cs = CPU(obj); cpu = POWERPC_CPU(cs); cs->cpu_index = cc->core_id + i; @@ -230,14 +228,13 @@ void spapr_cpu_core_class_init(ObjectClass *oc, void *data) dc->realize = spapr_cpu_core_realize; dc->unrealize = spapr_cpu_core_unrealizefn; dc->props = spapr_cpu_core_properties; - scc->cpu_class = cpu_class_by_name(TYPE_POWERPC_CPU, data); - g_assert(scc->cpu_class); + scc->cpu_type = data; } #define DEFINE_SPAPR_CPU_CORE_TYPE(cpu_model) \ { \ .parent = TYPE_SPAPR_CPU_CORE, \ - .class_data = (void *) cpu_model, \ + .class_data = (void *) POWERPC_CPU_TYPE_NAME(cpu_model), \ .class_init = spapr_cpu_core_class_init, \ .name = SPAPR_CPU_CORE_TYPE_NAME(cpu_model), \ } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 171d3d8..c2152ed 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2514,7 +2514,7 @@ static int kvm_ppc_register_host_cpu_type(void) type_info.instance_size = sizeof(sPAPRCPUCore); type_info.instance_init = NULL; type_info.class_init = spapr_cpu_core_class_init; - type_info.class_data = (void *) "host"; + type_info.class_data = (void *) POWERPC_CPU_TYPE_NAME("host"); type_register(&type_info); g_free((void *)type_info.name); #endif From patchwork Thu Oct 5 16:24:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JB94Crsz9t1G for ; Fri, 6 Oct 2017 03:29:05 +1100 (AEDT) Received: from localhost ([::1]:40781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e091D-0005qw-HV for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:29:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xd-0003Ae-BJ for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xc-0003YV-0V for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48875) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xb-0003Wh-HR; Thu, 05 Oct 2017 12:25:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 484707EABE; Thu, 5 Oct 2017 16:25:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 484707EABE Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE24B5E1A4; Thu, 5 Oct 2017 16:25:16 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:42 +0200 Message-Id: <1507220690-265042-16-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 05 Oct 2017 16:25:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 15/23] ppc: spapr: register 'host' core type along with the rest of core types 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" consolidate 'host' core type registration by moving it from KVM specific code into spapr_cpu_core.c, similar like it's done in x86 target. Signed-off-by: Igor Mammedov Reviewed-by: Greg Kurz Acked-by: David Gibson --- include/hw/ppc/spapr_cpu_core.h | 1 - hw/ppc/spapr_cpu_core.c | 5 ++++- target/ppc/kvm.c | 11 ----------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_core.h index 264ce68..42765de 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -38,5 +38,4 @@ typedef struct sPAPRCPUCoreClass { } sPAPRCPUCoreClass; char *spapr_get_cpu_core_type(const char *model); -void spapr_cpu_core_class_init(ObjectClass *oc, void *data); #endif diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 8e13e52..f2da4be 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -220,7 +220,7 @@ static Property spapr_cpu_core_properties[] = { DEFINE_PROP_END_OF_LIST() }; -void spapr_cpu_core_class_init(ObjectClass *oc, void *data) +static void spapr_cpu_core_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); sPAPRCPUCoreClass *scc = SPAPR_CPU_CORE_CLASS(oc); @@ -257,6 +257,9 @@ static const TypeInfo spapr_cpu_core_type_infos[] = { DEFINE_SPAPR_CPU_CORE_TYPE("power8e_v2.1"), DEFINE_SPAPR_CPU_CORE_TYPE("power8nvl_v1.0"), DEFINE_SPAPR_CPU_CORE_TYPE("power9_v1.0"), +#ifdef CONFIG_KVM + DEFINE_SPAPR_CPU_CORE_TYPE("host"), +#endif }; DEFINE_TYPES(spapr_cpu_core_type_infos) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index c2152ed..cb5777a 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2508,17 +2508,6 @@ static int kvm_ppc_register_host_cpu_type(void) oc = object_class_by_name(type_info.name); g_assert(oc); -#if defined(TARGET_PPC64) - type_info.name = g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, "host"); - type_info.parent = TYPE_SPAPR_CPU_CORE, - type_info.instance_size = sizeof(sPAPRCPUCore); - type_info.instance_init = NULL; - type_info.class_init = spapr_cpu_core_class_init; - type_info.class_data = (void *) POWERPC_CPU_TYPE_NAME("host"); - type_register(&type_info); - g_free((void *)type_info.name); -#endif - /* * Update generic CPU family class alias (e.g. on a POWER8NVL host, * we want "POWER8" to be a "family" alias that points to the current From patchwork Thu Oct 5 16:24:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JL86hf1z9rvt for ; Fri, 6 Oct 2017 03:36:00 +1100 (AEDT) Received: from localhost ([::1]:40817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e097v-0003IG-0y for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:35:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xi-0003Fq-3i for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xd-0003bS-Ed for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56164) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xd-0003Z0-2E; Thu, 05 Oct 2017 12:25:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7DA5780CF; Thu, 5 Oct 2017 16:25:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D7DA5780CF Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C9C95C54B; Thu, 5 Oct 2017 16:25:18 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:43 +0200 Message-Id: <1507220690-265042-17-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Oct 2017 16:25:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 16/23] ppc: spapr: use cpu model names as tcg defaults instead of aliases 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ad7afd6..0661dba 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3603,7 +3603,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) hc->unplug_request = spapr_machine_device_unplug_request; smc->dr_lmb_enabled = true; - smc->tcg_default_cpu = "POWER8"; + smc->tcg_default_cpu = "power8_v2.0"; mc->has_hotpluggable_cpus = true; smc->resize_hpt_default = SPAPR_RESIZE_HPT_ENABLED; fwc->get_dev_path = spapr_get_fw_dev_path; @@ -3849,7 +3849,7 @@ static void spapr_machine_2_7_class_options(MachineClass *mc) sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc); spapr_machine_2_8_class_options(mc); - smc->tcg_default_cpu = "POWER7"; + smc->tcg_default_cpu = "power7_v2.3"; SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_7); smc->phb_placement = phb_placement_2_7; } From patchwork Thu Oct 5 16:24:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JW00dpPz9t1G for ; Fri, 6 Oct 2017 03:43:40 +1100 (AEDT) Received: from localhost ([::1]:40861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09FK-0001WN-1p for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:43:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xi-0003G8-DH for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xf-0003eN-4T for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45925) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xe-0003cN-EH; Thu, 05 Oct 2017 12:25:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 764E85F7BB; Thu, 5 Oct 2017 16:25:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 764E85F7BB Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B9AE5C54B; Thu, 5 Oct 2017 16:25:20 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:44 +0200 Message-Id: <1507220690-265042-18-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 05 Oct 2017 16:25:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 17/23] ppc: spapr: use generic cpu_model parsing 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" use generic cpu_model parsing introduced by (6063d4c0f vl.c: convert cpu_model to cpu type and set of global properties before machine_init()) it allows to: * replace sPAPRMachineClass::tcg_default_cpu with MachineClass::default_cpu_type * drop cpu_parse_cpu_model() from hw/ppc/spapr.c and reuse one in vl.c * simplify spapr_get_cpu_core_type() by removing not needed anymore recurrsion since alias look up happens earlier at vl.c and spapr_get_cpu_core_type() works only with resulted from that cpu type. * spapr no more needs to parse/depend on being phased out MachineState::cpu_model, all tha parsing done by generic code and target specific callback. Signed-off-by: Igor Mammedov --- PS: patch is a little bit big but it's hard to split it due to dependencies, so pls bear with it. --- include/hw/ppc/spapr.h | 1 - include/hw/ppc/spapr_cpu_core.h | 2 +- target/ppc/cpu.h | 1 - hw/ppc/spapr.c | 16 ++++------------ hw/ppc/spapr_cpu_core.c | 30 ++++++++++-------------------- target/ppc/kvm.c | 9 ++++++--- target/ppc/translate_init.c | 26 +++++++++++++------------- 7 files changed, 34 insertions(+), 51 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 8ca4f94..9d21ca9 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -60,7 +60,6 @@ struct sPAPRMachineClass { /*< public >*/ bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ - const char *tcg_default_cpu; /* which (TCG) CPU to simulate by default */ bool pre_2_10_has_unused_icps; void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_core.h index 42765de..f2d48d6 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -37,5 +37,5 @@ typedef struct sPAPRCPUCoreClass { const char *cpu_type; } sPAPRCPUCoreClass; -char *spapr_get_cpu_core_type(const char *model); +const char *spapr_get_cpu_core_type(const char *cpu_type); #endif diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 64aef17..989761b 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1278,7 +1278,6 @@ extern const struct VMStateDescription vmstate_ppc_cpu; /*****************************************************************************/ void ppc_translate_init(void); -const char *ppc_cpu_lookup_alias(const char *alias); /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0661dba..29de845 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2123,7 +2123,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) { MachineState *machine = MACHINE(spapr); MachineClass *mc = MACHINE_GET_CLASS(machine); - char *type = spapr_get_cpu_core_type(machine->cpu_model); + const char *type = spapr_get_cpu_core_type(machine->cpu_type); int smt = kvmppc_smt_threads(); const CPUArchIdList *possible_cpus; int boot_cores_nr = smp_cpus / smp_threads; @@ -2178,7 +2178,6 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) object_property_set_bool(core, true, "realized", &error_fatal); } } - g_free(type); } static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp) @@ -2362,12 +2361,6 @@ static void ppc_spapr_init(MachineState *machine) } /* init CPUs */ - if (machine->cpu_model == NULL) { - machine->cpu_model = kvm_enabled() ? "host" : smc->tcg_default_cpu; - } - - cpu_parse_cpu_model(TYPE_POWERPC_CPU, machine->cpu_model); - spapr_set_vsmt_mode(spapr, &error_fatal); spapr_init_cpus(spapr); @@ -3258,7 +3251,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, MachineClass *mc = MACHINE_GET_CLASS(hotplug_dev); Error *local_err = NULL; CPUCore *cc = CPU_CORE(dev); - char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model); + const char *base_core_type = spapr_get_cpu_core_type(machine->cpu_type); const char *type = object_get_typename(OBJECT(dev)); CPUArchId *core_slot; int index; @@ -3304,7 +3297,6 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, numa_cpu_pre_plug(core_slot, dev, &local_err); out: - g_free(base_core_type); error_propagate(errp, local_err); } @@ -3603,7 +3595,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) hc->unplug_request = spapr_machine_device_unplug_request; smc->dr_lmb_enabled = true; - smc->tcg_default_cpu = "power8_v2.0"; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power8_v2.0"); mc->has_hotpluggable_cpus = true; smc->resize_hpt_default = SPAPR_RESIZE_HPT_ENABLED; fwc->get_dev_path = spapr_get_fw_dev_path; @@ -3849,7 +3841,7 @@ static void spapr_machine_2_7_class_options(MachineClass *mc) sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc); spapr_machine_2_8_class_options(mc); - smc->tcg_default_cpu = "power7_v2.3"; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power7_v2.3"); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_7); smc->phb_placement = phb_placement_2_7; } diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index f2da4be..2c47850 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -61,29 +61,19 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu, * Return the sPAPR CPU core type for @model which essentially is the CPU * model specified with -cpu cmdline option. */ -char *spapr_get_cpu_core_type(const char *model) +const char *spapr_get_cpu_core_type(const char *cpu_type) { - char *core_type; - gchar **model_pieces = g_strsplit(model, ",", 2); - gchar *cpu_model = g_ascii_strdown(model_pieces[0], -1); - g_strfreev(model_pieces); - - core_type = g_strdup_printf("%s-" TYPE_SPAPR_CPU_CORE, cpu_model); - - /* Check whether it exists or whether we have to look up an alias name */ - if (!object_class_by_name(core_type)) { - const char *realmodel; - - g_free(core_type); - core_type = NULL; - realmodel = ppc_cpu_lookup_alias(cpu_model); - if (realmodel) { - core_type = spapr_get_cpu_core_type(realmodel); - } + int len = strlen(cpu_type) - strlen(POWERPC_CPU_TYPE_SUFFIX); + char *core_type = g_strdup_printf(SPAPR_CPU_CORE_TYPE_NAME("%.*s"), + len, cpu_type); + ObjectClass *oc = object_class_by_name(core_type); + + g_free(core_type); + if (!oc) { + return NULL; } - g_free(cpu_model); - return core_type; + return object_class_get_name(oc); } static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index cb5777a..abc222e 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -123,7 +123,7 @@ static bool kvmppc_is_pr(KVMState *ks) return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0; } -static int kvm_ppc_register_host_cpu_type(void); +static int kvm_ppc_register_host_cpu_type(MachineState *ms); int kvm_arch_init(MachineState *ms, KVMState *s) { @@ -163,7 +163,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) "VM to stall at times!\n"); } - kvm_ppc_register_host_cpu_type(); + kvm_ppc_register_host_cpu_type(ms); return 0; } @@ -2487,12 +2487,13 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) return pvr_pcc; } -static int kvm_ppc_register_host_cpu_type(void) +static int kvm_ppc_register_host_cpu_type(MachineState *ms) { TypeInfo type_info = { .name = TYPE_HOST_POWERPC_CPU, .class_init = kvmppc_host_cpu_class_init, }; + MachineClass *mc = MACHINE_GET_CLASS(ms); PowerPCCPUClass *pvr_pcc; ObjectClass *oc; DeviceClass *dc; @@ -2504,6 +2505,8 @@ static int kvm_ppc_register_host_cpu_type(void) } type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc)); type_register(&type_info); + /* override TCG default cpu type with 'host' cpu model */ + mc->default_cpu_type = TYPE_HOST_POWERPC_CPU; oc = object_class_by_name(type_info.name); g_assert(oc); diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 5ee91e8..a968e86 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10277,6 +10277,19 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr) return pcc; } +static const char *ppc_cpu_lookup_alias(const char *alias) +{ + int ai; + + for (ai = 0; ppc_cpu_aliases[ai].alias != NULL; ai++) { + if (strcmp(ppc_cpu_aliases[ai].alias, alias) == 0) { + return ppc_cpu_aliases[ai].model; + } + } + + return NULL; +} + static ObjectClass *ppc_cpu_class_by_name(const char *name) { char *cpu_model, *typename; @@ -10370,19 +10383,6 @@ static void ppc_cpu_parse_featurestr(const char *typename, char *features, pcc->parent_parse_features(typename, features, errp); } -const char *ppc_cpu_lookup_alias(const char *alias) -{ - int ai; - - for (ai = 0; ppc_cpu_aliases[ai].alias != NULL; ai++) { - if (strcmp(ppc_cpu_aliases[ai].alias, alias) == 0) { - return ppc_cpu_aliases[ai].model; - } - } - - return NULL; -} - PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc) { ObjectClass *oc = OBJECT_CLASS(pcc); From patchwork Thu Oct 5 16:24:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JGs1gckz9rvt for ; Fri, 6 Oct 2017 03:33:09 +1100 (AEDT) Received: from localhost ([::1]:40803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0959-0000v9-9E for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:33:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xi-0003GC-EZ for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xg-0003fl-AH for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xg-0003em-1J; Thu, 05 Oct 2017 12:25:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 165E985545; Thu, 5 Oct 2017 16:25:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 165E985545 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id C035E5C552; Thu, 5 Oct 2017 16:25:21 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:45 +0200 Message-Id: <1507220690-265042-19-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 05 Oct 2017 16:25:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 18/23] ppc: pnv: use generic cpu_model parsing 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" use common cpu_model prasing in vl.c and set default cpu_model using generic MachineClass::default_cpu_type. Beside of switching to generic infrastructure it solves several issues. * ppc_cpu_class_by_name() is used to deal with lower/upper case and alias translations into actual cpu type, which fixes '-M powernv -cpu power8' and '-M powernv -cpu power9_v1.0' usecases which error out with: 'invalid CPU model 'FOO' for powernv machine' * allows to switch to lower-case typenames in pnv chip/core name (by convention typnames should be lower-case) * replace aliased names /power8, power9, .../ with exact cpu model names (i.e. typenames should be stable but aliases might decide to point to other cpu model withi family or changed by kvm). It will also help to simplify pnv_chip/core code and get rid of dependency on cpu_model parsing. Signed-off-by: Igor Mammedov Reviewed-by: Cédric Le Goater --- include/hw/ppc/pnv.h | 8 ++++---- hw/ppc/pnv.c | 22 ++++++++++------------ hw/ppc/pnv_core.c | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 9c5437d..2525f7f 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -80,19 +80,19 @@ typedef struct PnvChipClass { uint32_t (*core_pir)(PnvChip *chip, uint32_t core_id); } PnvChipClass; -#define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-POWER8E" +#define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-power8e_v2.1" #define PNV_CHIP_POWER8E(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8E) -#define TYPE_PNV_CHIP_POWER8 TYPE_PNV_CHIP "-POWER8" +#define TYPE_PNV_CHIP_POWER8 TYPE_PNV_CHIP "-power8_v2.0" #define PNV_CHIP_POWER8(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8) -#define TYPE_PNV_CHIP_POWER8NVL TYPE_PNV_CHIP "-POWER8NVL" +#define TYPE_PNV_CHIP_POWER8NVL TYPE_PNV_CHIP "-power8nvl_v1.0" #define PNV_CHIP_POWER8NVL(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8NVL) -#define TYPE_PNV_CHIP_POWER9 TYPE_PNV_CHIP "-POWER9" +#define TYPE_PNV_CHIP_POWER9 TYPE_PNV_CHIP "-power9_v1.0" #define PNV_CHIP_POWER9(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER9) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d46d91c..4169837 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -607,16 +607,13 @@ static void ppc_powernv_init(MachineState *machine) } } - /* We need some cpu model to instantiate the PnvChip class */ - if (machine->cpu_model == NULL) { - machine->cpu_model = "POWER8"; - } - /* Create the processor chips */ - chip_typename = g_strdup_printf(TYPE_PNV_CHIP "-%s", machine->cpu_model); + i = strlen(machine->cpu_type) - strlen(POWERPC_CPU_TYPE_SUFFIX); + chip_typename = g_strdup_printf(TYPE_PNV_CHIP "-%.*s", + i, machine->cpu_type); if (!object_class_by_name(chip_typename)) { - error_report("invalid CPU model '%s' for %s machine", - machine->cpu_model, MACHINE_GET_CLASS(machine)->name); + error_report("invalid CPU model '%.*s' for %s machine", + i, machine->cpu_type, MACHINE_GET_CLASS(machine)->name); exit(1); } @@ -716,7 +713,7 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "POWER8E"; + k->cpu_model = "power8e_v2.1"; k->chip_type = PNV_CHIP_POWER8E; k->chip_cfam_id = 0x221ef04980000000ull; /* P8 Murano DD2.1 */ k->cores_mask = POWER8E_CORE_MASK; @@ -738,7 +735,7 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "POWER8"; + k->cpu_model = "power8_v2.0"; k->chip_type = PNV_CHIP_POWER8; k->chip_cfam_id = 0x220ea04980000000ull; /* P8 Venice DD2.0 */ k->cores_mask = POWER8_CORE_MASK; @@ -760,7 +757,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "POWER8NVL"; + k->cpu_model = "power8nvl_v1.0"; k->chip_type = PNV_CHIP_POWER8NVL; k->chip_cfam_id = 0x120d304980000000ull; /* P8 Naples DD1.0 */ k->cores_mask = POWER8_CORE_MASK; @@ -782,7 +779,7 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "POWER9"; + k->cpu_model = "power9_v1.0"; k->chip_type = PNV_CHIP_POWER9; k->chip_cfam_id = 0x100d104980000000ull; /* P9 Nimbus DD1.0 */ k->cores_mask = POWER9_CORE_MASK; @@ -1133,6 +1130,7 @@ static void powernv_machine_class_init(ObjectClass *oc, void *data) mc->init = ppc_powernv_init; mc->reset = ppc_powernv_reset; mc->max_cpus = MAX_CPUS; + mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power8_v2.0"); mc->block_default_type = IF_IDE; /* Pnv provides a AHCI device for * storage */ mc->no_parallel = 1; diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 6726483..44b0b24 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -227,7 +227,7 @@ static const TypeInfo pnv_core_info = { }; static const char *pnv_core_models[] = { - "POWER8E", "POWER8", "POWER8NVL", "POWER9" + "power8e_v2.1", "power8_v2.0", "power8nvl_v1.0", "power9_v1.0" }; static void pnv_core_register_types(void) From patchwork Thu Oct 5 16:24:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JJx4Hc1z9rvt for ; Fri, 6 Oct 2017 03:34:57 +1100 (AEDT) Received: from localhost ([::1]:40809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e096t-0002L7-JF for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:34:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xj-0003HV-Jk for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xi-0003ht-BX for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xi-0003ge-3E; Thu, 05 Oct 2017 12:25:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9CCA64DF; Thu, 5 Oct 2017 16:25:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A9CCA64DF Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F7A85C54B; Thu, 5 Oct 2017 16:25:23 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:46 +0200 Message-Id: <1507220690-265042-20-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 05 Oct 2017 16:25:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 19/23] ppc: pnv: normalize core/chip type names 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" typically for cpus/core type names following convention is used new_type_prefix-superclass_typename make PNV core/chip to follow common convention. Signed-off-by: Igor Mammedov Reviewed-by: Cédric Le Goater Acked-by: David Gibson --- include/hw/ppc/pnv.h | 11 +++++++---- include/hw/ppc/pnv_core.h | 2 ++ hw/ppc/pnv.c | 2 +- hw/ppc/pnv_core.c | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 2525f7f..d82eee1 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -80,19 +80,22 @@ typedef struct PnvChipClass { uint32_t (*core_pir)(PnvChip *chip, uint32_t core_id); } PnvChipClass; -#define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-power8e_v2.1" +#define PNV_CHIP_TYPE_SUFFIX "-" TYPE_PNV_CHIP +#define PNV_CHIP_TYPE_NAME(cpu_model) cpu_model PNV_CHIP_TYPE_SUFFIX + +#define TYPE_PNV_CHIP_POWER8E PNV_CHIP_TYPE_NAME("power8e_v2.1") #define PNV_CHIP_POWER8E(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8E) -#define TYPE_PNV_CHIP_POWER8 TYPE_PNV_CHIP "-power8_v2.0" +#define TYPE_PNV_CHIP_POWER8 PNV_CHIP_TYPE_NAME("power8_v2.0") #define PNV_CHIP_POWER8(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8) -#define TYPE_PNV_CHIP_POWER8NVL TYPE_PNV_CHIP "-power8nvl_v1.0" +#define TYPE_PNV_CHIP_POWER8NVL PNV_CHIP_TYPE_NAME("power8nvl_v1.0") #define PNV_CHIP_POWER8NVL(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8NVL) -#define TYPE_PNV_CHIP_POWER9 TYPE_PNV_CHIP "-power9_v1.0" +#define TYPE_PNV_CHIP_POWER9 PNV_CHIP_TYPE_NAME("power9_v1.0") #define PNV_CHIP_POWER9(obj) \ OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER9) diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index 2955a41..3360c4b 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -45,6 +45,8 @@ typedef struct PnvCoreClass { ObjectClass *cpu_oc; } PnvCoreClass; +#define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_CORE +#define PNV_CORE_TYPE_NAME(cpu_model) cpu_model PNV_CORE_TYPE_SUFFIX extern char *pnv_core_typename(const char *model); #endif /* _PPC_PNV_CORE_H */ diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 4169837..9c5eb7c 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -609,7 +609,7 @@ static void ppc_powernv_init(MachineState *machine) /* Create the processor chips */ i = strlen(machine->cpu_type) - strlen(POWERPC_CPU_TYPE_SUFFIX); - chip_typename = g_strdup_printf(TYPE_PNV_CHIP "-%.*s", + chip_typename = g_strdup_printf(PNV_CHIP_TYPE_NAME("%.*s"), i, machine->cpu_type); if (!object_class_by_name(chip_typename)) { error_report("invalid CPU model '%.*s' for %s machine", diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 44b0b24..b3e3f23 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -252,5 +252,5 @@ type_init(pnv_core_register_types) char *pnv_core_typename(const char *model) { - return g_strdup_printf(TYPE_PNV_CORE "-%s", model); + return g_strdup_printf(PNV_CORE_TYPE_NAME("%s"), model); } From patchwork Thu Oct 5 16:24:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JPK5lmMz9rvt for ; Fri, 6 Oct 2017 03:38:45 +1100 (AEDT) Received: from localhost ([::1]:40832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09AZ-0005Ze-QF for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:38:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xo-0003NU-BL for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xj-0003ju-My for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xj-0003iZ-9n; Thu, 05 Oct 2017 12:25:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A02947A; Thu, 5 Oct 2017 16:25:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4A02947A Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2DF25C54B; Thu, 5 Oct 2017 16:25:24 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:47 +0200 Message-Id: <1507220690-265042-21-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 05 Oct 2017 16:25:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 20/23] ppc: pnv: drop PnvCoreClass::cpu_oc field 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" deduce cpu type directly from core type instead of maintaining type mapping in PnvCoreClass::cpu_oc and doing extra cpu_model parsing in pnv_core_class_init() Signed-off-by: Igor Mammedov Reviewed-by: Cédric Le Goater --- include/hw/ppc/pnv_core.h | 1 - hw/ppc/pnv_core.c | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index 3360c4b..a336a1f 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -42,7 +42,6 @@ typedef struct PnvCore { typedef struct PnvCoreClass { DeviceClass parent_class; - ObjectClass *cpu_oc; } PnvCoreClass; #define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_CORE diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index b3e3f23..acdfa17 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -27,6 +27,16 @@ #include "hw/ppc/pnv_xscom.h" #include "hw/ppc/xics.h" +static const char *pvn_core_cpu_typename(PnvCore *pc) +{ + const char *core_type = object_class_get_name(object_get_class(OBJECT(pc))); + int len = strlen(core_type) - strlen(PNV_CORE_TYPE_SUFFIX); + char *s = g_strdup_printf(POWERPC_CPU_TYPE_NAME("%.*s"), len, core_type); + const char *cpu_type = object_class_get_name(object_class_by_name(s)); + g_free(s); + return cpu_type; +} + static void powernv_cpu_reset(void *opaque) { PowerPCCPU *cpu = opaque; @@ -148,8 +158,7 @@ static void pnv_core_realize(DeviceState *dev, Error **errp) { PnvCore *pc = PNV_CORE(OBJECT(dev)); CPUCore *cc = CPU_CORE(OBJECT(dev)); - PnvCoreClass *pcc = PNV_CORE_GET_CLASS(OBJECT(dev)); - const char *typename = object_class_get_name(pcc->cpu_oc); + const char *typename = pvn_core_cpu_typename(pc); size_t size = object_type_get_instance_size(typename); Error *local_err = NULL; void *obj; @@ -211,11 +220,9 @@ static Property pnv_core_properties[] = { static void pnv_core_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); - PnvCoreClass *pcc = PNV_CORE_CLASS(oc); dc->realize = pnv_core_realize; dc->props = pnv_core_properties; - pcc->cpu_oc = cpu_class_by_name(TYPE_POWERPC_CPU, data); } static const TypeInfo pnv_core_info = { @@ -223,6 +230,7 @@ static const TypeInfo pnv_core_info = { .parent = TYPE_CPU_CORE, .instance_size = sizeof(PnvCore), .class_size = sizeof(PnvCoreClass), + .class_init = pnv_core_class_init, .abstract = true, }; @@ -239,8 +247,6 @@ static void pnv_core_register_types(void) TypeInfo ti = { .parent = TYPE_PNV_CORE, .instance_size = sizeof(PnvCore), - .class_init = pnv_core_class_init, - .class_data = (void *) pnv_core_models[i], }; ti.name = pnv_core_typename(pnv_core_models[i]); type_register(&ti); From patchwork Thu Oct 5 16:24:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JZ85nYsz9t16 for ; Fri, 6 Oct 2017 03:46:24 +1100 (AEDT) Received: from localhost ([::1]:40885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09Hy-00044E-TS for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:46:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xq-0003QL-U4 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xl-0003ml-5N for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xk-0003l8-Up; Thu, 05 Oct 2017 12:25:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E585825778; Thu, 5 Oct 2017 16:25:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E585825778 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9506B5E1A6; Thu, 5 Oct 2017 16:25:26 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:48 +0200 Message-Id: <1507220690-265042-22-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 05 Oct 2017 16:25:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 21/23] ppc: pnv: define core types statically 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" pnv core type definition doesn't have any fields that require it to be defined at runtime. So replace code that fills in TypeInfo at runtime with static TypeInfo array that does the same at complie time. Signed-off-by: Igor Mammedov Reviewed-by: Cédric Le Goater Acked-by: David Gibson --- hw/ppc/pnv_core.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index acdfa17..000c87e 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -225,38 +225,30 @@ static void pnv_core_class_init(ObjectClass *oc, void *data) dc->props = pnv_core_properties; } -static const TypeInfo pnv_core_info = { - .name = TYPE_PNV_CORE, - .parent = TYPE_CPU_CORE, - .instance_size = sizeof(PnvCore), - .class_size = sizeof(PnvCoreClass), - .class_init = pnv_core_class_init, - .abstract = true, -}; - -static const char *pnv_core_models[] = { - "power8e_v2.1", "power8_v2.0", "power8nvl_v1.0", "power9_v1.0" -}; - -static void pnv_core_register_types(void) -{ - int i ; - - type_register_static(&pnv_core_info); - for (i = 0; i < ARRAY_SIZE(pnv_core_models); ++i) { - TypeInfo ti = { - .parent = TYPE_PNV_CORE, - .instance_size = sizeof(PnvCore), - }; - ti.name = pnv_core_typename(pnv_core_models[i]); - type_register(&ti); - g_free((void *)ti.name); +#define DEFINE_PNV_CORE_TYPE(cpu_model) \ + { \ + .parent = TYPE_PNV_CORE, \ + .name = PNV_CORE_TYPE_NAME(cpu_model), \ } -} -type_init(pnv_core_register_types) +static const TypeInfo pnv_core_infos[] = { + { + .name = TYPE_PNV_CORE, + .parent = TYPE_CPU_CORE, + .instance_size = sizeof(PnvCore), + .class_size = sizeof(PnvCoreClass), + .class_init = pnv_core_class_init, + .abstract = true, + }, + DEFINE_PNV_CORE_TYPE("power8e_v2.1"), + DEFINE_PNV_CORE_TYPE("power8_v2.0"), + DEFINE_PNV_CORE_TYPE("power8nvl_v1.0"), + DEFINE_PNV_CORE_TYPE("power9_v1.0"), +}; char *pnv_core_typename(const char *model) { return g_strdup_printf(PNV_CORE_TYPE_NAME("%s"), model); } + +DEFINE_TYPES(pnv_core_infos) From patchwork Thu Oct 5 16:24:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JPH35lNz9t16 for ; Fri, 6 Oct 2017 03:38:43 +1100 (AEDT) Received: from localhost ([::1]:40831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09AX-0005Wo-Cl for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:38:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xo-0003NJ-5Y for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xm-0003pZ-Q5 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xm-0003nq-Gj; Thu, 05 Oct 2017 12:25:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EF808210D; Thu, 5 Oct 2017 16:25:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7EF808210D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33F8B5C54B; Thu, 5 Oct 2017 16:25:28 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:49 +0200 Message-Id: <1507220690-265042-23-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 05 Oct 2017 16:25:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 22/23] ppc: pnv: drop PnvChipClass::cpu_model field 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" deduce core type directly from chip type instead of maintaining type mapping in PnvChipClass::cpu_model. Signed-off-by: Igor Mammedov Reviewed-by: Cédric Le Goater --- include/hw/ppc/pnv.h | 1 - include/hw/ppc/pnv_core.h | 1 - hw/ppc/pnv.c | 25 +++++++++++++------------ hw/ppc/pnv_core.c | 5 ----- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index d82eee1..20244da 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -69,7 +69,6 @@ typedef struct PnvChipClass { SysBusDeviceClass parent_class; /*< public >*/ - const char *cpu_model; PnvChipType chip_type; uint64_t chip_cfam_id; uint64_t cores_mask; diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index a336a1f..e337af7 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -46,6 +46,5 @@ typedef struct PnvCoreClass { #define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_CORE #define PNV_CORE_TYPE_NAME(cpu_model) cpu_model PNV_CORE_TYPE_SUFFIX -extern char *pnv_core_typename(const char *model); #endif /* _PPC_PNV_CORE_H */ diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 9c5eb7c..ab7083b 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -55,6 +55,16 @@ #define KERNEL_LOAD_ADDR 0x20000000 #define INITRD_LOAD_ADDR 0x40000000 +static const char *pvn_chip_core_typename(const PnvChip *o) +{ + const char *chip_type = object_class_get_name(object_get_class(OBJECT(o))); + int len = strlen(chip_type) - strlen(PNV_CHIP_TYPE_SUFFIX); + char *s = g_strdup_printf(PNV_CORE_TYPE_NAME("%.*s"), len, chip_type); + const char *core_type = object_class_get_name(object_class_by_name(s)); + g_free(s); + return core_type; +} + /* * On Power Systems E880 (POWER8), the max cpus (threads) should be : * 4 * 4 sockets * 12 cores * 8 threads = 1536 @@ -270,8 +280,7 @@ static int pnv_chip_lpc_offset(PnvChip *chip, void *fdt) static void powernv_populate_chip(PnvChip *chip, void *fdt) { - PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip); - char *typename = pnv_core_typename(pcc->cpu_model); + const char *typename = pvn_chip_core_typename(chip); size_t typesize = object_type_get_instance_size(typename); int i; @@ -301,7 +310,6 @@ static void powernv_populate_chip(PnvChip *chip, void *fdt) powernv_populate_memory_node(fdt, chip->chip_id, chip->ram_start, chip->ram_size); } - g_free(typename); } static void powernv_populate_rtc(ISADevice *d, void *fdt, int lpc_off) @@ -713,7 +721,6 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "power8e_v2.1"; k->chip_type = PNV_CHIP_POWER8E; k->chip_cfam_id = 0x221ef04980000000ull; /* P8 Murano DD2.1 */ k->cores_mask = POWER8E_CORE_MASK; @@ -735,7 +742,6 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "power8_v2.0"; k->chip_type = PNV_CHIP_POWER8; k->chip_cfam_id = 0x220ea04980000000ull; /* P8 Venice DD2.0 */ k->cores_mask = POWER8_CORE_MASK; @@ -757,7 +763,6 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "power8nvl_v1.0"; k->chip_type = PNV_CHIP_POWER8NVL; k->chip_cfam_id = 0x120d304980000000ull; /* P8 Naples DD1.0 */ k->cores_mask = POWER8_CORE_MASK; @@ -779,7 +784,6 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PnvChipClass *k = PNV_CHIP_CLASS(klass); - k->cpu_model = "power9_v1.0"; k->chip_type = PNV_CHIP_POWER9; k->chip_cfam_id = 0x100d104980000000ull; /* P9 Nimbus DD1.0 */ k->cores_mask = POWER9_CORE_MASK; @@ -854,7 +858,7 @@ static void pnv_chip_init(Object *obj) static void pnv_chip_icp_realize(PnvChip *chip, Error **errp) { PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip); - char *typename = pnv_core_typename(pcc->cpu_model); + const char *typename = pvn_chip_core_typename(chip); size_t typesize = object_type_get_instance_size(typename); int i, j; char *name; @@ -879,8 +883,6 @@ static void pnv_chip_icp_realize(PnvChip *chip, Error **errp) memory_region_add_subregion(&chip->icp_mmio, pir << 12, &icp->mmio); } } - - g_free(typename); } static void pnv_chip_realize(DeviceState *dev, Error **errp) @@ -888,7 +890,7 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp) PnvChip *chip = PNV_CHIP(dev); Error *error = NULL; PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip); - char *typename = pnv_core_typename(pcc->cpu_model); + const char *typename = pvn_chip_core_typename(chip); size_t typesize = object_type_get_instance_size(typename); int i, core_hwid; @@ -947,7 +949,6 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp) &PNV_CORE(pnv_core)->xscom_regs); i++; } - g_free(typename); /* Create LPC controller */ object_property_set_bool(OBJECT(&chip->lpc), true, "realized", diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 000c87e..621b69e 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -246,9 +246,4 @@ static const TypeInfo pnv_core_infos[] = { DEFINE_PNV_CORE_TYPE("power9_v1.0"), }; -char *pnv_core_typename(const char *model) -{ - return g_strdup_printf(PNV_CORE_TYPE_NAME("%s"), model); -} - DEFINE_TYPES(pnv_core_infos) From patchwork Thu Oct 5 16:24:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 821943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7JSJ0nMRz9rvt for ; Fri, 6 Oct 2017 03:41:20 +1100 (AEDT) Received: from localhost ([::1]:40852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09D4-0007um-4p for incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 12:41:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e08xr-0003Qc-6D for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e08xo-0003sm-Ay for qemu-devel@nongnu.org; Thu, 05 Oct 2017 12:25:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56732) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e08xo-0003qm-2D; Thu, 05 Oct 2017 12:25:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F3F3780DB; Thu, 5 Oct 2017 16:25:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1F3F3780DB Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6D705C54B; Thu, 5 Oct 2017 16:25:29 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 18:24:50 +0200 Message-Id: <1507220690-265042-24-git-send-email-imammedo@redhat.com> In-Reply-To: <1507220690-265042-1-git-send-email-imammedo@redhat.com> References: <1507220690-265042-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 05 Oct 2017 16:25:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 23/23] ppc: pnv: consolidate type definitions and batch register them 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: "open list:ppce500" , "Edgar E. Iglesias" , =?utf-8?q?Herv=C3=A9_Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Use a new DEFINE_TYPES() helper to simplify type registration Signed-off-by: Igor Mammedov Reviewed-by: Cédric Le Goater Acked-by: David Gibson --- hw/ppc/pnv.c | 92 ++++++++++++++++++++++-------------------------------------- 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index ab7083b..e23dc3c 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -730,13 +730,6 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) dc->desc = "PowerNV Chip POWER8E"; } -static const TypeInfo pnv_chip_power8e_info = { - .name = TYPE_PNV_CHIP_POWER8E, - .parent = TYPE_PNV_CHIP, - .instance_size = sizeof(PnvChip), - .class_init = pnv_chip_power8e_class_init, -}; - static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -751,13 +744,6 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) dc->desc = "PowerNV Chip POWER8"; } -static const TypeInfo pnv_chip_power8_info = { - .name = TYPE_PNV_CHIP_POWER8, - .parent = TYPE_PNV_CHIP, - .instance_size = sizeof(PnvChip), - .class_init = pnv_chip_power8_class_init, -}; - static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -772,13 +758,6 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) dc->desc = "PowerNV Chip POWER8NVL"; } -static const TypeInfo pnv_chip_power8nvl_info = { - .name = TYPE_PNV_CHIP_POWER8NVL, - .parent = TYPE_PNV_CHIP, - .instance_size = sizeof(PnvChip), - .class_init = pnv_chip_power8nvl_class_init, -}; - static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -793,13 +772,6 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) dc->desc = "PowerNV Chip POWER9"; } -static const TypeInfo pnv_chip_power9_info = { - .name = TYPE_PNV_CHIP_POWER9, - .parent = TYPE_PNV_CHIP, - .instance_size = sizeof(PnvChip), - .class_init = pnv_chip_power9_class_init, -}; - static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp) { PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip); @@ -1001,15 +973,6 @@ static void pnv_chip_class_init(ObjectClass *klass, void *data) dc->desc = "PowerNV Chip"; } -static const TypeInfo pnv_chip_info = { - .name = TYPE_PNV_CHIP, - .parent = TYPE_SYS_BUS_DEVICE, - .class_init = pnv_chip_class_init, - .instance_init = pnv_chip_init, - .class_size = sizeof(PnvChipClass), - .abstract = true, -}; - static ICSState *pnv_ics_get(XICSFabric *xi, int irq) { PnvMachineState *pnv = POWERNV_MACHINE(xi); @@ -1145,27 +1108,40 @@ static void powernv_machine_class_init(ObjectClass *oc, void *data) powernv_machine_class_props_init(oc); } -static const TypeInfo powernv_machine_info = { - .name = TYPE_POWERNV_MACHINE, - .parent = TYPE_MACHINE, - .instance_size = sizeof(PnvMachineState), - .instance_init = powernv_machine_initfn, - .class_init = powernv_machine_class_init, - .interfaces = (InterfaceInfo[]) { - { TYPE_XICS_FABRIC }, - { TYPE_INTERRUPT_STATS_PROVIDER }, - { }, +#define DEFINE_PNV_CHIP_TYPE(type, class_initfn) \ + { \ + .name = type, \ + .class_init = class_initfn, \ + .parent = TYPE_PNV_CHIP, \ + } + +static const TypeInfo types[] = { + { + .name = TYPE_POWERNV_MACHINE, + .parent = TYPE_MACHINE, + .instance_size = sizeof(PnvMachineState), + .instance_init = powernv_machine_initfn, + .class_init = powernv_machine_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_XICS_FABRIC }, + { TYPE_INTERRUPT_STATS_PROVIDER }, + { }, + }, }, + { + .name = TYPE_PNV_CHIP, + .parent = TYPE_SYS_BUS_DEVICE, + .class_init = pnv_chip_class_init, + .instance_init = pnv_chip_init, + .instance_size = sizeof(PnvChip), + .class_size = sizeof(PnvChipClass), + .abstract = true, + }, + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER9, pnv_chip_power9_class_init), + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER8, pnv_chip_power8_class_init), + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER8E, pnv_chip_power8e_class_init), + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER8NVL, + pnv_chip_power8nvl_class_init), }; -static void powernv_machine_register_types(void) -{ - type_register_static(&powernv_machine_info); - type_register_static(&pnv_chip_info); - type_register_static(&pnv_chip_power8e_info); - type_register_static(&pnv_chip_power8_info); - type_register_static(&pnv_chip_power8nvl_info); - type_register_static(&pnv_chip_power9_info); -} - -type_init(powernv_machine_register_types) +DEFINE_TYPES(types)