From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Sagar Karandikar" <sagark@eecs.berkeley.edu>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jeff Cody" <codyprime@gmail.com>,
"Jason Wang" <jasowang@redhat.com>,
"Alistair Francis" <Alistair.Francis@wdc.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
qemu-block@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Max Reitz" <mreitz@redhat.com>, "Joel Stanley" <joel@jms.id.au>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Xie Changlong" <xiechanglong.d@gmail.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Beniamino Galvani" <b.galvani@gmail.com>,
qemu-arm@nongnu.org, "Peter Chubb" <peter.chubb@nicta.com.au>,
"Cédric Le Goater" <clg@kaod.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Kevin Wolf" <kwolf@redhat.com>,
qemu-riscv@nongnu.org, "Andrew Jeffery" <andrew@aj.id.au>,
"Wen Congyang" <wencongyang2@huawei.com>,
"Jean-Christophe Dubois" <jcd@tribudubois.net>,
qemu-ppc@nongnu.org,
"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH-for-5.1 v3 03/24] hw/arm/allwinner-a10: Move some code from realize() to init()
Date: Mon, 13 Apr 2020 23:02:06 +0200 [thread overview]
Message-ID: <effeb6fb-57b6-3b5c-f9b3-c7d2f7541532@amsat.org> (raw)
In-Reply-To: <20200412223619.11284-4-f4bug@amsat.org>
On 4/13/20 12:35 AM, Philippe Mathieu-Daudé wrote:
> Coccinelle reported:
>
> $ spatch ... --timeout 60 --sp-file \
> scripts/coccinelle/simplify-init-realize-error_propagate.cocci
> HANDLING: ./hw/arm/allwinner-a10.c
> >>> possible moves from aw_a10_init() to aw_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().
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> v3: Typo 'depend of' -> 'depend on' (eblake)
> ---
> hw/arm/allwinner-a10.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 62a67a3e1a..f41395734a 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -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);
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
> + 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,
>
next prev parent reply other threads:[~2020-04-13 21:03 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-12 22:35 [PATCH-for-5.1 v3 00/24] various: Fix error-propagation with Coccinelle scripts (part 1) Philippe Mathieu-Daudé
2020-04-12 22:35 ` [PATCH-for-5.1 v3 01/24] various: Remove suspicious '\' character outside of #define in C code Philippe Mathieu-Daudé
2020-04-13 15:56 ` Alistair Francis
2020-04-14 2:08 ` David Gibson
2020-04-29 6:03 ` Markus Armbruster
2020-04-12 22:35 ` [PATCH-for-5.1 v3 02/24] scripts/coccinelle: Script to simplify DeviceClass error propagation Philippe Mathieu-Daudé
2020-04-14 12:24 ` Markus Armbruster
2020-04-14 12:30 ` Philippe Mathieu-Daudé
2020-04-14 13:17 ` Markus Armbruster
2020-04-15 6:16 ` Philippe Mathieu-Daudé
2020-04-12 22:35 ` [PATCH-for-5.1 v3 03/24] hw/arm/allwinner-a10: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 21:02 ` Philippe Mathieu-Daudé [this message]
2020-04-12 22:35 ` [PATCH-for-5.1 v3 04/24] hw/arm/aspeed_ast2600: Simplify use of Error* Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 05/24] hw/arm/aspeed_ast2600: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-15 7:50 ` Cédric Le Goater
2020-04-12 22:36 ` [PATCH-for-5.1 v3 06/24] hw/arm/aspeed_soc: " Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 07/24] hw/arm/aspeed_soc: Simplify use of Error* Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 08/24] hw/arm/fsl-imx6: Simplify checks on 'smp_cpus' count Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 09/24] hw/arm/fsl-imx6: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 10/24] hw/arm/fsl-imx31: " Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 11/24] hw/arm/msf2-soc: Store MemoryRegion in MSF2State Philippe Mathieu-Daudé
2020-04-13 21:59 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 12/24] hw/arm/stm32f205_soc: Store MemoryRegion in STM32F205State Philippe Mathieu-Daudé
2020-04-13 22:00 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 13/24] hw/arm/stm32f205_soc: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:02 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 14/24] hw/arm/xlnx-zynqmp: Use single propagate_error() call Philippe Mathieu-Daudé
2020-04-13 22:05 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 15/24] hw/arm/xlnx-zynqmp: Split xlnx_zynqmp_create_rpu() as init + realize Philippe Mathieu-Daudé
2020-04-12 22:36 ` [PATCH-for-5.1 v3 16/24] hw/arm/xlnx-zynqmp: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:06 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 17/24] hw/microblaze/xlnx-zynqmp-pmu: " Philippe Mathieu-Daudé
2020-04-13 22:19 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 18/24] hw/pci-host/pnv_phb3: " Philippe Mathieu-Daudé
2020-04-14 2:10 ` David Gibson
2020-04-15 7:51 ` Cédric Le Goater
2020-04-12 22:36 ` [PATCH-for-5.1 v3 19/24] hw/riscv/sifive_e: " Philippe Mathieu-Daudé
2020-04-13 22:20 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 20/24] hw/riscv/sifive_u: Use single type_init() Philippe Mathieu-Daudé
2020-04-13 22:10 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 21/24] hw/riscv/sifive_u: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:16 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 22/24] hw/riscv/sifive_u: Store MemoryRegion in SiFiveUSoCState Philippe Mathieu-Daudé
2020-04-13 22:14 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 23/24] hw/riscv/sifive_u: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-13 22:15 ` Alistair Francis
2020-04-12 22:36 ` [PATCH-for-5.1 v3 24/24] hw/riscv/sifive_u: Rename MachineClass::init() Philippe Mathieu-Daudé
2020-04-13 22:14 ` Alistair Francis
2020-04-13 0:39 ` [PATCH-for-5.1 v3 00/24] various: Fix error-propagation with Coccinelle scripts (part 1) no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=effeb6fb-57b6-3b5c-f9b3-c7d2f7541532@amsat.org \
--to=f4bug@amsat.org \
--cc=Alistair.Francis@wdc.com \
--cc=alistair@alistair23.me \
--cc=andrew@aj.id.au \
--cc=armbru@redhat.com \
--cc=b.galvani@gmail.com \
--cc=clg@kaod.org \
--cc=codyprime@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=fam@euphon.net \
--cc=jasowang@redhat.com \
--cc=jcd@tribudubois.net \
--cc=joel@jms.id.au \
--cc=kbastian@mail.uni-paderborn.de \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.chubb@nicta.com.au \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=rth@twiddle.net \
--cc=sagark@eecs.berkeley.edu \
--cc=sundeep.lkml@gmail.com \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).