All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"open list:Xilinx ZynqMP" <qemu-arm@nongnu.org>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: [PATCH-for-5.1 v2 15/54] hw/arm/xlnx-zynqmp: Split xlnx_zynqmp_create_rpu() as init + realize
Date: Mon,  6 Apr 2020 19:47:04 +0200	[thread overview]
Message-ID: <20200406174743.16956-16-f4bug@amsat.org> (raw)
In-Reply-To: <20200406174743.16956-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/xlnx-zynqmp.c
  EXN: Coccinelle_modules.Common.Timeout

We 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().

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/xlnx-zynqmp.c | 45 +++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index 43d57fa7de..457057198a 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -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) {
-- 
2.21.1



  parent reply	other threads:[~2020-04-06 18:03 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 17:46 [PATCH-for-5.1 v2 00/54] various: Fix error-propagation with Coccinelle scripts Philippe Mathieu-Daudé
2020-04-06 17:46 ` [PATCH-for-5.1 v2 01/54] various: Remove suspicious '\' character outside of #define in C code Philippe Mathieu-Daudé
2020-04-06 17:46   ` Philippe Mathieu-Daudé
2020-04-06 17:57   ` Marc-André Lureau
2020-04-06 17:57     ` Marc-André Lureau
2020-04-06 17:46 ` [PATCH-for-5.1 v2 02/54] scripts/coccinelle: Script to simplify DeviceClass error propagation Philippe Mathieu-Daudé
2020-04-06 17:46 ` [PATCH-for-5.1 v2 03/54] hw/arm/allwinner-a10: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-06 18:00   ` Eric Blake
2020-04-12 22:28     ` Philippe Mathieu-Daudé
2020-04-06 17:46 ` [PATCH-for-5.1 v2 04/54] hw/arm/aspeed_ast2600: Simplify use of Error* Philippe Mathieu-Daudé
2020-04-07  6:46   ` Cédric Le Goater
2020-04-06 17:46 ` [PATCH-for-5.1 v2 05/54] hw/arm/aspeed_ast2600: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-06 17:46 ` [PATCH-for-5.1 v2 06/54] hw/arm/aspeed_soc: " Philippe Mathieu-Daudé
2020-04-07  6:47   ` Cédric Le Goater
2020-04-06 17:46 ` [PATCH-for-5.1 v2 07/54] hw/arm/aspeed_soc: Simplify use of Error* Philippe Mathieu-Daudé
2020-04-07  6:47   ` Cédric Le Goater
2020-04-06 17:46 ` [PATCH-for-5.1 v2 08/54] hw/arm/fsl-imx6: Simplify checks on 'smp_cpus' count Philippe Mathieu-Daudé
2020-04-06 17:46 ` [PATCH-for-5.1 v2 09/54] hw/arm/fsl-imx6: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-06 17:46 ` [PATCH-for-5.1 v2 10/54] hw/arm/fsl-imx31: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 11/54] hw/arm/msf2-soc: Store MemoryRegion in MSF2State Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 12/54] hw/arm/stm32f205_soc: Store MemoryRegion in STM32F205State Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 13/54] hw/arm/stm32f205_soc: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 14/54] hw/arm/xlnx-zynqmp: Use single propagate_error() call Philippe Mathieu-Daudé
2020-04-06 17:47 ` Philippe Mathieu-Daudé [this message]
2020-04-06 17:47 ` [PATCH-for-5.1 v2 16/54] hw/arm/xlnx-zynqmp: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 17/54] hw/microblaze/xlnx-zynqmp-pmu: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 18/54] hw/pci-host/pnv_phb3: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 19/54] hw/riscv/sifive_e: " Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 20/54] hw/riscv/sifive_u: Use single type_init() Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 21/54] hw/riscv/sifive_u: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 22/54] hw/riscv/sifive_u: Store MemoryRegion in SiFiveUSoCState Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 23/54] hw/riscv/sifive_u: Move some code from realize() to init() Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 24/54] hw/riscv/sifive_u: Rename MachineClass::init() Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 25/54] scripts/coccinelle: Catch missing error_propagate() calls in realize() Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 26/54] hw/arm/fsl-imx: Add missing error-propagation code Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 27/54] hw/arm/stm32f*05_soc: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 28/54] hw/arm/aspeed: " Philippe Mathieu-Daudé
2020-04-07  6:47   ` Cédric Le Goater
2020-04-06 17:47 ` [PATCH-for-5.1 v2 29/54] hw/arm/allwinner-a10: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 30/54] hw/arm/msf2-soc: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 31/54] hw/riscv/sifive: " Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 32/54] hw/arm/armv7m: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 33/54] hw/intc/arm_gicv3_its_kvm: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 34/54] hw/microblaze/xlnx-zynqmp-pmu: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 35/54] hw/pci-host/pnv_phb3: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 36/54] hw/block/onenand: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 37/54] scripts/coccinelle: Add script to catch missing error_propagate() calls Philippe Mathieu-Daudé
2020-04-06 20:06   ` Eric Blake
2020-04-06 17:47 ` [PATCH-for-5.1 v2 38/54] hw/arm/bcm2835_peripherals: Add missing error-propagation code Philippe Mathieu-Daudé
2020-04-06 17:55   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 39/54] hw/arm/fsl-imx: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 40/54] hw/arm/stm32fx05_soc: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 41/54] hw/dma/xilinx_axidma: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 42/54] hw/i386/x86: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 43/54] hw/mips/cps: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 44/54] hw/misc/macio/macio: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 45/54] hw/net/xilinx_axienet: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 46/54] hw/riscv/sifive_u: " Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 47/54] hw/sd/milkymist-memcard: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 48/54] scripts/coccinelle: Use &error_abort in TypeInfo::instance_init() Philippe Mathieu-Daudé
2020-04-07  7:07   ` Vladimir Sementsov-Ogievskiy
2020-04-07 11:03     ` Philippe Mathieu-Daudé
2020-04-07 13:01       ` Vladimir Sementsov-Ogievskiy
2020-04-07 13:07         ` Philippe Mathieu-Daudé
2020-04-07 17:27           ` Philippe Mathieu-Daudé
2020-04-07 17:54             ` Vladimir Sementsov-Ogievskiy
2020-04-07 18:16               ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 49/54] various: Use &error_abort in instance_init() Philippe Mathieu-Daudé
2020-04-06 17:47   ` Philippe Mathieu-Daudé
2020-04-06 18:19   ` Philippe Mathieu-Daudé
2020-04-06 18:19     ` Philippe Mathieu-Daudé
2020-04-07  6:47   ` Cédric Le Goater
2020-04-07  6:47     ` Cédric Le Goater
2020-04-07 13:27   ` Cornelia Huck
2020-04-07 13:27     ` Cornelia Huck
2020-04-06 17:47 ` [PATCH-for-5.1 v2 50/54] scripts/coccinelle: Find eventually missing error_propagate() calls Philippe Mathieu-Daudé
2020-04-07  7:15   ` Vladimir Sementsov-Ogievskiy
2020-04-06 17:47 ` [PATCH-for-5.1 v2 51/54] migration/colo: Add missing error-propagation code Philippe Mathieu-Daudé
2020-04-07  7:10   ` Juan Quintela
2020-04-06 17:47 ` [PATCH-for-5.1 v2 52/54] hw/mips/boston: " Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 53/54] hw/mips/mips_malta: " Philippe Mathieu-Daudé
2020-04-06 19:27   ` Philippe Mathieu-Daudé
2020-04-07 18:36   ` Richard Henderson
2020-04-12 22:28     ` Philippe Mathieu-Daudé
2020-04-06 17:47 ` [PATCH-for-5.1 v2 54/54] qga/commands-win32: " Philippe Mathieu-Daudé
2020-04-06 20:34 ` [PATCH-for-5.1 v2 00/54] various: Fix error-propagation with Coccinelle scripts no-reply
2020-04-06 20:39 ` 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=20200406174743.16956-16-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alistair@alistair23.me \
    --cc=armbru@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.