From patchwork Mon Oct 9 19:50:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823457 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 3y9rVp3BfWz9rxm for ; Tue, 10 Oct 2017 06:52:18 +1100 (AEDT) Received: from localhost ([::1]:59527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e64-0003Hz-DC for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:52:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5D-0003H2-1R for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e58-0006Ln-HA for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44526) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e56-0006Kv-UG; Mon, 09 Oct 2017 15:51:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA00680481; Mon, 9 Oct 2017 19:51:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DA00680481 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 8CB8B7770B; Mon, 9 Oct 2017 19:51:14 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:48 +0200 Message-Id: <1507578671-158758-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 09 Oct 2017 19:51: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 v2 01/24] 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 Mon Oct 9 19:50: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: 823456 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 3y9rVn2wDjz9rxm for ; Tue, 10 Oct 2017 06:52:17 +1100 (AEDT) Received: from localhost ([::1]:59526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e63-0003Hu-Bt for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5D-0003H1-11 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e58-0006MM-QA for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e58-0006LH-IQ; Mon, 09 Oct 2017 15:51:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B23E4A6F4; Mon, 9 Oct 2017 19:51:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7B23E4A6F4 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 2E5797770A; Mon, 9 Oct 2017 19:51:16 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:49 +0200 Message-Id: <1507578671-158758-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 09 Oct 2017 19:51:17 +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 v2 02/24] 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 Mon Oct 9 19:50: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: 823460 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 3y9rYy29DPz9sNw for ; Tue, 10 Oct 2017 06:55:02 +1100 (AEDT) Received: from localhost ([::1]:59535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e8i-0005lU-Cp for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:55:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5D-0003H4-DD for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5A-0006OH-C7 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5A-0006N8-4m; Mon, 09 Oct 2017 15:51:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D44613A98; Mon, 9 Oct 2017 19:51:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D44613A98 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 C44FE776FC; Mon, 9 Oct 2017 19:51:17 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:50 +0200 Message-Id: <1507578671-158758-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 09 Oct 2017 19:51:19 +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 v2 03/24] 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 Mon Oct 9 19:50:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823462 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 3y9rdJ5byQz9s7c for ; Tue, 10 Oct 2017 06:57:56 +1100 (AEDT) Received: from localhost ([::1]:59555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eBW-0008Fi-M8 for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:57:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5D-0003H3-Cp for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5B-0006Q3-TT for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5B-0006Pq-N0; Mon, 09 Oct 2017 15:51:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B203F13A5D; Mon, 9 Oct 2017 19:51:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B203F13A5D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 650C5776FC; Mon, 9 Oct 2017 19:51:19 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:51 +0200 Message-Id: <1507578671-158758-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 09 Oct 2017 19:51: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 v2 04/24] 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 Mon Oct 9 19:50:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823459 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 3y9rYx6V80z9s7c for ; Tue, 10 Oct 2017 06:55:01 +1100 (AEDT) Received: from localhost ([::1]:59534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e8h-0005lJ-VZ for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:55:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5E-0003HD-AQ for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5D-0006R0-J3 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5D-0006QT-D3; Mon, 09 Oct 2017 15:51:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56D9880474; Mon, 9 Oct 2017 19:51:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 56D9880474 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 0763E776FC; Mon, 9 Oct 2017 19:51:20 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:52 +0200 Message-Id: <1507578671-158758-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 09 Oct 2017 19:51:22 +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 v2 05/24] 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 Mon Oct 9 19:50:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823463 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 3y9rdL1fhfz9s7c for ; Tue, 10 Oct 2017 06:57:58 +1100 (AEDT) Received: from localhost ([::1]:59556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eBY-0008I9-9m for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:57:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5F-0003IG-VG for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5F-0006SZ-5k for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48578) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5E-0006Rl-Vw; Mon, 09 Oct 2017 15:51:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E96E77E442; Mon, 9 Oct 2017 19:51:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E96E77E442 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 9D9F4776FC; Mon, 9 Oct 2017 19:51:22 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:53 +0200 Message-Id: <1507578671-158758-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 09 Oct 2017 19:51: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 v2 06/24] 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 Mon Oct 9 19:50:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823473 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 3y9rjw1QV2z9rxl for ; Tue, 10 Oct 2017 07:01:56 +1100 (AEDT) Received: from localhost ([::1]:59584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eFO-00036t-7r for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:01:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5J-0003Kf-Lt for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5G-0006U7-OY for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55556) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5G-0006TL-J0; Mon, 09 Oct 2017 15:51:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B783C0587E9; Mon, 9 Oct 2017 19:51:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B783C0587E9 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.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 3DCBD6060A; Mon, 9 Oct 2017 19:51:24 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:54 +0200 Message-Id: <1507578671-158758-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 09 Oct 2017 19:51:25 +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 v2 07/24] 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 Mon Oct 9 19:50:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823476 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 3y9rn60q4pz9t1G for ; Tue, 10 Oct 2017 07:04:42 +1100 (AEDT) Received: from localhost ([::1]:59595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eI4-0005F3-3z for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:04:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5J-0003Ki-Lt for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5I-0006VL-B1 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39206) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5I-0006Un-5Q; Mon, 09 Oct 2017 15:51:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E741FEBD; Mon, 9 Oct 2017 19:51:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2E741FEBD Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 D2C866060A; Mon, 9 Oct 2017 19:51:25 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:55 +0200 Message-Id: <1507578671-158758-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 09 Oct 2017 19:51:27 +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 v2 08/24] 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 Mon Oct 9 19:50:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823458 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 3y9rVx10sqz9s06 for ; Tue, 10 Oct 2017 06:52:25 +1100 (AEDT) Received: from localhost ([::1]:59529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e6B-0003SB-8G for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:52:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5O-0003OY-Km for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5K-0006W0-3m for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5J-0006Vf-Ty; Mon, 09 Oct 2017 15:51:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7BB5820E1; Mon, 9 Oct 2017 19:51:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C7BB5820E1 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 76BFC6060A; Mon, 9 Oct 2017 19:51:27 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:56 +0200 Message-Id: <1507578671-158758-10-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 09 Oct 2017 19:51: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 v2 09/24] 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 Mon Oct 9 19:50:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823477 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 3y9rqs38kXz9t1G for ; Tue, 10 Oct 2017 07:07:05 +1100 (AEDT) Received: from localhost ([::1]:59615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eKN-0007BA-Fm for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:07:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5O-0003OZ-LV for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5L-0006WP-MI for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55800) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5L-0006WC-GI; Mon, 09 Oct 2017 15:51:31 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DB56C0587E6; Mon, 9 Oct 2017 19:51:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6DB56C0587E6 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.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 18BE56060A; Mon, 9 Oct 2017 19:51:28 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:57 +0200 Message-Id: <1507578671-158758-11-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 09 Oct 2017 19:51:30 +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 v2 10/24] 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 Mon Oct 9 19:50:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823461 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 3y9rZh5YvCz9s7c for ; Tue, 10 Oct 2017 06:55:39 +1100 (AEDT) Received: from localhost ([::1]:59540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e9J-0006Cf-Da for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:55:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5O-0003Oa-MS for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5N-0006X6-9N for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48924) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5N-0006Wp-0j; Mon, 09 Oct 2017 15:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06B3B7E43E; Mon, 9 Oct 2017 19:51:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 06B3B7E43E 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 B017377BE3; Mon, 9 Oct 2017 19:51:30 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:58 +0200 Message-Id: <1507578671-158758-12-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 09 Oct 2017 19:51:32 +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 v2 11/24] 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 37beb56..79a9615 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 Mon Oct 9 19:50:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823464 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 3y9rdp4rW5z9s7c for ; Tue, 10 Oct 2017 06:58:22 +1100 (AEDT) Received: from localhost ([::1]:59558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eBw-00007U-NE for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:58:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5Q-0003PY-7Y for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5O-0006Xh-VX for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37030) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5O-0006XJ-MM; Mon, 09 Oct 2017 15:51:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B073820EE; Mon, 9 Oct 2017 19:51:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9B073820EE 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 4FC5D6060A; Mon, 9 Oct 2017 19:51:32 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:50:59 +0200 Message-Id: <1507578671-158758-13-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 09 Oct 2017 19:51:33 +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 v2 12/24] 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 Set "max-cpu-compat" property only if it exists, in practice it should limit 'compat' hack to spapr machine and allow to avoid including machine/spapr headers in target/ppc/cpu.c Signed-off-by: Igor Mammedov Acked-by: David Gibson --- v2: - set "max-cpu-compat" property only if it exists, in practice it should limit 'compat' hack to spapr and allow to avoid including machine/spapr headers in target/ppc/cpu.c - do compat= parsing only if machine."max-cpu-compat" exists that would match what current code does. - add newline before ppc_cpu_parse_featurestr() definition --- 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 | 57 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 59 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 1a2ca8a..c7a0310 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2373,7 +2373,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 79a9615..b6610dd 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 0d6379f..3d16481 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10097,6 +10097,61 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name) return NULL; } +static void ppc_cpu_parse_featurestr(const char *type, char *features, + Error **errp) +{ + Object *machine = qdev_get_machine(); + const PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(object_class_by_name(type)); + + if (!features) { + return; + } + + if (object_property_find(machine, "max-cpu-compat", NULL)) { + int i; + char **inpieces; + char *s = features; + Error *local_err = NULL; + char *compat_str = NULL; + + /* + * 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) { + char *v = compat_str + strlen("compat="); + object_property_set_str(machine, v, "max-cpu-compat", &local_err); + } + g_strfreev(inpieces); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + + /* do property processing with generic handler */ + pcc->parent_parse_features(type, features, errp); +} + const char *ppc_cpu_lookup_alias(const char *alias) { int ai; @@ -10489,6 +10544,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 Mon Oct 9 19:51:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823471 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 3y9rjH0KkLz9sNw for ; Tue, 10 Oct 2017 07:01:23 +1100 (AEDT) Received: from localhost ([::1]:59577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eEr-0002d9-3p for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:01:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5R-0003R5-FR for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5Q-0006Ya-HF for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55992) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5Q-0006Xs-8G; Mon, 09 Oct 2017 15:51:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C4A6C059B60; Mon, 9 Oct 2017 19:51:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C4A6C059B60 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.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 E3D366060A; Mon, 9 Oct 2017 19:51:33 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:00 +0200 Message-Id: <1507578671-158758-14-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 09 Oct 2017 19:51:35 +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 v2 13/24] 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 Acked-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé --- v2: - fix rebase conflict: add newly added power9_v2 core --- include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 87 +++++++++++++---------------------------- 2 files changed, 30 insertions(+), 59 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 b6610dd..550d320 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -217,37 +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", - "power9_v2.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() @@ -265,33 +234,33 @@ 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_SPAPR_CPU_CORE_TYPE("power9_v2.0"), +}; + +DEFINE_TYPES(spapr_cpu_core_type_infos) From patchwork Mon Oct 9 19:51:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823480 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 3y9rtj6QySz9t2Z for ; Tue, 10 Oct 2017 07:09:33 +1100 (AEDT) Received: from localhost ([::1]:59623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eMl-0000Yh-SP for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:09:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5T-0003TQ-5d for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5S-0006Zl-5c for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5R-0006ZA-Rd; Mon, 09 Oct 2017 15:51:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFF395D689; Mon, 9 Oct 2017 19:51:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CFF395D689 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 8515560604; Mon, 9 Oct 2017 19:51:35 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:01 +0200 Message-Id: <1507578671-158758-15-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 09 Oct 2017 19:51:37 +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 v2 14/24] 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 c7a0310..fda2bbe 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3149,8 +3149,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++) { @@ -3246,8 +3245,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 550d320..a008056 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 Mon Oct 9 19:51:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823465 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 3y9rf16FD9z9s7c for ; Tue, 10 Oct 2017 06:58:33 +1100 (AEDT) Received: from localhost ([::1]:59559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eC7-0000HA-E0 for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 15:58:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5U-0003VO-Lj for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5T-0006aX-Mg for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49200) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5T-0006a9-E2; Mon, 09 Oct 2017 15:51:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70E947E43F; Mon, 9 Oct 2017 19:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 70E947E43F 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 2474260604; Mon, 9 Oct 2017 19:51:36 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:02 +0200 Message-Id: <1507578671-158758-16-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 09 Oct 2017 19:51:38 +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 v2 15/24] 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 --- v2: - fix rebase conflict due to new DEFINE_SPAPR_CPU_CORE_TYPE("power9_v2.0") entry in hw/ppc/spapr_cpu_core.c, no functional change --- 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 a008056..b5bbb6a 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); @@ -258,6 +258,9 @@ static const TypeInfo spapr_cpu_core_type_infos[] = { DEFINE_SPAPR_CPU_CORE_TYPE("power8nvl_v1.0"), DEFINE_SPAPR_CPU_CORE_TYPE("power9_v1.0"), DEFINE_SPAPR_CPU_CORE_TYPE("power9_v2.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 Mon Oct 9 19:51:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823474 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 3y9rlc5w9Wz9rxl for ; Tue, 10 Oct 2017 07:03:24 +1100 (AEDT) Received: from localhost ([::1]:59590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eGo-0004ER-Rz for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:03:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5Z-0003ao-ED for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5V-0006bF-8g for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5V-0006ar-1u; Mon, 09 Oct 2017 15:51:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11E39356D6; Mon, 9 Oct 2017 19:51:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11E39356D6 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 B8D8660604; Mon, 9 Oct 2017 19:51:38 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:03 +0200 Message-Id: <1507578671-158758-17-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 09 Oct 2017 19:51:40 +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 v2 16/24] 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 --- PS: - patch is made separate to reduce noise in follow up patch "ppc: spapr: use generic cpu_model parsing" --- 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 fda2bbe..30b4934 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3610,7 +3610,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; @@ -3856,7 +3856,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 Mon Oct 9 19:51:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823488 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 3y9rxN03yZz9t38 for ; Tue, 10 Oct 2017 07:11:51 +1100 (AEDT) Received: from localhost ([::1]:59641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eOz-0002JN-OE for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:11:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5Z-0003ay-Kn for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5W-0006bg-U0 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5W-0006bQ-NF; Mon, 09 Oct 2017 15:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5EE281DF9; Mon, 9 Oct 2017 19:51:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A5EE281DF9 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 5A5AB60604; Mon, 9 Oct 2017 19:51:40 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:04 +0200 Message-Id: <1507578671-158758-18-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 09 Oct 2017 19:51:41 +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 v2 17/24] ppc: move ppc_cpu_lookup_alias() before its first user 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" next commit will drop ppc_cpu_lookup_alias() declaration from header and make it static which will break its last user ppc_cpu_class_by_name() since ppc_cpu_class_by_name() defined before ppc_cpu_lookup_alias(). To avoid this move ppc_cpu_lookup_alias() right before ppc_cpu_class_by_name(). Signed-off-by: Igor Mammedov Acked-by: David Gibson Reviewed-by: Philippe Mathieu-Daudé --- v2: - split from "ppc: spapr: use generic cpu_model parsing" were asked by David, it makes the next patch a little smaller --- target/ppc/translate_init.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 3d16481..17ac95b 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10060,6 +10060,19 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr) return pcc; } +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; @@ -10152,19 +10165,6 @@ static void ppc_cpu_parse_featurestr(const char *type, char *features, pcc->parent_parse_features(type, 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 Mon Oct 9 19:51:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823475 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 3y9rmv2J20z9t1G for ; Tue, 10 Oct 2017 07:04:31 +1100 (AEDT) Received: from localhost ([::1]:59593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eHt-00055O-BH for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:04:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5a-0003bS-7D for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5Y-0006cQ-JH for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34140) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5Y-0006bw-A2; Mon, 09 Oct 2017 15:51:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47AE5356F6; Mon, 9 Oct 2017 19:51:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 47AE5356F6 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 EE7A560604; Mon, 9 Oct 2017 19:51:41 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:05 +0200 Message-Id: <1507578671-158758-19-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 09 Oct 2017 19:51:43 +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 v2 18/24] 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 Acked-by: David Gibson --- PS: patch is a little bit big but it's hard to split it due to dependencies, so pls bear with it. v2: - limit setting default cpu type to 'host' type only for spapr machine - split out ppc_cpu_lookup_alias() movement into separate patch --- 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 | 11 ++++++++--- target/ppc/translate_init.c | 2 +- 7 files changed, 24 insertions(+), 39 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 30b4934..355f216 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2129,7 +2129,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; @@ -2184,7 +2184,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) @@ -2369,12 +2368,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); @@ -3265,7 +3258,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; @@ -3311,7 +3304,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); } @@ -3610,7 +3602,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; @@ -3856,7 +3848,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 b5bbb6a..6c176c8 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..48dc3f7 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,10 @@ static int kvm_ppc_register_host_cpu_type(void) } type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc)); type_register(&type_info); + if (object_dynamic_cast(ms, TYPE_SPAPR_MACHINE)) { + /* 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 17ac95b..7b9bf6a 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10060,7 +10060,7 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr) return pcc; } -const char *ppc_cpu_lookup_alias(const char *alias) +static const char *ppc_cpu_lookup_alias(const char *alias) { int ai; From patchwork Mon Oct 9 19:51:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823472 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 3y9rjV5D7Lz9rxl for ; Tue, 10 Oct 2017 07:01:34 +1100 (AEDT) Received: from localhost ([::1]:59580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eF2-0002n6-PM for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:01:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5b-0003d7-G0 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5a-0006dT-7p for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37356) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5Z-0006cw-VJ; Mon, 09 Oct 2017 15:51:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD68B820E8; Mon, 9 Oct 2017 19:51:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DD68B820E8 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 9120660604; Mon, 9 Oct 2017 19:51:43 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:06 +0200 Message-Id: <1507578671-158758-20-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 09 Oct 2017 19:51:45 +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 v2 19/24] 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 84b2389..707f38c 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -606,16 +606,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); } @@ -715,7 +712,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; @@ -737,7 +734,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; @@ -759,7 +756,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; @@ -781,7 +778,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; @@ -1132,6 +1129,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 Mon Oct 9 19:51:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823479 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 3y9rqy6RwYz9t1G for ; Tue, 10 Oct 2017 07:07:10 +1100 (AEDT) Received: from localhost ([::1]:59617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eKS-0007Fq-V5 for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:07:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5c-0003fM-P4 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5b-0006eZ-QE for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5b-0006e1-I0; Mon, 09 Oct 2017 15:51:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B64E85363; Mon, 9 Oct 2017 19:51:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7B64E85363 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 3029D60604; Mon, 9 Oct 2017 19:51:45 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:07 +0200 Message-Id: <1507578671-158758-21-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 09 Oct 2017 19:51:46 +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 v2 20/24] 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 707f38c..3eafa28 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -608,7 +608,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 Mon Oct 9 19:51:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823490 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 3y9rz02xfyz9t38 for ; Tue, 10 Oct 2017 07:13:16 +1100 (AEDT) Received: from localhost ([::1]:59652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eQM-0003ZX-HD for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:13:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5e-0003i8-E7 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5d-0006fT-Dj for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5d-0006ex-4j; Mon, 09 Oct 2017 15:51:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C2E5820ED; Mon, 9 Oct 2017 19:51:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1C2E5820ED 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 C44415C684; Mon, 9 Oct 2017 19:51:46 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:08 +0200 Message-Id: <1507578671-158758-22-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 09 Oct 2017 19:51:48 +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 v2 21/24] 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: Philippe Mathieu-Daudé --- v2: - fix typo: s/pvn_core_cpu_typename/pnv_core_cpu_typename/ --- 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..bd7f2c9 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 *pnv_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 = pnv_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 Mon Oct 9 19:51:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823478 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 3y9rqt2flGz9t2Z for ; Tue, 10 Oct 2017 07:07:06 +1100 (AEDT) Received: from localhost ([::1]:59616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eKO-0007C6-7Y for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:07:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5j-0003nV-67 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5f-0006gl-2Q for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5e-0006g4-Qr; Mon, 09 Oct 2017 15:51:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2C8F61478; Mon, 9 Oct 2017 19:51:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B2C8F61478 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 643CD60604; Mon, 9 Oct 2017 19:51:48 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:09 +0200 Message-Id: <1507578671-158758-23-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 09 Oct 2017 19:51:49 +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 v2 22/24] 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 bd7f2c9..438dbd1 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 Mon Oct 9 19:51:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823481 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 3y9rvK6PcGz9t38 for ; Tue, 10 Oct 2017 07:10:05 +1100 (AEDT) Received: from localhost ([::1]:59630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eNH-0000w7-1W for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:10:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5j-0003oH-U2 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5g-0006hY-LK for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49668) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5g-0006h0-C5; Mon, 09 Oct 2017 15:51:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51A257E42A; Mon, 9 Oct 2017 19:51:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51A257E42A 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 0614460604; Mon, 9 Oct 2017 19:51:49 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:10 +0200 Message-Id: <1507578671-158758-24-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 09 Oct 2017 19:51:51 +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 v2 23/24] 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: Philippe Mathieu-Daudé --- v2: - fix typo: s/pvn_chip_core_typename/pnv_chip_core_typename/ --- 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 3eafa28..80c7f62 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 *pnv_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 @@ -269,8 +279,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 = pnv_chip_core_typename(chip); size_t typesize = object_type_get_instance_size(typename); int i; @@ -300,7 +309,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) @@ -712,7 +720,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; @@ -734,7 +741,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; @@ -756,7 +762,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; @@ -778,7 +783,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; @@ -853,7 +857,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 = pnv_chip_core_typename(chip); size_t typesize = object_type_get_instance_size(typename); int i, j; char *name; @@ -878,8 +882,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) @@ -887,7 +889,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 = pnv_chip_core_typename(chip); size_t typesize = object_type_get_instance_size(typename); int i, core_hwid; @@ -946,7 +948,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 438dbd1..71eb90a 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 Mon Oct 9 19:51:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 823491 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 3y9s0V1Yhbz9t2Z for ; Tue, 10 Oct 2017 07:14:34 +1100 (AEDT) Received: from localhost ([::1]:59657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eRc-0004Gi-BY for incoming@patchwork.ozlabs.org; Mon, 09 Oct 2017 16:14:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5j-0003oK-UW for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5i-0006iW-8I for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5h-0006iA-Vv; Mon, 09 Oct 2017 15:51:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E61D713A98; Mon, 9 Oct 2017 19:51:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E61D713A98 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 9A1FE6060A; Mon, 9 Oct 2017 19:51:51 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:11 +0200 Message-Id: <1507578671-158758-25-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 09 Oct 2017 19:51:53 +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 v2 24/24] 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 80c7f62..c35c439 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -729,13 +729,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); @@ -750,13 +743,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); @@ -771,13 +757,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); @@ -792,13 +771,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); @@ -1000,15 +972,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); @@ -1144,27 +1107,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)