various: Fix error-propagation with Coccinelle scripts (part 1)
Subsystems (9)
v3 cover various: Fix error-propagation with Coccinelle scripts (part 1)
This series is inspired of Peter Maydell fix [1]:
"hw/arm/xlnx-zynqmp.c: fix some error-handling code", but grew after v1 [2] review :/
Markus: I added the cocci patches to your Error section, I hope that's fine :)
Part 1: Simplify error propagation by moving some code from
DeviceClass::realize() to DeviceClass:initfn().
Regards,
Phil.
[1] https://www.mail-archive.com/[email protected]/msg691636.html
[2] https://www.mail-archive.com/[email protected]/msg692155.html
Supersedes: <[email protected]>
Philippe Mathieu-Daud=C3=A9 (24):
various: Remove suspicious '\' character outside of #define in C code scripts/coccinelle: Script to simplify DeviceClass error propagation hw/arm/allwinner-a10: Move some code from realize() to init() hw/arm/aspeed_ast2600: Simplify use of Error* hw/arm/aspeed_ast2600: Move some code from realize() to init() hw/arm/aspeed_soc: Move some code from realize() to init() hw/arm/aspeed_soc: Simplify use of Error*
hw/arm/fsl-imx6: Simplify checks on 'smp_cpus' count hw/arm/fsl-imx6: Move some code from realize() to init() hw/arm/fsl-imx31: Move some code from realize() to init() hw/arm/msf2-soc: Store MemoryRegion in MSF2State hw/arm/stm32f205_soc: Store MemoryRegion in STM32F205State hw/arm/stm32f205_soc: Move some code from realize() to init() hw/arm/xlnx-zynqmp: Use single propagate_error() call hw/arm/xlnx-zynqmp: Split xlnx_zynqmp_create_rpu() as init + realize hw/arm/xlnx-zynqmp: Move some code from realize() to init() hw/microblaze/xlnx-zynqmp-pmu: Move some code from realize() to init() hw/pci-host/pnv_phb3: Move some code from realize() to init() hw/riscv/sifive_e: Move some code from realize() to init() hw/riscv/sifive_u: Use single type_init() hw/riscv/sifive_u: Move some code from realize() to init() hw/riscv/sifive_u: Store MemoryRegion in SiFiveUSoCState hw/riscv/sifive_u: Move some code from realize() to init() hw/riscv/sifive_u: Rename MachineClass::init()
...implify-init-realize-error_propagate.cocci | 69 ++++++++++ include/hw/arm/msf2-soc.h | 4 + include/hw/arm/stm32f205_soc.h | 4 + include/hw/riscv/sifive_u.h | 2 + block/replication.c | 4 +- block/vhdx.c | 8 +- dump/dump.c | 2 +- hw/arm/allwinner-a10.c | 26 ++-- hw/arm/aspeed_ast2600.c | 61 +++++---- hw/arm/aspeed_soc.c | 19 +-- hw/arm/fsl-imx31.c | 4 +- hw/arm/fsl-imx6.c | 55 ++++---- hw/arm/msf2-soc.c | 18 +-- hw/arm/stm32f205_soc.c | 28 ++-- hw/arm/xlnx-zynqmp.c | 126 +++++++++--------- hw/microblaze/xlnx-zynqmp-pmu.c | 46 +++---- hw/net/virtio-net.c | 2 +- hw/pci-host/pnv_phb3.c | 8 +- hw/riscv/sifive_e.c | 26 ++-- hw/riscv/sifive_u.c | 66 +++++---- hw/scsi/scsi-disk.c | 2 +- hw/sd/sdhci.c | 2 +- target/i386/cpu.c | 18 +-- target/microblaze/cpu.c | 14 +- target/ppc/translate_init.inc.c | 4 +- MAINTAINERS | 1 + 26 files changed, 342 insertions(+), 277 deletions(-) create mode 100644 scripts/coccinelle/simplify-init-realize-error_propagate.=
cocci
--=20
2.21.1
PATCH v3 1/24 various: Remove suspicious '\' character outside of #define in C code
Fixes the following coccinelle warnings:
$ spatch --sp-file --verbose-parsing ... \
scripts/coccinelle/remove_local_err.cocci
...
SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5213
SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5261
SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:166
SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:167
SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:169
SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:170
SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:171
SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:172
SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:173
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5787
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5789
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5800
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5801
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5802
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5804
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5805
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5806
SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:6329
SUSPICIOUS: a \ character appears outside of a #define at ./hw/sd/sdhci.c:1133
SUSPICIOUS: a \ character appears outside of a #define at ./hw/scsi/scsi-disk.c:3081
SUSPICIOUS: a \ character appears outside of a #define at ./hw/net/virtio-net.c:1529
SUSPICIOUS: a \ character appears outside of a #define at ./hw/riscv/sifive_u.c:468
SUSPICIOUS: a \ character appears outside of a #define at ./dump/dump.c:1895
SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2209
SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2215
SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2221
SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2222
SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:172
SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:173--- block/replication.c | 4 ++-- block/vhdx.c | 8 ++++---- dump/dump.c | 2 +- hw/net/virtio-net.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/scsi/scsi-disk.c | 2 +- hw/sd/sdhci.c | 2 +- target/i386/cpu.c | 18 +++++++++--------- target/microblaze/cpu.c | 14 +++++++------- target/ppc/translate_init.inc.c | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-)
block/replication.c +2 -2
@@ -172,8 +172,8 @@ static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,if ((bs->open_flags & (BDRV_O_INACTIVE |BDRV_O_RDWR )) ==BDRV_O_RDWR ) { *nperm |=BLK_PERM_WRITE ; } - *nshared =BLK_PERM_CONSISTENT_READ \ - |BLK_PERM_WRITE \ + *nshared =BLK_PERM_CONSISTENT_READ + |BLK_PERM_WRITE |BLK_PERM_WRITE_UNCHANGED ;return ; }
block/vhdx.c +4 -4
@@ -2206,20 +2206,20 @@ static QemuOptsList vhdx_create_opts = { .name = VHDX_BLOCK_OPT_BLOCK_SIZE, .type = QEMU_OPT_SIZE, .def_value_str = stringify(0), - .help ="Block Size; min 1MB, max 256MB. " \ + .help ="Block Size; min 1MB, max 256MB. " "0 means auto-calculate based on image size." }, { .name = BLOCK_OPT_SUBFMT, .type = QEMU_OPT_STRING, - .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " \ + .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " "Default is 'dynamic'." }, { .name = VHDX_BLOCK_OPT_ZERO, .type = QEMU_OPT_BOOL, - .help ="Force use of payload blocks of type 'ZERO'. " \ -"Non-standard, but default. Do not set to 'off' when " \ + .help ="Force use of payload blocks of type 'ZERO'. " +"Non-standard, but default. Do not set to 'off' when " "using 'qemu-img convert' with subformat=dynamic." }, { NULL }
dump/dump.c +1 -1
@@ -1892,7 +1892,7 @@ static void dump_process(DumpState *s, Error **errp) result =qmp_query_dump (NULL );/* should never fail */ assert (result); -qapi_event_send_dump_completed (result, !!local_err, (local_err ? \ +qapi_event_send_dump_completed (result, !!local_err, (local_err ?error_get_pretty (local_err) :NULL ));qapi_free_DumpQueryResult (result);
hw/net/virtio-net.c +1 -1
@@ -1526,7 +1526,7 @@ static void virtio_net_rsc_extract_unit6(VirtioNetRscChain *chain, + sizeof(struct eth_header)); unit->ip = ip6; unit->ip_plen = &(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen); - unit->tcp = (struct tcp_header *)(((uint8_t *)unit->ip)\ + unit->tcp = (struct tcp_header *)(((uint8_t *)unit->ip) +sizeof (struct ip6_header )); unit->tcp_hdrlen = (htons (unit->tcp->th_offset_flags) &0xF000 ) >>10 ;
hw/riscv/sifive_u.c +1 -1
@@ -465,7 +465,7 @@ static void riscv_sifive_u_machine_instance_init(Object *obj)object_property_add_bool (obj,"start-in-flash" , sifive_u_get_start_in_flash, sifive_u_set_start_in_flash,NULL );object_property_set_description (obj,"start-in-flash" , -"Set on to tell QEMU's ROM to jump to " \ +"Set on to tell QEMU's ROM to jump to " "flash. Otherwise QEMU will jump to DRAM" ,NULL ); }
hw/scsi/scsi-disk.c +1 -1
@@ -3078,7 +3078,7 @@ static const TypeInfo scsi_cd_info = {#ifdef __linux__static Property scsi_block_properties[] = { -DEFINE_BLOCK_ERROR_PROPERTIES (SCSIDiskState, qdev.conf), \ +DEFINE_BLOCK_ERROR_PROPERTIES (SCSIDiskState, qdev.conf),DEFINE_PROP_DRIVE ("drive" , SCSIDiskState, qdev.conf.blk),DEFINE_PROP_BOOL ("share-rw" , SCSIDiskState, qdev.conf.share_rw, false), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0),
hw/sd/sdhci.c +1 -1
@@ -1130,7 +1130,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)/* Limit block size to the maximum buffer size */ if (extract32 (s->blksize,0 ,12 ) > s->buf_maxsz) { -qemu_log_mask (LOG_GUEST_ERROR ,"%s: Size 0x%x is larger than " \ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: Size 0x%x is larger than " "the maximum buffer 0x%x" , __func__, s->blksize, s->buf_maxsz);
target/i386/cpu.c +9 -9
@@ -5784,9 +5784,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,host_cpuid (index,0 , eax, ebx, ecx, edx);break ; } - *eax = (L1_DTLB_2M_ASSOC <<24 ) | (L1_DTLB_2M_ENTRIES <<16 ) | \ + *eax = (L1_DTLB_2M_ASSOC <<24 ) | (L1_DTLB_2M_ENTRIES <<16 ) | (L1_ITLB_2M_ASSOC <<8 ) | (L1_ITLB_2M_ENTRIES ); - *ebx = (L1_DTLB_4K_ASSOC <<24 ) | (L1_DTLB_4K_ENTRIES <<16 ) | \ + *ebx = (L1_DTLB_4K_ASSOC <<24 ) | (L1_DTLB_4K_ENTRIES <<16 ) | (L1_ITLB_4K_ASSOC <<8 ) | (L1_ITLB_4K_ENTRIES ); *ecx =encode_cache_cpuid80000005 (env->cache_info_amd.l1d_cache); *edx =encode_cache_cpuid80000005 (env->cache_info_amd.l1i_cache);
@@ -5797,13 +5797,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,host_cpuid (index,0 , eax, ebx, ecx, edx);break ; } - *eax = (AMD_ENC_ASSOC (L2_DTLB_2M_ASSOC ) <<28 ) | \ - (L2_DTLB_2M_ENTRIES <<16 ) | \ - (AMD_ENC_ASSOC (L2_ITLB_2M_ASSOC ) <<12 ) | \ + *eax = (AMD_ENC_ASSOC (L2_DTLB_2M_ASSOC ) <<28 ) | + (L2_DTLB_2M_ENTRIES <<16 ) | + (AMD_ENC_ASSOC (L2_ITLB_2M_ASSOC ) <<12 ) | (L2_ITLB_2M_ENTRIES ); - *ebx = (AMD_ENC_ASSOC (L2_DTLB_4K_ASSOC ) <<28 ) | \ - (L2_DTLB_4K_ENTRIES <<16 ) | \ - (AMD_ENC_ASSOC (L2_ITLB_4K_ASSOC ) <<12 ) | \ + *ebx = (AMD_ENC_ASSOC (L2_DTLB_4K_ASSOC ) <<28 ) | + (L2_DTLB_4K_ENTRIES <<16 ) | + (AMD_ENC_ASSOC (L2_ITLB_4K_ASSOC ) <<12 ) | (L2_ITLB_4K_ENTRIES ); encode_cache_cpuid80000006(env->cache_info_amd.l2_cache, cpu->enable_l3_cache ?
@@ -6326,7 +6326,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)*/ env->features[w] |=x86_cpu_get_supported_feature_word (w, cpu->migratable) & - ~env->user_features[w] & \ + ~env->user_features[w] & ~feature_word_info[w].no_autoenable_flags; } }
target/microblaze/cpu.c +7 -7
@@ -163,14 +163,14 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)qemu_init_vcpu (cs); - env->pvr.regs[0 ] =PVR0_USE_EXC_MASK \ - |PVR0_USE_ICACHE_MASK \ + env->pvr.regs[0 ] =PVR0_USE_EXC_MASK + |PVR0_USE_ICACHE_MASK |PVR0_USE_DCACHE_MASK ; - env->pvr.regs[2 ] =PVR2_D_OPB_MASK \ - |PVR2_D_LMB_MASK \ - |PVR2_I_OPB_MASK \ - |PVR2_I_LMB_MASK \ - |PVR2_FPU_EXC_MASK \ + env->pvr.regs[2 ] =PVR2_D_OPB_MASK + |PVR2_D_LMB_MASK + |PVR2_I_OPB_MASK + |PVR2_I_LMB_MASK + |PVR2_FPU_EXC_MASK |0 ; version = cpu->cfg.version ? cpu->cfg.version :DEFAULT_CPU_VERSION ;
target/ppc/translate_init.inc.c +2 -2
@@ -5210,7 +5210,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data)PPC_FLOAT_STFIWX |PPC_WAIT |PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | \ + pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 |PPC2_FP_CVT_S64 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull << MSR_GS) |
@@ -5258,7 +5258,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, void *data)PPC_FLOAT_STFIWX |PPC_WAIT |PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD |PPC_ALTIVEC ; - pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | \ + pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 |PPC2_FP_CVT_S64 |PPC2_ATOMIC_ISA206 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull << MSR_GS) |
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 01/24] various: Remove suspicious '\' character outside of #define in C code
Quoted 36 lines · Philippe Mathieu-Daudé
Fixes the following coccinelle warnings:
$ spatch --sp-file --verbose-parsing ... \ scripts/coccinelle/remove_local_err.cocci ... SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5213 SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5261 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:166 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:167 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:169 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:170 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:171 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:172 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:173 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5787 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5789 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5800 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5801 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5802 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5804 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5805 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5806 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:6329 SUSPICIOUS: a \ character appears outside of a #define at ./hw/sd/sdhci.c:1133 SUSPICIOUS: a \ character appears outside of a #define at ./hw/scsi/scsi-disk.c:3081 SUSPICIOUS: a \ character appears outside of a #define at ./hw/net/virtio-net.c:1529 SUSPICIOUS: a \ character appears outside of a #define at ./hw/riscv/sifive_u.c:468 SUSPICIOUS: a \ character appears outside of a #define at ./dump/dump.c:1895 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2209 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2215 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2221 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2222 SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:172 SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:173
Quoted 2 lines
Reviewed-by Marc-André Lureau <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 219 lines
--- block/replication.c | 4 ++-- block/vhdx.c | 8 ++++---- dump/dump.c | 2 +- hw/net/virtio-net.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/scsi/scsi-disk.c | 2 +- hw/sd/sdhci.c | 2 +- target/i386/cpu.c | 18 +++++++++--------- target/microblaze/cpu.c | 14 +++++++------- target/ppc/translate_init.inc.c | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-)block/replication.c +2
-2@@ -172,8 +172,8 @@ static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,if ((bs->open_flags & (BDRV_O_INACTIVE |BDRV_O_RDWR )) ==BDRV_O_RDWR ) { *nperm |=BLK_PERM_WRITE ; } - *nshared =BLK_PERM_CONSISTENT_READ \ - |BLK_PERM_WRITE \ + *nshared =BLK_PERM_CONSISTENT_READ + |BLK_PERM_WRITE |BLK_PERM_WRITE_UNCHANGED ;return ; }block/vhdx.c +4
-4@@ -2206,20 +2206,20 @@ static QemuOptsList vhdx_create_opts = { .name = VHDX_BLOCK_OPT_BLOCK_SIZE, .type = QEMU_OPT_SIZE, .def_value_str = stringify(0), - .help ="Block Size; min 1MB, max 256MB. " \ + .help ="Block Size; min 1MB, max 256MB. " "0 means auto-calculate based on image size." }, { .name = BLOCK_OPT_SUBFMT, .type = QEMU_OPT_STRING, - .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " \ + .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " "Default is 'dynamic'." }, { .name = VHDX_BLOCK_OPT_ZERO, .type = QEMU_OPT_BOOL, - .help ="Force use of payload blocks of type 'ZERO'. " \ -"Non-standard, but default. Do not set to 'off' when " \ + .help ="Force use of payload blocks of type 'ZERO'. " +"Non-standard, but default. Do not set to 'off' when " "using 'qemu-img convert' with subformat=dynamic." }, { NULL }dump/dump.c +1
-1@@ -1892,7 +1892,7 @@ static void dump_process(DumpState *s, Error **errp) result =qmp_query_dump (NULL );/* should never fail */ assert (result); -qapi_event_send_dump_completed (result, !!local_err, (local_err ? \ +qapi_event_send_dump_completed (result, !!local_err, (local_err ?error_get_pretty (local_err) :NULL ));qapi_free_DumpQueryResult (result);hw/net/virtio-net.c +1
-1@@ -1526,7 +1526,7 @@ static void virtio_net_rsc_extract_unit6(VirtioNetRscChain *chain, + sizeof(struct eth_header)); unit->ip = ip6; unit->ip_plen = &(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen); - unit->tcp = (struct tcp_header *)(((uint8_t *)unit->ip)\ + unit->tcp = (struct tcp_header *)(((uint8_t *)unit->ip) +sizeof (struct ip6_header )); unit->tcp_hdrlen = (htons (unit->tcp->th_offset_flags) &0xF000 ) >>10 ;hw/riscv/sifive_u.c +1
-1@@ -465,7 +465,7 @@ static void riscv_sifive_u_machine_instance_init(Object *obj)object_property_add_bool (obj,"start-in-flash" , sifive_u_get_start_in_flash, sifive_u_set_start_in_flash,NULL );object_property_set_description (obj,"start-in-flash" , -"Set on to tell QEMU's ROM to jump to " \ +"Set on to tell QEMU's ROM to jump to " "flash. Otherwise QEMU will jump to DRAM" ,NULL ); }hw/scsi/scsi-disk.c +1
-1@@ -3078,7 +3078,7 @@ static const TypeInfo scsi_cd_info = {#ifdef __linux__static Property scsi_block_properties[] = { -DEFINE_BLOCK_ERROR_PROPERTIES (SCSIDiskState, qdev.conf), \ +DEFINE_BLOCK_ERROR_PROPERTIES (SCSIDiskState, qdev.conf),DEFINE_PROP_DRIVE ("drive" , SCSIDiskState, qdev.conf.blk),DEFINE_PROP_BOOL ("share-rw" , SCSIDiskState, qdev.conf.share_rw, false), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0),hw/sd/sdhci.c +1
-1@@ -1130,7 +1130,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)/* Limit block size to the maximum buffer size */ if (extract32 (s->blksize,0 ,12 ) > s->buf_maxsz) { -qemu_log_mask (LOG_GUEST_ERROR ,"%s: Size 0x%x is larger than " \ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: Size 0x%x is larger than " "the maximum buffer 0x%x" , __func__, s->blksize, s->buf_maxsz);target/i386/cpu.c +9
-9@@ -5784,9 +5784,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,host_cpuid (index,0 , eax, ebx, ecx, edx);break ; } - *eax = (L1_DTLB_2M_ASSOC <<24 ) | (L1_DTLB_2M_ENTRIES <<16 ) | \ + *eax = (L1_DTLB_2M_ASSOC <<24 ) | (L1_DTLB_2M_ENTRIES <<16 ) | (L1_ITLB_2M_ASSOC <<8 ) | (L1_ITLB_2M_ENTRIES ); - *ebx = (L1_DTLB_4K_ASSOC <<24 ) | (L1_DTLB_4K_ENTRIES <<16 ) | \ + *ebx = (L1_DTLB_4K_ASSOC <<24 ) | (L1_DTLB_4K_ENTRIES <<16 ) | (L1_ITLB_4K_ASSOC <<8 ) | (L1_ITLB_4K_ENTRIES ); *ecx =encode_cache_cpuid80000005 (env->cache_info_amd.l1d_cache); *edx =encode_cache_cpuid80000005 (env->cache_info_amd.l1i_cache);@@ -5797,13 +5797,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,host_cpuid (index,0 , eax, ebx, ecx, edx);break ; } - *eax = (AMD_ENC_ASSOC (L2_DTLB_2M_ASSOC ) <<28 ) | \ - (L2_DTLB_2M_ENTRIES <<16 ) | \ - (AMD_ENC_ASSOC (L2_ITLB_2M_ASSOC ) <<12 ) | \ + *eax = (AMD_ENC_ASSOC (L2_DTLB_2M_ASSOC ) <<28 ) | + (L2_DTLB_2M_ENTRIES <<16 ) | + (AMD_ENC_ASSOC (L2_ITLB_2M_ASSOC ) <<12 ) | (L2_ITLB_2M_ENTRIES ); - *ebx = (AMD_ENC_ASSOC (L2_DTLB_4K_ASSOC ) <<28 ) | \ - (L2_DTLB_4K_ENTRIES <<16 ) | \ - (AMD_ENC_ASSOC (L2_ITLB_4K_ASSOC ) <<12 ) | \ + *ebx = (AMD_ENC_ASSOC (L2_DTLB_4K_ASSOC ) <<28 ) | + (L2_DTLB_4K_ENTRIES <<16 ) | + (AMD_ENC_ASSOC (L2_ITLB_4K_ASSOC ) <<12 ) | (L2_ITLB_4K_ENTRIES ); encode_cache_cpuid80000006(env->cache_info_amd.l2_cache, cpu->enable_l3_cache ?@@ -6326,7 +6326,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)*/ env->features[w] |=x86_cpu_get_supported_feature_word (w, cpu->migratable) & - ~env->user_features[w] & \ + ~env->user_features[w] & ~feature_word_info[w].no_autoenable_flags; } }target/microblaze/cpu.c +7
-7@@ -163,14 +163,14 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)qemu_init_vcpu (cs); - env->pvr.regs[0 ] =PVR0_USE_EXC_MASK \ - |PVR0_USE_ICACHE_MASK \ + env->pvr.regs[0 ] =PVR0_USE_EXC_MASK + |PVR0_USE_ICACHE_MASK |PVR0_USE_DCACHE_MASK ; - env->pvr.regs[2 ] =PVR2_D_OPB_MASK \ - |PVR2_D_LMB_MASK \ - |PVR2_I_OPB_MASK \ - |PVR2_I_LMB_MASK \ - |PVR2_FPU_EXC_MASK \ + env->pvr.regs[2 ] =PVR2_D_OPB_MASK + |PVR2_D_LMB_MASK + |PVR2_I_OPB_MASK + |PVR2_I_LMB_MASK + |PVR2_FPU_EXC_MASK |0 ; version = cpu->cfg.version ? cpu->cfg.version :DEFAULT_CPU_VERSION ;target/ppc/translate_init.inc.c +2
-3@@ -5210,7 +5210,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data)PPC_FLOAT_STFIWX |PPC_WAIT |PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | \ + pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 |PPC2_FP_CVT_S64 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull << MSR_GS) |@@ -5258,7 +5258,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, void *data)PPC_FLOAT_STFIWX |PPC_WAIT |PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD |PPC_ALTIVEC ; - pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | \ + pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 |PPC2_FP_CVT_S64 |PPC2_ATOMIC_ISA206 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull << MSR_GS) | --2.21.1
Re: [PATCH-for-5.1 v3 01/24] various: Remove suspicious '\' character outside of #define in C code
In reply to Philippe Mathieu-DaudéQuoted 35 lines · Philippe Mathieu-Daudé
Fixes the following coccinelle warnings:
$ spatch --sp-file --verbose-parsing ... \ scripts/coccinelle/remove_local_err.cocci ... SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5213 SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5261 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:166 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:167 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:169 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:170 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:171 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:172 SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:173 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5787 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5789 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5800 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5801 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5802 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5804 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5805 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5806 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:6329 SUSPICIOUS: a \ character appears outside of a #define at ./hw/sd/sdhci.c:1133 SUSPICIOUS: a \ character appears outside of a #define at ./hw/scsi/scsi-disk.c:3081 SUSPICIOUS: a \ character appears outside of a #define at ./hw/net/virtio-net.c:1529 SUSPICIOUS: a \ character appears outside of a #define at ./hw/riscv/sifive_u.c:468 SUSPICIOUS: a \ character appears outside of a #define at ./dump/dump.c:1895 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2209 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2215 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2221 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2222 SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:172 SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:173
Quoted 2 lines
Reviewed-by Marc-André Lureau <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
ppc parts
Quoted 215 lines
--- block/replication.c | 4 ++-- block/vhdx.c | 8 ++++---- dump/dump.c | 2 +- hw/net/virtio-net.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/scsi/scsi-disk.c | 2 +- hw/sd/sdhci.c | 2 +- target/i386/cpu.c | 18 +++++++++--------- target/microblaze/cpu.c | 14 +++++++------- target/ppc/translate_init.inc.c | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-)block/replication.c +2
-2@@ -172,8 +172,8 @@ static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,if ((bs->open_flags & (BDRV_O_INACTIVE |BDRV_O_RDWR )) ==BDRV_O_RDWR ) { *nperm |=BLK_PERM_WRITE ; } - *nshared =BLK_PERM_CONSISTENT_READ \ - |BLK_PERM_WRITE \ + *nshared =BLK_PERM_CONSISTENT_READ + |BLK_PERM_WRITE |BLK_PERM_WRITE_UNCHANGED ;return ; }block/vhdx.c +4
-4@@ -2206,20 +2206,20 @@ static QemuOptsList vhdx_create_opts = { .name = VHDX_BLOCK_OPT_BLOCK_SIZE, .type = QEMU_OPT_SIZE, .def_value_str = stringify(0), - .help ="Block Size; min 1MB, max 256MB. " \ + .help ="Block Size; min 1MB, max 256MB. " "0 means auto-calculate based on image size." }, { .name = BLOCK_OPT_SUBFMT, .type = QEMU_OPT_STRING, - .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " \ + .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " "Default is 'dynamic'." }, { .name = VHDX_BLOCK_OPT_ZERO, .type = QEMU_OPT_BOOL, - .help ="Force use of payload blocks of type 'ZERO'. " \ -"Non-standard, but default. Do not set to 'off' when " \ + .help ="Force use of payload blocks of type 'ZERO'. " +"Non-standard, but default. Do not set to 'off' when " "using 'qemu-img convert' with subformat=dynamic." }, { NULL }dump/dump.c +1
-1@@ -1892,7 +1892,7 @@ static void dump_process(DumpState *s, Error **errp) result =qmp_query_dump (NULL );/* should never fail */ assert (result); -qapi_event_send_dump_completed (result, !!local_err, (local_err ? \ +qapi_event_send_dump_completed (result, !!local_err, (local_err ?error_get_pretty (local_err) :NULL ));qapi_free_DumpQueryResult (result);hw/net/virtio-net.c +1
-1@@ -1526,7 +1526,7 @@ static void virtio_net_rsc_extract_unit6(VirtioNetRscChain *chain, + sizeof(struct eth_header)); unit->ip = ip6; unit->ip_plen = &(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen); - unit->tcp = (struct tcp_header *)(((uint8_t *)unit->ip)\ + unit->tcp = (struct tcp_header *)(((uint8_t *)unit->ip) +sizeof (struct ip6_header )); unit->tcp_hdrlen = (htons (unit->tcp->th_offset_flags) &0xF000 ) >>10 ;hw/riscv/sifive_u.c +1
-1@@ -465,7 +465,7 @@ static void riscv_sifive_u_machine_instance_init(Object *obj)object_property_add_bool (obj,"start-in-flash" , sifive_u_get_start_in_flash, sifive_u_set_start_in_flash,NULL );object_property_set_description (obj,"start-in-flash" , -"Set on to tell QEMU's ROM to jump to " \ +"Set on to tell QEMU's ROM to jump to " "flash. Otherwise QEMU will jump to DRAM" ,NULL ); }hw/scsi/scsi-disk.c +1
-1@@ -3078,7 +3078,7 @@ static const TypeInfo scsi_cd_info = {#ifdef __linux__static Property scsi_block_properties[] = { -DEFINE_BLOCK_ERROR_PROPERTIES (SCSIDiskState, qdev.conf), \ +DEFINE_BLOCK_ERROR_PROPERTIES (SCSIDiskState, qdev.conf),DEFINE_PROP_DRIVE ("drive" , SCSIDiskState, qdev.conf.blk),DEFINE_PROP_BOOL ("share-rw" , SCSIDiskState, qdev.conf.share_rw, false), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0),hw/sd/sdhci.c +1
-1@@ -1130,7 +1130,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)/* Limit block size to the maximum buffer size */ if (extract32 (s->blksize,0 ,12 ) > s->buf_maxsz) { -qemu_log_mask (LOG_GUEST_ERROR ,"%s: Size 0x%x is larger than " \ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: Size 0x%x is larger than " "the maximum buffer 0x%x" , __func__, s->blksize, s->buf_maxsz);target/i386/cpu.c +9
-9@@ -5784,9 +5784,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,host_cpuid (index,0 , eax, ebx, ecx, edx);break ; } - *eax = (L1_DTLB_2M_ASSOC <<24 ) | (L1_DTLB_2M_ENTRIES <<16 ) | \ + *eax = (L1_DTLB_2M_ASSOC <<24 ) | (L1_DTLB_2M_ENTRIES <<16 ) | (L1_ITLB_2M_ASSOC <<8 ) | (L1_ITLB_2M_ENTRIES ); - *ebx = (L1_DTLB_4K_ASSOC <<24 ) | (L1_DTLB_4K_ENTRIES <<16 ) | \ + *ebx = (L1_DTLB_4K_ASSOC <<24 ) | (L1_DTLB_4K_ENTRIES <<16 ) | (L1_ITLB_4K_ASSOC <<8 ) | (L1_ITLB_4K_ENTRIES ); *ecx =encode_cache_cpuid80000005 (env->cache_info_amd.l1d_cache); *edx =encode_cache_cpuid80000005 (env->cache_info_amd.l1i_cache);@@ -5797,13 +5797,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,host_cpuid (index,0 , eax, ebx, ecx, edx);break ; } - *eax = (AMD_ENC_ASSOC (L2_DTLB_2M_ASSOC ) <<28 ) | \ - (L2_DTLB_2M_ENTRIES <<16 ) | \ - (AMD_ENC_ASSOC (L2_ITLB_2M_ASSOC ) <<12 ) | \ + *eax = (AMD_ENC_ASSOC (L2_DTLB_2M_ASSOC ) <<28 ) | + (L2_DTLB_2M_ENTRIES <<16 ) | + (AMD_ENC_ASSOC (L2_ITLB_2M_ASSOC ) <<12 ) | (L2_ITLB_2M_ENTRIES ); - *ebx = (AMD_ENC_ASSOC (L2_DTLB_4K_ASSOC ) <<28 ) | \ - (L2_DTLB_4K_ENTRIES <<16 ) | \ - (AMD_ENC_ASSOC (L2_ITLB_4K_ASSOC ) <<12 ) | \ + *ebx = (AMD_ENC_ASSOC (L2_DTLB_4K_ASSOC ) <<28 ) | + (L2_DTLB_4K_ENTRIES <<16 ) | + (AMD_ENC_ASSOC (L2_ITLB_4K_ASSOC ) <<12 ) | (L2_ITLB_4K_ENTRIES ); encode_cache_cpuid80000006(env->cache_info_amd.l2_cache, cpu->enable_l3_cache ?@@ -6326,7 +6326,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)*/ env->features[w] |=x86_cpu_get_supported_feature_word (w, cpu->migratable) & - ~env->user_features[w] & \ + ~env->user_features[w] & ~feature_word_info[w].no_autoenable_flags; } }target/microblaze/cpu.c +7
-7@@ -163,14 +163,14 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)qemu_init_vcpu (cs); - env->pvr.regs[0 ] =PVR0_USE_EXC_MASK \ - |PVR0_USE_ICACHE_MASK \ + env->pvr.regs[0 ] =PVR0_USE_EXC_MASK + |PVR0_USE_ICACHE_MASK |PVR0_USE_DCACHE_MASK ; - env->pvr.regs[2 ] =PVR2_D_OPB_MASK \ - |PVR2_D_LMB_MASK \ - |PVR2_I_OPB_MASK \ - |PVR2_I_LMB_MASK \ - |PVR2_FPU_EXC_MASK \ + env->pvr.regs[2 ] =PVR2_D_OPB_MASK + |PVR2_D_LMB_MASK + |PVR2_I_OPB_MASK + |PVR2_I_LMB_MASK + |PVR2_FPU_EXC_MASK |0 ; version = cpu->cfg.version ? cpu->cfg.version :DEFAULT_CPU_VERSION ;target/ppc/translate_init.inc.c +2
-2@@ -5210,7 +5210,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data)PPC_FLOAT_STFIWX |PPC_WAIT |PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD ; - pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | \ + pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 |PPC2_FP_CVT_S64 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull << MSR_GS) |@@ -5258,7 +5258,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, void *data)PPC_FLOAT_STFIWX |PPC_WAIT |PPC_MEM_TLBSYNC |PPC_TLBIVAX |PPC_MEM_SYNC |PPC_64B |PPC_POPCNTB |PPC_POPCNTWD |PPC_ALTIVEC ; - pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 | \ + pcc->insns_flags2 =PPC2_BOOKE206 |PPC2_PRCNTL |PPC2_PERM_ISA206 |PPC2_FP_CVT_S64 |PPC2_ATOMIC_ISA206 ; pcc->msr_mask = (1ull <<MSR_CM ) | (1ull << MSR_GS) |
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: [PATCH-for-5.1 v3 01/24] various: Remove suspicious '\' character outside of #define in C code
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
Fixes the following coccinelle warnings:
$ spatch --sp-file --verbose-parsing ... \ scripts/coccinelle/remove_local_err.cocci ... SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5213
[...]
Quoted 4 lines
SUSPICIOUS: a \ character appears outside of a #define at
./block/replication.c:173Reviewed-by Marc-André Lureau <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
I'm queuing this patch just to get it out of the way. Thanks!
PATCH v3 2/24 scripts/coccinelle: Script to simplify DeviceClass error propagation
In reply to Philippe Mathieu-DaudéWhen a device uses an Error* with data not modified before realize(), this call can be moved to init(). Add a Coccinelle patch to find such uses.
--- ...implify-init-realize-error_propagate.cocci | 69 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 70 insertions(+) create mode 100644 scripts/coccinelle/simplify-init-realize-error_propagate.cocci
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +69 -0
@@ -0,0 +1,69 @@ +// Find error-propagation calls that don't need to be in DeviceClass::realize() +// because they don't use information user can change before calling realize(), +// so they can be moved to DeviceClass:initfn() where error propagation is not +// needed. +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h \ +// --sp-file \ +// scripts/coccinelle/simplify-init-realize-error_propagate.cocci \ +// --timeout 60 +// +// Inspired by https://www.mail-archive.com/[email protected]/msg692500.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_instance_init @ +TypeInfo info; +identifier instance_initfn; +@@ + info.instance_init = instance_initfn; + + +@ match_realize @ +identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +} + + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp =~ "(?!object_property_set_link)"; +symbol error_abort, error_fatal; +position pos; +@@ +void realizefn@pos(..., Error **errp) +{ + ... + Error *err = NULL; + <+... + func_with_errp(..., \(&error_abort\|&error_fatal\)); + ...+> +} + + +@ script:python @ +initfn << match_instance_init.instance_initfn; +realizefn << match_realize.realizefn; +p << propagate_in_realize.pos; +@@ +print('>>> possible moves from {}() to {}() in {}:{}' + .format(initfn, realizefn, p[0].file, p[0].line))
MAINTAINERS +1 -0
@@ -2058,6 +2058,7 @@ F: scripts/coccinelle/err-bad-newline.cocci F: scripts/coccinelle/error-use-after-free.cocci F: scripts/coccinelle/error_propagate_null.cocci F: scripts/coccinelle/remove_local_err.cocci +F: scripts/coccinelle/simplify-init-realize-error_propagate.cocci F: scripts/coccinelle/use-error_fatal.cocci GDB stub
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation
Quoted 49 lines · Philippe Mathieu-Daudé
When a device uses an Error* with data not modified before
realize(), this call can be moved toinit(). Add a Coccinelle patch to find such uses.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- ...implify-init-realize-error_propagate.cocci | 69 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 70 insertions(+) create mode 100644 scripts/coccinelle/simplify-init-realize-error_propagate.cocciscripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +32
-0@@ -0,0 +1,69 @@ +// Find error-propagation calls that don't need to be in DeviceClass::realize() +// because they don't use information user can change before calling realize(), +// so they can be moved to DeviceClass:initfn() where error propagation is not +// needed. +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h \ +// --sp-file \ +// scripts/coccinelle/simplify-init-realize-error_propagate.cocci \ +// --timeout 60 +// +// Inspired by https://www.mail-archive.com/[email protected]/msg692500.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_instance_init @ +TypeInfo info; +identifier instance_initfn; +@@ + info.instance_init = instance_initfn; + + +@ match_realize @
scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 42
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +10
-0+identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +}
I'm afraid this misses realize() methods of DeviceClass subclasses. Consider PCI device "i6300esb" (picked just because it's simple).
pci_device_class_init() sets DeviceClass method realize() to pci_qdev_realize(). pci_qdev_realize() does the work common to all PCI devices, and calls PCIDeviceClass method realize() for the work specific to the PCI device at hand.
i6300esb_class_init() sets PCIDeviceClass method realize() to i6300esb_realize().
Your first rule should match i6300esb_info alright, and thus identify i6300esb_class_init() as a class_init() method.
But your third rule can't match i6300esb_class_init()'s
k->realize = i6300esb_realize;
because @k is a PCIDeviceClass, not a DeviceClass.
I think it also misses cases that have a realize(), but no instance_init().
Finding only some instances of an anti-pattern can still be useful. But you should explain the script's limitations then, both in the script and the commit message.
scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 49
Quoted 7 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +7
-0+ + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp =~ "(?!object_property_set_link)";
What are you trying to accomplish with this lookahead assertion?
scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 56
Quoted 7 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +7
-0+symbol error_abort, error_fatal; +position pos; +@@ +void realizefn@pos(..., Error **errp) +{ + ... + Error *err = NULL;
Why is this line required for a match?
Quoted 25 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +13
-0+ <+... + func_with_errp(..., \(&error_abort\|&error_fatal\)); + ...+> +} + + +@ script:python @ +initfn << match_instance_init.instance_initfn; +realizefn << match_realize.realizefn; +p << propagate_in_realize.pos; +@@ +print('>>> possible moves from {}() to {}() in {}:{}' + .format(initfn, realizefn, p[0].file, p[0].line))MAINTAINERS +1
-0@@ -2058,6 +2058,7 @@ F: scripts/coccinelle/err-bad-newline.cocci F: scripts/coccinelle/error-use-after-free.cocci F: scripts/coccinelle/error_propagate_null.cocci F: scripts/coccinelle/remove_local_err.cocci +F: scripts/coccinelle/simplify-init-realize-error_propagate.cocci F: scripts/coccinelle/use-error_fatal.cocci GDB stub
Re: [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation
Quoted 80 lines · Markus Armbruster
Quoted 49 lines · Philippe Mathieu-Daudé
When a device uses an Error* with data not modified before
realize(), this call can be moved toinit(). Add a Coccinelle patch to find such uses.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- ...implify-init-realize-error_propagate.cocci | 69 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 70 insertions(+)create mode 100644
scripts/coccinelle/simplify-init-realize-error_propagate.cocciscripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +32
-0@@ -0,0 +1,69 @@ +// Find error-propagation calls that don't need to be in DeviceClass::realize() +// because they don't use information user can change before calling realize(), +// so they can be moved to DeviceClass:initfn() where error propagation is not +// needed. +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h \ +// --sp-file \ +// scripts/coccinelle/simplify-init-realize-error_propagate.cocci \ +// --timeout 60 +// +// Inspired by https://www.mail-archive.com/[email protected]/msg692500.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_instance_init @ +TypeInfo info; +identifier instance_initfn; +@@ + info.instance_init = instance_initfn; + + +@ match_realize @scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 42
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +10
-0+identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +}I'm afraid this misses
realize()methods of DeviceClass subclasses. Consider PCI device "i6300esb" (picked just because it's simple).
pci_device_class_init()sets DeviceClass methodrealize()topci_qdev_realize().pci_qdev_realize()does the work common to all PCI devices, and calls PCIDeviceClass methodrealize()for the work specific to the PCI device at hand.
i6300esb_class_init()sets PCIDeviceClass methodrealize()toi6300esb_realize().Your first rule should match
i6300esb_infoalright, and thus identifyi6300esb_class_init()as aclass_init()method.But your third rule can't match i6300esb_class_init()'s
k->realize = i6300esb_realize;
Quoted 8 lines
because @k is a PCIDeviceClass, not a DeviceClass.
I think it also misses cases that have a
realize(), but noinstance_init().Finding only some instances of an anti-pattern can still be useful. But you should explain the script's limitations then, both in the script and the commit message.
OK.
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 49
Quoted 8 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +7
-0+ + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp =~ "(?!object_property_set_link)";What are you trying to accomplish with this lookahead assertion?
"match all func_with_errp() except object_property_set_link()"?
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 56
Quoted 8 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +7
-0+symbol error_abort, error_fatal; +position pos; +@@ +void realizefn@pos(..., Error **errp) +{ + ... + Error *err = NULL;Why is this line required for a match?
Hmmm maybe I was expecting a local_err... else a left-over from previous intents :)
Quoted 27 lines
Quoted 26 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +13
-0+ <+... + func_with_errp(..., \(&error_abort\|&error_fatal\)); + ...+> +} + + +@ script:python @ +initfn << match_instance_init.instance_initfn; +realizefn << match_realize.realizefn; +p << propagate_in_realize.pos; +@@ +print('>>> possible moves from {}() to {}() in {}:{}' + .format(initfn, realizefn, p[0].file, p[0].line))MAINTAINERS +1
-0@@ -2058,6 +2058,7 @@ F: scripts/coccinelle/err-bad-newline.cocci F: scripts/coccinelle/error-use-after-free.cocci F: scripts/coccinelle/error_propagate_null.cocci F: scripts/coccinelle/remove_local_err.cocci +F: scripts/coccinelle/simplify-init-realize-error_propagate.cocci F: scripts/coccinelle/use-error_fatal.cocci GDB stub
Re: [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation
Quoted 103 lines · Philippe Mathieu-Daudé
Quoted 80 lines · Markus Armbruster
Quoted 49 lines · Philippe Mathieu-Daudé
When a device uses an Error* with data not modified before
realize(), this call can be moved toinit(). Add a Coccinelle patch to find such uses.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- ...implify-init-realize-error_propagate.cocci | 69 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 70 insertions(+)create mode 100644
scripts/coccinelle/simplify-init-realize-error_propagate.cocciscripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +32
-0@@ -0,0 +1,69 @@ +// Find error-propagation calls that don't need to be in DeviceClass::realize() +// because they don't use information user can change before calling realize(), +// so they can be moved to DeviceClass:initfn() where error propagation is not +// needed. +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h \ +// --sp-file \ +// scripts/coccinelle/simplify-init-realize-error_propagate.cocci \ +// --timeout 60 +// +// Inspired by https://www.mail-archive.com/[email protected]/msg692500.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_instance_init @ +TypeInfo info; +identifier instance_initfn; +@@ + info.instance_init = instance_initfn; + + +@ match_realize @scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 42
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +10
-0+identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +}I'm afraid this misses
realize()methods of DeviceClass subclasses. Consider PCI device "i6300esb" (picked just because it's simple).
pci_device_class_init()sets DeviceClass methodrealize()topci_qdev_realize().pci_qdev_realize()does the work common to all PCI devices, and calls PCIDeviceClass methodrealize()for the work specific to the PCI device at hand.
i6300esb_class_init()sets PCIDeviceClass methodrealize()toi6300esb_realize().Your first rule should match
i6300esb_infoalright, and thus identifyi6300esb_class_init()as aclass_init()method.But your third rule can't match i6300esb_class_init()'s
k->realize = i6300esb_realize;Quoted 8 lines
because @k is a PCIDeviceClass, not a DeviceClass.
I think it also misses cases that have a
realize(), but noinstance_init().Finding only some instances of an anti-pattern can still be useful. But you should explain the script's limitations then, both in the script and the commit message.
OK.
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 49
Quoted 8 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +7
-0+ + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp =~ "(?!object_property_set_link)";What are you trying to accomplish with this lookahead assertion?
Quoted 1 line
"match all
func_with_errp()exceptobject_property_set_link()"?
What's wrong with
identifier func_with_errp != object_property_set_link
?
[...]
Re: [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation
Quoted 105 lines · Markus Armbruster
Quoted 103 lines · Philippe Mathieu-Daudé
Quoted 80 lines · Markus Armbruster
Quoted 49 lines · Philippe Mathieu-Daudé
When a device uses an Error* with data not modified before
realize(), this call can be moved toinit(). Add a Coccinelle patch to find such uses.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- ...implify-init-realize-error_propagate.cocci | 69 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 70 insertions(+)create mode 100644
scripts/coccinelle/simplify-init-realize-error_propagate.cocciscripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +32
-0@@ -0,0 +1,69 @@ +// Find error-propagation calls that don't need to be in DeviceClass::realize() +// because they don't use information user can change before calling realize(), +// so they can be moved to DeviceClass:initfn() where error propagation is not +// needed. +// +// Copyright: (C) 2020 Philippe Mathieu-Daudé +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h \ +// --sp-file \ +// scripts/coccinelle/simplify-init-realize-error_propagate.cocci \ +// --timeout 60 +// +// Inspired by https://www.mail-archive.com/[email protected]/msg692500.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init = class_initfn; + + +@ match_instance_init @ +TypeInfo info; +identifier instance_initfn; +@@ + info.instance_init = instance_initfn; + + +@ match_realize @scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 42
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +10
-0+identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize = realizefn; + ... +}I'm afraid this misses
realize()methods of DeviceClass subclasses. Consider PCI device "i6300esb" (picked just because it's simple).
pci_device_class_init()sets DeviceClass methodrealize()topci_qdev_realize().pci_qdev_realize()does the work common to all PCI devices, and calls PCIDeviceClass methodrealize()for the work specific to the PCI device at hand.
i6300esb_class_init()sets PCIDeviceClass methodrealize()toi6300esb_realize().Your first rule should match
i6300esb_infoalright, and thus identifyi6300esb_class_init()as aclass_init()method.But your third rule can't match i6300esb_class_init()'s
k->realize = i6300esb_realize;Quoted 8 lines
because @k is a PCIDeviceClass, not a DeviceClass.
I think it also misses cases that have a
realize(), but noinstance_init().Finding only some instances of an anti-pattern can still be useful. But you should explain the script's limitations then, both in the script and the commit message.
OK.
Quoted 10 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci line 49
Quoted 8 lines
scripts/coccinelle/simplify-init-realize-error_propagate.cocci new file +7
-0+ + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp =~ "(?!object_property_set_link)";What are you trying to accomplish with this lookahead assertion?
Quoted 5 lines
Quoted 1 line
"match all
func_with_errp()exceptobject_property_set_link()"?What's wrong with
identifier func_with_errp != object_property_set_link
Nothing wrong, I didn't know this form by the time I wrote this script.
Quoted 5 lines
?
[...]
PATCH v3 3/24 hw/arm/allwinner-a10: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/allwinner-a10.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
aw_a10_init()toaw_a10_realize()in./hw/arm/allwinner-a10.c:77
Move the calls using &error_fatal which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/arm/allwinner-a10.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
hw/arm/allwinner-a10.c +13 -13
@@ -60,10 +60,18 @@ static void aw_a10_init(Object *obj)int i;for (i =0 ; i <AW_A10_NUM_USB ; i++) { +char bus[16 ]; +sysbus_init_child_obj (obj,"ehci[*]" ,OBJECT (&s->ehci[i]),sizeof (s->ehci[i]),TYPE_PLATFORM_EHCI );sysbus_init_child_obj (obj,"ohci[*]" ,OBJECT (&s->ohci[i]),sizeof (s->ohci[i]),TYPE_SYSBUS_OHCI ); +object_property_set_bool (OBJECT (&s->ehci[i]), true, +"companion-enable" , &error_fatal); + +sprintf (bus,"usb-bus.%d" , i); +object_property_set_str (OBJECT (&s->ohci[i]), bus,"masterbus" , + &error_fatal); } }
@@ -72,6 +80,11 @@ static void aw_a10_init(Object *obj)sysbus_init_child_obj (obj,"rtc" , &s->rtc,sizeof (s->rtc),TYPE_AW_RTC_SUN4I ); + +memory_region_init_ram (&s->sram_a, obj,"sram A" ,48 * KiB, + &error_fatal); +memory_region_add_subregion (get_system_memory (),0x00000000 , &s->sram_a); +create_unimplemented_device ("a10-sram-ctrl" ,0x01c00000 ,4 * KiB); }static void aw_a10_realize (DeviceState *dev,Error **errp)
@@ -113,11 +126,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (sysbusdev,4 ,qdev_get_gpio_in (dev,67 ));sysbus_connect_irq (sysbusdev,5 ,qdev_get_gpio_in (dev,68 )); -memory_region_init_ram (&s->sram_a,OBJECT (dev),"sram A" ,48 * KiB, - &error_fatal); -memory_region_add_subregion (get_system_memory (),0x00000000 , &s->sram_a); -create_unimplemented_device ("a10-sram-ctrl" ,0x01c00000 ,4 * KiB); -/* FIXME use qdev NIC properties instead of nd_table[] */ if (nd_table[0 ].used) {qemu_check_nic_model (&nd_table[0 ],TYPE_AW_EMAC );
@@ -149,12 +157,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)int i;for (i =0 ; i <AW_A10_NUM_USB ; i++) { -char bus[16 ]; - -sprintf (bus,"usb-bus.%d" , i); - -object_property_set_bool (OBJECT (&s->ehci[i]), true, -"companion-enable" , &error_fatal);object_property_set_bool (OBJECT (&s->ehci[i]), true,"realized" , &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0,
@@ -162,8 +164,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->ehci[i]),0 ,qdev_get_gpio_in (dev,39 + i)); -object_property_set_str (OBJECT (&s->ohci[i]), bus,"masterbus" , - &error_fatal);object_property_set_bool (OBJECT (&s->ohci[i]), true,"realized" , &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(&s->ohci[i]), 0,
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 03/24] hw/arm/allwinner-a10: Move some code from realize() to init()
Quoted 41 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/arm/allwinner-a10.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
aw_a10_init()toaw_a10_realize()in./hw/arm/allwinner-a10.c:77Move the calls using
&error_fatalwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/arm/allwinner-a10.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)hw/arm/allwinner-a10.c +8
-0@@ -60,10 +60,18 @@ static void aw_a10_init(Object *obj)int i;for (i =0 ; i <AW_A10_NUM_USB ; i++) { +char bus[16 ]; +sysbus_init_child_obj (obj,"ehci[*]" ,OBJECT (&s->ehci[i]),sizeof (s->ehci[i]),TYPE_PLATFORM_EHCI );sysbus_init_child_obj (obj,"ohci[*]" ,OBJECT (&s->ohci[i]),sizeof (s->ohci[i]),TYPE_SYSBUS_OHCI ); +object_property_set_bool (OBJECT (&s->ehci[i]), true, +"companion-enable" , &error_fatal); + +sprintf (bus,"usb-bus.%d" , i); +object_property_set_str (OBJECT (&s->ohci[i]), bus,"masterbus" , + &error_fatal); } }
hw/arm/allwinner-a10.c static void aw_a10_init(Object *obj) · line 86
Quoted 7 lines
hw/arm/allwinner-a10.c +4
-0@@ -72,6 +80,11 @@ static void aw_a10_init(Object *obj)sysbus_init_child_obj (obj,"rtc" , &s->rtc,sizeof (s->rtc),TYPE_AW_RTC_SUN4I ); + +memory_region_init_ram (&s->sram_a, obj,"sram A" ,48 * KiB, + &error_fatal); +memory_region_add_subregion (get_system_memory (),0x00000000 , &s->sram_a);
Unfortunately this makes qtest/device-introspect-test fail:
(qemu) device_add allwinner-a10,help
(qemu) device_add allwinner-a10,help
RAMBlock "sram A" already registered, abort!
Aborted (core dumped)
(gdb) bt
#1 0x00007ffff5089895 in abort () at /lib64/libc.so.6
#2 0x0000555557324445 in qemu_ram_set_idstr (new_block=0x614000026a40, name=0x602000231a50 "sram A", dev=0x633000038800) at exec.c:2023 #3 0x00005555595ed050 in vmstate_register_ram (mr=0x633000049610, dev=0x633000038800) at migration/savevm.c:2921
#4 0x0000555557569a85 in memory_region_init_ram (mr=0x633000049610, owner=0x633000038800, name=0x55555a4da6a0 <str> "sram A", size=49152, errp=0x55555c908d00 <error_fatal>)
at memory.c:3170
#5 0x0000555557b7cadf in aw_a10_init (obj=0x633000038800) at hw/arm/allwinner-a10.c:84
#6 0x00005555599b0c09 in object_init_with_type (obj=0x633000038800, ti=0x61300001da80) at qom/object.c:376
#7 0x0000555559994350 in object_initialize_with_type (data=0x633000038800, size=97024, type=0x61300001da80) at qom/object.c:516 #8 0x0000555559996756 in object_new_with_type (type=0x61300001da80) at qom/object.c:684
#9 0x0000555559996832 in object_new (typename=0x60200022e8b0 "allwinner-a10") at qom/object.c:699
#10 0x000055555979e809 in qmp_device_list_properties (typename=0x60200022e8b0 "allwinner-a10", errp=0x7fffffffafc0) at qom/qom-qmp-cmds.c:153
#11 0x00005555582b68cd in qdev_device_help (opts=0x607000120130) at qdev-monitor.c:282
Quoted 39 lines
hw/arm/allwinner-a10.c +1
-13+create_unimplemented_device ("a10-sram-ctrl" ,0x01c00000 ,4 * KiB); }static void aw_a10_realize (DeviceState *dev,Error **errp)@@ -113,11 +126,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (sysbusdev,4 ,qdev_get_gpio_in (dev,67 ));sysbus_connect_irq (sysbusdev,5 ,qdev_get_gpio_in (dev,68 )); -memory_region_init_ram (&s->sram_a,OBJECT (dev),"sram A" ,48 * KiB, - &error_fatal); -memory_region_add_subregion (get_system_memory (),0x00000000 , &s->sram_a); -create_unimplemented_device ("a10-sram-ctrl" ,0x01c00000 ,4 * KiB); -/* FIXME use qdev NIC properties instead of nd_table[] */ if (nd_table[0 ].used) {qemu_check_nic_model (&nd_table[0 ],TYPE_AW_EMAC );@@ -149,12 +157,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)int i;for (i =0 ; i <AW_A10_NUM_USB ; i++) { -char bus[16 ]; - -sprintf (bus,"usb-bus.%d" , i); - -object_property_set_bool (OBJECT (&s->ehci[i]), true, -"companion-enable" , &error_fatal);object_property_set_bool (OBJECT (&s->ehci[i]), true,"realized" , &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0,@@ -162,8 +164,6 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->ehci[i]),0 ,qdev_get_gpio_in (dev,39 + i)); -object_property_set_str (OBJECT (&s->ohci[i]), bus,"masterbus" , - &error_fatal);object_property_set_bool (OBJECT (&s->ohci[i]), true,"realized" , &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(&s->ohci[i]), 0,
PATCH v3 4/24 hw/arm/aspeed_ast2600: Simplify use of Error*
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/aspeed_ast2600.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
aspeed_soc_ast2600_init()toaspeed_soc_ast2600_realize()in./hw/arm/aspeed_ast2600.c:243
While reviewing we notice we don't need two different Error*, drop the one less used.
---
v3: Indented 'return'.
--- hw/arm/aspeed_ast2600.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
hw/arm/aspeed_ast2600.c +13 -7
@@ -245,7 +245,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)int i;AspeedSoCState *s =ASPEED_SOC (dev);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); -Error *err =NULL , *local_err =NULL ; +Error *err =NULL ;qemu_irq irq;/* IO space */
@@ -418,9 +418,12 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)return ; }object_property_set_int (OBJECT (&s->spi[i]),1 ,"num-cs" , &err); +if (err) { +error_propagate (errp, err); +return ; + }object_property_set_bool (OBJECT (&s->spi[i]), true,"realized" , - &local_err); -error_propagate (&err, local_err); + &err);if (err) {error_propagate (errp, err);return ;
@@ -472,12 +475,15 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)qdev_set_nic_properties (DEVICE (&s->ftgmac100[i]), &nd_table[i]);object_property_set_bool (OBJECT (&s->ftgmac100[i]), true,"aspeed" , &err); -object_property_set_bool (OBJECT (&s->ftgmac100[i]), true,"realized" , - &local_err); -error_propagate (&err, local_err);if (err) {error_propagate (errp, err); -return ; +return ; + } +object_property_set_bool (OBJECT (&s->ftgmac100[i]), true,"realized" , + &err); +if (err) { +error_propagate (errp, err); +return ; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ftgmac100[i]),0 , sc->memmap[ASPEED_ETH1 + i]);
Signature · 1 line
2.21.1
PATCH v3 5/24 hw/arm/aspeed_ast2600: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/aspeed_ast2600.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
aspeed_soc_ast2600_init()toaspeed_soc_ast2600_realize()in./hw/arm/aspeed_ast2600.c:243
Move the calls using &error_fatal which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/arm/aspeed_ast2600.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-)
hw/arm/aspeed_ast2600.c +20 -21
@@ -114,6 +114,16 @@ static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)return qdev_get_gpio_in (DEVICE (&s->a7mpcore), sc->irqmap[ctrl]); } +/* +* ASPEED ast2600 has 0xf as cluster ID +* +* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html +*/ +static uint64_t aspeed_calc_affinity (int cpu) +{ +return (0xf <<ARM_AFF1_SHIFT ) | cpu; +} +static void aspeed_soc_ast2600_init (Object *obj) {AspeedSoCState *s =ASPEED_SOC (obj);
@@ -130,6 +140,13 @@ static void aspeed_soc_ast2600_init(Object *obj)object_initialize_child (obj,"cpu[*]" ,OBJECT (&s->cpu[i]),sizeof (s->cpu[i]), sc->cpu_type, &error_abort,NULL ); +object_property_set_int (OBJECT (&s->cpu[i]),QEMU_PSCI_CONDUIT_SMC , +"psci-conduit" , &error_abort); +object_property_set_int (OBJECT (&s->cpu[i]),aspeed_calc_affinity (i), +"mp-affinity" , &error_abort); + +object_property_set_int (OBJECT (&s->cpu[i]),1125000000 ,"cntfrq" , + &error_abort); }snprintf (typename,sizeof (typename),"aspeed.scu-%s" , socname);
@@ -146,6 +163,9 @@ static void aspeed_soc_ast2600_init(Object *obj)sysbus_init_child_obj (obj,"a7mpcore" , &s->a7mpcore,sizeof (s->a7mpcore),TYPE_A15MPCORE_PRIV ); +object_property_set_int (OBJECT (&s->a7mpcore), +ASPEED_SOC_AST2600_MAX_IRQ +GIC_INTERNAL , +"num-irq" , &error_abort);sysbus_init_child_obj (obj,"rtc" ,OBJECT (&s->rtc),sizeof (s->rtc),TYPE_ASPEED_RTC );
@@ -230,16 +250,6 @@ static void aspeed_soc_ast2600_init(Object *obj) TYPE_SYSBUS_SDHCI); } -/* -* ASPEED ast2600 has 0xf as cluster ID -* -* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html -*/ -static uint64_t aspeed_calc_affinity (int cpu) -{ -return (0xf <<ARM_AFF1_SHIFT ) | cpu; -} -static void aspeed_soc_ast2600_realize (DeviceState *dev,Error **errp) {int i;
@@ -264,19 +274,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* CPU */ for (i =0 ; i < s->num_cpus; i++) { -object_property_set_int (OBJECT (&s->cpu[i]),QEMU_PSCI_CONDUIT_SMC , -"psci-conduit" , &error_abort);if (s->num_cpus >1 ) {object_property_set_int (OBJECT (&s->cpu[i]),ASPEED_A7MPCORE_ADDR ,"reset-cbar" , &error_abort); } -object_property_set_int (OBJECT (&s->cpu[i]),aspeed_calc_affinity (i), -"mp-affinity" , &error_abort); - -object_property_set_int (OBJECT (&s->cpu[i]),1125000000 ,"cntfrq" , - &error_abort); -/* * TODO: the secondary CPUs are started and a boot helper * is needed when using -kernel
@@ -292,9 +294,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* A7MPCORE */ object_property_set_int (OBJECT (&s->a7mpcore), s->num_cpus,"num-cpu" , &error_abort); -object_property_set_int (OBJECT (&s->a7mpcore), -ASPEED_SOC_AST2600_MAX_IRQ +GIC_INTERNAL , -"num-irq" , &error_abort);object_property_set_bool (OBJECT (&s->a7mpcore), true,"realized" , &error_abort);
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 05/24] hw/arm/aspeed_ast2600: Move some code from realize() to init()
Quoted 11 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/arm/aspeed_ast2600.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
aspeed_soc_ast2600_init()toaspeed_soc_ast2600_realize()in./hw/arm/aspeed_ast2600.c:243Move the calls using
&error_fatalwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 99 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/arm/aspeed_ast2600.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-)hw/arm/aspeed_ast2600.c +20
-21@@ -114,6 +114,16 @@ static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)return qdev_get_gpio_in (DEVICE (&s->a7mpcore), sc->irqmap[ctrl]); } +/* +* ASPEED ast2600 has 0xf as cluster ID +* +* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html +*/ +static uint64_t aspeed_calc_affinity (int cpu) +{ +return (0xf <<ARM_AFF1_SHIFT ) | cpu; +} +static void aspeed_soc_ast2600_init (Object *obj) {AspeedSoCState *s =ASPEED_SOC (obj);@@ -130,6 +140,13 @@ static void aspeed_soc_ast2600_init(Object *obj)object_initialize_child (obj,"cpu[*]" ,OBJECT (&s->cpu[i]),sizeof (s->cpu[i]), sc->cpu_type, &error_abort,NULL ); +object_property_set_int (OBJECT (&s->cpu[i]),QEMU_PSCI_CONDUIT_SMC , +"psci-conduit" , &error_abort); +object_property_set_int (OBJECT (&s->cpu[i]),aspeed_calc_affinity (i), +"mp-affinity" , &error_abort); + +object_property_set_int (OBJECT (&s->cpu[i]),1125000000 ,"cntfrq" , + &error_abort); }snprintf (typename,sizeof (typename),"aspeed.scu-%s" , socname);@@ -146,6 +163,9 @@ static void aspeed_soc_ast2600_init(Object *obj)sysbus_init_child_obj (obj,"a7mpcore" , &s->a7mpcore,sizeof (s->a7mpcore),TYPE_A15MPCORE_PRIV ); +object_property_set_int (OBJECT (&s->a7mpcore), +ASPEED_SOC_AST2600_MAX_IRQ +GIC_INTERNAL , +"num-irq" , &error_abort);sysbus_init_child_obj (obj,"rtc" ,OBJECT (&s->rtc),sizeof (s->rtc),TYPE_ASPEED_RTC );@@ -230,16 +250,6 @@ static void aspeed_soc_ast2600_init(Object *obj) TYPE_SYSBUS_SDHCI); } -/* -* ASPEED ast2600 has 0xf as cluster ID -* -* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/CIHEBGFG.html -*/ -static uint64_t aspeed_calc_affinity (int cpu) -{ -return (0xf <<ARM_AFF1_SHIFT ) | cpu; -} -static void aspeed_soc_ast2600_realize (DeviceState *dev,Error **errp) {int i;@@ -264,19 +274,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* CPU */ for (i =0 ; i < s->num_cpus; i++) { -object_property_set_int (OBJECT (&s->cpu[i]),QEMU_PSCI_CONDUIT_SMC , -"psci-conduit" , &error_abort);if (s->num_cpus >1 ) {object_property_set_int (OBJECT (&s->cpu[i]),ASPEED_A7MPCORE_ADDR ,"reset-cbar" , &error_abort); } -object_property_set_int (OBJECT (&s->cpu[i]),aspeed_calc_affinity (i), -"mp-affinity" , &error_abort); - -object_property_set_int (OBJECT (&s->cpu[i]),1125000000 ,"cntfrq" , - &error_abort); -/* * TODO: the secondary CPUs are started and a boot helper * is needed when using -kernel @@ -292,9 +294,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)/* A7MPCORE */ object_property_set_int (OBJECT (&s->a7mpcore), s->num_cpus,"num-cpu" , &error_abort); -object_property_set_int (OBJECT (&s->a7mpcore), -ASPEED_SOC_AST2600_MAX_IRQ +GIC_INTERNAL , -"num-irq" , &error_abort);object_property_set_bool (OBJECT (&s->a7mpcore), true,"realized" , &error_abort);
PATCH v3 6/24 hw/arm/aspeed_soc: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/aspeed_soc.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
aspeed_soc_init()toaspeed_soc_realize()in./hw/arm/aspeed_soc.c:231
Move the calls using &error_fatal which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/arm/aspeed_soc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
hw/arm/aspeed_soc.c +2 -4
@@ -183,6 +183,7 @@ static void aspeed_soc_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.spi%d-%s" , i +1 , socname);sysbus_init_child_obj (obj,"spi[*]" ,OBJECT (&s->spi[i]),sizeof (s->spi[i]), typename); +object_property_set_int (OBJECT (&s->spi[i]),1 ,"num-cs" , &error_abort); }for (i =0 ; i < sc->ehcis_num; i++) {
@@ -360,10 +361,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)/* SPI */ for (i =0 ; i < sc->spis_num; i++) { -object_property_set_int (OBJECT (&s->spi[i]),1 ,"num-cs" , &err); -object_property_set_bool (OBJECT (&s->spi[i]), true,"realized" , - &local_err); -error_propagate (&err, local_err); +object_property_set_bool (OBJECT (&s->spi[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);return ;
Signature · 1 line
2.21.1
PATCH v3 7/24 hw/arm/aspeed_soc: Simplify use of Error*
In reply to Philippe Mathieu-DaudéIn the previous commit we noticed we don't need two different Error*, drop the one less used.
---
v3: Indent 'return'
--- hw/arm/aspeed_soc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/arm/aspeed_soc.c +8 -5
@@ -234,7 +234,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)int i;AspeedSoCState *s =ASPEED_SOC (dev);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); -Error *err =NULL , *local_err =NULL ; +Error *err =NULL ;/* IO space */ create_unimplemented_device("aspeed_soc.io", sc->memmap[ASPEED_IOMEM],
@@ -413,12 +413,15 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)qdev_set_nic_properties (DEVICE (&s->ftgmac100[i]), &nd_table[i]);object_property_set_bool (OBJECT (&s->ftgmac100[i]), true,"aspeed" , &err); -object_property_set_bool (OBJECT (&s->ftgmac100[i]), true,"realized" , - &local_err); -error_propagate (&err, local_err);if (err) {error_propagate (errp, err); -return ; +return ; + } +object_property_set_bool (OBJECT (&s->ftgmac100[i]), true,"realized" , + &err); +if (err) { +error_propagate (errp, err); +return ; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ftgmac100[i]),0 , sc->memmap[ASPEED_ETH1 + i]);
Signature · 1 line
2.21.1
PATCH v3 8/24 hw/arm/fsl-imx6: Simplify checks on 'smp_cpus' count
In reply to Philippe Mathieu-DaudéCoccinelle failed at processing this file:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/fsl-imx6.c
Fatal error: exception Coccinelle_modules.Common.TimeoutWhile reviewing we notice the smp_cpus count is already limited by MachineClass::max_cpus:
static void sabrelite_machine_init(MachineClass *mc)
{
mc->max_cpus = FSL_IMX6_NUM_CPUS;
...
}So remove the check in realize(), but still assert in init().
--- hw/arm/fsl-imx6.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
hw/arm/fsl-imx6.c +2 -6
@@ -37,10 +37,12 @@static void fsl_imx6_init (Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ()); +unsigned int smp_cpus = ms->smp.cpus;FslIMX6State *s =FSL_IMX6 (obj);char name[NAME_SIZE ];int i; +assert (smp_cpus <=FSL_IMX6_NUM_CPUS );for (i =0 ; i <MIN (ms->smp.cpus,FSL_IMX6_NUM_CPUS ); i++) {snprintf (name,NAME_SIZE ,"cpu%d" , i); object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
@@ -121,12 +123,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)Error *err =NULL ;unsigned int smp_cpus = ms->smp.cpus; -if (smp_cpus >FSL_IMX6_NUM_CPUS ) { -error_setg (errp,"%s: Only %d CPUs are supported (%d requested)" , -TYPE_FSL_IMX6 ,FSL_IMX6_NUM_CPUS , smp_cpus); -return ; - } -for (i =0 ; i < smp_cpus; i++) {/* On uniprocessor, the CBAR is set to 0 */
Signature · 1 line
2.21.1
PATCH v3 9/24 hw/arm/fsl-imx6: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle failed at processing this file:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/fsl-imx6.c
Fatal error: exception Coccinelle_modules.Common.TimeoutWhile reviewing we noticed some functions can be called at init() time, reducing the need to add extra Error checks at realize() time. Move them. The coccinelle script succeeds after this.
--- hw/arm/fsl-imx6.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-)
hw/arm/fsl-imx6.c +23 -24
@@ -48,11 +48,30 @@ static void fsl_imx6_init(Object *obj)object_initialize_child (obj, name, &s->cpu[i],sizeof (s->cpu[i]),ARM_CPU_TYPE_NAME ("cortex-a9" ), &error_abort,NULL ); + +/* On uniprocessor, the CBAR is set to 0 */ +if (smp_cpus >1 ) { +object_property_set_int (OBJECT (&s->cpu[i]),FSL_IMX6_A9MPCORE_ADDR , +"reset-cbar" , &error_abort); + } + +/* All CPU but CPU 0 start in power off mode */ +if (i) { +object_property_set_bool (OBJECT (&s->cpu[i]), true, +"start-powered-off" , &error_abort); + } }sysbus_init_child_obj (obj,"a9mpcore" , &s->a9mpcore,sizeof (s->a9mpcore),TYPE_A9MPCORE_PRIV ); +object_property_set_int (OBJECT (&s->a9mpcore), smp_cpus,"num-cpu" , + &error_abort); + +object_property_set_int (OBJECT (&s->a9mpcore), +FSL_IMX6_MAX_IRQ +GIC_INTERNAL ,"num-irq" , + &error_abort); +sysbus_init_child_obj (obj,"ccm" , &s->ccm,sizeof (s->ccm),TYPE_IMX6_CCM );sysbus_init_child_obj (obj,"src" , &s->src,sizeof (s->src),TYPE_IMX6_SRC );
@@ -81,6 +100,10 @@ static void fsl_imx6_init(Object *obj)snprintf (name,NAME_SIZE ,"gpio%d" , i +1 );sysbus_init_child_obj (obj, name, &s->gpio[i],sizeof (s->gpio[i]),TYPE_IMX_GPIO ); +object_property_set_bool (OBJECT (&s->gpio[i]), true,"has-edge-sel" , + &error_abort); +object_property_set_bool (OBJECT (&s->gpio[i]), true,"has-upper-pin-irq" , + &error_abort); }for (i =0 ; i <FSL_IMX6_NUM_ESDHCS ; i++) {
@@ -124,19 +147,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)unsigned int smp_cpus = ms->smp.cpus;for (i =0 ; i < smp_cpus; i++) { - -/* On uniprocessor, the CBAR is set to 0 */ -if (smp_cpus >1 ) { -object_property_set_int (OBJECT (&s->cpu[i]),FSL_IMX6_A9MPCORE_ADDR , -"reset-cbar" , &error_abort); - } - -/* All CPU but CPU 0 start in power off mode */ -if (i) { -object_property_set_bool (OBJECT (&s->cpu[i]), true, -"start-powered-off" , &error_abort); - } -object_property_set_bool (OBJECT (&s->cpu[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -144,13 +154,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) } } -object_property_set_int (OBJECT (&s->a9mpcore), smp_cpus,"num-cpu" , - &error_abort); - -object_property_set_int (OBJECT (&s->a9mpcore), -FSL_IMX6_MAX_IRQ +GIC_INTERNAL ,"num-irq" , - &error_abort); -object_property_set_bool (OBJECT (&s->a9mpcore), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -310,10 +313,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) }, }; -object_property_set_bool (OBJECT (&s->gpio[i]), true,"has-edge-sel" , - &error_abort); -object_property_set_bool (OBJECT (&s->gpio[i]), true,"has-upper-pin-irq" , - &error_abort);object_property_set_bool (OBJECT (&s->gpio[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
Signature · 1 line
2.21.1
PATCH v3 10/24 hw/arm/fsl-imx31: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: hw/arm/fsl-imx31.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
fsl_imx31_init()tofsl_imx31_realize()inhw/arm/fsl-imx31.c:68
Move the calls using &error_abort which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/arm/fsl-imx31.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/fsl-imx31.c +2 -2
@@ -62,6 +62,8 @@ static void fsl_imx31_init(Object *obj)for (i =0 ; i <FSL_IMX31_NUM_GPIOS ; i++) {sysbus_init_child_obj (obj,"gpio[*]" , &s->gpio[i],sizeof (s->gpio[i]),TYPE_IMX_GPIO ); +object_property_set_bool (OBJECT (&s->gpio[i]), false,"has-edge-sel" , + &error_abort); } }
@@ -191,8 +193,6 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) { FSL_IMX31_GPIO3_ADDR, FSL_IMX31_GPIO3_IRQ } }; -object_property_set_bool (OBJECT (&s->gpio[i]), false,"has-edge-sel" , - &error_abort);object_property_set_bool (OBJECT (&s->gpio[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
Signature · 1 line
2.21.1
PATCH v3 11/24 hw/arm/msf2-soc: Store MemoryRegion in MSF2State
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/msf2-soc.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
m2sxxx_soc_initfn()tom2sxxx_soc_realize()in./hw/arm/msf2-soc.c:86
While reviewing we notice storing the MemoryRegion in the device state, we'll be able to later automatically simplify the error propagation calls.
--- include/hw/arm/msf2-soc.h | 4 ++++ hw/arm/msf2-soc.c | 18 +++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-)
include/hw/arm/msf2-soc.h +4 -0
@@ -50,6 +50,10 @@ typedef struct MSF2State {ARMv7MState armv7m; +MemoryRegion sram; +MemoryRegion nvm; +MemoryRegion nvm_alias; +char *cpu_type;char *part_name;uint64_t envm_size;
hw/arm/msf2-soc.c +7 -11
@@ -90,13 +90,9 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)SysBusDevice *busdev;Error *err =NULL ;int i; -MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *nvm =g_new (MemoryRegion,1 ); -MemoryRegion *nvm_alias =g_new (MemoryRegion,1 ); -MemoryRegion *sram =g_new (MemoryRegion,1 ); -memory_region_init_rom (nvm,OBJECT (dev_soc),"MSF2.eNVM" , s->envm_size, +memory_region_init_rom (&s->nvm,OBJECT (dev_soc),"MSF2.eNVM" , s->envm_size, &error_fatal);/* * On power-on, the eNVM region 0x60000000 is automatically
@@ -104,15 +100,15 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)* start address (0x0). We do not support remapping other eNVM, * eSRAM and DDR regions by guest(via Sysreg) currently. */ -memory_region_init_alias (nvm_alias,OBJECT (dev_soc),"MSF2.eNVM" , nvm,0 , - s->envm_size); +memory_region_init_alias (&s->nvm_alias,OBJECT (dev_soc),"MSF2.eNVM" , + &s->nvm,0 , s->envm_size); -memory_region_add_subregion (system_memory,ENVM_BASE_ADDRESS , nvm); -memory_region_add_subregion (system_memory,0 , nvm_alias); +memory_region_add_subregion (system_memory,ENVM_BASE_ADDRESS , &s->nvm); +memory_region_add_subregion (system_memory,0 , &s->nvm_alias); -memory_region_init_ram (sram,NULL ,"MSF2.eSRAM" , s->esram_size, +memory_region_init_ram (&s->sram,NULL ,"MSF2.eSRAM" , s->esram_size, &error_fatal); -memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , sram); +memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); armv7m =DEVICE (&s->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,81 );
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 11/24] hw/arm/msf2-soc: Store MemoryRegion in MSF2State
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/arm/msf2-soc.c
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
m2sxxx_soc_initfn()tom2sxxx_soc_realize()in./hw/arm/msf2-soc.c:86While reviewing we notice storing the MemoryRegion in the device state, we'll be able to later automatically simplify the error propagation calls.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 65 lines
--- include/hw/arm/msf2-soc.h | 4 ++++ hw/arm/msf2-soc.c | 18 +++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-)include/hw/arm/msf2-soc.h +4
-0@@ -50,6 +50,10 @@ typedef struct MSF2State {ARMv7MState armv7m; +MemoryRegion sram; +MemoryRegion nvm; +MemoryRegion nvm_alias; +char *cpu_type;char *part_name;uint64_t envm_size;hw/arm/msf2-soc.c +7
-12@@ -90,13 +90,9 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)SysBusDevice *busdev;Error *err =NULL ;int i; -MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *nvm =g_new (MemoryRegion,1 ); -MemoryRegion *nvm_alias =g_new (MemoryRegion,1 ); -MemoryRegion *sram =g_new (MemoryRegion,1 ); -memory_region_init_rom (nvm,OBJECT (dev_soc),"MSF2.eNVM" , s->envm_size, +memory_region_init_rom (&s->nvm,OBJECT (dev_soc),"MSF2.eNVM" , s->envm_size, &error_fatal);/* * On power-on, the eNVM region 0x60000000 is automatically @@ -104,15 +100,15 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)* start address (0x0). We do not support remapping other eNVM, * eSRAM and DDR regions by guest(via Sysreg) currently. */ -memory_region_init_alias (nvm_alias,OBJECT (dev_soc),"MSF2.eNVM" , nvm,0 , - s->envm_size); +memory_region_init_alias (&s->nvm_alias,OBJECT (dev_soc),"MSF2.eNVM" , + &s->nvm,0 , s->envm_size); -memory_region_add_subregion (system_memory,ENVM_BASE_ADDRESS , nvm); -memory_region_add_subregion (system_memory,0 , nvm_alias); +memory_region_add_subregion (system_memory,ENVM_BASE_ADDRESS , &s->nvm); +memory_region_add_subregion (system_memory,0 , &s->nvm_alias); -memory_region_init_ram (sram,NULL ,"MSF2.eSRAM" , s->esram_size, +memory_region_init_ram (&s->sram,NULL ,"MSF2.eSRAM" , s->esram_size, &error_fatal); -memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , sram); +memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); armv7m =DEVICE (&s->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,81 ); --2.21.1
PATCH v3 12/24 hw/arm/stm32f205_soc: Store MemoryRegion in STM32F205State
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/stm32f205_soc.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
stm32f205_soc_initfn()tostm32f205_soc_realize()in./hw/arm/stm32f205_soc.c:83
While reviewing we notice storing the MemoryRegion in the device state, we'll be able to later automatically simplify the error propagation calls.
--- include/hw/arm/stm32f205_soc.h | 4 ++++ hw/arm/stm32f205_soc.c | 18 +++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-)
include/hw/arm/stm32f205_soc.h +4 -0
@@ -56,6 +56,10 @@ typedef struct STM32F205State {ARMv7MState armv7m; +MemoryRegion sram; +MemoryRegion flash; +MemoryRegion flash_alias; +STM32F2XXSyscfgState syscfg;STM32F2XXUsartState usart[STM_NUM_USARTS ];STM32F2XXTimerState timer[STM_NUM_TIMERS ];
hw/arm/stm32f205_soc.c +7 -11
@@ -87,23 +87,19 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)SysBusDevice *busdev;Error *err =NULL ;int i; -MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *sram =g_new (MemoryRegion,1 ); -MemoryRegion *flash =g_new (MemoryRegion,1 ); -MemoryRegion *flash_alias =g_new (MemoryRegion,1 ); -memory_region_init_rom (flash,OBJECT (dev_soc),"STM32F205.flash" , +memory_region_init_rom (&s->flash,OBJECT (dev_soc),"STM32F205.flash" ,FLASH_SIZE , &error_fatal); -memory_region_init_alias (flash_alias,OBJECT (dev_soc), -"STM32F205.flash.alias" , flash,0 ,FLASH_SIZE ); +memory_region_init_alias (&s->flash_alias,OBJECT (dev_soc), +"STM32F205.flash.alias" , &s->flash,0 ,FLASH_SIZE ); -memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , flash); -memory_region_add_subregion (system_memory,0 , flash_alias); +memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , &s->flash); +memory_region_add_subregion (system_memory,0 , &s->flash_alias); -memory_region_init_ram (sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , +memory_region_init_ram (&s->sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , &error_fatal); -memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , sram); +memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); armv7m =DEVICE (&s->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,96 );
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 12/24] hw/arm/stm32f205_soc: Store MemoryRegion in STM32F205State
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/arm/stm32f205_soc.c
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
stm32f205_soc_initfn()tostm32f205_soc_realize()in./hw/arm/stm32f205_soc.c:83While reviewing we notice storing the MemoryRegion in the device state, we'll be able to later automatically simplify the error propagation calls.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 59 lines
--- include/hw/arm/stm32f205_soc.h | 4 ++++ hw/arm/stm32f205_soc.c | 18 +++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-)include/hw/arm/stm32f205_soc.h +4
-0@@ -56,6 +56,10 @@ typedef struct STM32F205State {ARMv7MState armv7m; +MemoryRegion sram; +MemoryRegion flash; +MemoryRegion flash_alias; +STM32F2XXSyscfgState syscfg;STM32F2XXUsartState usart[STM_NUM_USARTS ];STM32F2XXTimerState timer[STM_NUM_TIMERS ];hw/arm/stm32f205_soc.c +7
-12@@ -87,23 +87,19 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)SysBusDevice *busdev;Error *err =NULL ;int i; -MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *sram =g_new (MemoryRegion,1 ); -MemoryRegion *flash =g_new (MemoryRegion,1 ); -MemoryRegion *flash_alias =g_new (MemoryRegion,1 ); -memory_region_init_rom (flash,OBJECT (dev_soc),"STM32F205.flash" , +memory_region_init_rom (&s->flash,OBJECT (dev_soc),"STM32F205.flash" ,FLASH_SIZE , &error_fatal); -memory_region_init_alias (flash_alias,OBJECT (dev_soc), -"STM32F205.flash.alias" , flash,0 ,FLASH_SIZE ); +memory_region_init_alias (&s->flash_alias,OBJECT (dev_soc), +"STM32F205.flash.alias" , &s->flash,0 ,FLASH_SIZE ); -memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , flash); -memory_region_add_subregion (system_memory,0 , flash_alias); +memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , &s->flash); +memory_region_add_subregion (system_memory,0 , &s->flash_alias); -memory_region_init_ram (sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , +memory_region_init_ram (&s->sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , &error_fatal); -memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , sram); +memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); armv7m =DEVICE (&s->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,96 ); --2.21.1
PATCH v3 13/24 hw/arm/stm32f205_soc: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/stm32f205_soc.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
stm32f205_soc_initfn()tostm32f205_soc_realize()in./hw/arm/stm32f205_soc.c:83
Move the calls using &error_fatal which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/arm/stm32f205_soc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
hw/arm/stm32f205_soc.c +10 -10
@@ -49,6 +49,7 @@ static const int spi_irq[STM_NUM_SPIS] = {35, 36, 51};static void stm32f205_soc_initfn (Object *obj) {STM32F205State *s =STM32F205_SOC (obj); +MemoryRegion *system_memory =get_system_memory ();int i; sysbus_init_child_obj(obj, "armv7m", &s->armv7m, sizeof(s->armv7m),
@@ -78,6 +79,14 @@ static void stm32f205_soc_initfn(Object *obj)sysbus_init_child_obj (obj,"spi[*]" , &s->spi[i],sizeof (s->spi[i]),TYPE_STM32F2XX_SPI ); } + +memory_region_init_ram (&s->sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , + &error_fatal); +memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); + +memory_region_init_rom (&s->flash, obj,"STM32F205.flash" , +FLASH_SIZE , &error_fatal); +memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , &s->flash); }static void stm32f205_soc_realize (DeviceState *dev_soc,Error **errp)
@@ -87,19 +96,10 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)SysBusDevice *busdev;Error *err =NULL ;int i; -MemoryRegion *system_memory =get_system_memory (); -memory_region_init_rom (&s->flash,OBJECT (dev_soc),"STM32F205.flash" , -FLASH_SIZE , &error_fatal);memory_region_init_alias (&s->flash_alias,OBJECT (dev_soc),"STM32F205.flash.alias" , &s->flash,0 ,FLASH_SIZE ); - -memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , &s->flash); -memory_region_add_subregion (system_memory,0 , &s->flash_alias); - -memory_region_init_ram (&s->sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , - &error_fatal); -memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); +memory_region_add_subregion (get_system_memory (),0 , &s->flash_alias); armv7m =DEVICE (&s->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,96 );
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 13/24] hw/arm/stm32f205_soc: Move some code from realize() to init()
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/arm/stm32f205_soc.c
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
stm32f205_soc_initfn()tostm32f205_soc_realize()in./hw/arm/stm32f205_soc.c:83Move the calls using
&error_fatalwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 58 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/arm/stm32f205_soc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)hw/arm/stm32f205_soc.c +10
-11@@ -49,6 +49,7 @@ static const int spi_irq[STM_NUM_SPIS] = {35, 36, 51};static void stm32f205_soc_initfn (Object *obj) {STM32F205State *s =STM32F205_SOC (obj); +MemoryRegion *system_memory =get_system_memory ();int i; sysbus_init_child_obj(obj, "armv7m", &s->armv7m, sizeof(s->armv7m),@@ -78,6 +79,14 @@ static void stm32f205_soc_initfn(Object *obj)sysbus_init_child_obj (obj,"spi[*]" , &s->spi[i],sizeof (s->spi[i]),TYPE_STM32F2XX_SPI ); } + +memory_region_init_ram (&s->sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , + &error_fatal); +memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); + +memory_region_init_rom (&s->flash, obj,"STM32F205.flash" , +FLASH_SIZE , &error_fatal); +memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , &s->flash); }static void stm32f205_soc_realize (DeviceState *dev_soc,Error **errp)@@ -87,19 +96,10 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)SysBusDevice *busdev;Error *err =NULL ;int i; -MemoryRegion *system_memory =get_system_memory (); -memory_region_init_rom (&s->flash,OBJECT (dev_soc),"STM32F205.flash" , -FLASH_SIZE , &error_fatal);memory_region_init_alias (&s->flash_alias,OBJECT (dev_soc),"STM32F205.flash.alias" , &s->flash,0 ,FLASH_SIZE ); - -memory_region_add_subregion (system_memory,FLASH_BASE_ADDRESS , &s->flash); -memory_region_add_subregion (system_memory,0 , &s->flash_alias); - -memory_region_init_ram (&s->sram,NULL ,"STM32F205.sram" ,SRAM_SIZE , - &error_fatal); -memory_region_add_subregion (system_memory,SRAM_BASE_ADDRESS , &s->sram); +memory_region_add_subregion (get_system_memory (),0 , &s->flash_alias); armv7m =DEVICE (&s->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,96 ); --2.21.1
PATCH v3 14/24 hw/arm/xlnx-zynqmp: Use single propagate_error() call
In reply to Philippe Mathieu-DaudéCoccinelle failed at processing this file:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/xlnx-zynqmp.c
EXN: Coccinelle_modules.Common.TimeoutWe are going to manually add the missing propagate_error() calls. As there are many Error* calls used, simplify by using an unique call to propagate_error().
--- hw/arm/xlnx-zynqmp.c | 61 +++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 38 deletions(-)
hw/arm/xlnx-zynqmp.c +23 -38
@@ -385,15 +385,13 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->apu_cpu[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; } }object_property_set_bool (OBJECT (&s->gic), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }assert (ARRAY_SIZE (xlnx_zynqmp_gic_regions) ==XLNX_ZYNQMP_GIC_REGIONS );
@@ -462,8 +460,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)xlnx_zynqmp_create_rpu (ms, s, boot_cpu, &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }if (!s->boot_cpu_ptr) {
@@ -488,8 +485,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_bool (OBJECT (&s->gem[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->gem[i]),0 , gem_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,
@@ -500,8 +496,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)qdev_prop_set_chr (DEVICE (&s->uart[i]),"chardev" ,serial_hd (i));object_property_set_bool (OBJECT (&s->uart[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->uart[i]),0 , uart_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
@@ -512,8 +507,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_bool (OBJECT (&s->sata), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->sata),0 ,SATA_ADDR );
@@ -531,23 +525,19 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)*/ object_property_set_uint (sdhci,3 ,"sd-spec-version" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_uint (sdhci,SDHCI_CAPABILITIES ,"capareg" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_uint (sdhci,UHS_I ,"uhs" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_bool (sdhci, true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (sbd,0 , sdhci_addr[i]);sysbus_connect_irq (sbd,0 , gic_spi[sdhci_intr[i]]);
@@ -564,8 +554,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->spi[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->spi[i]),0 , spi_addr[i]);
@@ -582,8 +571,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->qspi), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->qspi),0 ,QSPI_ADDR );sysbus_mmio_map (SYS_BUS_DEVICE (&s->qspi),1 ,LQSPI_ADDR );
@@ -605,16 +593,14 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->dp), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->dp),0 ,DP_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->dp),0 , gic_spi[DP_IRQ ]);object_property_set_bool (OBJECT (&s->dpdma), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_link (OBJECT (&s->dp),OBJECT (&s->dpdma),"dpdma" , &error_abort);
@@ -623,16 +609,14 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->ipi), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ipi),0 ,IPI_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->ipi),0 , gic_spi[IPI_IRQ ]);object_property_set_bool (OBJECT (&s->rtc), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->rtc),0 ,RTC_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->rtc),0 , gic_spi[RTC_IRQ ]);
@@ -640,13 +624,11 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i <XLNX_ZYNQMP_NUM_GDMA_CH ; i++) {object_property_set_uint (OBJECT (&s->gdma[i]),128 ,"bus-width" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_bool (OBJECT (&s->gdma[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->gdma[i]),0 , gdma_ch_addr[i]);
@@ -657,14 +639,17 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i <XLNX_ZYNQMP_NUM_ADMA_CH ; i++) {object_property_set_bool (OBJECT (&s->adma[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->adma[i]),0 , adma_ch_addr[i]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->adma[i]),0 , gic_spi[adma_ch_intr[i]]); } +return ; + +out_propagate_error: +error_propagate (errp, err); }static Property xlnx_zynqmp_props[] = {
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 14/24] hw/arm/xlnx-zynqmp: Use single propagate_error() call
Quoted 11 lines · Philippe Mathieu-Daudé
Coccinelle failed at processing this file:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/arm/xlnx-zynqmp.c EXN: Coccinelle_modules.Common.TimeoutWe are going to manually add the missing
propagate_error()calls. As there are many Error* calls used, simplify by using an unique call topropagate_error().
I'm not a huge fan of goto's so I'm not sure this is simpler.
Alistair
Quoted 194 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/xlnx-zynqmp.c | 61 +++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 38 deletions(-)hw/arm/xlnx-zynqmp.c +23
-39@@ -385,15 +385,13 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->apu_cpu[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; } }object_property_set_bool (OBJECT (&s->gic), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }assert (ARRAY_SIZE (xlnx_zynqmp_gic_regions) ==XLNX_ZYNQMP_GIC_REGIONS );@@ -462,8 +460,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)xlnx_zynqmp_create_rpu (ms, s, boot_cpu, &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }if (!s->boot_cpu_ptr) {@@ -488,8 +485,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_bool (OBJECT (&s->gem[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->gem[i]),0 , gem_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,@@ -500,8 +496,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)qdev_prop_set_chr (DEVICE (&s->uart[i]),"chardev" ,serial_hd (i));object_property_set_bool (OBJECT (&s->uart[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->uart[i]),0 , uart_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,@@ -512,8 +507,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_bool (OBJECT (&s->sata), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->sata),0 ,SATA_ADDR );@@ -531,23 +525,19 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)*/ object_property_set_uint (sdhci,3 ,"sd-spec-version" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_uint (sdhci,SDHCI_CAPABILITIES ,"capareg" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_uint (sdhci,UHS_I ,"uhs" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_bool (sdhci, true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (sbd,0 , sdhci_addr[i]);sysbus_connect_irq (sbd,0 , gic_spi[sdhci_intr[i]]);@@ -564,8 +554,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->spi[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->spi[i]),0 , spi_addr[i]);@@ -582,8 +571,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->qspi), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->qspi),0 ,QSPI_ADDR );sysbus_mmio_map (SYS_BUS_DEVICE (&s->qspi),1 ,LQSPI_ADDR );@@ -605,16 +593,14 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->dp), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->dp),0 ,DP_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->dp),0 , gic_spi[DP_IRQ ]);object_property_set_bool (OBJECT (&s->dpdma), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_link (OBJECT (&s->dp),OBJECT (&s->dpdma),"dpdma" , &error_abort);@@ -623,16 +609,14 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->ipi), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ipi),0 ,IPI_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->ipi),0 , gic_spi[IPI_IRQ ]);object_property_set_bool (OBJECT (&s->rtc), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->rtc),0 ,RTC_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->rtc),0 , gic_spi[RTC_IRQ ]);@@ -640,13 +624,11 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i <XLNX_ZYNQMP_NUM_GDMA_CH ; i++) {object_property_set_uint (OBJECT (&s->gdma[i]),128 ,"bus-width" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }object_property_set_bool (OBJECT (&s->gdma[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->gdma[i]),0 , gdma_ch_addr[i]);@@ -657,14 +639,17 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i <XLNX_ZYNQMP_NUM_ADMA_CH ; i++) {object_property_set_bool (OBJECT (&s->adma[i]), true,"realized" , &err);if (err) { -error_propagate (errp, err); -return ; + goto out_propagate_error; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->adma[i]),0 , adma_ch_addr[i]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->adma[i]),0 , gic_spi[adma_ch_intr[i]]); } +return ; + +out_propagate_error: +error_propagate (errp, err); }static Property xlnx_zynqmp_props[] = { --2.21.1
PATCH v3 15/24 hw/arm/xlnx-zynqmp: Split xlnx_zynqmp_create_rpu() as init + realize
In reply to Philippe Mathieu-DaudéCoccinelle failed at processing this file:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/xlnx-zynqmp.c
EXN: Coccinelle_modules.Common.TimeoutWe are going to manually add the missing propagate_error() calls. Some functions can be called at init() time, reducing the need to add extra Error checks at realize() time. Split create_rpu() in init() and realize().
--- hw/arm/xlnx-zynqmp.c | 45 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-)
hw/arm/xlnx-zynqmp.c +28 -17
@@ -173,18 +173,9 @@ static inline int arm_gic_ppi_index(int cpu_nr, int ppi_index)return GIC_NUM_SPI_INTR + cpu_nr *GIC_INTERNAL + ppi_index; } -static void xlnx_zynqmp_create_rpu (MachineState *ms,XlnxZynqMPState *s, -const char *boot_cpu,Error **errp) +static void xlnx_zynqmp_rpu_init (XlnxZynqMPState *s,int num_rpus) { -Error *err =NULL ;int i; -int num_rpus =MIN (ms->smp.cpus -XLNX_ZYNQMP_NUM_APU_CPUS , -XLNX_ZYNQMP_NUM_RPU_CPUS ); - -if (num_rpus <=0 ) { -/* Don't create rpu-cluster object if there's nothing to put in it */ -return ; - } object_initialize_child(OBJECT(s), "rpu-cluster", &s->rpu_cluster, sizeof(s->rpu_cluster), TYPE_CPU_CLUSTER,
@@ -192,13 +183,25 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,qdev_prop_set_uint32 (DEVICE (&s->rpu_cluster),"cluster-id" ,1 );for (i =0 ; i < num_rpus; i++) { -char *name; -object_initialize_child (OBJECT (&s->rpu_cluster),"rpu-cpu[*]" , &s->rpu_cpu[i],sizeof (s->rpu_cpu[i]),ARM_CPU_TYPE_NAME ("cortex-r5f" ), &error_abort,NULL ); +object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true,"reset-hivecs" , + &error_abort); + } +} + +static void xlnx_zynqmp_rpu_realize (XlnxZynqMPState *s,int num_rpus, +const char *boot_cpu,Error **errp) +{ +Error *err =NULL ; +int i; + +for (i =0 ; i < num_rpus; i++) { +char *name; + name =object_get_canonical_path_component (OBJECT (&s->rpu_cpu[i]));if (strcmp (name, boot_cpu)) {/* Secondary CPUs start in PSCI powered-down state */
@@ -209,8 +212,6 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s, }g_free (name); -object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true,"reset-hivecs" , - &error_abort);object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true,"realized" , &err);if (err) {
@@ -228,6 +229,8 @@ static void xlnx_zynqmp_init(Object *obj)XlnxZynqMPState *s =XLNX_ZYNQMP (obj);int i;int num_apus =MIN (ms->smp.cpus,XLNX_ZYNQMP_NUM_APU_CPUS ); +int num_rpus =MIN (ms->smp.cpus -XLNX_ZYNQMP_NUM_APU_CPUS , +XLNX_ZYNQMP_NUM_RPU_CPUS ); object_initialize_child(obj, "apu-cluster", &s->apu_cluster, sizeof(s->apu_cluster), TYPE_CPU_CLUSTER,
@@ -290,6 +293,10 @@ static void xlnx_zynqmp_init(Object *obj)sysbus_init_child_obj (obj,"adma[*]" , &s->adma[i],sizeof (s->adma[i]),TYPE_XLNX_ZDMA ); } + +if (num_rpus >0 ) { +xlnx_zynqmp_rpu_init (s, num_rpus); + } }static void xlnx_zynqmp_realize (DeviceState *dev,Error **errp)
@@ -300,6 +307,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)uint8_t i;uint64_t ram_size;int num_apus =MIN (ms->smp.cpus,XLNX_ZYNQMP_NUM_APU_CPUS ); +int num_rpus =MIN (ms->smp.cpus -XLNX_ZYNQMP_NUM_APU_CPUS , +XLNX_ZYNQMP_NUM_RPU_CPUS );const char *boot_cpu = s->boot_cpu ? s->boot_cpu :"apu-cpu[0]" ;ram_addr_t ddr_low_size, ddr_high_size;qemu_irq gic_spi[GIC_NUM_SPI_INTR ];
@@ -458,9 +467,11 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) "RPUs just use -smp 6."); } -xlnx_zynqmp_create_rpu (ms, s, boot_cpu, &err); -if (err) { - goto out_propagate_error; +if (num_rpus >0 ) { +xlnx_zynqmp_rpu_realize (s, num_rpus, boot_cpu, &err); +if (err) { + goto out_propagate_error; + } }if (!s->boot_cpu_ptr) {
Signature · 1 line
2.21.1
PATCH v3 16/24 hw/arm/xlnx-zynqmp: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle failed at processing this file:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/arm/xlnx-zynqmp.c
EXN: Coccinelle_modules.Common.TimeoutMove the calls using &error_abort which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/arm/xlnx-zynqmp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
hw/arm/xlnx-zynqmp.c +11 -11
@@ -242,6 +242,11 @@ static void xlnx_zynqmp_init(Object *obj) &s->apu_cpu[i],sizeof (s->apu_cpu[i]),ARM_CPU_TYPE_NAME ("cortex-a53" ), &error_abort, NULL); + +object_property_set_int (OBJECT (&s->apu_cpu[i]),QEMU_PSCI_CONDUIT_SMC , +"psci-conduit" , &error_abort); +object_property_set_int (OBJECT (&s->apu_cpu[i]),GIC_BASE_ADDR , +"reset-cbar" , &error_abort); } sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic),
@@ -250,6 +255,10 @@ static void xlnx_zynqmp_init(Object *obj)for (i =0 ; i <XLNX_ZYNQMP_NUM_GEMS ; i++) {sysbus_init_child_obj (obj,"gem[*]" , &s->gem[i],sizeof (s->gem[i]),TYPE_CADENCE_GEM ); +object_property_set_int (OBJECT (&s->gem[i]),GEM_REVISION ,"revision" , + &error_abort); +object_property_set_int (OBJECT (&s->gem[i]),2 ,"num-priority-queues" , + &error_abort); }for (i =0 ; i <XLNX_ZYNQMP_NUM_UARTS ; i++) {
@@ -259,6 +268,8 @@ static void xlnx_zynqmp_init(Object *obj)sysbus_init_child_obj (obj,"sata" , &s->sata,sizeof (s->sata),TYPE_SYSBUS_AHCI ); +object_property_set_int (OBJECT (&s->sata),SATA_NUM_PORTS ,"num-ports" , + &error_abort);for (i =0 ; i <XLNX_ZYNQMP_NUM_SDHCI ; i++) { sysbus_init_child_obj(obj, "sdhci[*]", &s->sdhci[i],
@@ -370,9 +381,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i < num_apus; i++) {char *name; -object_property_set_int (OBJECT (&s->apu_cpu[i]),QEMU_PSCI_CONDUIT_SMC , -"psci-conduit" , &error_abort); - name =object_get_canonical_path_component (OBJECT (&s->apu_cpu[i]));if (strcmp (name, boot_cpu)) {/* Secondary CPUs start in PSCI powered-down state */
@@ -387,8 +395,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) s->secure, "has_el3", NULL);object_property_set_bool (OBJECT (&s->apu_cpu[i]), s->virt,"has_el2" ,NULL ); -object_property_set_int (OBJECT (&s->apu_cpu[i]),GIC_BASE_ADDR , -"reset-cbar" , &error_abort);object_property_set_int (OBJECT (&s->apu_cpu[i]), num_apus,"core-count" , &error_abort); object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
@@ -490,10 +496,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)qemu_check_nic_model (nd,TYPE_CADENCE_GEM );qdev_set_nic_properties (DEVICE (&s->gem[i]), nd); } -object_property_set_int (OBJECT (&s->gem[i]),GEM_REVISION ,"revision" , - &error_abort); -object_property_set_int (OBJECT (&s->gem[i]),2 ,"num-priority-queues" , - &error_abort);object_property_set_bool (OBJECT (&s->gem[i]), true,"realized" , &err);if (err) { goto out_propagate_error;
@@ -514,8 +516,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) gic_spi[uart_intr[i]]); } -object_property_set_int (OBJECT (&s->sata),SATA_NUM_PORTS ,"num-ports" , - &error_abort);object_property_set_bool (OBJECT (&s->sata), true,"realized" , &err);if (err) { goto out_propagate_error;
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 16/24] hw/arm/xlnx-zynqmp: Move some code from realize() to init()
Quoted 8 lines · Philippe Mathieu-Daudé
Coccinelle failed at processing this file:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/arm/xlnx-zynqmp.c EXN: Coccinelle_modules.Common.Timeout
Quoted 4 lines
Move the calls using
&error_abortwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 85 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/arm/xlnx-zynqmp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)hw/arm/xlnx-zynqmp.c +11
-12@@ -242,6 +242,11 @@ static void xlnx_zynqmp_init(Object *obj) &s->apu_cpu[i],sizeof (s->apu_cpu[i]),ARM_CPU_TYPE_NAME ("cortex-a53" ), &error_abort, NULL); + +object_property_set_int (OBJECT (&s->apu_cpu[i]),QEMU_PSCI_CONDUIT_SMC , +"psci-conduit" , &error_abort); +object_property_set_int (OBJECT (&s->apu_cpu[i]),GIC_BASE_ADDR , +"reset-cbar" , &error_abort); } sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic),@@ -250,6 +255,10 @@ static void xlnx_zynqmp_init(Object *obj)for (i =0 ; i <XLNX_ZYNQMP_NUM_GEMS ; i++) {sysbus_init_child_obj (obj,"gem[*]" , &s->gem[i],sizeof (s->gem[i]),TYPE_CADENCE_GEM ); +object_property_set_int (OBJECT (&s->gem[i]),GEM_REVISION ,"revision" , + &error_abort); +object_property_set_int (OBJECT (&s->gem[i]),2 ,"num-priority-queues" , + &error_abort); }for (i =0 ; i <XLNX_ZYNQMP_NUM_UARTS ; i++) {@@ -259,6 +268,8 @@ static void xlnx_zynqmp_init(Object *obj)sysbus_init_child_obj (obj,"sata" , &s->sata,sizeof (s->sata),TYPE_SYSBUS_AHCI ); +object_property_set_int (OBJECT (&s->sata),SATA_NUM_PORTS ,"num-ports" , + &error_abort);for (i =0 ; i <XLNX_ZYNQMP_NUM_SDHCI ; i++) { sysbus_init_child_obj(obj, "sdhci[*]", &s->sdhci[i],@@ -370,9 +381,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)for (i =0 ; i < num_apus; i++) {char *name; -object_property_set_int (OBJECT (&s->apu_cpu[i]),QEMU_PSCI_CONDUIT_SMC , -"psci-conduit" , &error_abort); - name =object_get_canonical_path_component (OBJECT (&s->apu_cpu[i]));if (strcmp (name, boot_cpu)) {/* Secondary CPUs start in PSCI powered-down state */ @@ -387,8 +395,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) s->secure, "has_el3", NULL);object_property_set_bool (OBJECT (&s->apu_cpu[i]), s->virt,"has_el2" ,NULL ); -object_property_set_int (OBJECT (&s->apu_cpu[i]),GIC_BASE_ADDR , -"reset-cbar" , &error_abort);object_property_set_int (OBJECT (&s->apu_cpu[i]), num_apus,"core-count" , &error_abort); object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",@@ -490,10 +496,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)qemu_check_nic_model (nd,TYPE_CADENCE_GEM );qdev_set_nic_properties (DEVICE (&s->gem[i]), nd); } -object_property_set_int (OBJECT (&s->gem[i]),GEM_REVISION ,"revision" , - &error_abort); -object_property_set_int (OBJECT (&s->gem[i]),2 ,"num-priority-queues" , - &error_abort);object_property_set_bool (OBJECT (&s->gem[i]), true,"realized" , &err);if (err) { goto out_propagate_error;@@ -514,8 +516,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) gic_spi[uart_intr[i]]); } -object_property_set_int (OBJECT (&s->sata),SATA_NUM_PORTS ,"num-ports" , - &error_abort);object_property_set_bool (OBJECT (&s->sata), true,"realized" , &err);if (err) { goto out_propagate_error; --2.21.1
PATCH v3 17/24 hw/microblaze/xlnx-zynqmp-pmu: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/microblaze/xlnx-zynqmp-pmu.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
xlnx_zynqmp_pmu_soc_init()toxlnx_zynqmp_pmu_soc_realize()in./hw/microblaze/xlnx-zynqmp-pmu.c:79
Move the calls using &error_abort which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/microblaze/xlnx-zynqmp-pmu.c | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-)
hw/microblaze/xlnx-zynqmp-pmu.c +23 -23
@@ -63,24 +63,6 @@ static void xlnx_zynqmp_pmu_soc_init(Object *obj)object_initialize_child (obj,"pmu-cpu" , &s->cpu,sizeof (s->cpu),TYPE_MICROBLAZE_CPU , &error_abort,NULL ); - -sysbus_init_child_obj (obj,"intc" , &s->intc,sizeof (s->intc), -TYPE_XLNX_PMU_IO_INTC ); - -/* Create the IPI device */ -for (int i =0 ; i <XLNX_ZYNQMP_PMU_NUM_IPIS ; i++) { -char *name =g_strdup_printf ("ipi%d" , i); -sysbus_init_child_obj (obj, name, &s->ipi[i], -sizeof (XlnxZynqMPIPI),TYPE_XLNX_ZYNQMP_IPI ); -g_free (name); - } -} - -static void xlnx_zynqmp_pmu_soc_realize (DeviceState *dev,Error **errp) -{ -XlnxZynqMPPMUSoCState *s =XLNX_ZYNQMP_PMU_SOC (dev); -Error *err =NULL ; -object_property_set_uint (OBJECT (&s->cpu),XLNX_ZYNQMP_PMU_ROM_ADDR ,"base-vectors" , &error_abort); object_property_set_bool(OBJECT(&s->cpu), true, "use-stack-protection",
@@ -99,18 +81,36 @@ static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp)object_property_set_str (OBJECT (&s->cpu),"8.40.b" ,"version" , &error_abort);object_property_set_uint (OBJECT (&s->cpu),0 ,"pvr" , &error_abort); -object_property_set_bool (OBJECT (&s->cpu), true,"realized" , &err); -if (err) { -error_propagate (errp, err); -return ; - } +sysbus_init_child_obj (obj,"intc" , &s->intc,sizeof (s->intc), +TYPE_XLNX_PMU_IO_INTC );object_property_set_uint (OBJECT (&s->intc),0x10 ,"intc-intr-size" , &error_abort);object_property_set_uint (OBJECT (&s->intc),0x0 ,"intc-level-edge" , &error_abort);object_property_set_uint (OBJECT (&s->intc),0xffff ,"intc-positive" , &error_abort); + +/* Create the IPI device */ +for (int i =0 ; i <XLNX_ZYNQMP_PMU_NUM_IPIS ; i++) { +char *name =g_strdup_printf ("ipi%d" , i); +sysbus_init_child_obj (obj, name, &s->ipi[i], +sizeof (XlnxZynqMPIPI),TYPE_XLNX_ZYNQMP_IPI ); +g_free (name); + } +} + +static void xlnx_zynqmp_pmu_soc_realize (DeviceState *dev,Error **errp) +{ +XlnxZynqMPPMUSoCState *s =XLNX_ZYNQMP_PMU_SOC (dev); +Error *err =NULL ; + +object_property_set_bool (OBJECT (&s->cpu), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +object_property_set_bool (OBJECT (&s->intc), true,"realized" , &err);if (err) {error_propagate (errp, err);
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 17/24] hw/microblaze/xlnx-zynqmp-pmu: Move some code from realize() to init()
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/microblaze/xlnx-zynqmp-pmu.c
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
xlnx_zynqmp_pmu_soc_init()toxlnx_zynqmp_pmu_soc_realize()in./hw/microblaze/xlnx-zynqmp-pmu.c:79Move the calls using
&error_abortwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 81 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/microblaze/xlnx-zynqmp-pmu.c | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-)hw/microblaze/xlnx-zynqmp-pmu.c +23
-24@@ -63,24 +63,6 @@ static void xlnx_zynqmp_pmu_soc_init(Object *obj)object_initialize_child (obj,"pmu-cpu" , &s->cpu,sizeof (s->cpu),TYPE_MICROBLAZE_CPU , &error_abort,NULL ); - -sysbus_init_child_obj (obj,"intc" , &s->intc,sizeof (s->intc), -TYPE_XLNX_PMU_IO_INTC ); - -/* Create the IPI device */ -for (int i =0 ; i <XLNX_ZYNQMP_PMU_NUM_IPIS ; i++) { -char *name =g_strdup_printf ("ipi%d" , i); -sysbus_init_child_obj (obj, name, &s->ipi[i], -sizeof (XlnxZynqMPIPI),TYPE_XLNX_ZYNQMP_IPI ); -g_free (name); - } -} - -static void xlnx_zynqmp_pmu_soc_realize (DeviceState *dev,Error **errp) -{ -XlnxZynqMPPMUSoCState *s =XLNX_ZYNQMP_PMU_SOC (dev); -Error *err =NULL ; -object_property_set_uint (OBJECT (&s->cpu),XLNX_ZYNQMP_PMU_ROM_ADDR ,"base-vectors" , &error_abort); object_property_set_bool(OBJECT(&s->cpu), true, "use-stack-protection",@@ -99,18 +81,36 @@ static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp)object_property_set_str (OBJECT (&s->cpu),"8.40.b" ,"version" , &error_abort);object_property_set_uint (OBJECT (&s->cpu),0 ,"pvr" , &error_abort); -object_property_set_bool (OBJECT (&s->cpu), true,"realized" , &err); -if (err) { -error_propagate (errp, err); -return ; - } +sysbus_init_child_obj (obj,"intc" , &s->intc,sizeof (s->intc), +TYPE_XLNX_PMU_IO_INTC );object_property_set_uint (OBJECT (&s->intc),0x10 ,"intc-intr-size" , &error_abort);object_property_set_uint (OBJECT (&s->intc),0x0 ,"intc-level-edge" , &error_abort);object_property_set_uint (OBJECT (&s->intc),0xffff ,"intc-positive" , &error_abort); + +/* Create the IPI device */ +for (int i =0 ; i <XLNX_ZYNQMP_PMU_NUM_IPIS ; i++) { +char *name =g_strdup_printf ("ipi%d" , i); +sysbus_init_child_obj (obj, name, &s->ipi[i], +sizeof (XlnxZynqMPIPI),TYPE_XLNX_ZYNQMP_IPI ); +g_free (name); + } +} + +static void xlnx_zynqmp_pmu_soc_realize (DeviceState *dev,Error **errp) +{ +XlnxZynqMPPMUSoCState *s =XLNX_ZYNQMP_PMU_SOC (dev); +Error *err =NULL ; + +object_property_set_bool (OBJECT (&s->cpu), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +object_property_set_bool (OBJECT (&s->intc), true,"realized" , &err);if (err) {error_propagate (errp, err); --2.21.1
PATCH v3 18/24 hw/pci-host/pnv_phb3: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/pci-host/pnv_phb3.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
pnv_phb3_instance_init()topnv_phb3_realize()in./hw/pci-host/pnv_phb3.c:992
Move the calls using &error_abort which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/pci-host/pnv_phb3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/pci-host/pnv_phb3.c +4 -4
@@ -970,6 +970,8 @@ static void pnv_phb3_instance_init(Object *obj)/* LSI sources */ object_initialize_child (obj,"lsi" , &phb->lsis,sizeof (phb->lsis),TYPE_ICS , &error_abort,NULL ); +object_property_set_int (OBJECT (&phb->lsis),PNV_PHB3_NUM_LSI ,"nr-irqs" , + &error_abort);/* Default init ... will be fixed by HW inits */ phb->lsis.offset =0 ;
@@ -977,6 +979,8 @@ static void pnv_phb3_instance_init(Object *obj)/* MSI sources */ object_initialize_child (obj,"msi" , &phb->msis,sizeof (phb->msis),TYPE_PHB3_MSI , &error_abort,NULL ); +object_property_set_int (OBJECT (&phb->msis),PHB3_MAX_MSI ,"nr-irqs" , + &error_abort);/* Power Bus Common Queue */ object_initialize_child(obj, "pbcq", &phb->pbcq, sizeof(phb->pbcq),
@@ -1005,8 +1009,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* LSI sources */ object_property_set_link (OBJECT (&phb->lsis),OBJECT (pnv),"xics" , &error_abort); -object_property_set_int (OBJECT (&phb->lsis),PNV_PHB3_NUM_LSI ,"nr-irqs" , - &error_abort);object_property_set_bool (OBJECT (&phb->lsis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
@@ -1024,8 +1026,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_link (OBJECT (&phb->msis),OBJECT (pnv),"xics" , &error_abort); -object_property_set_int (OBJECT (&phb->msis),PHB3_MAX_MSI ,"nr-irqs" , - &error_abort);object_property_set_bool (OBJECT (&phb->msis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 18/24] hw/pci-host/pnv_phb3: Move some code from realize() to init()
Quoted 11 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/pci-host/pnv_phb3.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
pnv_phb3_instance_init()topnv_phb3_realize()in./hw/pci-host/pnv_phb3.c:992Move the calls using
&error_abortwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 46 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/pci-host/pnv_phb3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/pci-host/pnv_phb3.c +4
-4@@ -970,6 +970,8 @@ static void pnv_phb3_instance_init(Object *obj)/* LSI sources */ object_initialize_child (obj,"lsi" , &phb->lsis,sizeof (phb->lsis),TYPE_ICS , &error_abort,NULL ); +object_property_set_int (OBJECT (&phb->lsis),PNV_PHB3_NUM_LSI ,"nr-irqs" , + &error_abort);/* Default init ... will be fixed by HW inits */ phb->lsis.offset =0 ;@@ -977,6 +979,8 @@ static void pnv_phb3_instance_init(Object *obj)/* MSI sources */ object_initialize_child (obj,"msi" , &phb->msis,sizeof (phb->msis),TYPE_PHB3_MSI , &error_abort,NULL ); +object_property_set_int (OBJECT (&phb->msis),PHB3_MAX_MSI ,"nr-irqs" , + &error_abort);/* Power Bus Common Queue */ object_initialize_child(obj, "pbcq", &phb->pbcq, sizeof(phb->pbcq),@@ -1005,8 +1009,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* LSI sources */ object_property_set_link (OBJECT (&phb->lsis),OBJECT (pnv),"xics" , &error_abort); -object_property_set_int (OBJECT (&phb->lsis),PNV_PHB3_NUM_LSI ,"nr-irqs" , - &error_abort);object_property_set_bool (OBJECT (&phb->lsis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);@@ -1024,8 +1026,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_link (OBJECT (&phb->msis),OBJECT (pnv),"xics" , &error_abort); -object_property_set_int (OBJECT (&phb->msis),PHB3_MAX_MSI ,"nr-irqs" , - &error_abort);object_property_set_bool (OBJECT (&phb->msis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
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: [PATCH-for-5.1 v3 18/24] hw/pci-host/pnv_phb3: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/pci-host/pnv_phb3.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
pnv_phb3_instance_init()topnv_phb3_realize()in./hw/pci-host/pnv_phb3.c:992Move the calls using
&error_abortwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 47 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/pci-host/pnv_phb3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/pci-host/pnv_phb3.c +4
-4@@ -970,6 +970,8 @@ static void pnv_phb3_instance_init(Object *obj)/* LSI sources */ object_initialize_child (obj,"lsi" , &phb->lsis,sizeof (phb->lsis),TYPE_ICS , &error_abort,NULL ); +object_property_set_int (OBJECT (&phb->lsis),PNV_PHB3_NUM_LSI ,"nr-irqs" , + &error_abort);/* Default init ... will be fixed by HW inits */ phb->lsis.offset =0 ;@@ -977,6 +979,8 @@ static void pnv_phb3_instance_init(Object *obj)/* MSI sources */ object_initialize_child (obj,"msi" , &phb->msis,sizeof (phb->msis),TYPE_PHB3_MSI , &error_abort,NULL ); +object_property_set_int (OBJECT (&phb->msis),PHB3_MAX_MSI ,"nr-irqs" , + &error_abort);/* Power Bus Common Queue */ object_initialize_child(obj, "pbcq", &phb->pbcq, sizeof(phb->pbcq),@@ -1005,8 +1009,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)/* LSI sources */ object_property_set_link (OBJECT (&phb->lsis),OBJECT (pnv),"xics" , &error_abort); -object_property_set_int (OBJECT (&phb->lsis),PNV_PHB3_NUM_LSI ,"nr-irqs" , - &error_abort);object_property_set_bool (OBJECT (&phb->lsis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);@@ -1024,8 +1026,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_link (OBJECT (&phb->msis),OBJECT (pnv),"xics" , &error_abort); -object_property_set_int (OBJECT (&phb->msis),PHB3_MAX_MSI ,"nr-irqs" , - &error_abort);object_property_set_bool (OBJECT (&phb->msis), true,"realized" , &local_err);if (local_err) {error_propagate (errp, local_err);
PATCH v3 19/24 hw/riscv/sifive_e: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/riscv/sifive_e.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_e_soc_init()toriscv_sifive_e_soc_realize()in./hw/riscv/sifive_e.c:135
Move the calls using &error_fatal which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/riscv/sifive_e.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
hw/riscv/sifive_e.c +14 -12
@@ -118,7 +118,9 @@ static void riscv_sifive_e_init(MachineState *machine)static void riscv_sifive_e_soc_init (Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ()); +const struct MemmapEntry *memmap = sifive_e_memmap;SiFiveESoCState *s =RISCV_E_SOC (obj); +MemoryRegion *sys_mem =get_system_memory (); object_initialize_child(obj, "cpus", &s->cpus, sizeof(s->cpus), TYPE_RISCV_HART_ARRAY,
@@ -130,6 +132,18 @@ static void riscv_sifive_e_soc_init(Object *obj)sysbus_init_child_obj (obj,"riscv.sifive.e.gpio0" , &s->gpio,sizeof (s->gpio),TYPE_SIFIVE_GPIO ); + +/* Mask ROM */ +memory_region_init_rom (&s->mask_rom, obj,"riscv.sifive.e.mrom" , + memmap[SIFIVE_E_MROM ].size, &error_fatal); +memory_region_add_subregion (sys_mem, + memmap[SIFIVE_E_MROM ].base, &s->mask_rom); + +/* Flash memory */ +memory_region_init_rom (&s->xip_mem, obj,"riscv.sifive.e.xip" , + memmap[SIFIVE_E_XIP ].size, &error_fatal); +memory_region_add_subregion (sys_mem, memmap[SIFIVE_E_XIP ].base, + &s->xip_mem); }static void riscv_sifive_e_soc_realize (DeviceState *dev,Error **errp)
@@ -144,12 +158,6 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->cpus), true,"realized" , &error_abort); -/* Mask ROM */ -memory_region_init_rom (&s->mask_rom,OBJECT (dev),"riscv.sifive.e.mrom" , - memmap[SIFIVE_E_MROM ].size, &error_fatal); -memory_region_add_subregion (sys_mem, - memmap[SIFIVE_E_MROM ].base, &s->mask_rom); -/* MMIO */ s->plic = sifive_plic_create(memmap[SIFIVE_E_PLIC].base, (char *)SIFIVE_E_PLIC_HART_CONFIG,
@@ -206,12 +214,6 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp) memmap[SIFIVE_E_QSPI2].base, memmap[SIFIVE_E_QSPI2].size);create_unimplemented_device ("riscv.sifive.e.pwm2" , memmap[SIFIVE_E_PWM2 ].base, memmap[SIFIVE_E_PWM2 ].size); - -/* Flash memory */ -memory_region_init_rom (&s->xip_mem,OBJECT (dev),"riscv.sifive.e.xip" , - memmap[SIFIVE_E_XIP ].size, &error_fatal); -memory_region_add_subregion (sys_mem, memmap[SIFIVE_E_XIP ].base, - &s->xip_mem); }static void riscv_sifive_e_machine_init (MachineClass *mc)
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 19/24] hw/riscv/sifive_e: Move some code from realize() to init()
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/riscv/sifive_e.c
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_e_soc_init()toriscv_sifive_e_soc_realize()in./hw/riscv/sifive_e.c:135Move the calls using
&error_fatalwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 69 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/riscv/sifive_e.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)hw/riscv/sifive_e.c +14
-13@@ -118,7 +118,9 @@ static void riscv_sifive_e_init(MachineState *machine)static void riscv_sifive_e_soc_init (Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ()); +const struct MemmapEntry *memmap = sifive_e_memmap;SiFiveESoCState *s =RISCV_E_SOC (obj); +MemoryRegion *sys_mem =get_system_memory (); object_initialize_child(obj, "cpus", &s->cpus, sizeof(s->cpus), TYPE_RISCV_HART_ARRAY,@@ -130,6 +132,18 @@ static void riscv_sifive_e_soc_init(Object *obj)sysbus_init_child_obj (obj,"riscv.sifive.e.gpio0" , &s->gpio,sizeof (s->gpio),TYPE_SIFIVE_GPIO ); + +/* Mask ROM */ +memory_region_init_rom (&s->mask_rom, obj,"riscv.sifive.e.mrom" , + memmap[SIFIVE_E_MROM ].size, &error_fatal); +memory_region_add_subregion (sys_mem, + memmap[SIFIVE_E_MROM ].base, &s->mask_rom); + +/* Flash memory */ +memory_region_init_rom (&s->xip_mem, obj,"riscv.sifive.e.xip" , + memmap[SIFIVE_E_XIP ].size, &error_fatal); +memory_region_add_subregion (sys_mem, memmap[SIFIVE_E_XIP ].base, + &s->xip_mem); }static void riscv_sifive_e_soc_realize (DeviceState *dev,Error **errp)@@ -144,12 +158,6 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->cpus), true,"realized" , &error_abort); -/* Mask ROM */ -memory_region_init_rom (&s->mask_rom,OBJECT (dev),"riscv.sifive.e.mrom" , - memmap[SIFIVE_E_MROM ].size, &error_fatal); -memory_region_add_subregion (sys_mem, - memmap[SIFIVE_E_MROM ].base, &s->mask_rom); -/* MMIO */ s->plic = sifive_plic_create(memmap[SIFIVE_E_PLIC].base, (char *)SIFIVE_E_PLIC_HART_CONFIG,@@ -206,12 +214,6 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp) memmap[SIFIVE_E_QSPI2].base, memmap[SIFIVE_E_QSPI2].size);create_unimplemented_device ("riscv.sifive.e.pwm2" , memmap[SIFIVE_E_PWM2 ].base, memmap[SIFIVE_E_PWM2 ].size); - -/* Flash memory */ -memory_region_init_rom (&s->xip_mem,OBJECT (dev),"riscv.sifive.e.xip" , - memmap[SIFIVE_E_XIP ].size, &error_fatal); -memory_region_add_subregion (sys_mem, memmap[SIFIVE_E_XIP ].base, - &s->xip_mem); }static void riscv_sifive_e_machine_init (MachineClass *mc) --2.21.1
PATCH v3 20/24 hw/riscv/sifive_u: Use single type_init()
In reply to Philippe Mathieu-DaudéWe can use a single type_init() to call multiple type_register*().
--- hw/riscv/sifive_u.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
hw/riscv/sifive_u.c +3 -9
@@ -601,13 +601,6 @@ static const TypeInfo riscv_sifive_u_soc_type_info = { .class_init = riscv_sifive_u_soc_class_init, }; -static void riscv_sifive_u_soc_register_types (void ) -{ -type_register_static (&riscv_sifive_u_soc_type_info); -} - -type_init (riscv_sifive_u_soc_register_types) -static void riscv_sifive_u_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -627,9 +620,10 @@ static const TypeInfo riscv_sifive_u_machine_typeinfo = { .instance_size = sizeof(SiFiveUState), }; -static void riscv_sifive_u_machine_init_register_types (void ) +static void riscv_sifive_u_register_types (void ) { +type_register_static (&riscv_sifive_u_soc_type_info);type_register_static (&riscv_sifive_u_machine_typeinfo); } -type_init (riscv_sifive_u_machine_init_register_types) +type_init (riscv_sifive_u_register_types)
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 20/24] hw/riscv/sifive_u: Use single type_init()
Quoted 4 lines · Philippe Mathieu-Daudé
We can use a single
type_init()to call multiple type_register*().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 39 lines
--- hw/riscv/sifive_u.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)hw/riscv/sifive_u.c +3
-10@@ -601,13 +601,6 @@ static const TypeInfo riscv_sifive_u_soc_type_info = { .class_init = riscv_sifive_u_soc_class_init, }; -static void riscv_sifive_u_soc_register_types (void ) -{ -type_register_static (&riscv_sifive_u_soc_type_info); -} - -type_init (riscv_sifive_u_soc_register_types) -static void riscv_sifive_u_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);@@ -627,9 +620,10 @@ static const TypeInfo riscv_sifive_u_machine_typeinfo = { .instance_size = sizeof(SiFiveUState), }; -static void riscv_sifive_u_machine_init_register_types (void ) +static void riscv_sifive_u_register_types (void ) { +type_register_static (&riscv_sifive_u_soc_type_info);type_register_static (&riscv_sifive_u_machine_typeinfo); } -type_init (riscv_sifive_u_machine_init_register_types) +type_init (riscv_sifive_u_register_types) --2.21.1
PATCH v3 21/24 hw/riscv/sifive_u: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/riscv/sifive_u.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_u_soc_init()toriscv_sifive_u_soc_realize()in./hw/riscv/sifive_u.c:473
Move the calls using &error_abort which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/riscv/sifive_u.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/riscv/sifive_u.c +2 -2
@@ -441,6 +441,8 @@ static void riscv_sifive_u_soc_init(Object *obj)qdev_prop_set_uint32 (DEVICE (&s->otp),"serial" ,OTP_SERIAL );sysbus_init_child_obj (obj,"gem" , &s->gem,sizeof (s->gem),TYPE_CADENCE_GEM ); +object_property_set_int (OBJECT (&s->gem),GEM_REVISION ,"revision" , + &error_abort); }static bool sifive_u_get_start_in_flash (Object *obj,Error **errp)
@@ -569,8 +571,6 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)qemu_check_nic_model (nd,TYPE_CADENCE_GEM );qdev_set_nic_properties (DEVICE (&s->gem), nd); } -object_property_set_int (OBJECT (&s->gem),GEM_REVISION ,"revision" , - &error_abort);object_property_set_bool (OBJECT (&s->gem), true,"realized" , &err);if (err) {error_propagate (errp, err);
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 21/24] hw/riscv/sifive_u: Move some code from realize() to init()
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/riscv/sifive_u.c
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_u_soc_init()toriscv_sifive_u_soc_realize()in./hw/riscv/sifive_u.c:473Move the calls using
&error_abortwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 32 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/riscv/sifive_u.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/riscv/sifive_u.c +2
-3@@ -441,6 +441,8 @@ static void riscv_sifive_u_soc_init(Object *obj)qdev_prop_set_uint32 (DEVICE (&s->otp),"serial" ,OTP_SERIAL );sysbus_init_child_obj (obj,"gem" , &s->gem,sizeof (s->gem),TYPE_CADENCE_GEM ); +object_property_set_int (OBJECT (&s->gem),GEM_REVISION ,"revision" , + &error_abort); }static bool sifive_u_get_start_in_flash (Object *obj,Error **errp)@@ -569,8 +571,6 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)qemu_check_nic_model (nd,TYPE_CADENCE_GEM );qdev_set_nic_properties (DEVICE (&s->gem), nd); } -object_property_set_int (OBJECT (&s->gem),GEM_REVISION ,"revision" , - &error_abort);object_property_set_bool (OBJECT (&s->gem), true,"realized" , &err);if (err) {error_propagate (errp, err); --2.21.1
PATCH v3 22/24 hw/riscv/sifive_u: Store MemoryRegion in SiFiveUSoCState
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/riscv/sifive_u.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_u_soc_init()toriscv_sifive_u_soc_realize()in./hw/riscv/sifive_u.c:473
While reviewing we notice storing the MemoryRegion in the device state, we'll be able to later automatically simplify the error propagation calls.
--- include/hw/riscv/sifive_u.h | 2 ++ hw/riscv/sifive_u.c | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-)
include/hw/riscv/sifive_u.h +2 -0
@@ -42,6 +42,8 @@ typedef struct SiFiveUSoCState {SiFiveUPRCIState prci;SiFiveUOTPState otp;CadenceGEMState gem; +MemoryRegion mask_rom; +MemoryRegion l2lim_mem; } SiFiveUSoCState;#define TYPE_RISCV_U_MACHINE MACHINE_TYPE_NAME("sifive_u")
hw/riscv/sifive_u.c +4 -6
@@ -478,8 +478,6 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)SiFiveUSoCState *s =RISCV_U_SOC (dev);const struct MemmapEntry *memmap = sifive_u_memmap;MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *mask_rom =g_new (MemoryRegion,1 ); -MemoryRegion *l2lim_mem =g_new (MemoryRegion,1 );qemu_irq plic_gpios[SIFIVE_U_PLIC_NUM_SOURCES ];char *plic_hart_config;size_t plic_hart_config_len;
@@ -503,10 +501,10 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) &error_abort);/* boot rom */ -memory_region_init_rom (mask_rom,OBJECT (dev),"riscv.sifive.u.mrom" , +memory_region_init_rom (&s->mask_rom,OBJECT (dev),"riscv.sifive.u.mrom" , memmap[SIFIVE_U_MROM ].size, &error_fatal);memory_region_add_subregion (system_memory, memmap[SIFIVE_U_MROM ].base, - mask_rom); + &s->mask_rom);/* * Add L2-LIM at reset size.
@@ -517,10 +515,10 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)* leave it enabled all the time. This won't break anything, but will be * too generous to misbehaving guests. */ -memory_region_init_ram (l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , +memory_region_init_ram (&s->l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , memmap[SIFIVE_U_L2LIM ].size, &error_fatal);memory_region_add_subregion (system_memory, memmap[SIFIVE_U_L2LIM ].base, - l2lim_mem); + &s->l2lim_mem);/* create PLIC hart topology configuration string */ plic_hart_config_len = (strlen(SIFIVE_U_PLIC_HART_CONFIG) + 1) *
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 22/24] hw/riscv/sifive_u: Store MemoryRegion in SiFiveUSoCState
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/riscv/sifive_u.c
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_u_soc_init()toriscv_sifive_u_soc_realize()in./hw/riscv/sifive_u.c:473While reviewing we notice storing the MemoryRegion in the device state, we'll be able to later automatically simplify the error propagation calls.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 61 lines
--- include/hw/riscv/sifive_u.h | 2 ++ hw/riscv/sifive_u.c | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-)include/hw/riscv/sifive_u.h +2
-0@@ -42,6 +42,8 @@ typedef struct SiFiveUSoCState {SiFiveUPRCIState prci;SiFiveUOTPState otp;CadenceGEMState gem; +MemoryRegion mask_rom; +MemoryRegion l2lim_mem; } SiFiveUSoCState;#define TYPE_RISCV_U_MACHINE MACHINE_TYPE_NAME("sifive_u")hw/riscv/sifive_u.c +4
-7@@ -478,8 +478,6 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)SiFiveUSoCState *s =RISCV_U_SOC (dev);const struct MemmapEntry *memmap = sifive_u_memmap;MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *mask_rom =g_new (MemoryRegion,1 ); -MemoryRegion *l2lim_mem =g_new (MemoryRegion,1 );qemu_irq plic_gpios[SIFIVE_U_PLIC_NUM_SOURCES ];char *plic_hart_config;size_t plic_hart_config_len;@@ -503,10 +501,10 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) &error_abort);/* boot rom */ -memory_region_init_rom (mask_rom,OBJECT (dev),"riscv.sifive.u.mrom" , +memory_region_init_rom (&s->mask_rom,OBJECT (dev),"riscv.sifive.u.mrom" , memmap[SIFIVE_U_MROM ].size, &error_fatal);memory_region_add_subregion (system_memory, memmap[SIFIVE_U_MROM ].base, - mask_rom); + &s->mask_rom);/* * Add L2-LIM at reset size. @@ -517,10 +515,10 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)* leave it enabled all the time. This won't break anything, but will be * too generous to misbehaving guests. */ -memory_region_init_ram (l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , +memory_region_init_ram (&s->l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , memmap[SIFIVE_U_L2LIM ].size, &error_fatal);memory_region_add_subregion (system_memory, memmap[SIFIVE_U_L2LIM ].base, - l2lim_mem); + &s->l2lim_mem);/* create PLIC hart topology configuration string */ plic_hart_config_len = (strlen(SIFIVE_U_PLIC_HART_CONFIG) + 1) * --2.21.1
PATCH v3 23/24 hw/riscv/sifive_u: Move some code from realize() to init()
In reply to Philippe Mathieu-DaudéCoccinelle reported:
$ spatch ... --timeout 60 --sp-file \
scripts/coccinelle/simplify-init-realize-error_propagate.cocci
HANDLING: ./hw/riscv/sifive_u.cQuoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_u_soc_init()toriscv_sifive_u_soc_realize()in./hw/riscv/sifive_u.c:473
Move the calls using &error_abort which don't depend on input updated before realize() to init().
---
v3: Typo 'depend of' -> 'depend on' (eblake)
--- hw/riscv/sifive_u.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
hw/riscv/sifive_u.c +22 -20
@@ -406,6 +406,8 @@ static void riscv_sifive_u_init(MachineState *machine)static void riscv_sifive_u_soc_init (Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ()); +const struct MemmapEntry *memmap = sifive_u_memmap; +MemoryRegion *system_memory =get_system_memory ();SiFiveUSoCState *s =RISCV_U_SOC (obj); object_initialize_child(obj, "e-cluster", &s->e_cluster,
@@ -443,6 +445,26 @@ static void riscv_sifive_u_soc_init(Object *obj) TYPE_CADENCE_GEM);object_property_set_int (OBJECT (&s->gem),GEM_REVISION ,"revision" , &error_abort); + +/* boot rom */ +memory_region_init_rom (&s->mask_rom, obj,"riscv.sifive.u.mrom" , + memmap[SIFIVE_U_MROM ].size, &error_fatal); +memory_region_add_subregion (system_memory, memmap[SIFIVE_U_MROM ].base, + &s->mask_rom); + +/* +* Add L2-LIM at reset size. +* This should be reduced in size as the L2 Cache Controller WayEnable +* register is incremented. Unfortunately I don't see a nice (or any) way +* to handle reducing or blocking out the L2 LIM while still allowing it +* be re returned to all enabled after a reset. For the time being, just +* leave it enabled all the time. This won't break anything, but will be +* too generous to misbehaving guests. +*/ +memory_region_init_ram (&s->l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , + memmap[SIFIVE_U_L2LIM ].size, &error_fatal); +memory_region_add_subregion (system_memory, memmap[SIFIVE_U_L2LIM ].base, + &s->l2lim_mem); }static bool sifive_u_get_start_in_flash (Object *obj,Error **errp)
@@ -500,26 +522,6 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->u_cluster), true,"realized" , &error_abort); -/* boot rom */ -memory_region_init_rom (&s->mask_rom,OBJECT (dev),"riscv.sifive.u.mrom" , - memmap[SIFIVE_U_MROM ].size, &error_fatal); -memory_region_add_subregion (system_memory, memmap[SIFIVE_U_MROM ].base, - &s->mask_rom); - -/* -* Add L2-LIM at reset size. -* This should be reduced in size as the L2 Cache Controller WayEnable -* register is incremented. Unfortunately I don't see a nice (or any) way -* to handle reducing or blocking out the L2 LIM while still allowing it -* be re returned to all enabled after a reset. For the time being, just -* leave it enabled all the time. This won't break anything, but will be -* too generous to misbehaving guests. -*/ -memory_region_init_ram (&s->l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , - memmap[SIFIVE_U_L2LIM ].size, &error_fatal); -memory_region_add_subregion (system_memory, memmap[SIFIVE_U_L2LIM ].base, - &s->l2lim_mem); -/* create PLIC hart topology configuration string */ plic_hart_config_len = (strlen (SIFIVE_U_PLIC_HART_CONFIG ) +1 ) * ms->smp.cpus;
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 23/24] hw/riscv/sifive_u: Move some code from realize() to init()
Quoted 6 lines · Philippe Mathieu-Daudé
Coccinelle reported:
$ spatch ... --timeout 60 --sp-file \ scripts/coccinelle/simplify-init-realize-error_propagate.cocci HANDLING: ./hw/riscv/sifive_u.c
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
possible moves from
riscv_sifive_u_soc_init()toriscv_sifive_u_soc_realize()in./hw/riscv/sifive_u.c:473Move the calls using
&error_abortwhich don't depend on input updated beforerealize()toinit().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 77 lines
---
v3: Typo 'depend of' -> 'depend on' (eblake)--- hw/riscv/sifive_u.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)hw/riscv/sifive_u.c +22
-21@@ -406,6 +406,8 @@ static void riscv_sifive_u_init(MachineState *machine)static void riscv_sifive_u_soc_init (Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ()); +const struct MemmapEntry *memmap = sifive_u_memmap; +MemoryRegion *system_memory =get_system_memory ();SiFiveUSoCState *s =RISCV_U_SOC (obj); object_initialize_child(obj, "e-cluster", &s->e_cluster,@@ -443,6 +445,26 @@ static void riscv_sifive_u_soc_init(Object *obj) TYPE_CADENCE_GEM);object_property_set_int (OBJECT (&s->gem),GEM_REVISION ,"revision" , &error_abort); + +/* boot rom */ +memory_region_init_rom (&s->mask_rom, obj,"riscv.sifive.u.mrom" , + memmap[SIFIVE_U_MROM ].size, &error_fatal); +memory_region_add_subregion (system_memory, memmap[SIFIVE_U_MROM ].base, + &s->mask_rom); + +/* +* Add L2-LIM at reset size. +* This should be reduced in size as the L2 Cache Controller WayEnable +* register is incremented. Unfortunately I don't see a nice (or any) way +* to handle reducing or blocking out the L2 LIM while still allowing it +* be re returned to all enabled after a reset. For the time being, just +* leave it enabled all the time. This won't break anything, but will be +* too generous to misbehaving guests. +*/ +memory_region_init_ram (&s->l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , + memmap[SIFIVE_U_L2LIM ].size, &error_fatal); +memory_region_add_subregion (system_memory, memmap[SIFIVE_U_L2LIM ].base, + &s->l2lim_mem); }static bool sifive_u_get_start_in_flash (Object *obj,Error **errp)@@ -500,26 +522,6 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->u_cluster), true,"realized" , &error_abort); -/* boot rom */ -memory_region_init_rom (&s->mask_rom,OBJECT (dev),"riscv.sifive.u.mrom" , - memmap[SIFIVE_U_MROM ].size, &error_fatal); -memory_region_add_subregion (system_memory, memmap[SIFIVE_U_MROM ].base, - &s->mask_rom); - -/* -* Add L2-LIM at reset size. -* This should be reduced in size as the L2 Cache Controller WayEnable -* register is incremented. Unfortunately I don't see a nice (or any) way -* to handle reducing or blocking out the L2 LIM while still allowing it -* be re returned to all enabled after a reset. For the time being, just -* leave it enabled all the time. This won't break anything, but will be -* too generous to misbehaving guests. -*/ -memory_region_init_ram (&s->l2lim_mem,NULL ,"riscv.sifive.u.l2lim" , - memmap[SIFIVE_U_L2LIM ].size, &error_fatal); -memory_region_add_subregion (system_memory, memmap[SIFIVE_U_L2LIM ].base, - &s->l2lim_mem); -/* create PLIC hart topology configuration string */ plic_hart_config_len = (strlen (SIFIVE_U_PLIC_HART_CONFIG ) +1 ) * ms->smp.cpus; --2.21.1
PATCH v3 24/24 hw/riscv/sifive_u: Rename MachineClass::init()
In reply to Philippe Mathieu-DaudéAs there already is the riscv_sifive_u_soc_init() method, rename riscv_sifive_u_init() as riscv_sifive_u_machine_init().
--- hw/riscv/sifive_u.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/riscv/sifive_u.c +2 -2
@@ -312,7 +312,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,g_free (nodename); } -static void riscv_sifive_u_init (MachineState *machine) +static void riscv_sifive_u_machine_init (MachineState *machine) {const struct MemmapEntry *memmap = sifive_u_memmap;SiFiveUState *s =RISCV_U_MACHINE (machine);
@@ -606,7 +606,7 @@ static void riscv_sifive_u_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="RISC-V Board compatible with SiFive U SDK" ; - mc->init = riscv_sifive_u_init; + mc->init = riscv_sifive_u_machine_init; mc->max_cpus =SIFIVE_U_MANAGEMENT_CPU_COUNT +SIFIVE_U_COMPUTE_CPU_COUNT ; mc->min_cpus =SIFIVE_U_MANAGEMENT_CPU_COUNT +1 ; mc->default_cpus = mc->min_cpus;
Signature · 1 line
2.21.1
Re: [PATCH-for-5.1 v3 24/24] hw/riscv/sifive_u: Rename MachineClass::init()
Quoted 5 lines · Philippe Mathieu-Daudé
As there already is the
riscv_sifive_u_soc_init()method, renameriscv_sifive_u_init()asriscv_sifive_u_machine_init().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 30 lines
--- hw/riscv/sifive_u.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/riscv/sifive_u.c +2
-3@@ -312,7 +312,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,g_free (nodename); } -static void riscv_sifive_u_init (MachineState *machine) +static void riscv_sifive_u_machine_init (MachineState *machine) {const struct MemmapEntry *memmap = sifive_u_memmap;SiFiveUState *s =RISCV_U_MACHINE (machine);@@ -606,7 +606,7 @@ static void riscv_sifive_u_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="RISC-V Board compatible with SiFive U SDK" ; - mc->init = riscv_sifive_u_init; + mc->init = riscv_sifive_u_machine_init; mc->max_cpus =SIFIVE_U_MANAGEMENT_CPU_COUNT +SIFIVE_U_COMPUTE_CPU_COUNT ; mc->min_cpus =SIFIVE_U_MANAGEMENT_CPU_COUNT +1 ; mc->default_cpus = mc->min_cpus; --2.21.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
RAMBlock "sram A" already registered, abort!
Broken pipe/tmp/qemu-test/src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)
ERROR - too few tests run (expected 6, got 5)
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 179
TEST iotest-qcow2: 181
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=abc4f09082a8440eb816686d7f9d7a98', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-99kbwerb/src/docker-src.2020-04-12-20.27.23.7092:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=abc4f09082a8440eb816686d7f9d7a98
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-99kbwerb/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 12m32.887s
user 0m9.441s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]