generalize parsing of cpu_model (part 3/PPC)
v2 cover generalize parsing of cpu_model (part 3/PPC)
Changelog:
- v2:
* rebase on dgibson/ppc-for-2.11 tree
* fix typo: s/pvn_chip_core_typename/pnv_chip_core_typename/
* fix typo: s/pvn_core_cpu_typename/pnv_core_cpu_typename/
* limit setting default cpu type to 'host' type only for spapr machine
* split out ppc_cpu_lookup_alias() movement into separate patch
* fix rebase conflict: add newly added power9_v2 core
* 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 practically does.
* add newline before ppc_cpu_parse_featurestr() definition
* pickup Acked-by/Reviewed-by where it's appropriate
this series is continuation of effort to remove boards dependency on cpu_model parsing and generalizing default cpu type handling. For background story look at merged:
[PATCH v2 0/5] generalize parsing of cpu_model (x86/arm)
https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg03564.html
Part 3 is independent subset that takes care of all PPC boards. Series borrows the 1st 3 patches from earlier posted part 2
qom: update doc comment for type_register[_static]()
qom: introduce type_register_static_array()
qom: add helper macro DEFINE_TYPES()
to avoid interdependency, hopefully this 3 will be merged via machine-next, but it's fine for them to go via any tree (whichever first)
Beside of switching to generic cpu_model parsing series contains a bunch of cleanups/simplifications which reduces code a bit and normalizes code that I've happend to touch to a typical QEMU patterns.
git tree for testing:
https://github.com/imammedo/qemu/branches cpu_init_removal_ppc_part3_v2
Refference to v1:
https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg01087.html
Igor Mammedov (24):
qom: update doc comment for type_register[_static]()
qom: introduce type_register_static_array()
qom: add helper macro DEFINE_TYPES()
ppc: mpc8544ds/e500plat: use generic cpu_model parsing
ppc: mac_newworld: use generic cpu_model parsing
ppc: mac_oldworld: use generic cpu_model parsing
ppc: bamboo: use generic cpu_model parsing
ppc: replace cpu_model with cpu_type on ref405ep,taihu boards
ppc: virtex-ml507: replace cpu_model with cpu_type
ppc: 40p/prep: replace cpu_model with cpu_type
ppc: spapr: replace ppc_cpu_parse_features() with
cpu_parse_cpu_model()
ppc: move '-cpu foo,compat=xxx' parsing into
ppc_cpu_parse_featurestr()
ppc: spapr: define core types statically
ppc: spapr: use cpu type name directly
ppc: spapr: register 'host' core type along with the rest of core
types
ppc: spapr: use cpu model names as tcg defaults instead of aliases
ppc: move ppc_cpu_lookup_alias() before its first user
ppc: spapr: use generic cpu_model parsing
ppc: pnv: use generic cpu_model parsing
ppc: pnv: normalize core/chip type names
ppc: pnv: drop PnvCoreClass::cpu_oc field
ppc: pnv: define core types statically
ppc: pnv: drop PnvChipClass::cpu_model field
ppc: pnv: consolidate type definitions and batch register them
include/hw/ppc/pnv.h | 12 +-- include/hw/ppc/pnv_core.h | 4 +- include/hw/ppc/ppc.h | 2 - include/hw/ppc/spapr.h | 2 - include/hw/ppc/spapr_cpu_core.h | 7 +- include/qom/object.h | 50 ++++++++++- target/ppc/cpu-qom.h | 1 + target/ppc/cpu.h | 1 - hw/ppc/e500.c | 8 +- hw/ppc/e500plat.c | 1 + hw/ppc/mac_newworld.c | 15 ++-- hw/ppc/mac_oldworld.c | 6 +- hw/ppc/mpc8544ds.c | 2 + hw/ppc/pnv.c | 131 ++++++++++++---------------- hw/ppc/pnv_core.c | 67 +++++++-------- hw/ppc/ppc.c | 25 ------ hw/ppc/ppc405_uc.c | 6 +- hw/ppc/ppc440_bamboo.c | 7 +- hw/ppc/ppc4xx_devs.c | 4 +- hw/ppc/prep.c | 12 +-- hw/ppc/spapr.c | 22 ++--- hw/ppc/spapr_cpu_core.c | 184 ++++++++++------------------------------ hw/ppc/virtex_ml507.c | 11 +-- qom/object.c | 9 ++ target/ppc/kvm.c | 22 ++--- target/ppc/translate_init.c | 69 +++++++++++++-- 26 files changed, 305 insertions(+), 375 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/24 qom: update doc comment for type_register[_static]()
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.
--- include/qom/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/qom/object.h +2 -2
@@ -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);
Signature · 1 line
2.7.4
PATCH v2 2/24 qom: introduce type_register_static_array()
In reply to Igor Mammedovit will help to remove code duplication of registration static types in places that have open coded loop to perform batch type registering.
--- include/qom/object.h | 10 ++++++++++ qom/object.c | 9 +++++++++ 2 files changed, 19 insertions(+)
include/qom/object.h +10 -0
@@ -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.
qom/object.c +9 -0
@@ -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 ) {
Signature · 1 line
2.7.4
PATCH v2 3/24 qom: add helper macro DEFINE_TYPES()
In reply to Igor MammedovDEFINE_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.
--- include/qom/object.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
include/qom/object.h +36 -0
@@ -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() +* +* <example> +* <programlisting> +* 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) +* </programlisting> +* </example> +* * 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.
Signature · 1 line
2.7.4
PATCH v2 4/24 ppc: mpc8544ds/e500plat: use generic cpu_model parsing
In reply to Igor Mammedov--- hw/ppc/e500.c | 8 +------- hw/ppc/e500plat.c | 1 + hw/ppc/mpc8544ds.c | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-)
hw/ppc/e500.c +1 -7
@@ -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);
hw/ppc/e500plat.c +1 -0
@@ -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)
hw/ppc/mpc8544ds.c +2 -0
@@ -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)
Signature · 1 line
2.7.4
PATCH v2 5/24 ppc: mac_newworld: use generic cpu_model parsing
In reply to Igor Mammedov--- hw/ppc/mac_newworld.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
hw/ppc/mac_newworld.c +6 -9
@@ -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 = {
Signature · 1 line
2.7.4
PATCH v2 6/24 ppc: mac_oldworld: use generic cpu_model parsing
In reply to Igor Mammedov--- hw/ppc/mac_oldworld.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
hw/ppc/mac_oldworld.c +2 -4
@@ -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 = {
Signature · 1 line
2.7.4
PATCH v2 7/24 ppc: bamboo: use generic cpu_model parsing
In reply to Igor Mammedov--- hw/ppc/ppc440_bamboo.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
hw/ppc/ppc440_bamboo.c +2 -5
@@ -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)
Signature · 1 line
2.7.4
PATCH v2 8/24 ppc: replace cpu_model with cpu_type on ref405ep, taihu boards
In reply to Igor Mammedov--- hw/ppc/ppc405_uc.c | 6 ++++-- hw/ppc/ppc4xx_devs.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-)
hw/ppc/ppc405_uc.c +4 -2
@@ -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;
hw/ppc/ppc4xx_devs.c +2 -2
@@ -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 */
Signature · 1 line
2.7.4
PATCH v2 9/24 ppc: virtex-ml507: replace cpu_model with cpu_type
In reply to Igor Mammedov--- hw/ppc/virtex_ml507.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
hw/ppc/virtex_ml507.c +4 -7
@@ -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)
Signature · 1 line
2.7.4
PATCH v2 10/24 ppc: 40p/prep: replace cpu_model with cpu_type
In reply to Igor Mammedov--- hw/ppc/prep.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
hw/ppc/prep.c +4 -8
@@ -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)
Signature · 1 line
2.7.4
PATCH v2 11/24 ppc: spapr: replace ppc_cpu_parse_features() with cpu_parse_cpu_model()
In reply to Igor Mammedovppc_cpu_parse_features() is doing practically the same thing as generic cpu_parse_cpu_model(). So remove duplicated impl. and reuse generic one.
--- 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(-)
include/hw/ppc/ppc.h +0 -2
@@ -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
hw/ppc/ppc.c +0 -25
@@ -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); -}
hw/ppc/spapr_cpu_core.c +4 -5
@@ -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); }
Signature · 1 line
2.7.4
PATCH v2 12/24 ppc: move '-cpu foo, compat=xxx' parsing into ppc_cpu_parse_featurestr()
In reply to Igor Mammedovthere 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
---
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(-)
include/hw/ppc/spapr.h +0 -1
@@ -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);
target/ppc/cpu-qom.h +1 -0
@@ -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);
hw/ppc/spapr.c +1 -1
@@ -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);
hw/ppc/spapr_cpu_core.c +0 -50
56 lines not on this page · raw message
target/ppc/translate_init.c +57 -0
69 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 12/24] ppc: move '-cpu foo, compat=xxx' parsing into ppc_cpu_parse_featurestr()
Quoted 11 lines · Igor Mammedov
there is a dedicated callback
CPUClass::parse_featureswhich 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 fromspapr_cpu_core.cinto it. That removes a dependency of board/core code oncpu_modelparsing and would let to reuse common -cpu parsing introduced by6063d4c0
Quoted 5 lines
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.cSigned-off-by Igor Mammedov <[email protected]>
Quoted 190 lines
---
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 intarget/ppc/cpu.c
- do compat= parsing only if machine."max-cpu-compat" exists that would match what current code does.
- add newline beforeppc_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(-)include/hw/ppc/spapr.h +0
-1@@ -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);target/ppc/cpu-qom.h +1
-0@@ -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);hw/ppc/spapr.c +1
-1@@ -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);hw/ppc/spapr_cpu_core.c +0
-50@@ -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;target/ppc/translate_init.c +57
-0@@ -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;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 13/24 ppc: spapr: define core types statically
In reply to Igor Mammedovspapr 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.
---
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(-)
include/hw/ppc/spapr_cpu_core.h +2 -0
@@ -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;
hw/ppc/spapr_cpu_core.c +28 -59
98 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 13/24] ppc: spapr: define core types statically
Quoted 6 lines · Igor Mammedov
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 <[email protected]>
Quoted 125 lines
---
v2:
- fix rebase conflict: add newly addedpower9_v2core--- include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 87 +++++++++++++---------------------------- 2 files changed, 30 insertions(+), 59 deletions(-)include/hw/ppc/spapr_cpu_core.h +2
-0@@ -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;hw/ppc/spapr_cpu_core.c +28
-59@@ -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)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 13/24] ppc: spapr: define core types statically
In reply to Igor MammedovQuoted 10 lines · On Mon, 9 Oct 2017 21:51:00 +0200 Igor Mammedov <[email protected]> wrote:
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 <[email protected]>---
v2:
- fix rebase conflict: add newly addedpower9_v2core
---
Quoted 121 lines
include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 87 +++++++++++++---------------------------- 2 files changed, 30 insertions(+), 59 deletions(-)include/hw/ppc/spapr_cpu_core.h +2
-0@@ -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;hw/ppc/spapr_cpu_core.c +28
-59@@ -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)
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 13/24] ppc: spapr: define core types statically
Quoted 8 lines · On Tue, 10 Oct 2017 09:29:46 +0200 Greg Kurz <[email protected]> wrote:
Quoted 5 lines · On Mon, 9 Oct 2017 21:51:00 +0200 Igor Mammedov <[email protected]> wrote:
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.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Igor Mammedov <[email protected]>---
v2:
- fix rebase conflict: add newly addedpower9_v2core
---Reviewed-by Greg Kurz <[email protected]>
Oops, this patch causes a regression when you try to pass a sPAPR core to a non-pseries machine.
Without this patch:
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core qemu-system-ppc64: -device host-spapr-cpu-core: 'host-spapr-cpu-core' is not a valid device model name
With this patch:
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core ** ERROR:qom/object.c:217:object_type_get_instance_size: assertion failed: (type != NULL) Aborted
#0 0x00007ffff760eff0 in raise () from /lib64/libc.so.6 #1 0x00007ffff761136c in abort () from /lib64/libc.so.6 #2 0x00007ffff78caa04 in g_assertion_message () from /lib64/libglib-2.0.so.0 #3 0x00007ffff78cab0c in g_assertion_message_expr () from /lib64/libglib-2.0.so.0 #4 0x00000000106abaac in object_type_get_instance_size (typename=0x108a3ac0 "host-powerpc64-cpu") at qom/object.c:217 #5 0x00000000101bb018 in spapr_cpu_core_realize (dev=0x111bcc10, errp=0x7fffffffe730) at hw/ppc/spapr_cpu_core.c:154 #6 0x000000001043e8b4 in device_set_realized (obj=0x111bcc10, value=true, errp=0x7fffffffe9f0) at hw/core/qdev.c:914 #7 0x00000000106b1390 in property_set_bool (obj=0x111bcc10, v=0x111c16a0, name=0x108cd520 "realized", opaque=0x111bcb60, errp=0x7fffffffe9f0) at qom/object.c:1906 #8 0x00000000106aeab8 in object_property_set (obj=0x111bcc10, v=0x111c16a0, name=0x108cd520 "realized", errp=0x7fffffffe9f0) at qom/object.c:1102 #9 0x00000000106b3068 in object_property_set_qobject (obj=0x111bcc10, value=0x111c1660, name=0x108cd520 "realized", errp=0x7fffffffe9f0) at qom/qom-qobject.c:27
#10 0x00000000106aee5c in object_property_set_bool (obj=0x111bcc10, value=true, name=0x108cd520 "realized", errp=0x7fffffffe9f0) at qom/object.c:1171 #11 0x000000001036b8cc in qdev_device_add (opts=0x110f4b30, errp=0x7fffffffea78) at qdev-monitor.c:630
#12 0x0000000010378e40 in device_init_func (opaque=0x0, opts=0x110f4b30, errp=0x0) at vl.c:2432
#13 0x0000000010850464 in qemu_opts_foreach (list=0x10abbaa8 <qemu_device_opts>, func=0x10378df4 <device_init_func>, opaque=0x0, errp=0x0) at util/qemu-option.c:1104 #14 0x000000001037fe0c in main (argc=5, argv=0x7ffffffff298, envp=0x7ffffffff2c8) at vl.c:4767
We're crashing because the host CPU type wasn't registered... Before, we would gently fail to add the CPU core because its type wouldn't be registered either.
There's a strong correlation between the CPU type and CPU core type. I don't believe we can handle this cleanly in the sPAPR code.
So I only see two options here: either drop this patch, or find a way to register the host CPU type at QOM init time as well. It would be really unfortunate to bury Igor's cleanup... I'd rather go forward so I started looking at the latter.
As explained in another mail recently, we cannot rely on the object class hierarchy to do that since object_class_get_list() cannot be safely called during the QOM init phase. It really needs all the parent types to be registered, because it will try to initialize them at some point (look for type_initialize in qom/object.c).
https://lists.nongnu.org/archive/html/qemu-ppc/2017-09/msg00794.html
But since we only need CPU model names to register CPU types, building a PVR<->CPU model table in the PPC code seem to be enough. Some more tweaking in the POWERPC_FAMILY() magic is also needed to support migration on heterogeneous-but-compatible HW (eg, POWER8 <-> POWER8E).
I think that this patch should be reverted from David's staging tree for now, I'll repost it when I have a proposal for the host CPU.
Cheers,
--
Greg
Quoted 123 lines
Quoted 121 lines
include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 87 +++++++++++++---------------------------- 2 files changed, 30 insertions(+), 59 deletions(-)include/hw/ppc/spapr_cpu_core.h +2
-0@@ -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;hw/ppc/spapr_cpu_core.c +28
-59@@ -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, \587 + .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)
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 13/24] ppc: spapr: define core types statically
Quoted 29 lines · On Thu, 12 Oct 2017 15:10:30 +0200 Greg Kurz <[email protected]> wrote:
Quoted 8 lines · On Tue, 10 Oct 2017 09:29:46 +0200 Greg Kurz <[email protected]> wrote:
Quoted 5 lines · On Mon, 9 Oct 2017 21:51:00 +0200 Igor Mammedov <[email protected]> wrote:
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.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Igor Mammedov <[email protected]>---
v2:
- fix rebase conflict: add newly addedpower9_v2core
---Reviewed-by Greg Kurz <[email protected]>Oops, this patch causes a regression when you try to pass a sPAPR core to a non-pseries machine.
Without this patch:
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core qemu-system-ppc64: -device host-spapr-cpu-core: 'host-spapr-cpu-core' is not a valid device model name
Quoted 7 lines
With this patch:
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core ** ERROR:qom/object.c:217:object_type_get_instance_size: assertion failed: (type != NULL) Aborted
there shouldn't be type host-spapr-cpu-core with this patch since you don't have -enable-kvm on CLI maybe you are talking about
[PATCH v2 15/24] ppc: spapr: register 'host' core type along with the rest of core types
[...]
Quoted 2 lines
I think that this patch should be reverted from David's staging tree for now, I'll repost it when I have a proposal for the host CPU.
let me find ppc host and look into it before reverting, maybe there is easier way around this 'very corner' case.
Quoted 130 lines
Cheers,
--
GregQuoted 123 lines
Quoted 121 lines
include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 87 +++++++++++++---------------------------- 2 files changed, 30 insertions(+), 59 deletions(-)include/hw/ppc/spapr_cpu_core.h +2
-0@@ -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;hw/ppc/spapr_cpu_core.c +28
-59@@ -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, \587 + .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)
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 13/24] ppc: spapr: define core types statically
Quoted 34 lines · On Thu, 12 Oct 2017 16:58:39 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 31 lines · On Thu, 12 Oct 2017 15:10:30 +0200 Greg Kurz <[email protected]> wrote:
Quoted 8 lines · On Tue, 10 Oct 2017 09:29:46 +0200 Greg Kurz <[email protected]> wrote:
Quoted 5 lines · On Mon, 9 Oct 2017 21:51:00 +0200 Igor Mammedov <[email protected]> wrote:
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.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Igor Mammedov <[email protected]>---
v2:
- fix rebase conflict: add newly addedpower9_v2core
---Reviewed-by Greg Kurz <[email protected]>Oops, this patch causes a regression when you try to pass a sPAPR core to a non-pseries machine.
Without this patch:
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core qemu-system-ppc64: -device host-spapr-cpu-core: 'host-spapr-cpu-core' is not a valid device model nameWith this patch:
Quoted 9 lines
Quoted 5 lines
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core ** ERROR:qom/object.c:217:object_type_get_instance_size: assertion failed: (type != NULL) Abortedthere shouldn't be type host-spapr-cpu-core with this patch since you don't have -enable-kvm on CLI maybe you are talking about
[PATCH v2 15/24] ppc: spapr: register 'host' core type along with the rest of core types
Oops you're right, I replied to the wrong mail... of course, I meant the following commit in David's staging tree:
https://github.com/dgibson/qemu/commit/c18165144076cef0c17206f5231cf9787c944037
Quoted 9 lines
[...]
Quoted 2 lines
I think that this patch should be reverted from David's staging tree for now, I'll repost it when I have a proposal for the host CPU.
let me find ppc host and look into it before reverting, maybe there is easier way around this 'very corner' case.
Matter of personal opinion. It's not my call anyway :)
Quoted 132 lines
Quoted 131 lines
Cheers,
--
GregQuoted 123 lines
Quoted 121 lines
include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 87 +++++++++++++---------------------------- 2 files changed, 30 insertions(+), 59 deletions(-)include/hw/ppc/spapr_cpu_core.h +2
-0@@ -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;hw/ppc/spapr_cpu_core.c +28
-59@@ -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, \587 + .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)
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 13/24] ppc: spapr: define core types statically
Quoted 47 lines · On Thu, 12 Oct 2017 17:20:51 +0200 Greg Kurz <[email protected]> wrote:
Quoted 34 lines · On Thu, 12 Oct 2017 16:58:39 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 31 lines · On Thu, 12 Oct 2017 15:10:30 +0200 Greg Kurz <[email protected]> wrote:
Quoted 8 lines · On Tue, 10 Oct 2017 09:29:46 +0200 Greg Kurz <[email protected]> wrote:
Quoted 5 lines · On Mon, 9 Oct 2017 21:51:00 +0200 Igor Mammedov <[email protected]> wrote:
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.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Igor Mammedov <[email protected]>---
v2:
- fix rebase conflict: add newly addedpower9_v2core
---Reviewed-by Greg Kurz <[email protected]>Oops, this patch causes a regression when you try to pass a sPAPR core to a non-pseries machine.
Without this patch:
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core qemu-system-ppc64: -device host-spapr-cpu-core: 'host-spapr-cpu-core' is not a valid device model nameWith this patch:
Quoted 9 lines
Quoted 5 lines
$ ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core ** ERROR:qom/object.c:217:object_type_get_instance_size: assertion failed: (type != NULL) Abortedthere shouldn't be type host-spapr-cpu-core with this patch since you don't have -enable-kvm on CLI maybe you are talking about
[PATCH v2 15/24] ppc: spapr: register 'host' core type along with the rest of core types
Quoted 4 lines
Oops you're right, I replied to the wrong mail... of course, I meant the following commit in David's staging tree:
https://github.com/dgibson/qemu/commit/c18165144076cef0c17206f5231cf9787c944037
fixed by:
[PATCH v2 14/24] fixup! ppc: spapr: use cpu type name directly
also I've stumbled upon another issue, fixup also posted:
[PATCH v2 18/24] fixup! ppc: spapr: use generic cpu_model parsing
fixup well localized and didn't cause conflicts so there is no need to respin series
Re: [Qemu-devel] [PATCH v2 13/24] ppc: spapr: define core types statically
In reply to Igor MammedovQuoted 4 lines · Igor Mammedov
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.
"compile"
Quoted 2 lines
Signed-off-by Igor Mammedov <[email protected]>
Quoted 126 lines
---
v2:
- fix rebase conflict: add newly addedpower9_v2core--- include/hw/ppc/spapr_cpu_core.h | 2 + hw/ppc/spapr_cpu_core.c | 87 +++++++++++++---------------------------- 2 files changed, 30 insertions(+), 59 deletions(-)include/hw/ppc/spapr_cpu_core.h +2
-0@@ -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;hw/ppc/spapr_cpu_core.c +28
-59@@ -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)
PATCH v2 14/24 ppc: spapr: use cpu type name directly
In reply to Igor Mammedovreplace sPAPRCPUCoreClass::cpu_class with cpu type name since it were needed just to get that at points it were accessed.
--- 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(-)
include/hw/ppc/spapr_cpu_core.h +1 -1
@@ -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);
hw/ppc/spapr.c +2 -4
@@ -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++) {
hw/ppc/spapr_cpu_core.c +5 -8
@@ -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), \ }
target/ppc/kvm.c +1 -1
@@ -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
Signature · 1 line
2.7.4
PATCH v2 14/24 fixup! ppc: spapr: use cpu type name directly
follow up commit that registers host-spapr-cpu-core type unconditionally
"ppc: spapr: register 'host' core type along with the rest of core types"
makes 'non' machine crash
ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core ERROR:qom/object.c:217:object_type_get_instance_size: assertion failed: (type != NULL) Aborted
before it qemu fails cleanly with
ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core
qemu-system-ppc64: -device host-spapr-cpu-core: 'host-spapr-cpu-core' is not a valid device model name
spapr_cpu_core_realize() already has explicit check for pseries machine, so move access to host cpu type after it so 'none' machine would fail cleanly as expected.
--- hw/ppc/spapr_cpu_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/ppc/spapr_cpu_core.c +2 -1
@@ -151,7 +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)); -size_t size =object_type_get_instance_size (scc->cpu_type); +size_t size;Error *local_err =NULL ;void *obj;int i, j;
@@ -162,6 +162,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)return ; } + size =object_type_get_instance_size (scc->cpu_type); sc->threads =g_malloc0 (size * cc->nr_threads);for (i =0 ; i < cc->nr_threads; i++) {char id[32 ];
Signature · 1 line
2.7.4
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 14/24] fixup! ppc: spapr: use cpu type name directly
Quoted 12 lines · On Thu, 12 Oct 2017 17:48:19 +0200 Igor Mammedov <[email protected]> wrote:
follow up commit that registers host-spapr-cpu-core type unconditionally
"ppc: spapr: register 'host' core type along with the rest of core types"makes 'non' machine crash
ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core ERROR:qom/object.c:217:object_type_get_instance_size: assertion failed: (type != NULL) Abortedbefore it qemu fails cleanly with
ppc64-softmmu/qemu-system-ppc64 -M none -device host-spapr-cpu-core
qemu-system-ppc64: -device host-spapr-cpu-core: 'host-spapr-cpu-core' is not a valid device model name
Quoted 7 lines
spapr_cpu_core_realize()already has explicit check for pseries machine, so move access to host cpu type after it so 'none' machine would fail cleanly as expected.Reported-by Greg Kurz <[email protected]>Signed-off-by Igor Mammedov <[email protected]>---
That's much simpler indeed than trying to register the host CPU type at QOM init... which turns out to be quite hairy compared to the gain :)
Quoted 24 lines
hw/ppc/spapr_cpu_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/ppc/spapr_cpu_core.c +2
-1@@ -151,7 +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)); -size_t size =object_type_get_instance_size (scc->cpu_type); +size_t size;Error *local_err =NULL ;void *obj;int i, j;@@ -162,6 +162,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)return ; } + size =object_type_get_instance_size (scc->cpu_type); sc->threads =g_malloc0 (size * cc->nr_threads);for (i =0 ; i < cc->nr_threads; i++) {char id[32 ];
PATCH v2 15/24 ppc: spapr: register 'host' core type along with the rest of core types
In reply to Igor Mammedovconsolidate 'host' core type registration by moving it from KVM specific code into spapr_cpu_core.c, similar like it's done in x86 target.
---
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(-)
include/hw/ppc/spapr_cpu_core.h +0 -1
@@ -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
hw/ppc/spapr_cpu_core.c +4 -1
@@ -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)
target/ppc/kvm.c +0 -11
@@ -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
Signature · 1 line
2.7.4
PATCH v2 16/24 ppc: spapr: use cpu model names as tcg defaults instead of aliases
In reply to Igor Mammedov---
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(-)
hw/ppc/spapr.c +2 -2
@@ -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; }
Signature · 1 line
2.7.4
PATCH v2 17/24 ppc: move ppc_cpu_lookup_alias() before its first user
In reply to Igor Mammedovnext 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().
---
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(-)
target/ppc/translate_init.c +13 -13
@@ -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);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 17/24] ppc: move ppc_cpu_lookup_alias() before its first user
Quoted 8 lines · Igor Mammedov
next commit will drop
ppc_cpu_lookup_alias()declaration from header and make it static which will break its last userppc_cpu_class_by_name()sinceppc_cpu_class_by_name()defined beforeppc_cpu_lookup_alias().To avoid this move
ppc_cpu_lookup_alias()right beforeppc_cpu_class_by_name().Signed-off-by Igor Mammedov <[email protected]>
Quoted 53 lines
---
v2:
- split from "ppc: spapr: use genericcpu_modelparsing" 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(-)target/ppc/translate_init.c +13
-13@@ -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);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 17/24] ppc: move ppc_cpu_lookup_alias() before its first user
In reply to Igor MammedovQuoted 8 lines · Igor Mammedov
next commit will drop
ppc_cpu_lookup_alias()declaration from header and make it static which will break its last userppc_cpu_class_by_name()sinceppc_cpu_class_by_name()defined beforeppc_cpu_lookup_alias().To avoid this move
ppc_cpu_lookup_alias()right beforeppc_cpu_class_by_name().Signed-off-by Igor Mammedov <[email protected]>
Quoted 54 lines
---
v2:
- split from "ppc: spapr: use genericcpu_modelparsing" 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(-)target/ppc/translate_init.c +13
-13@@ -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);
PATCH v2 18/24 ppc: spapr: use generic cpu_model parsing
In reply to Igor Mammedovuse 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.
---
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(-)
include/hw/ppc/spapr.h +0 -1
@@ -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,
include/hw/ppc/spapr_cpu_core.h +1 -1
@@ -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
target/ppc/cpu.h +0 -1
@@ -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. */
hw/ppc/spapr.c +4 -12
@@ -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; }
hw/ppc/spapr_cpu_core.c +10 -20
@@ -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)
target/ppc/kvm.c +8 -3
@@ -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);
target/ppc/translate_init.c +1 -1
@@ -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;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 18/24] ppc: spapr: use generic cpu_model parsing
Quoted 16 lines · Igor Mammedov
use generic
cpu_modelparsing introduced by
(6063d4c0fvl.c: convertcpu_modelto cpu type and set of global properties beforemachine_init())it allows to:
* replacesPAPRMachineClass::tcg_default_cpuwithMachineClass::default_cpu_type
* dropcpu_parse_cpu_model()fromhw/ppc/spapr.cand reuse one invl.c
* simplifyspapr_get_cpu_core_type()by removing not needed anymore recurrsion since alias look up happens earlier atvl.candspapr_get_cpu_core_type()works only with resulted from that cpu type.
* spapr no more needs to parse/depend on being phased outMachineState::cpu_model, all tha parsing done by generic code and target specific callback.
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>
Quoted 227 lines
---
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 outppc_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(-)include/hw/ppc/spapr.h +0
-1@@ -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,include/hw/ppc/spapr_cpu_core.h +1
-1@@ -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 target/ppc/cpu.h +0
-1@@ -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. */ hw/ppc/spapr.c +4
-12@@ -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; }hw/ppc/spapr_cpu_core.c +10
-20@@ -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)target/ppc/kvm.c +8
-3@@ -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);target/ppc/translate_init.c +1
-1@@ -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;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 18/24 fixup! ppc: spapr: use generic cpu_model parsing
In reply to Igor Mammedovinot sure how it managed to compile locally and on travis but build fails with type mismatch on PPC host, fixup it by casting to expected type
--- target/ppc/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/kvm.c +1 -1
@@ -2505,7 +2505,7 @@ static int kvm_ppc_register_host_cpu_type(MachineState *ms) } type_info.parent =object_class_get_name (OBJECT_CLASS (pvr_pcc));type_register (&type_info); -if (object_dynamic_cast (ms,TYPE_SPAPR_MACHINE )) { +if (object_dynamic_cast (OBJECT (ms),TYPE_SPAPR_MACHINE )) {/* override TCG default cpu type with 'host' cpu model */ mc->default_cpu_type =TYPE_HOST_POWERPC_CPU ; }
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 18/24] fixup! ppc: spapr: use generic cpu_model parsing
Quoted 1 line · Igor Mammedov
inot sure how it managed to compile locally and on travis
Because target/ppc/kvm.c is only compiled on a ppc _host_.
Quoted 2 lines
but build fails with type mismatch on PPC host, fixup it by casting to expected type
I already hit this one and fixed it up in place.
Quoted 19 lines
Signed-off-by Igor Mammedov <[email protected]>--- target/ppc/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/kvm.c +1
-1@@ -2505,7 +2505,7 @@ static int kvm_ppc_register_host_cpu_type(MachineState *ms) } type_info.parent =object_class_get_name (OBJECT_CLASS (pvr_pcc));type_register (&type_info); -if (object_dynamic_cast (ms,TYPE_SPAPR_MACHINE )) { +if (object_dynamic_cast (OBJECT (ms),TYPE_SPAPR_MACHINE )) {/* override TCG default cpu type with 'host' cpu model */ mc->default_cpu_type =TYPE_HOST_POWERPC_CPU ; }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 18/24] fixup! ppc: spapr: use generic cpu_model parsing
Quoted 4 lines · David Gibson
Quoted 1 line · Igor Mammedov
inot sure how it managed to compile locally and on travis
Because
target/ppc/kvm.cis only compiled on a ppc _host_.
that or in cross environment, to be precise.
Quoted 26 lines
Quoted 3 lines
but build fails with type mismatch on PPC host, fixup it by casting to expected type
I already hit this one and fixed it up in place.
Quoted 19 lines
Signed-off-by Igor Mammedov <[email protected]>--- target/ppc/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/kvm.c +1
-1@@ -2505,7 +2505,7 @@ static int kvm_ppc_register_host_cpu_type(MachineState *ms) } type_info.parent =object_class_get_name (OBJECT_CLASS (pvr_pcc));type_register (&type_info); -if (object_dynamic_cast (ms,TYPE_SPAPR_MACHINE )) { +if (object_dynamic_cast (OBJECT (ms),TYPE_SPAPR_MACHINE )) {/* override TCG default cpu type with 'host' cpu model */ mc->default_cpu_type =TYPE_HOST_POWERPC_CPU ; }
Signature · 1 line
Alexey
PATCH v2 19/24 ppc: pnv: use generic cpu_model parsing
In reply to Igor Mammedovuse 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.
--- include/hw/ppc/pnv.h | 8 ++++---- hw/ppc/pnv.c | 22 ++++++++++------------ hw/ppc/pnv_core.c | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-)
include/hw/ppc/pnv.h +4 -4
@@ -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)
hw/ppc/pnv.c +10 -12
@@ -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 ;
hw/ppc/pnv_core.c +1 -1
@@ -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 )
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 19/24] ppc: pnv: use generic cpu_model parsing
Quoted 19 lines · Igor Mammedov
use common
cpu_modelprasing invl.cand set defaultcpu_modelusing genericMachineClass::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 oncpu_modelparsing.
Quoted 2 lines
Signed-off-by Igor Mammedov <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>
It wouldn't have had an actual patch collision, but this should have the new power9 v2.0...
[...]
include/hw/ppc/pnv.h typedef struct PnvChipClass { · line 97
Quoted 4 lines
include/hw/ppc/pnv.h +1
-1-#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)
here
[...]
hw/ppc/pnv.c static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) · line 784
Quoted 9 lines
hw/ppc/pnv.c +1
-1@@ -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 ;
..and here..
hw/ppc/pnv_core.c static const TypeInfo pnv_core_info = { · line 231
Quoted 4 lines
static const char *pnv_core_models[] = {
hw/ppc/pnv_core.c +1
-1- "POWER8E", "POWER8", "POWER8NVL", "POWER9" + "power8e_v2.1", "power8_v2.0", "power8nvl_v1.0", "power9_v1.0" };
..and here.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH v2 20/24 ppc: pnv: normalize core/chip type names
In reply to Igor Mammedovtypically for cpus/core type names following convention is used
new_type_prefix-superclass_typename
make PNV core/chip to follow common convention.
--- 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(-)
include/hw/ppc/pnv.h +7 -4
@@ -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)
include/hw/ppc/pnv_core.h +2 -0
@@ -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_SUFFIXextern char *pnv_core_typename (const char *model);#endif /* _PPC_PNV_CORE_H */
hw/ppc/pnv.c +1 -1
@@ -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",
hw/ppc/pnv_core.c +1 -1
@@ -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); }
Signature · 1 line
2.7.4
PATCH v2 21/24 ppc: pnv: drop PnvCoreClass::cpu_oc field
In reply to Igor Mammedovdeduce 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()
---
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(-)
include/hw/ppc/pnv_core.h +0 -1
@@ -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
hw/ppc/pnv_core.c +12 -6
@@ -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);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 21/24] ppc: pnv: drop PnvCoreClass::cpu_oc field
Quoted 5 lines · Igor Mammedov
deduce cpu type directly from core type instead of maintaining type mapping in
PnvCoreClass::cpu_ocand doing extracpu_modelparsing inpnv_core_class_init()Signed-off-by Igor Mammedov <[email protected]>
Quoted 81 lines
---
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(-)include/hw/ppc/pnv_core.h +0
-1@@ -42,7 +42,6 @@ typedef struct PnvCore {typedef struct PnvCoreClass {DeviceClass parent_class; -ObjectClass *cpu_oc; }PnvCoreClass ;#define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_COREhw/ppc/pnv_core.c +12
-6@@ -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);
PATCH v2 22/24 ppc: pnv: define core types statically
In reply to Igor Mammedovpnv 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.
--- hw/ppc/pnv_core.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-)
hw/ppc/pnv_core.c +20 -28
@@ -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)
Signature · 1 line
2.7.4
PATCH v2 23/24 ppc: pnv: drop PnvChipClass::cpu_model field
In reply to Igor Mammedovdeduce core type directly from chip type instead of maintaining type mapping in PnvChipClass::cpu_model.
---
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(-)
include/hw/ppc/pnv.h +0 -1
@@ -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;
include/hw/ppc/pnv_core.h +0 -1
@@ -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 */
hw/ppc/pnv.c +13 -12
@@ -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",
hw/ppc/pnv_core.c +0 -5
@@ -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)
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v2 23/24] ppc: pnv: drop PnvChipClass::cpu_model field
Quoted 4 lines · Igor Mammedov
deduce core type directly from chip type instead of maintaining type mapping in
PnvChipClass::cpu_model.Signed-off-by Igor Mammedov <[email protected]>
Quoted 154 lines
---
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(-)include/hw/ppc/pnv.h +0
-1@@ -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;include/hw/ppc/pnv_core.h +0
-1@@ -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 */ hw/ppc/pnv.c +13
-12@@ -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",hw/ppc/pnv_core.c +0
-5@@ -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)
PATCH v2 24/24 ppc: pnv: consolidate type definitions and batch register them
In reply to Igor MammedovUse a new DEFINE_TYPES() helper to simplify type registration
--- hw/ppc/pnv.c | 92 ++++++++++++++++++++++-------------------------------------- 1 file changed, 34 insertions(+), 58 deletions(-)
hw/ppc/pnv.c +34 -58
@@ -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)
Signature · 1 line
2.7.4
On Mon, Oct 09, 2017 at 09:50:47PM +0200, Igor Mammedov wrote:
Applied to ppc-for-2.11. There was a small error in 19/24, which reverted pnv to defaulting to POWER9 v1.0 whereas I've recently changed it to v2.0. Rather than requiring a respin I adjusted that myself, and fixed the minor conflicts in the subsequent patches.
Quoted 106 lines
Changelog:
- v2:
* rebase on dgibson/ppc-for-2.11 tree
* fix typo: s/pvn_chip_core_typename/pnv_chip_core_typename/
* fix typo: s/pvn_core_cpu_typename/pnv_core_cpu_typename/
* limit setting default cpu type to 'host' type only for spapr machine
* split outppc_cpu_lookup_alias()movement into separate patch
* fix rebase conflict: add newly addedpower9_v2core
* 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
intarget/ppc/cpu.c
* do compat= parsing only if machine."max-cpu-compat" exists that would match what current code practically does.
* add newline beforeppc_cpu_parse_featurestr()definition
* pickup Acked-by/Reviewed-by where it's appropriatethis series is continuation of effort to remove boards dependency on
cpu_modelparsing and generalizing default cpu type handling. For background story look at merged:[PATCH v2 0/5] generalize parsing of
cpu_model(x86/arm)
https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg03564.htmlPart 3 is independent subset that takes care of all PPC boards. Series borrows the 1st 3 patches from earlier posted part 2
qom: update doc comment for type_register[_static]()
qom: introducetype_register_static_array()
qom: add helper macroDEFINE_TYPES()
to avoid interdependency, hopefully this 3 will be merged via machine-next, but it's fine for them to go via any tree (whichever first)Beside of switching to generic
cpu_modelparsing series contains a bunch of cleanups/simplifications which reduces code a bit and normalizes code that I've happend to touch to a typical QEMU patterns.git tree for testing:
https://github.com/imammedo/qemu/branchescpu_init_removal_ppc_part3_v2Refference to v1:
https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg01087.htmlCC Alexander Graf <[email protected]> (supporter:ppce500)CC David Gibson <[email protected]> (maintainer:PowerPC)CC "Hervé Poussineau" <[email protected]> (maintainer:PReP)CC "Edgar E. Iglesias" <[email protected]> (odd fixer:virtex_ml507)CC [email protected] (open list:ppce500)Igor Mammedov (24):
qom: update doc comment for type_register[_static]()
qom: introducetype_register_static_array()
qom: add helper macroDEFINE_TYPES()
ppc: mpc8544ds/e500plat: use genericcpu_modelparsing
ppc:mac_newworld: use genericcpu_modelparsing
ppc:mac_oldworld: use genericcpu_modelparsing
ppc: bamboo: use genericcpu_modelparsing
ppc: replacecpu_modelwithcpu_typeon ref405ep,taihu boards
ppc: virtex-ml507: replacecpu_modelwithcpu_type
ppc: 40p/prep: replacecpu_modelwithcpu_type
ppc: spapr: replaceppc_cpu_parse_features()with
cpu_parse_cpu_model()
ppc: move '-cpu foo,compat=xxx' parsing into
ppc_cpu_parse_featurestr()
ppc: spapr: define core types statically
ppc: spapr: use cpu type name directly
ppc: spapr: register 'host' core type along with the rest of core
types
ppc: spapr: use cpu model names as tcg defaults instead of aliases
ppc: moveppc_cpu_lookup_alias()before its first user
ppc: spapr: use genericcpu_modelparsing
ppc: pnv: use genericcpu_modelparsing
ppc: pnv: normalize core/chip type names
ppc: pnv: dropPnvCoreClass::cpu_ocfield
ppc: pnv: define core types statically
ppc: pnv: dropPnvChipClass::cpu_modelfield
ppc: pnv: consolidate type definitions and batch register theminclude/hw/ppc/pnv.h | 12 +-- include/hw/ppc/pnv_core.h | 4 +- include/hw/ppc/ppc.h | 2 - include/hw/ppc/spapr.h | 2 - include/hw/ppc/spapr_cpu_core.h | 7 +- include/qom/object.h | 50 ++++++++++- target/ppc/cpu-qom.h | 1 + target/ppc/cpu.h | 1 - hw/ppc/e500.c | 8 +- hw/ppc/e500plat.c | 1 + hw/ppc/mac_newworld.c | 15 ++-- hw/ppc/mac_oldworld.c | 6 +- hw/ppc/mpc8544ds.c | 2 + hw/ppc/pnv.c | 131 ++++++++++++---------------- hw/ppc/pnv_core.c | 67 +++++++-------- hw/ppc/ppc.c | 25 ------ hw/ppc/ppc405_uc.c | 6 +- hw/ppc/ppc440_bamboo.c | 7 +- hw/ppc/ppc4xx_devs.c | 4 +- hw/ppc/prep.c | 12 +-- hw/ppc/spapr.c | 22 ++--- hw/ppc/spapr_cpu_core.c | 184 ++++++++++------------------------------ hw/ppc/virtex_ml507.c | 11 +-- qom/object.c | 9 ++ target/ppc/kvm.c | 22 ++--- target/ppc/translate_init.c | 69 +++++++++++++-- 26 files changed, 305 insertions(+), 375 deletions(-)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 6 lines · On Tue, 10 Oct 2017 13:21:37 +1100 David Gibson <[email protected]>…
On Mon, Oct 09, 2017 at 09:50:47PM +0200, Igor Mammedov wrote:
Applied to ppc-for-2.11. There was a small error in 19/24, which reverted pnv to defaulting to POWER9 v1.0 whereas I've recently changed it to v2.0. Rather than requiring a respin I adjusted that myself, and fixed the minor conflicts in the subsequent patches.
there were conflicts in spapr code but not in pnv, so I haven't noticed. I've checked commit on ppc-for-2.11 branch and it looks good. Anyways thanks for fixing it up.
Quoted 108 lines
Quoted 107 lines
Changelog:
- v2:
* rebase on dgibson/ppc-for-2.11 tree
* fix typo: s/pvn_chip_core_typename/pnv_chip_core_typename/
* fix typo: s/pvn_core_cpu_typename/pnv_core_cpu_typename/
* limit setting default cpu type to 'host' type only for spapr machine
* split outppc_cpu_lookup_alias()movement into separate patch
* fix rebase conflict: add newly addedpower9_v2core
* 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
intarget/ppc/cpu.c
* do compat= parsing only if machine."max-cpu-compat" exists that would match what current code practically does.
* add newline beforeppc_cpu_parse_featurestr()definition
* pickup Acked-by/Reviewed-by where it's appropriatethis series is continuation of effort to remove boards dependency on
cpu_modelparsing and generalizing default cpu type handling. For background story look at merged:[PATCH v2 0/5] generalize parsing of
cpu_model(x86/arm)
https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg03564.htmlPart 3 is independent subset that takes care of all PPC boards. Series borrows the 1st 3 patches from earlier posted part 2
qom: update doc comment for type_register[_static]()
qom: introducetype_register_static_array()
qom: add helper macroDEFINE_TYPES()
to avoid interdependency, hopefully this 3 will be merged via machine-next, but it's fine for them to go via any tree (whichever first)Beside of switching to generic
cpu_modelparsing series contains a bunch of cleanups/simplifications which reduces code a bit and normalizes code that I've happend to touch to a typical QEMU patterns.git tree for testing:
https://github.com/imammedo/qemu/branchescpu_init_removal_ppc_part3_v2Refference to v1:
https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg01087.htmlCC Alexander Graf <[email protected]> (supporter:ppce500)CC David Gibson <[email protected]> (maintainer:PowerPC)CC "Hervé Poussineau" <[email protected]> (maintainer:PReP)CC "Edgar E. Iglesias" <[email protected]> (odd fixer:virtex_ml507)CC [email protected] (open list:ppce500)Igor Mammedov (24):
qom: update doc comment for type_register[_static]()
qom: introducetype_register_static_array()
qom: add helper macroDEFINE_TYPES()
ppc: mpc8544ds/e500plat: use genericcpu_modelparsing
ppc:mac_newworld: use genericcpu_modelparsing
ppc:mac_oldworld: use genericcpu_modelparsing
ppc: bamboo: use genericcpu_modelparsing
ppc: replacecpu_modelwithcpu_typeon ref405ep,taihu boards
ppc: virtex-ml507: replacecpu_modelwithcpu_type
ppc: 40p/prep: replacecpu_modelwithcpu_type
ppc: spapr: replaceppc_cpu_parse_features()with
cpu_parse_cpu_model()
ppc: move '-cpu foo,compat=xxx' parsing into
ppc_cpu_parse_featurestr()
ppc: spapr: define core types statically
ppc: spapr: use cpu type name directly
ppc: spapr: register 'host' core type along with the rest of core
types
ppc: spapr: use cpu model names as tcg defaults instead of aliases
ppc: moveppc_cpu_lookup_alias()before its first user
ppc: spapr: use genericcpu_modelparsing
ppc: pnv: use genericcpu_modelparsing
ppc: pnv: normalize core/chip type names
ppc: pnv: dropPnvCoreClass::cpu_ocfield
ppc: pnv: define core types statically
ppc: pnv: dropPnvChipClass::cpu_modelfield
ppc: pnv: consolidate type definitions and batch register theminclude/hw/ppc/pnv.h | 12 +-- include/hw/ppc/pnv_core.h | 4 +- include/hw/ppc/ppc.h | 2 - include/hw/ppc/spapr.h | 2 - include/hw/ppc/spapr_cpu_core.h | 7 +- include/qom/object.h | 50 ++++++++++- target/ppc/cpu-qom.h | 1 + target/ppc/cpu.h | 1 - hw/ppc/e500.c | 8 +- hw/ppc/e500plat.c | 1 + hw/ppc/mac_newworld.c | 15 ++-- hw/ppc/mac_oldworld.c | 6 +- hw/ppc/mpc8544ds.c | 2 + hw/ppc/pnv.c | 131 ++++++++++++---------------- hw/ppc/pnv_core.c | 67 +++++++-------- hw/ppc/ppc.c | 25 ------ hw/ppc/ppc405_uc.c | 6 +- hw/ppc/ppc440_bamboo.c | 7 +- hw/ppc/ppc4xx_devs.c | 4 +- hw/ppc/prep.c | 12 +-- hw/ppc/spapr.c | 22 ++--- hw/ppc/spapr_cpu_core.c | 184 ++++++++++------------------------------ hw/ppc/virtex_ml507.c | 11 +-- qom/object.c | 9 ++ target/ppc/kvm.c | 22 ++--- target/ppc/translate_init.c | 69 +++++++++++++-- 26 files changed, 305 insertions(+), 375 deletions(-)
Quoted 11 lines · Igor Mammedov
Quoted 6 lines · On Tue, 10 Oct 2017 13:21:37 +1100 David Gibson <[email protected]>…
On Mon, Oct 09, 2017 at 09:50:47PM +0200, Igor Mammedov wrote:
Applied to ppc-for-2.11. There was a small error in 19/24, which reverted pnv to defaulting to POWER9 v1.0 whereas I've recently changed it to v2.0. Rather than requiring a respin I adjusted that myself, and fixed the minor conflicts in the subsequent patches.
there were conflicts in spapr code but not in pnv, so I haven't
Quoted 1 line
noticed.
Yeah, that's what I figured.
Quoted 2 lines
I've checked commit on ppc-for-2.11 branch and it looks good. Anyways thanks for fixing it up.
No problem.
Quoted 110 lines
Quoted 109 lines
Quoted 108 lines
Changelog:
- v2:
* rebase on dgibson/ppc-for-2.11 tree
* fix typo: s/pvn_chip_core_typename/pnv_chip_core_typename/
* fix typo: s/pvn_core_cpu_typename/pnv_core_cpu_typename/
* limit setting default cpu type to 'host' type only for spapr machine
* split outppc_cpu_lookup_alias()movement into separate patch
* fix rebase conflict: add newly addedpower9_v2core
* 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
intarget/ppc/cpu.c
* do compat= parsing only if machine."max-cpu-compat" exists that would match what current code practically does.
* add newline beforeppc_cpu_parse_featurestr()definition
* pickup Acked-by/Reviewed-by where it's appropriatethis series is continuation of effort to remove boards dependency on
cpu_modelparsing and generalizing default cpu type handling. For background story look at merged:[PATCH v2 0/5] generalize parsing of
cpu_model(x86/arm)
https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg03564.htmlPart 3 is independent subset that takes care of all PPC boards. Series borrows the 1st 3 patches from earlier posted part 2
qom: update doc comment for type_register[_static]()
qom: introducetype_register_static_array()
qom: add helper macroDEFINE_TYPES()
to avoid interdependency, hopefully this 3 will be merged via machine-next, but it's fine for them to go via any tree (whichever first)Beside of switching to generic
cpu_modelparsing series contains a bunch of cleanups/simplifications which reduces code a bit and normalizes code that I've happend to touch to a typical QEMU patterns.git tree for testing:
https://github.com/imammedo/qemu/branchescpu_init_removal_ppc_part3_v2Refference to v1:
https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg01087.htmlCC Alexander Graf <[email protected]> (supporter:ppce500)CC David Gibson <[email protected]> (maintainer:PowerPC)CC "Hervé Poussineau" <[email protected]> (maintainer:PReP)CC "Edgar E. Iglesias" <[email protected]> (odd fixer:virtex_ml507)CC [email protected] (open list:ppce500)Igor Mammedov (24):
qom: update doc comment for type_register[_static]()
qom: introducetype_register_static_array()
qom: add helper macroDEFINE_TYPES()
ppc: mpc8544ds/e500plat: use genericcpu_modelparsing
ppc:mac_newworld: use genericcpu_modelparsing
ppc:mac_oldworld: use genericcpu_modelparsing
ppc: bamboo: use genericcpu_modelparsing
ppc: replacecpu_modelwithcpu_typeon ref405ep,taihu boards
ppc: virtex-ml507: replacecpu_modelwithcpu_type
ppc: 40p/prep: replacecpu_modelwithcpu_type
ppc: spapr: replaceppc_cpu_parse_features()with
cpu_parse_cpu_model()
ppc: move '-cpu foo,compat=xxx' parsing into
ppc_cpu_parse_featurestr()
ppc: spapr: define core types statically
ppc: spapr: use cpu type name directly
ppc: spapr: register 'host' core type along with the rest of core
types
ppc: spapr: use cpu model names as tcg defaults instead of aliases
ppc: moveppc_cpu_lookup_alias()before its first user
ppc: spapr: use genericcpu_modelparsing
ppc: pnv: use genericcpu_modelparsing
ppc: pnv: normalize core/chip type names
ppc: pnv: dropPnvCoreClass::cpu_ocfield
ppc: pnv: define core types statically
ppc: pnv: dropPnvChipClass::cpu_modelfield
ppc: pnv: consolidate type definitions and batch register theminclude/hw/ppc/pnv.h | 12 +-- include/hw/ppc/pnv_core.h | 4 +- include/hw/ppc/ppc.h | 2 - include/hw/ppc/spapr.h | 2 - include/hw/ppc/spapr_cpu_core.h | 7 +- include/qom/object.h | 50 ++++++++++- target/ppc/cpu-qom.h | 1 + target/ppc/cpu.h | 1 - hw/ppc/e500.c | 8 +- hw/ppc/e500plat.c | 1 + hw/ppc/mac_newworld.c | 15 ++-- hw/ppc/mac_oldworld.c | 6 +- hw/ppc/mpc8544ds.c | 2 + hw/ppc/pnv.c | 131 ++++++++++++---------------- hw/ppc/pnv_core.c | 67 +++++++-------- hw/ppc/ppc.c | 25 ------ hw/ppc/ppc405_uc.c | 6 +- hw/ppc/ppc440_bamboo.c | 7 +- hw/ppc/ppc4xx_devs.c | 4 +- hw/ppc/prep.c | 12 +-- hw/ppc/spapr.c | 22 ++--- hw/ppc/spapr_cpu_core.c | 184 ++++++++++------------------------------ hw/ppc/virtex_ml507.c | 11 +-- qom/object.c | 9 ++ target/ppc/kvm.c | 22 ++--- target/ppc/translate_init.c | 69 +++++++++++++-- 26 files changed, 305 insertions(+), 375 deletions(-)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson