qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] hw/arm: Cleanups before pflash refactor
@ 2023-01-09 11:53 Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 01/13] hw/arm/pxa2xx: Simplify pxa255_init() Philippe Mathieu-Daudé
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

Various trivial cleanups:
- Remove unnecessary sysmem argument from pxa2xx_init()
- Use IEC binary prefix definitions
- Remove unreachable code calling pflash_cfi01_register()
  (another use in PPC sam460ex will be removed separately).

Philippe Mathieu-Daudé (13):
  hw/arm/pxa2xx: Simplify pxa255_init()
  hw/arm/pxa2xx: Simplify pxa270_init()
  hw/arm/collie: Use the IEC binary prefix definitions
  hw/arm/collie: Simplify flash creation using for() loop
  hw/arm/gumstix: Improve documentation
  hw/arm/gumstix: Use the IEC binary prefix definitions
  hw/arm/mainstone: Use the IEC binary prefix definitions
  hw/arm/musicpal: Use the IEC binary prefix definitions
  hw/arm/omap_sx1: Remove unused 'total_ram' definitions
  hw/arm/omap_sx1: Use the IEC binary prefix definitions
  hw/arm/z2: Use the IEC binary prefix definitions
  hw/arm/vexpress: Remove dead code in vexpress_common_init()
  hw/arm: Remove unreachable code calling pflash_cfi01_register()

 hw/arm/collie.c      | 25 +++++++++++-----------
 hw/arm/gumstix.c     | 45 +++++++++++++++++---------------------
 hw/arm/mainstone.c   | 37 +++++++++++++++-----------------
 hw/arm/musicpal.c    |  9 +++++---
 hw/arm/omap_sx1.c    | 51 +++++++++++++++++++-------------------------
 hw/arm/pxa2xx.c      |  8 ++++---
 hw/arm/spitz.c       |  6 ++----
 hw/arm/tosa.c        |  2 +-
 hw/arm/versatilepb.c |  6 ++----
 hw/arm/vexpress.c    | 10 +--------
 hw/arm/z2.c          | 16 ++++++--------
 include/hw/arm/pxa.h |  5 ++---
 12 files changed, 98 insertions(+), 122 deletions(-)

-- 
2.38.1



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/13] hw/arm/pxa2xx: Simplify pxa255_init()
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 02/13] hw/arm/pxa2xx: Simplify pxa270_init() Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

Since pxa255_init() must map the device in the system memory,
there is no point in passing get_system_memory() by argument.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/gumstix.c     | 3 +--
 hw/arm/pxa2xx.c      | 4 +++-
 hw/arm/tosa.c        | 2 +-
 include/hw/arm/pxa.h | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 3a4bc332c4..c167518a46 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -51,12 +51,11 @@ static void connex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
     uint32_t connex_rom = 0x01000000;
     uint32_t connex_ram = 0x04000000;
 
-    cpu = pxa255_init(address_space_mem, connex_ram);
+    cpu = pxa255_init(connex_ram);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 93dda83d7a..8b8845fc63 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -11,6 +11,7 @@
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "qapi/error.h"
+#include "exec/address-spaces.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
 #include "migration/vmstate.h"
@@ -2230,8 +2231,9 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
 }
 
 /* Initialise a PXA255 integrated chip (ARM based core).  */
-PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
+PXA2xxState *pxa255_init(unsigned int sdram_size)
 {
+    MemoryRegion *address_space = get_system_memory();
     PXA2xxState *s;
     int i;
     DriveInfo *dinfo;
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index d5a6763cf9..3ca2e4459c 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -242,7 +242,7 @@ static void tosa_init(MachineState *machine)
     TC6393xbState *tmio;
     DeviceState *scp0, *scp1;
 
-    mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
+    mpu = pxa255_init(tosa_binfo.ram_size);
 
     memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
     memory_region_add_subregion(address_space_mem, 0, rom);
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
index 1095504b86..c26007e57f 100644
--- a/include/hw/arm/pxa.h
+++ b/include/hw/arm/pxa.h
@@ -195,6 +195,6 @@ struct PXA2xxI2SState {
 
 PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size,
                          const char *revision);
-PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size);
+PXA2xxState *pxa255_init(unsigned int sdram_size);
 
 #endif /* PXA_H */
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/13] hw/arm/pxa2xx: Simplify pxa270_init()
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 01/13] hw/arm/pxa2xx: Simplify pxa255_init() Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 03/13] hw/arm/collie: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

Since pxa270_init() must map the device in the system memory,
there is no point in passing get_system_memory() by argument.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/gumstix.c     |  3 +--
 hw/arm/mainstone.c   | 10 ++++------
 hw/arm/pxa2xx.c      |  4 ++--
 hw/arm/spitz.c       |  6 ++----
 hw/arm/z2.c          |  3 +--
 include/hw/arm/pxa.h |  3 +--
 6 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index c167518a46..ab9b0182f6 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -80,12 +80,11 @@ static void verdex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
     uint32_t verdex_rom = 0x02000000;
     uint32_t verdex_ram = 0x10000000;
 
-    cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
+    cpu = pxa270_init(verdex_ram, machine->cpu_type);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index 8454b65458..f6293c6c13 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -108,8 +108,7 @@ static struct arm_boot_info mainstone_binfo = {
     .ram_size = 0x04000000,
 };
 
-static void mainstone_common_init(MemoryRegion *address_space_mem,
-                                  MachineState *machine,
+static void mainstone_common_init(MachineState *machine,
                                   enum mainstone_model_e model, int arm_id)
 {
     uint32_t sector_len = 256 * 1024;
@@ -121,11 +120,10 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
     MemoryRegion *rom = g_new(MemoryRegion, 1);
 
     /* Setup CPU & memory */
-    mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
-                      machine->cpu_type);
+    mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type);
     memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
                            &error_fatal);
-    memory_region_add_subregion(address_space_mem, 0, rom);
+    memory_region_add_subregion(get_system_memory(), 0x00000000, rom);
 
     /* There are two 32MiB flash devices on the board */
     for (i = 0; i < 2; i ++) {
@@ -165,7 +163,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
 
 static void mainstone_init(MachineState *machine)
 {
-    mainstone_common_init(get_system_memory(), machine, mainstone, 0x196);
+    mainstone_common_init(machine, mainstone, 0x196);
 }
 
 static void mainstone2_machine_init(MachineClass *mc)
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 8b8845fc63..07d5dd8691 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -2092,9 +2092,9 @@ static void pxa2xx_reset(void *opaque, int line, int level)
 }
 
 /* Initialise a PXA270 integrated chip (ARM based core).  */
-PXA2xxState *pxa270_init(MemoryRegion *address_space,
-                         unsigned int sdram_size, const char *cpu_type)
+PXA2xxState *pxa270_init(unsigned int sdram_size, const char *cpu_type)
 {
+    MemoryRegion *address_space = get_system_memory();
     PXA2xxState *s;
     int i;
     DriveInfo *dinfo;
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index 5aab0b8565..f732fe0acf 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -986,18 +986,16 @@ static void spitz_common_init(MachineState *machine)
     SpitzMachineState *sms = SPITZ_MACHINE(machine);
     enum spitz_model_e model = smc->model;
     PXA2xxState *mpu;
-    MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *rom = g_new(MemoryRegion, 1);
 
     /* Setup CPU & memory */
-    mpu = pxa270_init(address_space_mem, spitz_binfo.ram_size,
-                      machine->cpu_type);
+    mpu = pxa270_init(spitz_binfo.ram_size, machine->cpu_type);
     sms->mpu = mpu;
 
     sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
 
     memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
-    memory_region_add_subregion(address_space_mem, 0, rom);
+    memory_region_add_subregion(get_system_memory(), 0, rom);
 
     /* Setup peripherals */
     spitz_keyboard_register(mpu);
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 9c1e876207..8eb6f495bc 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -299,7 +299,6 @@ static const TypeInfo aer915_info = {
 
 static void z2_init(MachineState *machine)
 {
-    MemoryRegion *address_space_mem = get_system_memory();
     uint32_t sector_len = 0x10000;
     PXA2xxState *mpu;
     DriveInfo *dinfo;
@@ -308,7 +307,7 @@ static void z2_init(MachineState *machine)
     DeviceState *wm;
 
     /* Setup CPU & memory */
-    mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, machine->cpu_type);
+    mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
index c26007e57f..ba8f49e48e 100644
--- a/include/hw/arm/pxa.h
+++ b/include/hw/arm/pxa.h
@@ -193,8 +193,7 @@ struct PXA2xxI2SState {
 
 # define PA_FMT			"0x%08lx"
 
-PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size,
-                         const char *revision);
+PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision);
 PXA2xxState *pxa255_init(unsigned int sdram_size);
 
 #endif /* PXA_H */
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/13] hw/arm/collie: Use the IEC binary prefix definitions
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 01/13] hw/arm/pxa2xx: Simplify pxa255_init() Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 02/13] hw/arm/pxa2xx: Simplify pxa270_init() Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 04/13] hw/arm/collie: Simplify flash creation using for() loop Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

Add definitions for RAM / Flash / Flash blocksize.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/collie.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/arm/collie.c b/hw/arm/collie.c
index 8df31e2793..d59c376e60 100644
--- a/hw/arm/collie.c
+++ b/hw/arm/collie.c
@@ -20,6 +20,10 @@
 #include "cpu.h"
 #include "qom/object.h"
 
+#define RAM_SIZE            (512 * MiB)
+#define FLASH_SIZE          (32 * MiB)
+#define FLASH_SECTOR_SIZE   (64 * KiB)
+
 struct CollieMachineState {
     MachineState parent;
 
@@ -31,7 +35,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE)
 
 static struct arm_boot_info collie_binfo = {
     .loader_start = SA_SDCS0,
-    .ram_size = 0x20000000,
+    .ram_size = RAM_SIZE,
 };
 
 static void collie_init(MachineState *machine)
@@ -52,14 +56,14 @@ static void collie_init(MachineState *machine)
     memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
-    pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
+    pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
                     dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                    64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
+                    FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
 
     dinfo = drive_get(IF_PFLASH, 0, 1);
-    pflash_cfi01_register(SA_CS1, "collie.fl2", 0x02000000,
+    pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
                     dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                    64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
+                    FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
 
     sysbus_create_simple("scoop", 0x40800000, NULL);
 
@@ -75,7 +79,7 @@ static void collie_machine_class_init(ObjectClass *oc, void *data)
     mc->init = collie_init;
     mc->ignore_memory_transaction_failures = true;
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110");
-    mc->default_ram_size = 0x20000000;
+    mc->default_ram_size = RAM_SIZE;
     mc->default_ram_id = "strongarm.sdram";
 }
 
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/13] hw/arm/collie: Simplify flash creation using for() loop
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 03/13] hw/arm/collie: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 05/13] hw/arm/gumstix: Improve documentation Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/collie.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/hw/arm/collie.c b/hw/arm/collie.c
index d59c376e60..9edff59370 100644
--- a/hw/arm/collie.c
+++ b/hw/arm/collie.c
@@ -40,7 +40,6 @@ static struct arm_boot_info collie_binfo = {
 
 static void collie_init(MachineState *machine)
 {
-    DriveInfo *dinfo;
     MachineClass *mc = MACHINE_GET_CLASS(machine);
     CollieMachineState *cms = COLLIE_MACHINE(machine);
 
@@ -55,15 +54,13 @@ static void collie_init(MachineState *machine)
 
     memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
 
-    dinfo = drive_get(IF_PFLASH, 0, 0);
-    pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
-                    dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                    FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
-
-    dinfo = drive_get(IF_PFLASH, 0, 1);
-    pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
-                    dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                    FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
+    for (unsigned i = 0; i < 2; i++) {
+        DriveInfo *dinfo = drive_get(IF_PFLASH, 0, i);
+        pflash_cfi01_register(i ? SA_CS1 : SA_CS0,
+                              i ? "collie.fl2" : "collie.fl1", FLASH_SIZE,
+                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
+    }
 
     sysbus_create_simple("scoop", 0x40800000, NULL);
 
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/13] hw/arm/gumstix: Improve documentation
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 04/13] hw/arm/collie: Simplify flash creation using for() loop Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 06/13] hw/arm/gumstix: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé,
	Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Add a comment describing the Connex uses a Numonyx RC28F128J3F75
flash, and the Verdex uses a Micron RC28F256P30TFA.

Correct the Verdex machine description (we model the 'Pro' board).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20200223231044.8003-3-philmd@redhat.com>
---
 hw/arm/gumstix.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index ab9b0182f6..89c15bee75 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -10,7 +10,7 @@
  * Contributions after 2012-01-13 are licensed under the terms of the
  * GNU GPL, version 2 or (at your option) any later version.
  */
- 
+
 /* 
  * Example usage:
  * 
@@ -64,6 +64,7 @@ static void connex_init(MachineState *machine)
         exit(1);
     }
 
+    /* Numonyx RC28F128J3F75 */
     if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                sector_len, 2, 0, 0, 0, 0, 0)) {
@@ -93,6 +94,7 @@ static void verdex_init(MachineState *machine)
         exit(1);
     }
 
+    /* Micron RC28F256P30TFA */
     if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                sector_len, 2, 0, 0, 0, 0, 0)) {
@@ -124,7 +126,7 @@ static void verdex_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->desc = "Gumstix Verdex (PXA270)";
+    mc->desc = "Gumstix Verdex Pro XL6P COMs (PXA270)";
     mc->init = verdex_init;
     mc->ignore_memory_transaction_failures = true;
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/13] hw/arm/gumstix: Use the IEC binary prefix definitions
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 05/13] hw/arm/gumstix: Improve documentation Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 07/13] hw/arm/mainstone: " Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé,
	Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

IEC binary prefixes ease code review: the unit is explicit.

Add definitions for RAM / Flash / Flash blocksize.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20200223231044.8003-3-philmd@redhat.com>
---
 hw/arm/gumstix.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 89c15bee75..579d363577 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -35,6 +35,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "hw/arm/pxa.h"
 #include "net/net.h"
@@ -45,17 +46,20 @@
 #include "sysemu/qtest.h"
 #include "cpu.h"
 
-static const int sector_len = 128 * 1024;
+#define CONNEX_FLASH_SIZE   (16 * MiB)
+#define CONNEX_RAM_SIZE     (64 * MiB)
+
+#define VERDEX_FLASH_SIZE   (32 * MiB)
+#define VERDEX_RAM_SIZE     (256 * MiB)
+
+#define FLASH_SECTOR_SIZE   (128 * KiB)
 
 static void connex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
 
-    uint32_t connex_rom = 0x01000000;
-    uint32_t connex_ram = 0x04000000;
-
-    cpu = pxa255_init(connex_ram);
+    cpu = pxa255_init(CONNEX_RAM_SIZE);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {
@@ -65,9 +69,9 @@ static void connex_init(MachineState *machine)
     }
 
     /* Numonyx RC28F128J3F75 */
-    if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
+    if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               sector_len, 2, 0, 0, 0, 0, 0)) {
+                               FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
         exit(1);
     }
@@ -82,10 +86,7 @@ static void verdex_init(MachineState *machine)
     PXA2xxState *cpu;
     DriveInfo *dinfo;
 
-    uint32_t verdex_rom = 0x02000000;
-    uint32_t verdex_ram = 0x10000000;
-
-    cpu = pxa270_init(verdex_ram, machine->cpu_type);
+    cpu = pxa270_init(VERDEX_RAM_SIZE, machine->cpu_type);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {
@@ -95,9 +96,9 @@ static void verdex_init(MachineState *machine)
     }
 
     /* Micron RC28F256P30TFA */
-    if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
+    if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               sector_len, 2, 0, 0, 0, 0, 0)) {
+                               FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
         exit(1);
     }
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/13] hw/arm/mainstone: Use the IEC binary prefix definitions
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 06/13] hw/arm/gumstix: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 08/13] hw/arm/musicpal: " Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

Add the FLASH_SECTOR_SIZE definition.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/mainstone.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index f6293c6c13..eebaed6e3e 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -12,6 +12,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "hw/arm/pxa.h"
@@ -99,19 +100,20 @@ static const struct keymap map[0xE0] = {
 
 enum mainstone_model_e { mainstone };
 
-#define MAINSTONE_RAM	0x04000000
-#define MAINSTONE_ROM	0x00800000
-#define MAINSTONE_FLASH	0x02000000
+#define MAINSTONE_RAM_SIZE      (64 * MiB)
+#define MAINSTONE_ROM_SIZE      (8 * MiB)
+#define MAINSTONE_FLASH_SIZE    (32 * MiB)
 
 static struct arm_boot_info mainstone_binfo = {
     .loader_start = PXA2XX_SDRAM_BASE,
-    .ram_size = 0x04000000,
+    .ram_size = MAINSTONE_RAM_SIZE,
 };
 
+#define FLASH_SECTOR_SIZE   (256 * KiB)
+
 static void mainstone_common_init(MachineState *machine,
                                   enum mainstone_model_e model, int arm_id)
 {
-    uint32_t sector_len = 256 * 1024;
     hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
     PXA2xxState *mpu;
     DeviceState *mst_irq;
@@ -121,7 +123,7 @@ static void mainstone_common_init(MachineState *machine,
 
     /* Setup CPU & memory */
     mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type);
-    memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
+    memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM_SIZE,
                            &error_fatal);
     memory_region_add_subregion(get_system_memory(), 0x00000000, rom);
 
@@ -130,9 +132,9 @@ static void mainstone_common_init(MachineState *machine,
         dinfo = drive_get(IF_PFLASH, 0, i);
         if (!pflash_cfi01_register(mainstone_flash_base[i],
                                    i ? "mainstone.flash1" : "mainstone.flash0",
-                                   MAINSTONE_FLASH,
+                                   MAINSTONE_FLASH_SIZE,
                                    dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                                   sector_len, 4, 0, 0, 0, 0, 0)) {
+                                   FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
             error_report("Error registering flash memory");
             exit(1);
         }
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/13] hw/arm/musicpal: Use the IEC binary prefix definitions
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 07/13] hw/arm/mainstone: " Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 09/13] hw/arm/omap_sx1: Remove unused 'total_ram' definitions Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

Add the FLASH_SECTOR_SIZE definition.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/musicpal.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index b65c020115..73e2b7e4ce 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
@@ -1196,6 +1197,8 @@ static const TypeInfo musicpal_key_info = {
     .class_init    = musicpal_key_class_init,
 };
 
+#define FLASH_SECTOR_SIZE   (64 * KiB)
+
 static struct arm_boot_info musicpal_binfo = {
     .loader_start = 0x0,
     .board_id = 0x20e,
@@ -1264,8 +1267,8 @@ static void musicpal_init(MachineState *machine)
         BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
 
         flash_size = blk_getlength(blk);
-        if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
-            flash_size != 32*1024*1024) {
+        if (flash_size != 8 * MiB && flash_size != 16 * MiB &&
+            flash_size != 32 * MiB) {
             error_report("Invalid flash image size");
             exit(1);
         }
@@ -1277,7 +1280,7 @@ static void musicpal_init(MachineState *machine)
          */
         pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX,
                               "musicpal.flash", flash_size,
-                              blk, 0x10000,
+                              blk, FLASH_SECTOR_SIZE,
                               MP_FLASH_SIZE_MAX / flash_size,
                               2, 0x00BF, 0x236D, 0x0000, 0x0000,
                               0x5555, 0x2AAA, 0);
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/13] hw/arm/omap_sx1: Remove unused 'total_ram' definitions
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 08/13] hw/arm/musicpal: " Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 10/13] hw/arm/omap_sx1: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

The total_ram_v1/total_ram_v2 definitions were never used.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/omap_sx1.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index 57829b3744..84b7059f7c 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -91,8 +91,6 @@ static const MemoryRegionOps static_ops = {
 #define flash0_size	(16 * 1024 * 1024)
 #define flash1_size	( 8 * 1024 * 1024)
 #define flash2_size	(32 * 1024 * 1024)
-#define total_ram_v1	(sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
-#define total_ram_v2	(sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
 
 static struct arm_boot_info sx1_binfo = {
     .loader_start = OMAP_EMIFF_BASE,
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/13] hw/arm/omap_sx1: Use the IEC binary prefix definitions
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 09/13] hw/arm/omap_sx1: Remove unused 'total_ram' definitions Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 11/13] hw/arm/z2: " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/omap_sx1.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index 84b7059f7c..d1b0ec3264 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -26,6 +26,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "ui/console.h"
 #include "hw/arm/omap.h"
@@ -86,15 +87,15 @@ static const MemoryRegionOps static_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-#define sdram_size	0x02000000
-#define sector_size	(128 * 1024)
-#define flash0_size	(16 * 1024 * 1024)
-#define flash1_size	( 8 * 1024 * 1024)
-#define flash2_size	(32 * 1024 * 1024)
+#define SDRAM_SIZE      (32 * MiB)
+#define SECTOR_SIZE     (128 * KiB)
+#define FLASH0_SIZE     (16 * MiB)
+#define FLASH1_SIZE     (8 * MiB)
+#define FLASH2_SIZE     (32 * MiB)
 
 static struct arm_boot_info sx1_binfo = {
     .loader_start = OMAP_EMIFF_BASE,
-    .ram_size = sdram_size,
+    .ram_size = SDRAM_SIZE,
     .board_id = 0x265,
 };
 
@@ -111,7 +112,7 @@ static void sx1_init(MachineState *machine, const int version)
     static uint32_t cs3val = 0x00001139;
     DriveInfo *dinfo;
     int fl_idx;
-    uint32_t flash_size = flash0_size;
+    uint32_t flash_size = FLASH0_SIZE;
 
     if (machine->ram_size != mc->default_ram_size) {
         char *sz = size_to_str(mc->default_ram_size);
@@ -121,7 +122,7 @@ static void sx1_init(MachineState *machine, const int version)
     }
 
     if (version == 2) {
-        flash_size = flash2_size;
+        flash_size = FLASH2_SIZE;
     }
 
     memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, machine->ram);
@@ -154,7 +155,7 @@ static void sx1_init(MachineState *machine, const int version)
         if (!pflash_cfi01_register(OMAP_CS0_BASE,
                                    "omap_sx1.flash0-1", flash_size,
                                    blk_by_legacy_dinfo(dinfo),
-                                   sector_size, 4, 0, 0, 0, 0, 0)) {
+                                   SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
             fprintf(stderr, "qemu: Error registering flash memory %d.\n",
                            fl_idx);
         }
@@ -165,18 +166,18 @@ static void sx1_init(MachineState *machine, const int version)
             (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
         MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
         memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
-                               flash1_size, &error_fatal);
+                               FLASH1_SIZE, &error_fatal);
         memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
 
         memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
-                              "sx1.cs1", OMAP_CS1_SIZE - flash1_size);
+                              "sx1.cs1", OMAP_CS1_SIZE - FLASH1_SIZE);
         memory_region_add_subregion(address_space,
-                                OMAP_CS1_BASE + flash1_size, &cs[1]);
+                                OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]);
 
         if (!pflash_cfi01_register(OMAP_CS1_BASE,
-                                   "omap_sx1.flash1-1", flash1_size,
+                                   "omap_sx1.flash1-1", FLASH1_SIZE,
                                    blk_by_legacy_dinfo(dinfo),
-                                   sector_size, 4, 0, 0, 0, 0, 0)) {
+                                   SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
             fprintf(stderr, "qemu: Error registering flash memory %d.\n",
                            fl_idx);
         }
@@ -218,7 +219,7 @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data)
     mc->init = sx1_init_v2;
     mc->ignore_memory_transaction_failures = true;
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
-    mc->default_ram_size = sdram_size;
+    mc->default_ram_size = SDRAM_SIZE;
     mc->default_ram_id = "omap1.dram";
 }
 
@@ -236,7 +237,7 @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data)
     mc->init = sx1_init_v1;
     mc->ignore_memory_transaction_failures = true;
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
-    mc->default_ram_size = sdram_size;
+    mc->default_ram_size = SDRAM_SIZE;
     mc->default_ram_id = "omap1.dram";
 }
 
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/13] hw/arm/z2: Use the IEC binary prefix definitions
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 10/13] hw/arm/omap_sx1: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 12/13] hw/arm/vexpress: Remove dead code in vexpress_common_init() Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

Add the FLASH_SECTOR_SIZE definition.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/z2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 8eb6f495bc..839be3ca16 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -12,6 +12,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/arm/pxa.h"
 #include "hw/arm/boot.h"
 #include "hw/i2c/i2c.h"
@@ -297,9 +298,10 @@ static const TypeInfo aer915_info = {
     .class_init    = aer915_class_init,
 };
 
+#define FLASH_SECTOR_SIZE   (64 * KiB)
+
 static void z2_init(MachineState *machine)
 {
-    uint32_t sector_len = 0x10000;
     PXA2xxState *mpu;
     DriveInfo *dinfo;
     void *z2_lcd;
@@ -312,7 +314,7 @@ static void z2_init(MachineState *machine)
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               sector_len, 4, 0, 0, 0, 0, 0)) {
+                               FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
         exit(1);
     }
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 12/13] hw/arm/vexpress: Remove dead code in vexpress_common_init()
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 11/13] hw/arm/z2: " Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 11:53 ` [PATCH 13/13] hw/arm: Remove unreachable code calling pflash_cfi01_register() Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

Upon introduction in commit b8433303fb ("Set proper device-width
for vexpress flash"), ve_pflash_cfi01_register() was calling
qdev_init_nofail() which can not fail. This call was later
converted with a script to use &error_fatal, still unable to
fail. Remove the unreachable code.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/vexpress.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index e1d1983ae6..757236767b 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -659,10 +659,6 @@ static void vexpress_common_init(MachineState *machine)
     dinfo = drive_get(IF_PFLASH, 0, 0);
     pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0",
                                        dinfo);
-    if (!pflash0) {
-        error_report("vexpress: error registering flash 0");
-        exit(1);
-    }
 
     if (map[VE_NORFLASHALIAS] != -1) {
         /* Map flash 0 as an alias into low memory */
@@ -673,11 +669,7 @@ static void vexpress_common_init(MachineState *machine)
     }
 
     dinfo = drive_get(IF_PFLASH, 0, 1);
-    if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1",
-                                  dinfo)) {
-        error_report("vexpress: error registering flash 1");
-        exit(1);
-    }
+    ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo);
 
     sram_size = 0x2000000;
     memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size,
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 13/13] hw/arm: Remove unreachable code calling pflash_cfi01_register()
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 12/13] hw/arm/vexpress: Remove dead code in vexpress_common_init() Philippe Mathieu-Daudé
@ 2023-01-09 11:53 ` Philippe Mathieu-Daudé
  2023-01-09 17:40 ` [PATCH 00/13] hw/arm: Cleanups before pflash refactor Richard Henderson
  2023-01-12 17:04 ` Peter Maydell
  14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-09 11:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka, Philippe Mathieu-Daudé

Since its QOM'ification in commit 368a354f02 ("pflash_cfi0x:
QOMified") the pflash_cfi01_register() function does not fail.

This call was later converted with a script to use &error_fatal,
still unable to fail. Remove the unreachable code.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/gumstix.c     | 18 ++++++------------
 hw/arm/mainstone.c   | 13 +++++--------
 hw/arm/omap_sx1.c    | 22 ++++++++--------------
 hw/arm/versatilepb.c |  6 ++----
 hw/arm/z2.c          |  9 +++------
 5 files changed, 24 insertions(+), 44 deletions(-)

diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 579d363577..2ca4140c9f 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -69,12 +69,9 @@ static void connex_init(MachineState *machine)
     }
 
     /* Numonyx RC28F128J3F75 */
-    if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
-                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
-        error_report("Error registering flash memory");
-        exit(1);
-    }
+    pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
+                          dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                          FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
 
     /* Interrupt line of NIC is connected to GPIO line 36 */
     smc91c111_init(&nd_table[0], 0x04000300,
@@ -96,12 +93,9 @@ static void verdex_init(MachineState *machine)
     }
 
     /* Micron RC28F256P30TFA */
-    if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
-                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
-        error_report("Error registering flash memory");
-        exit(1);
-    }
+    pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
+                          dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                          FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
 
     /* Interrupt line of NIC is connected to GPIO line 99 */
     smc91c111_init(&nd_table[0], 0x04000300,
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index eebaed6e3e..68329c4617 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -130,14 +130,11 @@ static void mainstone_common_init(MachineState *machine,
     /* There are two 32MiB flash devices on the board */
     for (i = 0; i < 2; i ++) {
         dinfo = drive_get(IF_PFLASH, 0, i);
-        if (!pflash_cfi01_register(mainstone_flash_base[i],
-                                   i ? "mainstone.flash1" : "mainstone.flash0",
-                                   MAINSTONE_FLASH_SIZE,
-                                   dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                                   FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
-            error_report("Error registering flash memory");
-            exit(1);
-        }
+        pflash_cfi01_register(mainstone_flash_base[i],
+                              i ? "mainstone.flash1" : "mainstone.flash0",
+                              MAINSTONE_FLASH_SIZE,
+                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
     }
 
     mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index d1b0ec3264..1d156bc344 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -152,13 +152,10 @@ static void sx1_init(MachineState *machine, const int version)
 
     fl_idx = 0;
     if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
-        if (!pflash_cfi01_register(OMAP_CS0_BASE,
-                                   "omap_sx1.flash0-1", flash_size,
-                                   blk_by_legacy_dinfo(dinfo),
-                                   SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
-            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
-                           fl_idx);
-        }
+        pflash_cfi01_register(OMAP_CS0_BASE,
+                              "omap_sx1.flash0-1", flash_size,
+                              blk_by_legacy_dinfo(dinfo),
+                              SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
         fl_idx++;
     }
 
@@ -174,13 +171,10 @@ static void sx1_init(MachineState *machine, const int version)
         memory_region_add_subregion(address_space,
                                 OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]);
 
-        if (!pflash_cfi01_register(OMAP_CS1_BASE,
-                                   "omap_sx1.flash1-1", FLASH1_SIZE,
-                                   blk_by_legacy_dinfo(dinfo),
-                                   SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
-            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
-                           fl_idx);
-        }
+        pflash_cfi01_register(OMAP_CS1_BASE,
+                              "omap_sx1.flash1-1", FLASH1_SIZE,
+                              blk_by_legacy_dinfo(dinfo),
+                              SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
         fl_idx++;
     } else {
         memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index ecc1f6cf74..43172d72ea 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -385,13 +385,11 @@ static void versatile_init(MachineState *machine, int board_id)
     /* 0x34000000 NOR Flash */
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
-    if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
+    pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
                           VERSATILE_FLASH_SIZE,
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                           VERSATILE_FLASH_SECT_SIZE,
-                          4, 0x0089, 0x0018, 0x0000, 0x0, 0)) {
-        fprintf(stderr, "qemu: Error registering flash memory.\n");
-    }
+                          4, 0x0089, 0x0018, 0x0000, 0x0, 0);
 
     versatile_binfo.ram_size = machine->ram_size;
     versatile_binfo.board_id = board_id;
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 839be3ca16..dc25304290 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -312,12 +312,9 @@ static void z2_init(MachineState *machine)
     mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
-    if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
-                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
-        error_report("Error registering flash memory");
-        exit(1);
-    }
+    pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
+                          dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                          FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
 
     /* setup keypad */
     pxa27x_register_keypad(mpu->kp, map, 0x100);
-- 
2.38.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/13] hw/arm: Cleanups before pflash refactor
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2023-01-09 11:53 ` [PATCH 13/13] hw/arm: Remove unreachable code calling pflash_cfi01_register() Philippe Mathieu-Daudé
@ 2023-01-09 17:40 ` Richard Henderson
  2023-01-12 17:04 ` Peter Maydell
  14 siblings, 0 replies; 16+ messages in thread
From: Richard Henderson @ 2023-01-09 17:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-arm, Jan Kiszka

On 1/9/23 03:53, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (13):
>    hw/arm/pxa2xx: Simplify pxa255_init()
>    hw/arm/pxa2xx: Simplify pxa270_init()
>    hw/arm/collie: Use the IEC binary prefix definitions
>    hw/arm/collie: Simplify flash creation using for() loop
>    hw/arm/gumstix: Improve documentation
>    hw/arm/gumstix: Use the IEC binary prefix definitions
>    hw/arm/mainstone: Use the IEC binary prefix definitions
>    hw/arm/musicpal: Use the IEC binary prefix definitions
>    hw/arm/omap_sx1: Remove unused 'total_ram' definitions
>    hw/arm/omap_sx1: Use the IEC binary prefix definitions
>    hw/arm/z2: Use the IEC binary prefix definitions
>    hw/arm/vexpress: Remove dead code in vexpress_common_init()
>    hw/arm: Remove unreachable code calling pflash_cfi01_register()

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/13] hw/arm: Cleanups before pflash refactor
  2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2023-01-09 17:40 ` [PATCH 00/13] hw/arm: Cleanups before pflash refactor Richard Henderson
@ 2023-01-12 17:04 ` Peter Maydell
  14 siblings, 0 replies; 16+ messages in thread
From: Peter Maydell @ 2023-01-12 17:04 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel, qemu-arm, Jan Kiszka

On Mon, 9 Jan 2023 at 11:53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Various trivial cleanups:
> - Remove unnecessary sysmem argument from pxa2xx_init()
> - Use IEC binary prefix definitions
> - Remove unreachable code calling pflash_cfi01_register()
>   (another use in PPC sam460ex will be removed separately).
>



Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-01-12 17:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-09 11:53 [PATCH 00/13] hw/arm: Cleanups before pflash refactor Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 01/13] hw/arm/pxa2xx: Simplify pxa255_init() Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 02/13] hw/arm/pxa2xx: Simplify pxa270_init() Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 03/13] hw/arm/collie: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 04/13] hw/arm/collie: Simplify flash creation using for() loop Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 05/13] hw/arm/gumstix: Improve documentation Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 06/13] hw/arm/gumstix: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 07/13] hw/arm/mainstone: " Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 08/13] hw/arm/musicpal: " Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 09/13] hw/arm/omap_sx1: Remove unused 'total_ram' definitions Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 10/13] hw/arm/omap_sx1: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 11/13] hw/arm/z2: " Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 12/13] hw/arm/vexpress: Remove dead code in vexpress_common_init() Philippe Mathieu-Daudé
2023-01-09 11:53 ` [PATCH 13/13] hw/arm: Remove unreachable code calling pflash_cfi01_register() Philippe Mathieu-Daudé
2023-01-09 17:40 ` [PATCH 00/13] hw/arm: Cleanups before pflash refactor Richard Henderson
2023-01-12 17:04 ` Peter Maydell

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