qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Jean-Christophe Dubois" <jcd@tribudubois.net>,
	qemu-ppc@nongnu.org,
	"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH-for-5.1 v3 09/24] hw/arm/fsl-imx6: Move some code from realize() to init()
Date: Mon, 13 Apr 2020 00:36:04 +0200	[thread overview]
Message-ID: <20200412223619.11284-10-f4bug@amsat.org> (raw)
In-Reply-To: <20200412223619.11284-1-f4bug@amsat.org>

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.Timeout

While 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.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/fsl-imx6.c | 47 +++++++++++++++++++++++------------------------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 3d37352b08..6bf8aa0404 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -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);
-- 
2.21.1



  parent reply	other threads:[~2020-04-12 22:40 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é
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 ` Philippe Mathieu-Daudé [this message]
2020-04-12 22:36 ` [PATCH-for-5.1 v3 10/24] hw/arm/fsl-imx31: Move some code from realize() to init() 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=20200412223619.11284-10-f4bug@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).