Re: [Qemu-devel] [PATCH v2 5/5] arm: drop intermediate cpu_model -> cpu type parsing and use cpu type directly
On Thu, Sep 14, 2017 at 12:50 AM, Igor Mammedovwrote: > On Thu, 14 Sep 2017 00:47:20 -0300 > Philippe Mathieu-Daudé wrote: > >> Hi Igor, >> >> awesome clean refactor! > Thanks, > > there is more patches on this topic for other targets to post > but it's waiting on 1-3/5 to land in master so it would be > easier for maintainers to verify/test them without fishing out > dependencies from mail list. > > hopefully everything will land in 2.11 so we won't have to deal > with cpu_model anywhere except of one place vl.c. > >> just 1 comment inlined. >> >> On 09/13/2017 01:04 PM, Igor Mammedov wrote: >> > there are 2 use cases to deal with: >> >1: fixed CPU models per board/soc >> >2: boards with user configurable cpu_model and fallback to >> > default cpu_model if user hasn't specified one explicitly >> > >> > For the 1st >> >drop intermediate cpu_model parsing and use const cpu type >> >directly, which replaces: >> > typename = object_class_get_name( >> > cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) >> > object_new(typename) >> >with >> > object_new(FOO_CPU_TYPE_NAME) >> >or >> > cpu_generic_init(BASE_CPU_TYPE, "my cpu model") >> >with >> > cpu_create(FOO_CPU_TYPE_NAME) >> > >> > as result 1st use case doesn't have to invoke not necessary >> > translation and not needed code is removed. >> > >> > For the 2nd >> > 1: set default cpu type with MachineClass::default_cpu_type and >> > 2: use generic cpu_model parsing that done before machine_init() >> > is run and: >> > 2.1: drop custom cpu_model parsing where pattern is: >> > typename = object_class_get_name( >> > cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) >> > [parse_features(typename, cpu_model, ) ] >> > >> > 2.2: or replace cpu_generic_init() which does what >> > 2.1 does + create_cpu(typename) with just >> > create_cpu(machine->cpu_type) >> > as result cpu_name -> cpu_type translation is done using >> > generic machine code one including parsing optional features >> > if supported/present (removes a bunch of duplicated cpu_model >> > parsing code) and default cpu type is defined in an uniform way >> > within machine_class_init callbacks instead of adhoc places >> > in boadr's machine_init code. >> > >> > Signed-off-by: Igor Mammedov >> > Reviewed-by: Eduardo Habkost >> > --- >> > v2: >> > - fix merge conflicts with ignore_memory_transaction_failures >> > - fix couple merge conflicts where SoC type string where replaced by >> > type macro >> > - keep plain prefix string in: strncmp(cpu_type, "pxa27", 5) >> > - s/"%s" ARM_CPU_TYPE_SUFFIX/ARM_CPU_TYPE_NAME("%s")/ >> > --- > [...] > >> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c >> > index fe96557..fe26e99 100644 >> > --- a/hw/arm/virt.c >> > +++ b/hw/arm/virt.c >> > @@ -163,13 +163,13 @@ static const int a15irqmap[] = { >> > }; >> > >> > static const char *valid_cpus[] = { >> > -"cortex-a15", >> > -"cortex-a53", >> > -"cortex-a57", >> > -"host", >> > +ARM_CPU_TYPE_NAME("cortex-a15"), >> > +ARM_CPU_TYPE_NAME("cortex-a53"), >> > +ARM_CPU_TYPE_NAME("cortex-a57"), >> > +ARM_CPU_TYPE_NAME("host"), >> > }; >> > >> > -static bool cpuname_valid(const char *cpu) >> > +static bool cpu_type_valid(const char *cpu) >> > { >> > int i; >> >> I'd just change this by: >> >> static bool cpuname_valid(const char *cpu) >> { >> static const char *valid_cpus[] = { >> ARM_CPU_TYPE_NAME("cortex-a15"), >> ARM_CPU_TYPE_NAME("cortex-a53"), >> ARM_CPU_TYPE_NAME("cortex-a57"), >> }; >> int i; >> >> for (i = 0; i < ARRAY_SIZE(valid_cpus); i++) { >> if (strcmp(cpu, valid_cpus[i]) == 0) { >> return true; >> } >> } > >> return kvm_enabled() && !strcmp(cpu, ARM_CPU_TYPE_NAME("host"); > here is one more case to consider for valid_cpus refactoring, > CCing Alistair. Thanks, I have a few comments I need to look at for this. I'm going to hold off until this series lands though. Thanks, Alistair > >> } >> >> Anyway this can be a later patch. > this check might be removed or superseded by generic valid_cpus work > that Alistair is working on, anyways it should be part of that work > as change is not directly related to this series. > > > [...]
Re: [Qemu-devel] [PATCH v2 5/5] arm: drop intermediate cpu_model -> cpu type parsing and use cpu type directly
On Wed, Sep 13, 2017 at 9:04 AM, Igor Mammedovwrote: > there are 2 use cases to deal with: > 1: fixed CPU models per board/soc > 2: boards with user configurable cpu_model and fallback to > default cpu_model if user hasn't specified one explicitly > > For the 1st > drop intermediate cpu_model parsing and use const cpu type > directly, which replaces: > typename = object_class_get_name( >cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) > object_new(typename) > with > object_new(FOO_CPU_TYPE_NAME) > or > cpu_generic_init(BASE_CPU_TYPE, "my cpu model") > with > cpu_create(FOO_CPU_TYPE_NAME) > > as result 1st use case doesn't have to invoke not necessary > translation and not needed code is removed. > > For the 2nd > 1: set default cpu type with MachineClass::default_cpu_type and > 2: use generic cpu_model parsing that done before machine_init() > is run and: > 2.1: drop custom cpu_model parsing where pattern is: >typename = object_class_get_name( >cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) >[parse_features(typename, cpu_model, ) ] > > 2.2: or replace cpu_generic_init() which does what > 2.1 does + create_cpu(typename) with just > create_cpu(machine->cpu_type) > as result cpu_name -> cpu_type translation is done using > generic machine code one including parsing optional features > if supported/present (removes a bunch of duplicated cpu_model > parsing code) and default cpu type is defined in an uniform way > within machine_class_init callbacks instead of adhoc places > in boadr's machine_init code. > > Signed-off-by: Igor Mammedov > Reviewed-by: Eduardo Habkost Fox the Xilinx and Netduino stuff: Reviewed-by: Alistair Francis Thanks, Alistair > --- > v2: > - fix merge conflicts with ignore_memory_transaction_failures > - fix couple merge conflicts where SoC type string where replaced by type > macro > - keep plain prefix string in: strncmp(cpu_type, "pxa27", 5) > - s/"%s" ARM_CPU_TYPE_SUFFIX/ARM_CPU_TYPE_NAME("%s")/ > --- > include/hw/arm/armv7m.h| 2 +- > include/hw/arm/aspeed_soc.h| 2 +- > include/hw/arm/stm32f205_soc.h | 2 +- > target/arm/cpu.h | 3 +++ > hw/arm/armv7m.c| 40 +--- > hw/arm/aspeed_soc.c| 13 +--- > hw/arm/collie.c| 10 +++-- > hw/arm/exynos4210.c| 6 +- > hw/arm/gumstix.c | 5 +++-- > hw/arm/highbank.c | 10 - > hw/arm/integratorcp.c | 30 ++- > hw/arm/mainstone.c | 9 - > hw/arm/mps2.c | 17 +++- > hw/arm/musicpal.c | 7 ++- > hw/arm/netduino2.c | 2 +- > hw/arm/nseries.c | 4 +++- > hw/arm/omap1.c | 7 ++- > hw/arm/omap2.c | 4 ++-- > hw/arm/omap_sx1.c | 5 - > hw/arm/palm.c | 5 +++-- > hw/arm/pxa2xx.c| 10 - > hw/arm/realview.c | 25 +-- > hw/arm/spitz.c | 12 ++- > hw/arm/stellaris.c | 16 +++ > hw/arm/stm32f205_soc.c | 4 ++-- > hw/arm/strongarm.c | 10 +++-- > hw/arm/tosa.c | 4 > hw/arm/versatilepb.c | 15 +++--- > hw/arm/vexpress.c | 32 + > hw/arm/virt.c | 46 > +- > hw/arm/xilinx_zynq.c | 10 ++--- > hw/arm/z2.c| 9 +++-- > target/arm/cpu.c | 2 +- > 33 files changed, 114 insertions(+), 264 deletions(-) > > diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h > index 10eb058..68cb30d 100644 > --- a/include/hw/arm/armv7m.h > +++ b/include/hw/arm/armv7m.h > @@ -55,7 +55,7 @@ typedef struct ARMv7MState { > MemoryRegion container; > > /* Properties */ > -char *cpu_model; > +char *cpu_type; > /* MemoryRegion the board provides to us (with its devices, RAM, etc) */ > MemoryRegion *board_memory; > } ARMv7MState; > diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h > index 0b88baa..f26914a 100644 > --- a/include/hw/arm/aspeed_soc.h > +++ b/include/hw/arm/aspeed_soc.h > @@ -49,7 +49,7 @@ typedef struct AspeedSoCState { > > typedef struct AspeedSoCInfo { > const char *name; > -const char *cpu_model; > +const char *cpu_type; > uint32_t silicon_rev; > hwaddr sdram_base; > uint64_t sram_size; > diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h > index e2dce11..922a733 100644 > --- a/include/hw/arm/stm32f205_soc.h > +++ b/include/hw/arm/stm32f205_soc.h > @@ -52,7 +52,7 @@ typedef
Re: [Qemu-devel] [PATCH v2 5/5] arm: drop intermediate cpu_model -> cpu type parsing and use cpu type directly
On Thu, 14 Sep 2017 00:47:20 -0300 Philippe Mathieu-Daudéwrote: > Hi Igor, > > awesome clean refactor! Thanks, there is more patches on this topic for other targets to post but it's waiting on 1-3/5 to land in master so it would be easier for maintainers to verify/test them without fishing out dependencies from mail list. hopefully everything will land in 2.11 so we won't have to deal with cpu_model anywhere except of one place vl.c. > just 1 comment inlined. > > On 09/13/2017 01:04 PM, Igor Mammedov wrote: > > there are 2 use cases to deal with: > >1: fixed CPU models per board/soc > >2: boards with user configurable cpu_model and fallback to > > default cpu_model if user hasn't specified one explicitly > > > > For the 1st > >drop intermediate cpu_model parsing and use const cpu type > >directly, which replaces: > > typename = object_class_get_name( > > cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) > > object_new(typename) > >with > > object_new(FOO_CPU_TYPE_NAME) > >or > > cpu_generic_init(BASE_CPU_TYPE, "my cpu model") > >with > > cpu_create(FOO_CPU_TYPE_NAME) > > > > as result 1st use case doesn't have to invoke not necessary > > translation and not needed code is removed. > > > > For the 2nd > > 1: set default cpu type with MachineClass::default_cpu_type and > > 2: use generic cpu_model parsing that done before machine_init() > > is run and: > > 2.1: drop custom cpu_model parsing where pattern is: > > typename = object_class_get_name( > > cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) > > [parse_features(typename, cpu_model, ) ] > > > > 2.2: or replace cpu_generic_init() which does what > > 2.1 does + create_cpu(typename) with just > > create_cpu(machine->cpu_type) > > as result cpu_name -> cpu_type translation is done using > > generic machine code one including parsing optional features > > if supported/present (removes a bunch of duplicated cpu_model > > parsing code) and default cpu type is defined in an uniform way > > within machine_class_init callbacks instead of adhoc places > > in boadr's machine_init code. > > > > Signed-off-by: Igor Mammedov > > Reviewed-by: Eduardo Habkost > > --- > > v2: > > - fix merge conflicts with ignore_memory_transaction_failures > > - fix couple merge conflicts where SoC type string where replaced by type > > macro > > - keep plain prefix string in: strncmp(cpu_type, "pxa27", 5) > > - s/"%s" ARM_CPU_TYPE_SUFFIX/ARM_CPU_TYPE_NAME("%s")/ > > --- [...] > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > > index fe96557..fe26e99 100644 > > --- a/hw/arm/virt.c > > +++ b/hw/arm/virt.c > > @@ -163,13 +163,13 @@ static const int a15irqmap[] = { > > }; > > > > static const char *valid_cpus[] = { > > -"cortex-a15", > > -"cortex-a53", > > -"cortex-a57", > > -"host", > > +ARM_CPU_TYPE_NAME("cortex-a15"), > > +ARM_CPU_TYPE_NAME("cortex-a53"), > > +ARM_CPU_TYPE_NAME("cortex-a57"), > > +ARM_CPU_TYPE_NAME("host"), > > }; > > > > -static bool cpuname_valid(const char *cpu) > > +static bool cpu_type_valid(const char *cpu) > > { > > int i; > > I'd just change this by: > > static bool cpuname_valid(const char *cpu) > { > static const char *valid_cpus[] = { > ARM_CPU_TYPE_NAME("cortex-a15"), > ARM_CPU_TYPE_NAME("cortex-a53"), > ARM_CPU_TYPE_NAME("cortex-a57"), > }; > int i; > > for (i = 0; i < ARRAY_SIZE(valid_cpus); i++) { > if (strcmp(cpu, valid_cpus[i]) == 0) { > return true; > } > } > return kvm_enabled() && !strcmp(cpu, ARM_CPU_TYPE_NAME("host"); here is one more case to consider for valid_cpus refactoring, CCing Alistair. > } > > Anyway this can be a later patch. this check might be removed or superseded by generic valid_cpus work that Alistair is working on, anyways it should be part of that work as change is not directly related to this series. [...]
Re: [Qemu-devel] [PATCH v2 5/5] arm: drop intermediate cpu_model -> cpu type parsing and use cpu type directly
Hi Igor, awesome clean refactor! just 1 comment inlined. On 09/13/2017 01:04 PM, Igor Mammedov wrote: there are 2 use cases to deal with: 1: fixed CPU models per board/soc 2: boards with user configurable cpu_model and fallback to default cpu_model if user hasn't specified one explicitly For the 1st drop intermediate cpu_model parsing and use const cpu type directly, which replaces: typename = object_class_get_name( cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) object_new(typename) with object_new(FOO_CPU_TYPE_NAME) or cpu_generic_init(BASE_CPU_TYPE, "my cpu model") with cpu_create(FOO_CPU_TYPE_NAME) as result 1st use case doesn't have to invoke not necessary translation and not needed code is removed. For the 2nd 1: set default cpu type with MachineClass::default_cpu_type and 2: use generic cpu_model parsing that done before machine_init() is run and: 2.1: drop custom cpu_model parsing where pattern is: typename = object_class_get_name( cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) [parse_features(typename, cpu_model, ) ] 2.2: or replace cpu_generic_init() which does what 2.1 does + create_cpu(typename) with just create_cpu(machine->cpu_type) as result cpu_name -> cpu_type translation is done using generic machine code one including parsing optional features if supported/present (removes a bunch of duplicated cpu_model parsing code) and default cpu type is defined in an uniform way within machine_class_init callbacks instead of adhoc places in boadr's machine_init code. Signed-off-by: Igor MammedovReviewed-by: Eduardo Habkost --- v2: - fix merge conflicts with ignore_memory_transaction_failures - fix couple merge conflicts where SoC type string where replaced by type macro - keep plain prefix string in: strncmp(cpu_type, "pxa27", 5) - s/"%s" ARM_CPU_TYPE_SUFFIX/ARM_CPU_TYPE_NAME("%s")/ --- include/hw/arm/armv7m.h| 2 +- include/hw/arm/aspeed_soc.h| 2 +- include/hw/arm/stm32f205_soc.h | 2 +- target/arm/cpu.h | 3 +++ hw/arm/armv7m.c| 40 +--- hw/arm/aspeed_soc.c| 13 +--- hw/arm/collie.c| 10 +++-- hw/arm/exynos4210.c| 6 +- hw/arm/gumstix.c | 5 +++-- hw/arm/highbank.c | 10 - hw/arm/integratorcp.c | 30 ++- hw/arm/mainstone.c | 9 - hw/arm/mps2.c | 17 +++- hw/arm/musicpal.c | 7 ++- hw/arm/netduino2.c | 2 +- hw/arm/nseries.c | 4 +++- hw/arm/omap1.c | 7 ++- hw/arm/omap2.c | 4 ++-- hw/arm/omap_sx1.c | 5 - hw/arm/palm.c | 5 +++-- hw/arm/pxa2xx.c| 10 - hw/arm/realview.c | 25 +-- hw/arm/spitz.c | 12 ++- hw/arm/stellaris.c | 16 +++ hw/arm/stm32f205_soc.c | 4 ++-- hw/arm/strongarm.c | 10 +++-- hw/arm/tosa.c | 4 hw/arm/versatilepb.c | 15 +++--- hw/arm/vexpress.c | 32 + hw/arm/virt.c | 46 +- hw/arm/xilinx_zynq.c | 10 ++--- hw/arm/z2.c| 9 +++-- target/arm/cpu.c | 2 +- 33 files changed, 114 insertions(+), 264 deletions(-) diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h index 10eb058..68cb30d 100644 --- a/include/hw/arm/armv7m.h +++ b/include/hw/arm/armv7m.h @@ -55,7 +55,7 @@ typedef struct ARMv7MState { MemoryRegion container; /* Properties */ -char *cpu_model; +char *cpu_type; /* MemoryRegion the board provides to us (with its devices, RAM, etc) */ MemoryRegion *board_memory; } ARMv7MState; diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index 0b88baa..f26914a 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -49,7 +49,7 @@ typedef struct AspeedSoCState { typedef struct AspeedSoCInfo { const char *name; -const char *cpu_model; +const char *cpu_type; uint32_t silicon_rev; hwaddr sdram_base; uint64_t sram_size; diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h index e2dce11..922a733 100644 --- a/include/hw/arm/stm32f205_soc.h +++ b/include/hw/arm/stm32f205_soc.h @@ -52,7 +52,7 @@ typedef struct STM32F205State { SysBusDevice parent_obj; /*< public >*/ -char *cpu_model; +char *cpu_type; ARMv7MState armv7m; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 98b9b26..1bfdd8d
[Qemu-devel] [PATCH v2 5/5] arm: drop intermediate cpu_model -> cpu type parsing and use cpu type directly
there are 2 use cases to deal with: 1: fixed CPU models per board/soc 2: boards with user configurable cpu_model and fallback to default cpu_model if user hasn't specified one explicitly For the 1st drop intermediate cpu_model parsing and use const cpu type directly, which replaces: typename = object_class_get_name( cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) object_new(typename) with object_new(FOO_CPU_TYPE_NAME) or cpu_generic_init(BASE_CPU_TYPE, "my cpu model") with cpu_create(FOO_CPU_TYPE_NAME) as result 1st use case doesn't have to invoke not necessary translation and not needed code is removed. For the 2nd 1: set default cpu type with MachineClass::default_cpu_type and 2: use generic cpu_model parsing that done before machine_init() is run and: 2.1: drop custom cpu_model parsing where pattern is: typename = object_class_get_name( cpu_class_by_name(TYPE_ARM_CPU, cpu_model)) [parse_features(typename, cpu_model, ) ] 2.2: or replace cpu_generic_init() which does what 2.1 does + create_cpu(typename) with just create_cpu(machine->cpu_type) as result cpu_name -> cpu_type translation is done using generic machine code one including parsing optional features if supported/present (removes a bunch of duplicated cpu_model parsing code) and default cpu type is defined in an uniform way within machine_class_init callbacks instead of adhoc places in boadr's machine_init code. Signed-off-by: Igor MammedovReviewed-by: Eduardo Habkost --- v2: - fix merge conflicts with ignore_memory_transaction_failures - fix couple merge conflicts where SoC type string where replaced by type macro - keep plain prefix string in: strncmp(cpu_type, "pxa27", 5) - s/"%s" ARM_CPU_TYPE_SUFFIX/ARM_CPU_TYPE_NAME("%s")/ --- include/hw/arm/armv7m.h| 2 +- include/hw/arm/aspeed_soc.h| 2 +- include/hw/arm/stm32f205_soc.h | 2 +- target/arm/cpu.h | 3 +++ hw/arm/armv7m.c| 40 +--- hw/arm/aspeed_soc.c| 13 +--- hw/arm/collie.c| 10 +++-- hw/arm/exynos4210.c| 6 +- hw/arm/gumstix.c | 5 +++-- hw/arm/highbank.c | 10 - hw/arm/integratorcp.c | 30 ++- hw/arm/mainstone.c | 9 - hw/arm/mps2.c | 17 +++- hw/arm/musicpal.c | 7 ++- hw/arm/netduino2.c | 2 +- hw/arm/nseries.c | 4 +++- hw/arm/omap1.c | 7 ++- hw/arm/omap2.c | 4 ++-- hw/arm/omap_sx1.c | 5 - hw/arm/palm.c | 5 +++-- hw/arm/pxa2xx.c| 10 - hw/arm/realview.c | 25 +-- hw/arm/spitz.c | 12 ++- hw/arm/stellaris.c | 16 +++ hw/arm/stm32f205_soc.c | 4 ++-- hw/arm/strongarm.c | 10 +++-- hw/arm/tosa.c | 4 hw/arm/versatilepb.c | 15 +++--- hw/arm/vexpress.c | 32 + hw/arm/virt.c | 46 +- hw/arm/xilinx_zynq.c | 10 ++--- hw/arm/z2.c| 9 +++-- target/arm/cpu.c | 2 +- 33 files changed, 114 insertions(+), 264 deletions(-) diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h index 10eb058..68cb30d 100644 --- a/include/hw/arm/armv7m.h +++ b/include/hw/arm/armv7m.h @@ -55,7 +55,7 @@ typedef struct ARMv7MState { MemoryRegion container; /* Properties */ -char *cpu_model; +char *cpu_type; /* MemoryRegion the board provides to us (with its devices, RAM, etc) */ MemoryRegion *board_memory; } ARMv7MState; diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index 0b88baa..f26914a 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -49,7 +49,7 @@ typedef struct AspeedSoCState { typedef struct AspeedSoCInfo { const char *name; -const char *cpu_model; +const char *cpu_type; uint32_t silicon_rev; hwaddr sdram_base; uint64_t sram_size; diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h index e2dce11..922a733 100644 --- a/include/hw/arm/stm32f205_soc.h +++ b/include/hw/arm/stm32f205_soc.h @@ -52,7 +52,7 @@ typedef struct STM32F205State { SysBusDevice parent_obj; /*< public >*/ -char *cpu_model; +char *cpu_type; ARMv7MState armv7m; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 98b9b26..1bfdd8d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2088,6 +2088,9 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, #define cpu_init(cpu_model)