qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine
@ 2025-02-04  0:22 Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 01/12] hw/arm/raspi: Access SoC parent object using BCM283X_BASE() macro Philippe Mathieu-Daudé
                   ` (11 more replies)
  0 siblings, 12 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Full rewrite of v1 [1], addressing Zoltan & Peter suggestion.

Introduce a generic 'raspi' machine, which takes a 'model'
and 'revision' properties, and any memory size. The 'board_rev'
register is filled appropriately.

Before, merge raspi4b.c within raspi.c (more is planned here
with the MPCore refactor [2]).

Regards,

Phil.

[1] https://lore.kernel.org/qemu-devel/20250201091528.1177-1-philmd@linaro.org/
[2] https://lore.kernel.org/qemu-devel/20231212162935.42910-1-philmd@linaro.org/

Philippe Mathieu-Daudé (12):
  hw/arm/raspi: Access SoC parent object using  BCM283X_BASE() macro
  hw/arm/raspi: Merge model 4B with other models
  hw/arm/raspi: Unify RASPI_MACHINE types
  hw/arm/raspi: Pass board_rev as argument to raspi_base_machine_init()
  hw/arm/raspi: Consider processor id in types[] array
  hw/arm/raspi: Consider network interface for B models
  hw/arm/raspi: Check ramsize is within chipset aperture
  hw/arm/raspi: Introduce generic Raspberry Pi machine
  hw/arm/raspi: Have the generic machine take a 'revision' property
  hw/arm/raspi: List models creatable by the generic 'raspi' machine
  hw/arm/raspi: Deprecate old raspiX machine names
  hw/arm/raspi: Support more models

 docs/about/deprecated.rst               |  13 +
 include/hw/arm/raspi_platform.h         |   5 +-
 hw/arm/raspi.c                          | 383 ++++++++++++++++++++++--
 hw/arm/raspi4b.c                        | 136 ---------
 tests/qtest/bcm2835-dma-test.c          |   2 +-
 tests/qtest/bcm2835-i2c-test.c          |   2 +-
 tests/qtest/boot-serial-test.c          |   3 +-
 hw/arm/meson.build                      |   2 +-
 tests/functional/test_aarch64_raspi3.py |   5 +-
 tests/functional/test_aarch64_raspi4.py |   4 +-
 tests/functional/test_arm_raspi2.py     |   4 +-
 11 files changed, 385 insertions(+), 174 deletions(-)
 delete mode 100644 hw/arm/raspi4b.c

-- 
2.47.1



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

* [PATCH v2 01/12] hw/arm/raspi: Access SoC parent object using BCM283X_BASE() macro
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04 15:01   ` Peter Maydell
  2025-02-04  0:22 ` [PATCH v2 02/12] hw/arm/raspi: Merge model 4B with other models Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

We shouldn't access a QOM parent object directly.
Use the appropriate type-cast macro.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/raspi.c   | 2 +-
 hw/arm/raspi4b.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index a7a662f40db..508f90479e2 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -312,7 +312,7 @@ void raspi_machine_init(MachineState *machine)
 
     object_initialize_child(OBJECT(machine), "soc", soc,
                             board_soc_type(mc->board_rev));
-    raspi_base_machine_init(machine, &soc->parent_obj);
+    raspi_base_machine_init(machine, BCM283X_BASE(soc));
 }
 
 void raspi_machine_class_common_init(MachineClass *mc,
diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
index 1264e0d6eed..9b08a598f39 100644
--- a/hw/arm/raspi4b.c
+++ b/hw/arm/raspi4b.c
@@ -104,7 +104,7 @@ static void raspi4b_machine_init(MachineState *machine)
     object_initialize_child(OBJECT(machine), "soc", soc,
                             board_soc_type(mc->board_rev));
 
-    raspi_base_machine_init(machine, &soc->parent_obj);
+    raspi_base_machine_init(machine, BCM283X_BASE(soc));
 }
 
 static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
-- 
2.47.1



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

* [PATCH v2 02/12] hw/arm/raspi: Merge model 4B with other models
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 01/12] hw/arm/raspi: Access SoC parent object using BCM283X_BASE() macro Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04 15:02   ` Peter Maydell
  2025-02-04  0:22 ` [PATCH v2 03/12] hw/arm/raspi: Unify RASPI_MACHINE types Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Except we alter the device tree blob, the 4B
is just another raspi model.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/raspi.c     | 114 ++++++++++++++++++++++++++++++++++++-
 hw/arm/raspi4b.c   | 136 ---------------------------------------------
 hw/arm/meson.build |   2 +-
 3 files changed, 114 insertions(+), 138 deletions(-)
 delete mode 100644 hw/arm/raspi4b.c

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 508f90479e2..3fa382d62ce 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -8,6 +8,10 @@
  * Raspberry Pi 3 emulation Copyright (c) 2018 Zoltán Baldaszti
  * Upstream code cleanup (c) 2018 Pekka Enberg
  *
+ * Raspberry Pi 4 emulation Copyright (C) 2022 Ovchinnikov Vitalii
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
@@ -16,20 +20,27 @@
 #include "qemu/units.h"
 #include "qemu/cutils.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
 #include "hw/arm/boot.h"
 #include "hw/arm/bcm2836.h"
 #include "hw/arm/bcm2838.h"
 #include "hw/arm/raspi_platform.h"
+#include "hw/display/bcm2835_fb.h"
 #include "hw/registerfields.h"
 #include "qemu/error-report.h"
 #include "hw/boards.h"
 #include "hw/loader.h"
 #include "hw/arm/boot.h"
 #include "qom/object.h"
+#include "system/device_tree.h"
+#include <libfdt.h>
 
 #define TYPE_RASPI_MACHINE  MACHINE_TYPE_NAME("raspi-common")
 OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE)
 
+#define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b")
+OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
+
 #define SMPBOOT_ADDR    0x300 /* this should leave enough space for ATAGS */
 #define MVBAR_ADDR      0x400 /* secure vectors */
 #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
@@ -44,6 +55,11 @@ struct RaspiMachineState {
     BCM283XState soc;
 };
 
+struct Raspi4bMachineState {
+    RaspiBaseMachineState parent_obj;
+    BCM2838State soc;
+};
+
 /*
  * Board revision codes:
  * www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/
@@ -301,6 +317,83 @@ void raspi_base_machine_init(MachineState *machine,
                boot_ram_size);
 }
 
+#ifdef TARGET_AARCH64
+/*
+ * Add second memory region if board RAM amount exceeds VC base address
+ * (see https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf
+ * 1.2 Address Map)
+ */
+static int raspi4_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len)
+{
+    int ret;
+    uint32_t acells, scells;
+    char *nodename = g_strdup_printf("/memory@%" PRIx64, mem_base);
+
+    acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells",
+                                   NULL, &error_fatal);
+    scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells",
+                                   NULL, &error_fatal);
+    if (acells == 0 || scells == 0) {
+        fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
+        ret = -1;
+    } else {
+        qemu_fdt_add_subnode(fdt, nodename);
+        qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory");
+        ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg",
+                                           acells, mem_base,
+                                           scells, mem_len);
+    }
+
+    g_free(nodename);
+    return ret;
+}
+
+static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt)
+{
+    uint64_t ram_size;
+
+    /* Temporarily disable following devices until they are implemented */
+    const char *nodes_to_remove[] = {
+        "brcm,bcm2711-pcie",
+        "brcm,bcm2711-rng200",
+        "brcm,bcm2711-thermal",
+        "brcm,bcm2711-genet-v5",
+    };
+
+    for (int i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) {
+        const char *dev_str = nodes_to_remove[i];
+
+        int offset = fdt_node_offset_by_compatible(fdt, -1, dev_str);
+        if (offset >= 0) {
+            if (!fdt_nop_node(fdt, offset)) {
+                warn_report("bcm2711 dtc: %s has been disabled!", dev_str);
+            }
+        }
+    }
+
+    ram_size = board_ram_size(info->board_id);
+
+    if (info->ram_size > UPPER_RAM_BASE) {
+        raspi4_add_memory_node(fdt, UPPER_RAM_BASE, ram_size - UPPER_RAM_BASE);
+    }
+}
+
+static void raspi4b_machine_init(MachineState *machine)
+{
+    Raspi4bMachineState *s = RASPI4B_MACHINE(machine);
+    RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(machine);
+    RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine);
+    BCM2838State *soc = &s->soc;
+
+    s_base->binfo.modify_dtb = raspi4_modify_dtb;
+    s_base->binfo.board_id = mc->board_rev;
+
+    object_initialize_child(OBJECT(machine), "soc", soc,
+                            board_soc_type(mc->board_rev));
+    raspi_base_machine_init(machine, BCM283X_BASE(soc));
+}
+#endif /* TARGET_AARCH64 */
+
 void raspi_machine_init(MachineState *machine)
 {
     RaspiMachineState *s = RASPI_MACHINE(machine);
@@ -382,6 +475,20 @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data)
     rmc->board_rev = 0xa02082;
     raspi_machine_class_init(mc, rmc->board_rev);
 };
+
+static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
+
+#if HOST_LONG_BITS == 32
+    rmc->board_rev = 0xa03111; /* Revision 1.1, 1 Gb RAM */
+#else
+    rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */
+#endif
+    raspi_machine_class_common_init(mc, rmc->board_rev);
+    mc->init = raspi4b_machine_init;
+}
 #endif /* TARGET_AARCH64 */
 
 static const TypeInfo raspi_machine_types[] = {
@@ -406,7 +513,12 @@ static const TypeInfo raspi_machine_types[] = {
         .name           = MACHINE_TYPE_NAME("raspi3b"),
         .parent         = TYPE_RASPI_MACHINE,
         .class_init     = raspi3b_machine_class_init,
-#endif
+    }, {
+        .name           = MACHINE_TYPE_NAME("raspi4"),
+        .parent         = TYPE_RASPI_BASE_MACHINE,
+        .instance_size  = sizeof(Raspi4bMachineState),
+        .class_init     = raspi4b_machine_class_init,
+#endif /* TARGET_AARCH64 */
     }, {
         .name           = TYPE_RASPI_MACHINE,
         .parent         = TYPE_RASPI_BASE_MACHINE,
diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
deleted file mode 100644
index 9b08a598f39..00000000000
--- a/hw/arm/raspi4b.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Raspberry Pi 4B emulation
- *
- * Copyright (C) 2022 Ovchinnikov Vitalii <vitalii.ovchinnikov@auriga.com>
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-#include "qemu/osdep.h"
-#include "qemu/units.h"
-#include "qemu/cutils.h"
-#include "qapi/error.h"
-#include "qapi/visitor.h"
-#include "hw/arm/raspi_platform.h"
-#include "hw/display/bcm2835_fb.h"
-#include "hw/registerfields.h"
-#include "qemu/error-report.h"
-#include "system/device_tree.h"
-#include "hw/boards.h"
-#include "hw/loader.h"
-#include "hw/arm/boot.h"
-#include "qom/object.h"
-#include "hw/arm/bcm2838.h"
-#include <libfdt.h>
-
-#define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b")
-OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
-
-struct Raspi4bMachineState {
-    RaspiBaseMachineState parent_obj;
-    BCM2838State soc;
-};
-
-/*
- * Add second memory region if board RAM amount exceeds VC base address
- * (see https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf
- * 1.2 Address Map)
- */
-static int raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len)
-{
-    int ret;
-    uint32_t acells, scells;
-    char *nodename = g_strdup_printf("/memory@%" PRIx64, mem_base);
-
-    acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells",
-                                   NULL, &error_fatal);
-    scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells",
-                                   NULL, &error_fatal);
-    if (acells == 0 || scells == 0) {
-        fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
-        ret = -1;
-    } else {
-        qemu_fdt_add_subnode(fdt, nodename);
-        qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory");
-        ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg",
-                                           acells, mem_base,
-                                           scells, mem_len);
-    }
-
-    g_free(nodename);
-    return ret;
-}
-
-static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt)
-{
-    uint64_t ram_size;
-
-    /* Temporarily disable following devices until they are implemented */
-    const char *nodes_to_remove[] = {
-        "brcm,bcm2711-pcie",
-        "brcm,bcm2711-rng200",
-        "brcm,bcm2711-thermal",
-        "brcm,bcm2711-genet-v5",
-    };
-
-    for (int i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) {
-        const char *dev_str = nodes_to_remove[i];
-
-        int offset = fdt_node_offset_by_compatible(fdt, -1, dev_str);
-        if (offset >= 0) {
-            if (!fdt_nop_node(fdt, offset)) {
-                warn_report("bcm2711 dtc: %s has been disabled!", dev_str);
-            }
-        }
-    }
-
-    ram_size = board_ram_size(info->board_id);
-
-    if (info->ram_size > UPPER_RAM_BASE) {
-        raspi_add_memory_node(fdt, UPPER_RAM_BASE, ram_size - UPPER_RAM_BASE);
-    }
-}
-
-static void raspi4b_machine_init(MachineState *machine)
-{
-    Raspi4bMachineState *s = RASPI4B_MACHINE(machine);
-    RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(machine);
-    RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine);
-    BCM2838State *soc = &s->soc;
-
-    s_base->binfo.modify_dtb = raspi4_modify_dtb;
-    s_base->binfo.board_id = mc->board_rev;
-
-    object_initialize_child(OBJECT(machine), "soc", soc,
-                            board_soc_type(mc->board_rev));
-
-    raspi_base_machine_init(machine, BCM283X_BASE(soc));
-}
-
-static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
-{
-    MachineClass *mc = MACHINE_CLASS(oc);
-    RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
-
-#if HOST_LONG_BITS == 32
-    rmc->board_rev = 0xa03111; /* Revision 1.1, 1 Gb RAM */
-#else
-    rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */
-#endif
-    raspi_machine_class_common_init(mc, rmc->board_rev);
-    mc->init = raspi4b_machine_init;
-}
-
-static const TypeInfo raspi4b_machine_type = {
-    .name           = TYPE_RASPI4B_MACHINE,
-    .parent         = TYPE_RASPI_BASE_MACHINE,
-    .instance_size  = sizeof(Raspi4bMachineState),
-    .class_init     = raspi4b_machine_class_init,
-};
-
-static void raspi4b_machine_register_type(void)
-{
-    type_register_static(&raspi4b_machine_type);
-}
-
-type_init(raspi4b_machine_register_type)
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
index 490234b3b84..5177260d42b 100644
--- a/hw/arm/meson.build
+++ b/hw/arm/meson.build
@@ -27,7 +27,7 @@ arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubi
 arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
 arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c'))
 arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c'))
-arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c', 'raspi4b.c'))
+arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c'))
 arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'))
 arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
-- 
2.47.1



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

* [PATCH v2 03/12] hw/arm/raspi: Unify RASPI_MACHINE types
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 01/12] hw/arm/raspi: Access SoC parent object using BCM283X_BASE() macro Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 02/12] hw/arm/raspi: Merge model 4B with other models Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04 15:06   ` Peter Maydell
  2025-02-04  0:22 ` [PATCH v2 04/12] hw/arm/raspi: Pass board_rev as argument to raspi_base_machine_init() Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Merge Raspi4bMachineState within RaspiMachineState by
using an unnamed union.

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

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 3fa382d62ce..ef94d57dab5 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -38,9 +38,6 @@
 #define TYPE_RASPI_MACHINE  MACHINE_TYPE_NAME("raspi-common")
 OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE)
 
-#define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b")
-OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
-
 #define SMPBOOT_ADDR    0x300 /* this should leave enough space for ATAGS */
 #define MVBAR_ADDR      0x400 /* secure vectors */
 #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
@@ -49,15 +46,12 @@ OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
 #define SPINTABLE_ADDR  0xd8 /* Pi 3 bootloader spintable */
 
 struct RaspiMachineState {
-    /*< private >*/
     RaspiBaseMachineState parent_obj;
-    /*< public >*/
-    BCM283XState soc;
-};
 
-struct Raspi4bMachineState {
-    RaspiBaseMachineState parent_obj;
-    BCM2838State soc;
+    union {
+        BCM283XState soc;
+        BCM2838State soc4;
+    };
 };
 
 /*
@@ -380,10 +374,10 @@ static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt)
 
 static void raspi4b_machine_init(MachineState *machine)
 {
-    Raspi4bMachineState *s = RASPI4B_MACHINE(machine);
+    RaspiMachineState *s = RASPI_MACHINE(machine);
     RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(machine);
     RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine);
-    BCM2838State *soc = &s->soc;
+    BCM2838State *soc = &s->soc4;
 
     s_base->binfo.modify_dtb = raspi4_modify_dtb;
     s_base->binfo.board_id = mc->board_rev;
@@ -515,8 +509,7 @@ static const TypeInfo raspi_machine_types[] = {
         .class_init     = raspi3b_machine_class_init,
     }, {
         .name           = MACHINE_TYPE_NAME("raspi4"),
-        .parent         = TYPE_RASPI_BASE_MACHINE,
-        .instance_size  = sizeof(Raspi4bMachineState),
+        .parent         = TYPE_RASPI_MACHINE,
         .class_init     = raspi4b_machine_class_init,
 #endif /* TARGET_AARCH64 */
     }, {
-- 
2.47.1



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

* [PATCH v2 04/12] hw/arm/raspi: Pass board_rev as argument to raspi_base_machine_init()
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 03/12] hw/arm/raspi: Unify RASPI_MACHINE types Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Since callers already have reference to the RaspiBaseMachineClass,
directly pass 'board_rev' as argument to raspi_base_machine_init().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/arm/raspi_platform.h | 2 +-
 hw/arm/raspi.c                  | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h
index 7bc4807fa51..defb786153b 100644
--- a/include/hw/arm/raspi_platform.h
+++ b/include/hw/arm/raspi_platform.h
@@ -58,7 +58,7 @@ void raspi_machine_init(MachineState *machine);
 
 typedef struct BCM283XBaseState BCM283XBaseState;
 void raspi_base_machine_init(MachineState *machine,
-                             BCM283XBaseState *soc);
+                             BCM283XBaseState *soc, const uint32_t board_rev);
 
 void raspi_machine_class_common_init(MachineClass *mc,
                                      uint32_t board_rev);
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index ef94d57dab5..571b50bef7e 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -254,10 +254,8 @@ static void setup_boot(MachineState *machine, ARMCPU *cpu,
 }
 
 void raspi_base_machine_init(MachineState *machine,
-                             BCM283XBaseState *soc)
+                             BCM283XBaseState *soc, const uint32_t board_rev)
 {
-    RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine);
-    uint32_t board_rev = mc->board_rev;
     uint64_t ram_size = board_ram_size(board_rev);
     uint32_t vcram_base, vcram_size;
     size_t boot_ram_size;
@@ -384,7 +382,7 @@ static void raspi4b_machine_init(MachineState *machine)
 
     object_initialize_child(OBJECT(machine), "soc", soc,
                             board_soc_type(mc->board_rev));
-    raspi_base_machine_init(machine, BCM283X_BASE(soc));
+    raspi_base_machine_init(machine, BCM283X_BASE(soc), mc->board_rev);
 }
 #endif /* TARGET_AARCH64 */
 
@@ -399,7 +397,7 @@ void raspi_machine_init(MachineState *machine)
 
     object_initialize_child(OBJECT(machine), "soc", soc,
                             board_soc_type(mc->board_rev));
-    raspi_base_machine_init(machine, BCM283X_BASE(soc));
+    raspi_base_machine_init(machine, BCM283X_BASE(soc), mc->board_rev);
 }
 
 void raspi_machine_class_common_init(MachineClass *mc,
-- 
2.47.1



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

* [PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 04/12] hw/arm/raspi: Pass board_rev as argument to raspi_base_machine_init() Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04 15:08   ` Peter Maydell
  2025-02-04  0:22 ` [PATCH v2 06/12] hw/arm/raspi: Consider network interface for B models Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Expand the current type2model array to include the processor id.

Since the BCM2838 is indistinctly used as BCM2711 (within the
Linux community), add it as alias in RaspiProcessorId.

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

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 571b50bef7e..1a6a1f8ff22 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -70,6 +70,7 @@ typedef enum RaspiProcessorId {
     PROCESSOR_ID_BCM2836 = 1,
     PROCESSOR_ID_BCM2837 = 2,
     PROCESSOR_ID_BCM2838 = 3,
+    PROCESSOR_ID_BCM2711 = 3,
 } RaspiProcessorId;
 
 static const struct {
@@ -82,6 +83,30 @@ static const struct {
     [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
 };
 
+static const struct {
+    RaspiProcessorId proc_id;
+    const char *model;
+} types[] = {
+    {PROCESSOR_ID_BCM2835, "A"},
+    {PROCESSOR_ID_BCM2835, "B"},
+    {PROCESSOR_ID_BCM2835, "A+"},
+    {PROCESSOR_ID_BCM2835, "B+"},
+    {PROCESSOR_ID_BCM2836, "2B"},
+    { },
+    {PROCESSOR_ID_BCM2835, "CM1"},
+    { },
+    {PROCESSOR_ID_BCM2837, "3B"},
+    {PROCESSOR_ID_BCM2835, "Zero"},
+    {PROCESSOR_ID_BCM2837, "CM3"},
+    { },
+    {PROCESSOR_ID_BCM2835, "ZeroW"},
+    {PROCESSOR_ID_BCM2837, "3B+"},
+    {PROCESSOR_ID_BCM2837, "3A+"},
+    { },
+    {PROCESSOR_ID_BCM2837, "CM3+"},
+    {PROCESSOR_ID_BCM2711, "4B"},
+};
+
 uint64_t board_ram_size(uint32_t board_rev)
 {
     assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
@@ -110,16 +135,12 @@ static int cores_count(uint32_t board_rev)
 
 static const char *board_type(uint32_t board_rev)
 {
-    static const char *types[] = {
-        "A", "B", "A+", "B+", "2B", "Alpha", "CM1", NULL, "3B", "Zero",
-        "CM3", NULL, "Zero W", "3B+", "3A+", NULL, "CM3+", "4B",
-    };
     assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
     int bt = FIELD_EX32(board_rev, REV_CODE, TYPE);
-    if (bt >= ARRAY_SIZE(types) || !types[bt]) {
+    if (bt >= ARRAY_SIZE(types) || !types[bt].model) {
         return "Unknown";
     }
-    return types[bt];
+    return types[bt].model;
 }
 
 static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
-- 
2.47.1



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

* [PATCH v2 06/12] hw/arm/raspi: Consider network interface for B models
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04 15:09   ` Peter Maydell
  2025-02-04  0:22 ` [PATCH v2 07/12] hw/arm/raspi: Check ramsize is within chipset aperture Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Raspberry Pi 'B' models have an ethernet chipset (the LAN9512).
Since we don't yet model it, add a /* TODO */ comment.

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

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 1a6a1f8ff22..68332fba027 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -143,6 +143,16 @@ static const char *board_type(uint32_t board_rev)
     return types[bt].model;
 }
 
+static bool is_model_b(uint32_t board_rev)
+{
+    return !!strchr(board_type(board_rev), 'B');
+}
+
+static bool has_enet(uint32_t board_rev)
+{
+    return is_model_b(board_rev);
+}
+
 static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
 {
     static const ARMInsnFixup smpboot[] = {
@@ -304,6 +314,10 @@ void raspi_base_machine_init(MachineState *machine,
                             machine->kernel_cmdline, &error_abort);
     qdev_realize(DEVICE(soc), NULL, &error_fatal);
 
+    if (has_enet(board_rev)) {
+        /* TODO: model LAN9512 and wire over USB2 */
+    }
+
     /* Create and plug in the SD cards */
     di = drive_get(IF_SD, 0, 0);
     blk = di ? blk_by_legacy_dinfo(di) : NULL;
-- 
2.47.1



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

* [PATCH v2 07/12] hw/arm/raspi: Check ramsize is within chipset aperture
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 06/12] hw/arm/raspi: Consider network interface for B models Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04 15:10   ` Peter Maydell
  2025-02-04  0:22 ` [PATCH v2 08/12] hw/arm/raspi: Introduce generic Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Add the 'max_ramsize' field to the soc_property[] array,
corresponding to the maximum DRAM size a SoC can map.

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

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 68332fba027..d44277001ee 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -76,11 +76,12 @@ typedef enum RaspiProcessorId {
 static const struct {
     const char *type;
     int cores_count;
+    uint64_t max_ramsize;
 } soc_property[] = {
-    [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1},
-    [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS},
-    [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS},
-    [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
+    [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1,              512 * MiB},
+    [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS,  1 * GiB},
+    [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS,  1 * GiB},
+    [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS,  8 * GiB},
 };
 
 static const struct {
@@ -133,6 +134,11 @@ static int cores_count(uint32_t board_rev)
     return soc_property[board_processor_id(board_rev)].cores_count;
 }
 
+static uint64_t ramsize_max(uint32_t board_rev)
+{
+    return soc_property[board_processor_id(board_rev)].max_ramsize;
+}
+
 static const char *board_type(uint32_t board_rev)
 {
     assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
@@ -294,6 +300,7 @@ void raspi_base_machine_init(MachineState *machine,
     BlockBackend *blk;
     BusState *bus;
     DeviceState *carddev;
+    uint64_t max_ramsize;
 
     if (machine->ram_size != ram_size) {
         char *size_str = size_to_str(ram_size);
@@ -301,6 +308,12 @@ void raspi_base_machine_init(MachineState *machine,
         g_free(size_str);
         exit(1);
     }
+    max_ramsize = ramsize_max(board_rev);
+    if (ram_size > max_ramsize) {
+        g_autofree char *max_ramsize_str = size_to_str(max_ramsize);
+        error_report("At most %s of RAM can be used", max_ramsize_str);
+         exit(1);
+    }
 
     /* FIXME: Remove when we have custom CPU address space support */
     memory_region_add_subregion_overlap(get_system_memory(), 0,
-- 
2.47.1



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

* [PATCH v2 08/12] hw/arm/raspi: Introduce generic Raspberry Pi machine
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 07/12] hw/arm/raspi: Check ramsize is within chipset aperture Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 09/12] hw/arm/raspi: Have the generic machine take a 'revision' property Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

The generic 'raspi' machine takes a 'model' argument and
create the machine associated with the model, with the
RAM size requested (or default to the minimum of 256MB
if not precised).

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2797
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/arm/raspi_platform.h |   3 +-
 hw/arm/raspi.c                  | 127 ++++++++++++++++++++++++++++----
 2 files changed, 115 insertions(+), 15 deletions(-)

diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h
index defb786153b..14cb91e153c 100644
--- a/include/hw/arm/raspi_platform.h
+++ b/include/hw/arm/raspi_platform.h
@@ -41,7 +41,8 @@ OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass,
 struct RaspiBaseMachineState {
     /*< private >*/
     MachineState parent_obj;
-    /*< public >*/
+
+    uint32_t board_rev;
     struct arm_boot_info binfo;
 };
 
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index d44277001ee..1dc41701efe 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -300,20 +300,6 @@ void raspi_base_machine_init(MachineState *machine,
     BlockBackend *blk;
     BusState *bus;
     DeviceState *carddev;
-    uint64_t max_ramsize;
-
-    if (machine->ram_size != ram_size) {
-        char *size_str = size_to_str(ram_size);
-        error_report("Invalid RAM size, should be %s", size_str);
-        g_free(size_str);
-        exit(1);
-    }
-    max_ramsize = ramsize_max(board_rev);
-    if (ram_size > max_ramsize) {
-        g_autofree char *max_ramsize_str = size_to_str(max_ramsize);
-        error_report("At most %s of RAM can be used", max_ramsize_str);
-         exit(1);
-    }
 
     /* FIXME: Remove when we have custom CPU address space support */
     memory_region_add_subregion_overlap(get_system_memory(), 0,
@@ -448,6 +434,115 @@ void raspi_machine_init(MachineState *machine)
     raspi_base_machine_init(machine, BCM283X_BASE(soc), mc->board_rev);
 }
 
+static void raspi_generic_machine_init(MachineState *ms)
+{
+    RaspiMachineState *s = RASPI_MACHINE(ms);
+    RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(ms);
+    uint32_t board_rev = s_base->board_rev;
+    const char *soc_type = board_soc_type(board_rev);
+    BCM283XBaseState *bsoc;
+    uint64_t ram_size;
+    uint64_t max_ramsize;
+
+    if (!board_rev) {
+        error_report("Missing model");
+        exit(1);
+    }
+
+    ram_size = ROUND_UP(ms->ram_size, 256 * MiB);
+    if (ram_size != ms->ram_size) {
+        g_autofree char *ram_size_str = size_to_str(ms->ram_size);
+        g_autofree char *rounded_size_str = size_to_str(ram_size);
+        warn_report("Invalid RAM size %s, rounding to %s",
+                    ram_size_str, rounded_size_str);
+    }
+    max_ramsize = ramsize_max(board_rev);
+    if (ram_size > max_ramsize) {
+        g_autofree char *max_ramsize_str = size_to_str(max_ramsize);
+        error_report("At most %s of RAM can be used with BCM%s",
+                     max_ramsize_str, soc_type + 3);
+        exit(1);
+    }
+    board_rev = FIELD_DP32(board_rev, REV_CODE, MEMORY_SIZE,
+                           ctz64(ms->ram_size) - 28);
+
+    ms->ram = g_new(MemoryRegion, 1);
+    memory_region_init(ms->ram, OBJECT(ms), "DRAM", ram_size);
+
+    if (board_processor_id(board_rev) == PROCESSOR_ID_BCM2838) {
+        BCM2838State *soc = &s->soc4;
+        bsoc = BCM283X_BASE(soc);
+        object_initialize_child(OBJECT(ms), "soc", soc, soc_type);
+    } else {
+        BCM283XState *soc = &s->soc;
+        bsoc = BCM283X_BASE(soc);
+        object_initialize_child(OBJECT(ms), "soc", soc, soc_type);
+    }
+    raspi_base_machine_init(ms, bsoc, board_rev);
+}
+
+static void raspi_update_board_rev(RaspiBaseMachineState *s)
+{
+    MachineState *ms = MACHINE(s);
+    RaspiProcessorId proc;
+    unsigned model_index;
+
+    s->board_rev = FIELD_DP32(s->board_rev, REV_CODE, STYLE, 1);
+
+    model_index = FIELD_EX32(s->board_rev, REV_CODE, TYPE);
+    proc = types[model_index].proc_id;
+    s->board_rev = FIELD_DP32(s->board_rev, REV_CODE, PROCESSOR, proc);
+
+    ms->smp.max_cpus = soc_property[proc].cores_count;
+}
+
+static void raspi_set_machine_model(Object *obj, const char *value, Error **errp)
+{
+    for (unsigned i = 0; i < ARRAY_SIZE(types); i++) {
+        if (types[i].model && !strcmp(value, types[i].model)) {
+            RaspiBaseMachineState *s = RASPI_BASE_MACHINE(obj);
+
+            s->board_rev = FIELD_DP32(s->board_rev, REV_CODE, TYPE, i);
+
+            return raspi_update_board_rev(s);
+        }
+    }
+    error_setg(errp, "Invalid model");
+}
+
+static char *raspi_get_machine_model(Object *obj, Error **errp)
+{
+    RaspiBaseMachineState *s = RASPI_BASE_MACHINE(obj);
+
+    return g_strdup(types[FIELD_EX32(s->board_rev, REV_CODE, TYPE)].model);
+}
+
+static void raspi_generic_machine_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
+
+    rmc->board_rev = FIELD_DP32(0, REV_CODE, STYLE, 1);
+
+    mc->desc = "Raspberry Pi";
+    mc->block_default_type = IF_SD;
+    mc->no_parallel = 1;
+    mc->no_floppy = 1;
+    mc->no_cdrom = 1;
+    mc->default_cpus = 1;
+    mc->min_cpus = 1;
+    mc->max_cpus = 4;
+    mc->default_ram_size = 0;
+    mc->default_ram_id = "DRAM";
+    mc->init = raspi_generic_machine_init;
+
+    object_class_property_add_str(oc, "model",
+                                  raspi_get_machine_model,
+                                  raspi_set_machine_model);
+    object_class_property_set_description(oc, "model", "Set machine model.");
+};
+
+
 void raspi_machine_class_common_init(MachineClass *mc,
                                      uint32_t board_rev)
 {
@@ -533,6 +628,10 @@ static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo raspi_machine_types[] = {
     {
+        .name           = MACHINE_TYPE_NAME("raspi"),
+        .parent         = TYPE_RASPI_MACHINE,
+        .class_init     = raspi_generic_machine_class_init,
+    }, {
         .name           = MACHINE_TYPE_NAME("raspi0"),
         .parent         = TYPE_RASPI_MACHINE,
         .class_init     = raspi0_machine_class_init,
-- 
2.47.1



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

* [PATCH v2 09/12] hw/arm/raspi: Have the generic machine take a 'revision' property
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 08/12] hw/arm/raspi: Introduce generic Raspberry Pi machine Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 10/12] hw/arm/raspi: List models creatable by the generic 'raspi' machine Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Add a property to specify the board revision. This allows to
create a Raspberry Pi 2B with BCM2836 SoC (rev 1.0 and 1.1)
or BCM2837 (rev 1.2 up to 1.5).

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

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 1dc41701efe..b184ac3c446 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -491,6 +491,10 @@ static void raspi_update_board_rev(RaspiBaseMachineState *s)
 
     model_index = FIELD_EX32(s->board_rev, REV_CODE, TYPE);
     proc = types[model_index].proc_id;
+    if (model_index == 4 && FIELD_EX32(s->board_rev, REV_CODE, REVISION) > 1) {
+        /* 2B rev 1.0 and 1.1 have BCM2836, 1.2+ have BCM2837 */
+        proc = PROCESSOR_ID_BCM2837;
+    }
     s->board_rev = FIELD_DP32(s->board_rev, REV_CODE, PROCESSOR, proc);
 
     ms->smp.max_cpus = soc_property[proc].cores_count;
@@ -517,6 +521,35 @@ static char *raspi_get_machine_model(Object *obj, Error **errp)
     return g_strdup(types[FIELD_EX32(s->board_rev, REV_CODE, TYPE)].model);
 }
 
+static void raspi_set_machine_rev(Object *obj, const char *value, Error **errp)
+{
+    RaspiBaseMachineState *s;
+    int rev;
+
+    if (strlen(value) != 3 || value[0] != '1' || value[1] != '.') {
+        error_setg(errp, "Invalid revision");
+        return;
+    }
+    rev = value[2] - '0';
+    if (rev < 0 || rev > 5) {
+        error_setg(errp, "Invalid revision");
+        return;
+    }
+
+    s = RASPI_BASE_MACHINE(obj);
+    s->board_rev = FIELD_DP32(s->board_rev, REV_CODE, REVISION, rev);
+
+    return raspi_update_board_rev(s);
+}
+
+static char *raspi_get_machine_rev(Object *obj, Error **errp)
+{
+    RaspiBaseMachineState *s = RASPI_BASE_MACHINE(obj);
+
+    return g_strdup_printf("1.%u",
+                           FIELD_EX32(s->board_rev, REV_CODE, REVISION));
+}
+
 static void raspi_generic_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -540,6 +573,12 @@ static void raspi_generic_machine_class_init(ObjectClass *oc, void *data)
                                   raspi_get_machine_model,
                                   raspi_set_machine_model);
     object_class_property_set_description(oc, "model", "Set machine model.");
+    object_class_property_add_str(oc, "revision",
+                                  raspi_get_machine_rev,
+                                  raspi_set_machine_rev);
+    object_class_property_set_description(oc, "revision",
+                                          "Set machine revision. "
+                                          "Valid values are 1.0 to 1.5");
 };
 
 
-- 
2.47.1



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

* [PATCH v2 10/12] hw/arm/raspi: List models creatable by the generic 'raspi' machine
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 09/12] hw/arm/raspi: Have the generic machine take a 'revision' property Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names Philippe Mathieu-Daudé
  2025-02-04  0:22 ` [PATCH v2 12/12] hw/arm/raspi: Support more models Philippe Mathieu-Daudé
  11 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

All the following models can be created (with different RAM size):

  $ qemu-system-aarch64 -M raspi
  qemu-system-aarch64: Missing model, try -M raspi,model=help
  $ qemu-system-aarch64 -M raspi,model=help
  Available models (processor):
  - A          (BCM2835)
  - B          (BCM2835)
  - A+         (BCM2835)
  - B+         (BCM2835)
  - 2B         (BCM2836)
  - CM1        (BCM2835)
  - 3B         (BCM2837)
  - Zero       (BCM2835)
  - CM3        (BCM2837)
  - ZeroW      (BCM2835)
  - 3B+        (BCM2837)
  - 3A+        (BCM2837)
  - CM3+       (BCM2837)
  - 4B         (BCM2838)

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/raspi.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index b184ac3c446..8cae1ff6f93 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -445,7 +445,7 @@ static void raspi_generic_machine_init(MachineState *ms)
     uint64_t max_ramsize;
 
     if (!board_rev) {
-        error_report("Missing model");
+        error_report("Missing model, try -M raspi,model=help");
         exit(1);
     }
 
@@ -500,8 +500,33 @@ static void raspi_update_board_rev(RaspiBaseMachineState *s)
     ms->smp.max_cpus = soc_property[proc].cores_count;
 }
 
+static void raspi_list_machine_models(void)
+{
+    printf("Available models (processor):\n");
+
+    for (unsigned i = 0; i < ARRAY_SIZE(types); i++) {
+        const char *soc_type;
+
+        if (!types[i].model) {
+            continue;
+        }
+
+        soc_type = soc_property[types[i].proc_id].type;
+        if (!soc_type) {
+            continue;
+        }
+        printf("- %-10s (BCM%s)\n",
+               types[i].model,
+               soc_property[types[i].proc_id].type + 3);
+    }
+}
+
 static void raspi_set_machine_model(Object *obj, const char *value, Error **errp)
 {
+    if (!strcmp(value, "help")) {
+        raspi_list_machine_models();
+        exit(0);
+    }
     for (unsigned i = 0; i < ARRAY_SIZE(types); i++) {
         if (types[i].model && !strcmp(value, types[i].model)) {
             RaspiBaseMachineState *s = RASPI_BASE_MACHINE(obj);
@@ -512,6 +537,7 @@ static void raspi_set_machine_model(Object *obj, const char *value, Error **errp
         }
     }
     error_setg(errp, "Invalid model");
+    error_append_hint(errp, "Use model=help to list models.\n");
 }
 
 static char *raspi_get_machine_model(Object *obj, Error **errp)
-- 
2.47.1



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

* [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 10/12] hw/arm/raspi: List models creatable by the generic 'raspi' machine Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  2025-02-04  9:22   ` Peter Maydell
  2025-02-04  0:22 ` [PATCH v2 12/12] hw/arm/raspi: Support more models Philippe Mathieu-Daudé
  11 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

All previous raspi machines can be created using the
generic machine. Deprecate the old names to maintain
a single one. Update the tests.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
QOM HMP introspection test fails because without the 'model'
argument set, no machine is created...

  $ qemu-system-aarch64 -M raspi
  qemu-system-aarch64: Missing model, try -M raspi,model=help
---
 docs/about/deprecated.rst               | 13 +++++++++++++
 hw/arm/raspi.c                          |  5 +++++
 tests/qtest/bcm2835-dma-test.c          |  2 +-
 tests/qtest/bcm2835-i2c-test.c          |  2 +-
 tests/qtest/boot-serial-test.c          |  3 ++-
 tests/functional/test_aarch64_raspi3.py |  5 ++---
 tests/functional/test_aarch64_raspi4.py |  4 ++--
 tests/functional/test_arm_raspi2.py     |  4 ++--
 8 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 4a3c302962a..c9a11a52f78 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
 Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
 CPUs. Big endian support is not tested.
 
+ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
+which takes the model as argument.
+
+    - `raspi0`` is now an alias for ``raspi,model=Zero``
+    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
+    - `raspi2b`` is now an alias for ``raspi,model=2B``
+    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
+    - `raspi3b`` is now an alias for ``raspi,model=3B``
+    - `raspi4b`` is now an alias for ``raspi,model=4B``
+
 Backend options
 ---------------
 
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 8cae1ff6f93..86ecc988e06 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -637,6 +637,7 @@ static void raspi0_machine_class_init(ObjectClass *oc, void *data)
 
     rmc->board_rev = 0x920092; /* Revision 1.2 */
     raspi_machine_class_init(mc, rmc->board_rev);
+    mc->deprecation_reason = "-M raspi,model=Zero";
 };
 
 static void raspi1ap_machine_class_init(ObjectClass *oc, void *data)
@@ -646,6 +647,7 @@ static void raspi1ap_machine_class_init(ObjectClass *oc, void *data)
 
     rmc->board_rev = 0x900021; /* Revision 1.1 */
     raspi_machine_class_init(mc, rmc->board_rev);
+    mc->deprecation_reason = "-M raspi,model=A+ (-m 512m)";
 };
 
 static void raspi2b_machine_class_init(ObjectClass *oc, void *data)
@@ -655,6 +657,7 @@ static void raspi2b_machine_class_init(ObjectClass *oc, void *data)
 
     rmc->board_rev = 0xa21041;
     raspi_machine_class_init(mc, rmc->board_rev);
+    mc->deprecation_reason = "-M raspi,model=2B -m 1g";
 };
 
 #ifdef TARGET_AARCH64
@@ -665,6 +668,7 @@ static void raspi3ap_machine_class_init(ObjectClass *oc, void *data)
 
     rmc->board_rev = 0x9020e0; /* Revision 1.0 */
     raspi_machine_class_init(mc, rmc->board_rev);
+    mc->deprecation_reason = "-M raspi,model=3A+ -m 512m";
 };
 
 static void raspi3b_machine_class_init(ObjectClass *oc, void *data)
@@ -674,6 +678,7 @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data)
 
     rmc->board_rev = 0xa02082;
     raspi_machine_class_init(mc, rmc->board_rev);
+    mc->deprecation_reason = "-M raspi,model=3B -m 1g";
 };
 
 static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
diff --git a/tests/qtest/bcm2835-dma-test.c b/tests/qtest/bcm2835-dma-test.c
index 18901b76d21..705e6b2362b 100644
--- a/tests/qtest/bcm2835-dma-test.c
+++ b/tests/qtest/bcm2835-dma-test.c
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/bcm2835/dma/test_interrupts",
                    bcm2835_dma_test_interrupts);
-    qtest_start("-machine raspi3b");
+    qtest_start("-machine raspi,model=3B -m 1g");
     ret = g_test_run();
     qtest_end();
     return ret;
diff --git a/tests/qtest/bcm2835-i2c-test.c b/tests/qtest/bcm2835-i2c-test.c
index 15991949260..15904abf393 100644
--- a/tests/qtest/bcm2835-i2c-test.c
+++ b/tests/qtest/bcm2835-i2c-test.c
@@ -104,7 +104,7 @@ int main(int argc, char **argv)
     }
 
     /* Run I2C tests with TMP105 slaves on all three buses */
-    qtest_start("-M raspi3b "
+    qtest_start("-M raspi,model=3B -m 1g "
                 "-device tmp105,address=0x50,bus=i2c-bus.0 "
                 "-device tmp105,address=0x50,bus=i2c-bus.1 "
                 "-device tmp105,address=0x50,bus=i2c-bus.2");
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
index a05d26ee996..fbafd73facb 100644
--- a/tests/qtest/boot-serial-test.c
+++ b/tests/qtest/boot-serial-test.c
@@ -188,7 +188,8 @@ static const testdef_t tests[] = {
       sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 },
     { "microblazeel", "petalogix-ml605", "", "TT",
       sizeof(kernel_plml605), kernel_plml605 },
-    { "arm", "raspi2b", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 },
+    { "arm", "raspi,model=2B -m 1g", "", "TT",
+      sizeof(bios_raspi2), 0, bios_raspi2 },
     { "aarch64", "virt", "-cpu max", "TT", sizeof(kernel_aarch64),
       kernel_aarch64 },
     { "arm", "microbit", "", "T", sizeof(kernel_nrf51), kernel_nrf51 },
diff --git a/tests/functional/test_aarch64_raspi3.py b/tests/functional/test_aarch64_raspi3.py
index 74f6630ed26..05766d93b3f 100755
--- a/tests/functional/test_aarch64_raspi3.py
+++ b/tests/functional/test_aarch64_raspi3.py
@@ -21,10 +21,9 @@ def test_aarch64_raspi3_atf(self):
         efi_name = 'RPI_EFI.fd'
         efi_fd = self.archive_extract(self.ASSET_RPI3_UEFI, member=efi_name)
 
-        self.set_machine('raspi3b')
+        self.set_machine('raspi,model=3B -m 1g')
         self.vm.set_console(console_index=1)
-        self.vm.add_args('-cpu', 'cortex-a53',
-                         '-nodefaults',
+        self.vm.add_args('-nodefaults',
                          '-device', f'loader,file={efi_fd},force-raw=true')
         self.vm.launch()
         self.wait_for_console_pattern('version UEFI Firmware v1.15')
diff --git a/tests/functional/test_aarch64_raspi4.py b/tests/functional/test_aarch64_raspi4.py
index 7a4302b0c5a..3becee9333a 100755
--- a/tests/functional/test_aarch64_raspi4.py
+++ b/tests/functional/test_aarch64_raspi4.py
@@ -34,7 +34,7 @@ def test_arm_raspi4(self):
         dtb_path = self.archive_extract(self.ASSET_KERNEL_20190215,
                                         member='boot/bcm2711-rpi-4-b.dtb')
 
-        self.set_machine('raspi4b')
+        self.set_machine('raspi,model=4B -m 1g')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                'earlycon=pl011,mmio32,0xfe201000 ' +
@@ -64,7 +64,7 @@ def test_arm_raspi4_initrd(self):
                                         member='boot/bcm2711-rpi-4-b.dtb')
         initrd_path = self.uncompress(self.ASSET_INITRD)
 
-        self.set_machine('raspi4b')
+        self.set_machine('raspi,model=4B -m 1g')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                'earlycon=pl011,mmio32,0xfe201000 ' +
diff --git a/tests/functional/test_arm_raspi2.py b/tests/functional/test_arm_raspi2.py
index d3c7aaa39b0..37390a9c360 100755
--- a/tests/functional/test_arm_raspi2.py
+++ b/tests/functional/test_arm_raspi2.py
@@ -39,7 +39,7 @@ def do_test_arm_raspi2(self, uart_id):
         dtb_path = self.archive_extract(self.ASSET_KERNEL_20190215,
                                         member='boot/bcm2709-rpi-2-b.dtb')
 
-        self.set_machine('raspi2b')
+        self.set_machine('raspi,model=2B -m 1g')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                serial_kernel_cmdline[uart_id] +
@@ -65,7 +65,7 @@ def test_arm_raspi2_initrd(self):
                                         member='boot/bcm2709-rpi-2-b.dtb')
         initrd_path = self.uncompress(self.ASSET_INITRD)
 
-        self.set_machine('raspi2b')
+        self.set_machine('raspi,model=2B -m 1g')
         self.vm.set_console()
         kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
                                'earlycon=pl011,0x3f201000 console=ttyAMA0 '
-- 
2.47.1



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

* [PATCH v2 12/12] hw/arm/raspi: Support more models
  2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2025-02-04  0:22 ` [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names Philippe Mathieu-Daudé
@ 2025-02-04  0:22 ` Philippe Mathieu-Daudé
  11 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  0:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, BALATON Zoltan, Peter Maydell,
	Laurent Vivier, Ovchinnikov Vitalii, Philippe Mathieu-Daudé,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

Allow to create the following machines:

  - Zero2W
  - 400
  - CM4 and CM4S

Fill the arrays with the BCM2712-based machines (raspi5),
but since we don't model the SoC, these machines can't
be created (and aren't listed in the 'help' output).

List taken from:
https://github.com/raspberrypi/documentation/blob/9b126446a5/documentation/asciidoc/computers/raspberry-pi/revision-codes.adoc

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

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 86ecc988e06..2346550eec5 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -71,6 +71,7 @@ typedef enum RaspiProcessorId {
     PROCESSOR_ID_BCM2837 = 2,
     PROCESSOR_ID_BCM2838 = 3,
     PROCESSOR_ID_BCM2711 = 3,
+    PROCESSOR_ID_BCM2712 = 4,
 } RaspiProcessorId;
 
 static const struct {
@@ -82,6 +83,7 @@ static const struct {
     [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS,  1 * GiB},
     [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS,  1 * GiB},
     [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS,  8 * GiB},
+    [PROCESSOR_ID_BCM2712] = {NULL,         BCM283X_NCPUS,  16 * GiB},
 };
 
 static const struct {
@@ -106,6 +108,17 @@ static const struct {
     { },
     {PROCESSOR_ID_BCM2837, "CM3+"},
     {PROCESSOR_ID_BCM2711, "4B"},
+    {PROCESSOR_ID_BCM2837, "Zero2W"},
+    {PROCESSOR_ID_BCM2711, "400"},
+
+    {PROCESSOR_ID_BCM2711, "CM4"},
+    {PROCESSOR_ID_BCM2711, "CM4S"},
+    { },
+    {PROCESSOR_ID_BCM2712, "5"},
+    {PROCESSOR_ID_BCM2712, "CM5"},
+    {PROCESSOR_ID_BCM2712, "500"},
+    {PROCESSOR_ID_BCM2712, "CM5lite"},
+    { },
 };
 
 uint64_t board_ram_size(uint32_t board_rev)
-- 
2.47.1



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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  0:22 ` [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names Philippe Mathieu-Daudé
@ 2025-02-04  9:22   ` Peter Maydell
  2025-02-04  9:51     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 30+ messages in thread
From: Peter Maydell @ 2025-02-04  9:22 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> All previous raspi machines can be created using the
> generic machine. Deprecate the old names to maintain
> a single one. Update the tests.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> index 4a3c302962a..c9a11a52f78 100644
> --- a/docs/about/deprecated.rst
> +++ b/docs/about/deprecated.rst
> @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
>  Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
>  CPUs. Big endian support is not tested.
>
> +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
> +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> +
> +The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
> +which takes the model as argument.
> +
> +    - `raspi0`` is now an alias for ``raspi,model=Zero``
> +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
> +    - `raspi2b`` is now an alias for ``raspi,model=2B``
> +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
> +    - `raspi3b`` is now an alias for ``raspi,model=3B``
> +    - `raspi4b`` is now an alias for ``raspi,model=4B``

This is not how we typically handle "we have a bunch
of different devboards in one family". What's wrong with the
existing set of machine names?

Can we implement "support more than just the fixed amount
of RAM" by making '-m 2G' work, without changing the
machine names at all, please?

thanks
-- PMM


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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  9:22   ` Peter Maydell
@ 2025-02-04  9:51     ` Philippe Mathieu-Daudé
  2025-02-04  9:57       ` Daniel P. Berrangé
  2025-02-04  9:58       ` BALATON Zoltan
  0 siblings, 2 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04  9:51 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On 4/2/25 10:22, Peter Maydell wrote:
> On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> All previous raspi machines can be created using the
>> generic machine. Deprecate the old names to maintain
>> a single one. Update the tests.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
>> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
>> index 4a3c302962a..c9a11a52f78 100644
>> --- a/docs/about/deprecated.rst
>> +++ b/docs/about/deprecated.rst
>> @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
>>   Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
>>   CPUs. Big endian support is not tested.
>>
>> +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
>> +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>> +
>> +The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
>> +which takes the model as argument.
>> +
>> +    - `raspi0`` is now an alias for ``raspi,model=Zero``
>> +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
>> +    - `raspi2b`` is now an alias for ``raspi,model=2B``
>> +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
>> +    - `raspi3b`` is now an alias for ``raspi,model=3B``
>> +    - `raspi4b`` is now an alias for ``raspi,model=4B``
> 
> This is not how we typically handle "we have a bunch
> of different devboards in one family". What's wrong with the
> existing set of machine names?

Zoltan and you don't want to add more machine names, then you
don't want a generic machine. This is very confusing.

See previous patch:

   $ qemu-system-aarch64 -M raspi,model=help
   Available models (processor):
   - A          (BCM2835)
   - B          (BCM2835)
   - A+         (BCM2835)
   - B+         (BCM2835)
   - CM1        (BCM2835)
   - Zero       (BCM2835)
   - ZeroW      (BCM2835)
   - 2B         (BCM2836)
   - 3B         (BCM2837)
   - CM3        (BCM2837)
   - 3B+        (BCM2837)
   - 3A+        (BCM2837)
   - CM3+       (BCM2837)
   - 4B         (BCM2838)

Can we or not add the other raspi models?

> Can we implement "support more than just the fixed amount
> of RAM" by making '-m 2G' work, without changing the
> machine names at all, please?

We surely can if we find developers motivated to do the work.

Regards,

Phil.


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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  9:51     ` Philippe Mathieu-Daudé
@ 2025-02-04  9:57       ` Daniel P. Berrangé
  2025-02-04 10:48         ` Philippe Mathieu-Daudé
  2025-02-04 11:13         ` Peter Maydell
  2025-02-04  9:58       ` BALATON Zoltan
  1 sibling, 2 replies; 30+ messages in thread
From: Daniel P. Berrangé @ 2025-02-04  9:57 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, qemu-devel, BALATON Zoltan, Laurent Vivier,
	Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas, Paolo Bonzini,
	qemu-arm, Alex Bennée, devel

On Tue, Feb 04, 2025 at 10:51:04AM +0100, Philippe Mathieu-Daudé wrote:
> On 4/2/25 10:22, Peter Maydell wrote:
> > On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> > > 
> > > All previous raspi machines can be created using the
> > > generic machine. Deprecate the old names to maintain
> > > a single one. Update the tests.
> > > 
> > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > 
> > > diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> > > index 4a3c302962a..c9a11a52f78 100644
> > > --- a/docs/about/deprecated.rst
> > > +++ b/docs/about/deprecated.rst
> > > @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
> > >   Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
> > >   CPUs. Big endian support is not tested.
> > > 
> > > +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
> > > +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > > +
> > > +The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
> > > +which takes the model as argument.
> > > +
> > > +    - `raspi0`` is now an alias for ``raspi,model=Zero``
> > > +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
> > > +    - `raspi2b`` is now an alias for ``raspi,model=2B``
> > > +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
> > > +    - `raspi3b`` is now an alias for ``raspi,model=3B``
> > > +    - `raspi4b`` is now an alias for ``raspi,model=4B``
> > 
> > This is not how we typically handle "we have a bunch
> > of different devboards in one family". What's wrong with the
> > existing set of machine names?
> 
> Zoltan and you don't want to add more machine names, then you
> don't want a generic machine. This is very confusing.

IMHO we can have distinct machines for each model, but
*NOT* have further machines for each RAM size within a
model.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  9:51     ` Philippe Mathieu-Daudé
  2025-02-04  9:57       ` Daniel P. Berrangé
@ 2025-02-04  9:58       ` BALATON Zoltan
  2025-02-22 21:57         ` Jared Mauch
  1 sibling, 1 reply; 30+ messages in thread
From: BALATON Zoltan @ 2025-02-04  9:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, qemu-devel, Daniel P . Berrangé,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

[-- Attachment #1: Type: text/plain, Size: 2922 bytes --]

On Tue, 4 Feb 2025, Philippe Mathieu-Daudé wrote:
> On 4/2/25 10:22, Peter Maydell wrote:
>> On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> 
>> wrote:
>>> 
>>> All previous raspi machines can be created using the
>>> generic machine. Deprecate the old names to maintain
>>> a single one. Update the tests.
>>> 
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> 
>>> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
>>> index 4a3c302962a..c9a11a52f78 100644
>>> --- a/docs/about/deprecated.rst
>>> +++ b/docs/about/deprecated.rst
>>> @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` 
>>> and ``xlnx-zynqmp-pmu`` ma
>>>   Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little 
>>> endian
>>>   CPUs. Big endian support is not tested.
>>> 
>>> +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and 
>>> ``raspi4b`` machines (since 10.0)
>>> +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>> +
>>> +The Raspberry Pi machines have been unified under the generic ``raspi`` 
>>> machine,
>>> +which takes the model as argument.
>>> +
>>> +    - `raspi0`` is now an alias for ``raspi,model=Zero``
>>> +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
>>> +    - `raspi2b`` is now an alias for ``raspi,model=2B``
>>> +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
>>> +    - `raspi3b`` is now an alias for ``raspi,model=3B``
>>> +    - `raspi4b`` is now an alias for ``raspi,model=4B``
>> 
>> This is not how we typically handle "we have a bunch
>> of different devboards in one family". What's wrong with the
>> existing set of machine names?
>
> Zoltan and you don't want to add more machine names, then you
> don't want a generic machine. This is very confusing.

I said either rastpi4b,revision=1.4 or -machine raspi4b -memory 4g would 
be better IMHO. Peter perefers -memory which is also fine with me. I just 
don't think adding more machine names where only RAM size is different 
would be better than using -memory for that as usual.

Regards,
BALATON Zoltan

> See previous patch:
>
>  $ qemu-system-aarch64 -M raspi,model=help
>  Available models (processor):
>  - A          (BCM2835)
>  - B          (BCM2835)
>  - A+         (BCM2835)
>  - B+         (BCM2835)
>  - CM1        (BCM2835)
>  - Zero       (BCM2835)
>  - ZeroW      (BCM2835)
>  - 2B         (BCM2836)
>  - 3B         (BCM2837)
>  - CM3        (BCM2837)
>  - 3B+        (BCM2837)
>  - 3A+        (BCM2837)
>  - CM3+       (BCM2837)
>  - 4B         (BCM2838)
>
> Can we or not add the other raspi models?
>
>> Can we implement "support more than just the fixed amount
>> of RAM" by making '-m 2G' work, without changing the
>> machine names at all, please?
>
> We surely can if we find developers motivated to do the work.
>
> Regards,
>
> Phil.
>
>

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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  9:57       ` Daniel P. Berrangé
@ 2025-02-04 10:48         ` Philippe Mathieu-Daudé
  2025-02-04 10:51           ` Daniel P. Berrangé
  2025-02-04 11:13         ` Peter Maydell
  1 sibling, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04 10:48 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Peter Maydell, qemu-devel, BALATON Zoltan, Laurent Vivier,
	Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas, Paolo Bonzini,
	qemu-arm, Alex Bennée, devel

On 4/2/25 10:57, Daniel P. Berrangé wrote:
> On Tue, Feb 04, 2025 at 10:51:04AM +0100, Philippe Mathieu-Daudé wrote:
>> On 4/2/25 10:22, Peter Maydell wrote:
>>> On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>>
>>>> All previous raspi machines can be created using the
>>>> generic machine. Deprecate the old names to maintain
>>>> a single one. Update the tests.
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>
>>>> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
>>>> index 4a3c302962a..c9a11a52f78 100644
>>>> --- a/docs/about/deprecated.rst
>>>> +++ b/docs/about/deprecated.rst
>>>> @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
>>>>    Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
>>>>    CPUs. Big endian support is not tested.
>>>>
>>>> +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
>>>> +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>> +
>>>> +The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
>>>> +which takes the model as argument.
>>>> +
>>>> +    - `raspi0`` is now an alias for ``raspi,model=Zero``
>>>> +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
>>>> +    - `raspi2b`` is now an alias for ``raspi,model=2B``
>>>> +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
>>>> +    - `raspi3b`` is now an alias for ``raspi,model=3B``
>>>> +    - `raspi4b`` is now an alias for ``raspi,model=4B``
>>>
>>> This is not how we typically handle "we have a bunch
>>> of different devboards in one family". What's wrong with the
>>> existing set of machine names?
>>
>> Zoltan and you don't want to add more machine names, then you
>> don't want a generic machine. This is very confusing.
> 
> IMHO we can have distinct machines for each model, but
> *NOT* have further machines for each RAM size within a
> model.

Got it. Unfortunately I spent more than my hobbyist time credit
doing this, so if I find the motivation to revisit, it'll be later.

Still, having machine memory size depending on the host config was
a bad design choice IMHO, as we test different setup depending on
the host being used, so not really a "reproducible" setup.


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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04 10:48         ` Philippe Mathieu-Daudé
@ 2025-02-04 10:51           ` Daniel P. Berrangé
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel P. Berrangé @ 2025-02-04 10:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, qemu-devel, BALATON Zoltan, Laurent Vivier,
	Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas, Paolo Bonzini,
	qemu-arm, Alex Bennée, devel

On Tue, Feb 04, 2025 at 11:48:10AM +0100, Philippe Mathieu-Daudé wrote:
> On 4/2/25 10:57, Daniel P. Berrangé wrote:
> > On Tue, Feb 04, 2025 at 10:51:04AM +0100, Philippe Mathieu-Daudé wrote:
> > > On 4/2/25 10:22, Peter Maydell wrote:
> > > > On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> > > > > 
> > > > > All previous raspi machines can be created using the
> > > > > generic machine. Deprecate the old names to maintain
> > > > > a single one. Update the tests.
> > > > > 
> > > > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > > > 
> > > > > diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> > > > > index 4a3c302962a..c9a11a52f78 100644
> > > > > --- a/docs/about/deprecated.rst
> > > > > +++ b/docs/about/deprecated.rst
> > > > > @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
> > > > >    Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
> > > > >    CPUs. Big endian support is not tested.
> > > > > 
> > > > > +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
> > > > > +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > > > > +
> > > > > +The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
> > > > > +which takes the model as argument.
> > > > > +
> > > > > +    - `raspi0`` is now an alias for ``raspi,model=Zero``
> > > > > +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
> > > > > +    - `raspi2b`` is now an alias for ``raspi,model=2B``
> > > > > +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
> > > > > +    - `raspi3b`` is now an alias for ``raspi,model=3B``
> > > > > +    - `raspi4b`` is now an alias for ``raspi,model=4B``
> > > > 
> > > > This is not how we typically handle "we have a bunch
> > > > of different devboards in one family". What's wrong with the
> > > > existing set of machine names?
> > > 
> > > Zoltan and you don't want to add more machine names, then you
> > > don't want a generic machine. This is very confusing.
> > 
> > IMHO we can have distinct machines for each model, but
> > *NOT* have further machines for each RAM size within a
> > model.
> 
> Got it. Unfortunately I spent more than my hobbyist time credit
> doing this, so if I find the motivation to revisit, it'll be later.
> 
> Still, having machine memory size depending on the host config was
> a bad design choice IMHO, as we test different setup depending on
> the host being used, so not really a "reproducible" setup.

Yeah that one is a bit ugly. IMHO it would be valid to just leave
it defaulted to 2GB and ensure we get a nice error message on
32-bit hosts, letting users override RAM size if they desire. Or
its just another reason to kill 32-bit hosts

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  9:57       ` Daniel P. Berrangé
  2025-02-04 10:48         ` Philippe Mathieu-Daudé
@ 2025-02-04 11:13         ` Peter Maydell
  2025-02-04 13:40           ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 11:13 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Philippe Mathieu-Daudé, qemu-devel, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 09:57, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Tue, Feb 04, 2025 at 10:51:04AM +0100, Philippe Mathieu-Daudé wrote:
> > On 4/2/25 10:22, Peter Maydell wrote:
> > > On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> > > >
> > > > All previous raspi machines can be created using the
> > > > generic machine. Deprecate the old names to maintain
> > > > a single one. Update the tests.
> > > >
> > > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > >
> > > > diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> > > > index 4a3c302962a..c9a11a52f78 100644
> > > > --- a/docs/about/deprecated.rst
> > > > +++ b/docs/about/deprecated.rst
> > > > @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
> > > >   Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
> > > >   CPUs. Big endian support is not tested.
> > > >
> > > > +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
> > > > +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > > > +
> > > > +The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
> > > > +which takes the model as argument.
> > > > +
> > > > +    - `raspi0`` is now an alias for ``raspi,model=Zero``
> > > > +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
> > > > +    - `raspi2b`` is now an alias for ``raspi,model=2B``
> > > > +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
> > > > +    - `raspi3b`` is now an alias for ``raspi,model=3B``
> > > > +    - `raspi4b`` is now an alias for ``raspi,model=4B``
> > >
> > > This is not how we typically handle "we have a bunch
> > > of different devboards in one family". What's wrong with the
> > > existing set of machine names?
> >
> > Zoltan and you don't want to add more machine names, then you
> > don't want a generic machine. This is very confusing.
>
> IMHO we can have distinct machines for each model, but
> *NOT* have further machines for each RAM size within a
> model.

Yes, this was what I was intending to suggest. Apologies
if I was confusing with what I said the previous time round.

thanks
-- PMM


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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04 11:13         ` Peter Maydell
@ 2025-02-04 13:40           ` Philippe Mathieu-Daudé
  2025-02-04 13:52             ` Peter Maydell
  0 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04 13:40 UTC (permalink / raw)
  To: Peter Maydell, Daniel P. Berrangé
  Cc: qemu-devel, BALATON Zoltan, Laurent Vivier, Ovchinnikov Vitalii,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

On 4/2/25 12:13, Peter Maydell wrote:
> On Tue, 4 Feb 2025 at 09:57, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>
>> On Tue, Feb 04, 2025 at 10:51:04AM +0100, Philippe Mathieu-Daudé wrote:
>>> On 4/2/25 10:22, Peter Maydell wrote:
>>>> On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>>>
>>>>> All previous raspi machines can be created using the
>>>>> generic machine. Deprecate the old names to maintain
>>>>> a single one. Update the tests.
>>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>>
>>>>> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
>>>>> index 4a3c302962a..c9a11a52f78 100644
>>>>> --- a/docs/about/deprecated.rst
>>>>> +++ b/docs/about/deprecated.rst
>>>>> @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
>>>>>    Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added for little endian
>>>>>    CPUs. Big endian support is not tested.
>>>>>
>>>>> +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b`` and ``raspi4b`` machines (since 10.0)
>>>>> +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>> +
>>>>> +The Raspberry Pi machines have been unified under the generic ``raspi`` machine,
>>>>> +which takes the model as argument.
>>>>> +
>>>>> +    - `raspi0`` is now an alias for ``raspi,model=Zero``
>>>>> +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
>>>>> +    - `raspi2b`` is now an alias for ``raspi,model=2B``
>>>>> +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
>>>>> +    - `raspi3b`` is now an alias for ``raspi,model=3B``
>>>>> +    - `raspi4b`` is now an alias for ``raspi,model=4B``
>>>>
>>>> This is not how we typically handle "we have a bunch
>>>> of different devboards in one family". What's wrong with the
>>>> existing set of machine names?
>>>
>>> Zoltan and you don't want to add more machine names, then you
>>> don't want a generic machine. This is very confusing.
>>
>> IMHO we can have distinct machines for each model, but
>> *NOT* have further machines for each RAM size within a
>> model.
> 
> Yes, this was what I was intending to suggest. Apologies
> if I was confusing with what I said the previous time round.

OK, let's see if we understand each other correctly as developer,
before explaining to users, taking the 4B model as example.

The 4B come in 4 physical variants, depending on the amount of
DRAM: 1G, 2G, 4G and 8G.

We can not allocate 2G on 32-bit hosts, so to have a reproducible
guest behavior on 32/64-bit hosts, it makes sense to takes the
model with 1G of DRAM as default for the 'raspi4b' machine.

If an user specify -m 2G ... 8G, we can adapt the 'board_rev'
register to expose the corresponding amount of ram. Now, how /
where to tell the users 1/ the default is 1G, and 2/ they can use
2/4/8G?


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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04 13:40           ` Philippe Mathieu-Daudé
@ 2025-02-04 13:52             ` Peter Maydell
  2025-02-04 14:59               ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 13:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Daniel P. Berrangé, qemu-devel, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 13:40, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 4/2/25 12:13, Peter Maydell wrote:
> > On Tue, 4 Feb 2025 at 09:57, Daniel P. Berrangé <berrange@redhat.com> wrote:
> >> IMHO we can have distinct machines for each model, but
> >> *NOT* have further machines for each RAM size within a
> >> model.
> >
> > Yes, this was what I was intending to suggest. Apologies
> > if I was confusing with what I said the previous time round.
>
> OK, let's see if we understand each other correctly as developer,
> before explaining to users, taking the 4B model as example.
>
> The 4B come in 4 physical variants, depending on the amount of
> DRAM: 1G, 2G, 4G and 8G.
>
> We can not allocate 2G on 32-bit hosts, so to have a reproducible
> guest behavior on 32/64-bit hosts, it makes sense to takes the
> model with 1G of DRAM as default for the 'raspi4b' machine.

At the moment we create the 1GB version on 32-bit hosts and
the 2GB version on 64-bit hosts. I dunno that that's ideal,
but I think it's probably best not to change that at this point.

> If an user specify -m 2G ... 8G, we can adapt the 'board_rev'
> register to expose the corresponding amount of ram. Now, how /
> where to tell the users 1/ the default is 1G, and 2/ they can use
> 2/4/8G?

In the documentation: docs/system/arm/raspi.rst .

-- PMM


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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04 13:52             ` Peter Maydell
@ 2025-02-04 14:59               ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-04 14:59 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Daniel P. Berrangé, qemu-devel, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On 4/2/25 14:52, Peter Maydell wrote:
> On Tue, 4 Feb 2025 at 13:40, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> On 4/2/25 12:13, Peter Maydell wrote:
>>> On Tue, 4 Feb 2025 at 09:57, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>>> IMHO we can have distinct machines for each model, but
>>>> *NOT* have further machines for each RAM size within a
>>>> model.
>>>
>>> Yes, this was what I was intending to suggest. Apologies
>>> if I was confusing with what I said the previous time round.
>>
>> OK, let's see if we understand each other correctly as developer,
>> before explaining to users, taking the 4B model as example.
>>
>> The 4B come in 4 physical variants, depending on the amount of
>> DRAM: 1G, 2G, 4G and 8G.
>>
>> We can not allocate 2G on 32-bit hosts, so to have a reproducible
>> guest behavior on 32/64-bit hosts, it makes sense to takes the
>> model with 1G of DRAM as default for the 'raspi4b' machine.
> 
> At the moment we create the 1GB version on 32-bit hosts and
> the 2GB version on 64-bit hosts. I dunno that that's ideal,
> but I think it's probably best not to change that at this point.

Well this is annoying in my "unify qemu-system-{arm/aarch64}" effort,
but not a blocker.

>> If an user specify -m 2G ... 8G, we can adapt the 'board_rev'
>> register to expose the corresponding amount of ram. Now, how /
>> where to tell the users 1/ the default is 1G, and 2/ they can use
>> 2/4/8G?
> 
> In the documentation: docs/system/arm/raspi.rst .

OK.

Back to this series, please tell me if patches 1-7 aren't useful or
if you prefer them in a separate series:

   hw/arm/raspi: Access SoC parent object using  BCM283X_BASE() macro
   hw/arm/raspi: Merge model 4B with other models
   hw/arm/raspi: Unify RASPI_MACHINE types
   hw/arm/raspi: Pass board_rev as argument to raspi_base_machine_init()
   hw/arm/raspi: Consider processor id in types[] array
   hw/arm/raspi: Consider network interface for B models
   hw/arm/raspi: Check ramsize is within chipset aperture

Thanks,

Phil.


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

* Re: [PATCH v2 01/12] hw/arm/raspi: Access SoC parent object using BCM283X_BASE() macro
  2025-02-04  0:22 ` [PATCH v2 01/12] hw/arm/raspi: Access SoC parent object using BCM283X_BASE() macro Philippe Mathieu-Daudé
@ 2025-02-04 15:01   ` Peter Maydell
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 15:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 00:22, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> We shouldn't access a QOM parent object directly.
> Use the appropriate type-cast macro.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/raspi.c   | 2 +-
>  hw/arm/raspi4b.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 02/12] hw/arm/raspi: Merge model 4B with other models
  2025-02-04  0:22 ` [PATCH v2 02/12] hw/arm/raspi: Merge model 4B with other models Philippe Mathieu-Daudé
@ 2025-02-04 15:02   ` Peter Maydell
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 15:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 00:22, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Except we alter the device tree blob, the 4B
> is just another raspi model.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/raspi.c     | 114 ++++++++++++++++++++++++++++++++++++-
>  hw/arm/raspi4b.c   | 136 ---------------------------------------------
>  hw/arm/meson.build |   2 +-
>  3 files changed, 114 insertions(+), 138 deletions(-)
>  delete mode 100644 hw/arm/raspi4b.c

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 03/12] hw/arm/raspi: Unify RASPI_MACHINE types
  2025-02-04  0:22 ` [PATCH v2 03/12] hw/arm/raspi: Unify RASPI_MACHINE types Philippe Mathieu-Daudé
@ 2025-02-04 15:06   ` Peter Maydell
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 15:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Merge Raspi4bMachineState within RaspiMachineState by
> using an unnamed union.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/raspi.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index 3fa382d62ce..ef94d57dab5 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -38,9 +38,6 @@
>  #define TYPE_RASPI_MACHINE  MACHINE_TYPE_NAME("raspi-common")
>  OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE)
>
> -#define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b")
> -OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
> -
>  #define SMPBOOT_ADDR    0x300 /* this should leave enough space for ATAGS */
>  #define MVBAR_ADDR      0x400 /* secure vectors */
>  #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
> @@ -49,15 +46,12 @@ OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
>  #define SPINTABLE_ADDR  0xd8 /* Pi 3 bootloader spintable */
>
>  struct RaspiMachineState {
> -    /*< private >*/
>      RaspiBaseMachineState parent_obj;
> -    /*< public >*/
> -    BCM283XState soc;
> -};
>
> -struct Raspi4bMachineState {
> -    RaspiBaseMachineState parent_obj;
> -    BCM2838State soc;
> +    union {
> +        BCM283XState soc;
> +        BCM2838State soc4;
> +    };

Do we have any other examples of using a union like this?
I think it's exactly because the components are different
for raspi4b that it has its own machine state struct.

thanks
-- PMM


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

* Re: [PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array
  2025-02-04  0:22 ` [PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array Philippe Mathieu-Daudé
@ 2025-02-04 15:08   ` Peter Maydell
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 15:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Expand the current type2model array to include the processor id.
>
> Since the BCM2838 is indistinctly used as BCM2711 (within the
> Linux community), add it as alias in RaspiProcessorId.

Can you explain this in more detail? Presumably the hardware
itself has whatever ID it has...

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

-- PMM


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

* Re: [PATCH v2 06/12] hw/arm/raspi: Consider network interface for B models
  2025-02-04  0:22 ` [PATCH v2 06/12] hw/arm/raspi: Consider network interface for B models Philippe Mathieu-Daudé
@ 2025-02-04 15:09   ` Peter Maydell
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 15:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Raspberry Pi 'B' models have an ethernet chipset (the LAN9512).
> Since we don't yet model it, add a /* TODO */ comment.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/raspi.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index 1a6a1f8ff22..68332fba027 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -143,6 +143,16 @@ static const char *board_type(uint32_t board_rev)
>      return types[bt].model;
>  }
>
> +static bool is_model_b(uint32_t board_rev)
> +{
> +    return !!strchr(board_type(board_rev), 'B');
> +}
> +
> +static bool has_enet(uint32_t board_rev)
> +{
> +    return is_model_b(board_rev);
> +}
> +
>  static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
>  {
>      static const ARMInsnFixup smpboot[] = {
> @@ -304,6 +314,10 @@ void raspi_base_machine_init(MachineState *machine,
>                              machine->kernel_cmdline, &error_abort);
>      qdev_realize(DEVICE(soc), NULL, &error_fatal);
>
> +    if (has_enet(board_rev)) {
> +        /* TODO: model LAN9512 and wire over USB2 */
> +    }
> +

Why bother, if we don't do anything anyway? We can
say in the TODO comment
 /* TODO: "B" models have a LAN9512 on the USB bus */

thanks
-- PMM


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

* Re: [PATCH v2 07/12] hw/arm/raspi: Check ramsize is within chipset aperture
  2025-02-04  0:22 ` [PATCH v2 07/12] hw/arm/raspi: Check ramsize is within chipset aperture Philippe Mathieu-Daudé
@ 2025-02-04 15:10   ` Peter Maydell
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Maydell @ 2025-02-04 15:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Daniel P . Berrangé, BALATON Zoltan,
	Laurent Vivier, Ovchinnikov Vitalii, Jared Mauch, Fabiano Rosas,
	Paolo Bonzini, qemu-arm, Alex Bennée, devel

On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Add the 'max_ramsize' field to the soc_property[] array,
> corresponding to the maximum DRAM size a SoC can map.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/raspi.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index 68332fba027..d44277001ee 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -76,11 +76,12 @@ typedef enum RaspiProcessorId {
>  static const struct {
>      const char *type;
>      int cores_count;
> +    uint64_t max_ramsize;
>  } soc_property[] = {
> -    [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1},
> -    [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS},
> -    [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS},
> -    [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS},
> +    [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1,              512 * MiB},
> +    [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS,  1 * GiB},
> +    [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS,  1 * GiB},
> +    [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS,  8 * GiB},
>  };
>
>  static const struct {
> @@ -133,6 +134,11 @@ static int cores_count(uint32_t board_rev)
>      return soc_property[board_processor_id(board_rev)].cores_count;
>  }
>
> +static uint64_t ramsize_max(uint32_t board_rev)
> +{
> +    return soc_property[board_processor_id(board_rev)].max_ramsize;
> +}
> +
>  static const char *board_type(uint32_t board_rev)
>  {
>      assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
> @@ -294,6 +300,7 @@ void raspi_base_machine_init(MachineState *machine,
>      BlockBackend *blk;
>      BusState *bus;
>      DeviceState *carddev;
> +    uint64_t max_ramsize;
>
>      if (machine->ram_size != ram_size) {
>          char *size_str = size_to_str(ram_size);
> @@ -301,6 +308,12 @@ void raspi_base_machine_init(MachineState *machine,
>          g_free(size_str);
>          exit(1);
>      }
> +    max_ramsize = ramsize_max(board_rev);
> +    if (ram_size > max_ramsize) {
> +        g_autofree char *max_ramsize_str = size_to_str(max_ramsize);
> +        error_report("At most %s of RAM can be used", max_ramsize_str);
> +         exit(1);

Indent error?

> +    }

Otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names
  2025-02-04  9:58       ` BALATON Zoltan
@ 2025-02-22 21:57         ` Jared Mauch
  0 siblings, 0 replies; 30+ messages in thread
From: Jared Mauch @ 2025-02-22 21:57 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Philippe Mathieu-Daudé, Peter Maydell, qemu-devel,
	Daniel P . Berrangé, Laurent Vivier, Ovchinnikov Vitalii,
	Jared Mauch, Fabiano Rosas, Paolo Bonzini, qemu-arm,
	Alex Bennée, devel

On Tue, Feb 04, 2025 at 10:58:39AM +0100, BALATON Zoltan wrote:
> On Tue, 4 Feb 2025, Philippe Mathieu-Daudé wrote:
> > On 4/2/25 10:22, Peter Maydell wrote:
> > > On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé
> > > <philmd@linaro.org> wrote:
> > > > 
> > > > All previous raspi machines can be created using the
> > > > generic machine. Deprecate the old names to maintain
> > > > a single one. Update the tests.
> > > > 
> > > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > > 
> > > > diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> > > > index 4a3c302962a..c9a11a52f78 100644
> > > > --- a/docs/about/deprecated.rst
> > > > +++ b/docs/about/deprecated.rst
> > > > @@ -257,6 +257,19 @@ Big-Endian variants of MicroBlaze
> > > > ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` ma
> > > >   Both ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` were added
> > > > for little endian
> > > >   CPUs. Big endian support is not tested.
> > > > 
> > > > +ARM ``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``,
> > > > ``raspi3b`` and ``raspi4b`` machines (since 10.0)
> > > > +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > > > +
> > > > +The Raspberry Pi machines have been unified under the generic
> > > > ``raspi`` machine,
> > > > +which takes the model as argument.
> > > > +
> > > > +    - `raspi0`` is now an alias for ``raspi,model=Zero``
> > > > +    - `raspi1ap`` is now an alias for ``raspi,model=1A+``
> > > > +    - `raspi2b`` is now an alias for ``raspi,model=2B``
> > > > +    - `raspi3ap`` is now an alias for ``raspi,model=3A+``
> > > > +    - `raspi3b`` is now an alias for ``raspi,model=3B``
> > > > +    - `raspi4b`` is now an alias for ``raspi,model=4B``
> > > 
> > > This is not how we typically handle "we have a bunch
> > > of different devboards in one family". What's wrong with the
> > > existing set of machine names?
> > 
> > Zoltan and you don't want to add more machine names, then you
> > don't want a generic machine. This is very confusing.
> 
> I said either rastpi4b,revision=1.4 or -machine raspi4b -memory 4g would be
> better IMHO. Peter perefers -memory which is also fine with me. I just don't
> think adding more machine names where only RAM size is different would be
> better than using -memory for that as usual.

	I'm the annoying root cause of this as I had filed this:
https://gitlab.com/qemu-project/qemu/-/issues/2797#note_2326724893

Which was really a question around providing more memory options, I'm
happy seeing a lot of thought has gone into my simple question/request,
but it's unclear reading this thread where things concluded.

	Is there a chance these are in a branch that one could build
against to get consensus on some of this style vs substance stuff?  I
get it that it's tricky and do generally think that one could restrict
armhf vs arm64 to having 64-bit support in the (hypervisor) OS.

	I was wanting to tweak some disk images before imaging a bunch
of nvme for use and saw using kvm/qemu as a straightforward path to
doing that on my laptop (x86_64) before firing up a bunch of compute
modules etc.

	- Jared
[i'm not subscribed to the qemu-dev list, so I expect mailman will
hold/bounce me]

-- 
Jared Mauch  | pgp key available via finger from jared@puck.nether.net
clue++;      | http://puck.nether.net/~jared/  My statements are only mine.


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

end of thread, other threads:[~2025-02-22 22:14 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-04  0:22 [PATCH v2 00/12] hw/arm/raspi: Allow creating any Raspberry Pi machine Philippe Mathieu-Daudé
2025-02-04  0:22 ` [PATCH v2 01/12] hw/arm/raspi: Access SoC parent object using BCM283X_BASE() macro Philippe Mathieu-Daudé
2025-02-04 15:01   ` Peter Maydell
2025-02-04  0:22 ` [PATCH v2 02/12] hw/arm/raspi: Merge model 4B with other models Philippe Mathieu-Daudé
2025-02-04 15:02   ` Peter Maydell
2025-02-04  0:22 ` [PATCH v2 03/12] hw/arm/raspi: Unify RASPI_MACHINE types Philippe Mathieu-Daudé
2025-02-04 15:06   ` Peter Maydell
2025-02-04  0:22 ` [PATCH v2 04/12] hw/arm/raspi: Pass board_rev as argument to raspi_base_machine_init() Philippe Mathieu-Daudé
2025-02-04  0:22 ` [PATCH v2 05/12] hw/arm/raspi: Consider processor id in types[] array Philippe Mathieu-Daudé
2025-02-04 15:08   ` Peter Maydell
2025-02-04  0:22 ` [PATCH v2 06/12] hw/arm/raspi: Consider network interface for B models Philippe Mathieu-Daudé
2025-02-04 15:09   ` Peter Maydell
2025-02-04  0:22 ` [PATCH v2 07/12] hw/arm/raspi: Check ramsize is within chipset aperture Philippe Mathieu-Daudé
2025-02-04 15:10   ` Peter Maydell
2025-02-04  0:22 ` [PATCH v2 08/12] hw/arm/raspi: Introduce generic Raspberry Pi machine Philippe Mathieu-Daudé
2025-02-04  0:22 ` [PATCH v2 09/12] hw/arm/raspi: Have the generic machine take a 'revision' property Philippe Mathieu-Daudé
2025-02-04  0:22 ` [PATCH v2 10/12] hw/arm/raspi: List models creatable by the generic 'raspi' machine Philippe Mathieu-Daudé
2025-02-04  0:22 ` [PATCH v2 11/12] hw/arm/raspi: Deprecate old raspiX machine names Philippe Mathieu-Daudé
2025-02-04  9:22   ` Peter Maydell
2025-02-04  9:51     ` Philippe Mathieu-Daudé
2025-02-04  9:57       ` Daniel P. Berrangé
2025-02-04 10:48         ` Philippe Mathieu-Daudé
2025-02-04 10:51           ` Daniel P. Berrangé
2025-02-04 11:13         ` Peter Maydell
2025-02-04 13:40           ` Philippe Mathieu-Daudé
2025-02-04 13:52             ` Peter Maydell
2025-02-04 14:59               ` Philippe Mathieu-Daudé
2025-02-04  9:58       ` BALATON Zoltan
2025-02-22 21:57         ` Jared Mauch
2025-02-04  0:22 ` [PATCH v2 12/12] hw/arm/raspi: Support more models Philippe Mathieu-Daudé

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