All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, jan.kiszka@web.de
Subject: [PATCH v6 24/79] arm/musicpal: use memdev for RAM
Date: Wed, 19 Feb 2020 11:08:58 -0500	[thread overview]
Message-ID: <20200219160953.13771-25-imammedo@redhat.com> (raw)
In-Reply-To: <20200219160953.13771-1-imammedo@redhat.com>

memory_region_allocate_system_memory() API is going away, so
replace it with memdev allocated MemoryRegion. The later is
initialized by generic code, so board only needs to opt in
to memdev scheme by providing
  MachineClass::default_ram_id
and using MachineState::ram instead of manually initializing
RAM memory region.

PS:
 while at it add check for user supplied RAM size and error
 out if it mismatches board expected value.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
v2:
  * fix format string causing build failure on 32-bit host
    (Philippe Mathieu-Daudé <philmd@redhat.com>)

CC: jan.kiszka@web.de
---
 hw/arm/musicpal.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index dc551bb0c0..db8b03cb83 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -32,6 +32,7 @@
 #include "sysemu/runstate.h"
 #include "exec/address-spaces.h"
 #include "ui/pixel_ops.h"
+#include "qemu/cutils.h"
 
 #define MP_MISC_BASE            0x80002000
 #define MP_MISC_SIZE            0x00001000
@@ -1589,16 +1590,21 @@ static void musicpal_init(MachineState *machine)
     int i;
     unsigned long flash_size;
     DriveInfo *dinfo;
+    MachineClass *mc = MACHINE_GET_CLASS(machine);
     MemoryRegion *address_space_mem = get_system_memory();
-    MemoryRegion *ram = g_new(MemoryRegion, 1);
     MemoryRegion *sram = g_new(MemoryRegion, 1);
 
+    /* For now we use a fixed - the original - RAM size */
+    if (machine->ram_size != mc->default_ram_size) {
+        char *sz = size_to_str(mc->default_ram_size);
+        error_report("Invalid RAM size, should be %s", sz);
+        g_free(sz);
+        exit(EXIT_FAILURE);
+    }
+
     cpu = ARM_CPU(cpu_create(machine->cpu_type));
 
-    /* For now we use a fixed - the original - RAM size */
-    memory_region_allocate_system_memory(ram, NULL, "musicpal.ram",
-                                         MP_RAM_DEFAULT_SIZE);
-    memory_region_add_subregion(address_space_mem, 0, ram);
+    memory_region_add_subregion(address_space_mem, 0, machine->ram);
 
     memory_region_init_ram(sram, NULL, "musicpal.sram", MP_SRAM_SIZE,
                            &error_fatal);
@@ -1714,6 +1720,8 @@ static void musicpal_machine_init(MachineClass *mc)
     mc->init = musicpal_init;
     mc->ignore_memory_transaction_failures = true;
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926");
+    mc->default_ram_size = MP_RAM_DEFAULT_SIZE;
+    mc->default_ram_id = "musicpal.ram";
 }
 
 DEFINE_MACHINE("musicpal", musicpal_machine_init)
-- 
2.18.1



  parent reply	other threads:[~2020-02-19 16:22 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 16:08 [PATCH v6 00/79] refactor main RAM allocation to use hostmem backend Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 01/79] numa: remove deprecated -mem-path fallback to anonymous RAM Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 02/79] machine: introduce memory-backend property Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 03/79] machine: alias -mem-path and -mem-prealloc into memory-foo backend Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 04/79] machine: introduce convenience MachineState::ram Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 05/79] initialize MachineState::ram in NUMA case Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 06/79] vl.c: move -m parsing after memory backends has been processed Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 07/79] vl.c: ensure that ram_size matches size of machine.memory-backend Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 08/79] alpha/dp264: use memdev for RAM Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 09/79] arm/aspeed: actually check RAM size Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 10/79] arm/aspeed: use memdev for RAM Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 11/79] arm/collie: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 12/79] arm/cubieboard: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 13/79] arm/digic_boards: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 14/79] arm/highbank: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 15/79] arm/imx25_pdk: drop RAM size fixup Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 16/79] arm/imx25_pdk: use memdev for RAM Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 17/79] arm/integratorcp: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 18/79] arm/kzm: drop RAM size fixup Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 19/79] arm/kzm: use memdev for RAM Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 20/79] arm/mcimx6ul-evk: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 21/79] arm/mcimx7d-sabre: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 22/79] arm/mps2-tz: " Igor Mammedov
2020-02-19 16:08 ` [PATCH v6 23/79] arm/mps2: " Igor Mammedov
2020-02-19 16:08 ` Igor Mammedov [this message]
2020-02-19 16:08 ` [PATCH v6 25/79] arm/nseries: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 26/79] arm/omap_sx1: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 27/79] arm/palm: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 28/79] arm/sabrelite: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 29/79] arm/raspi: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 30/79] arm/sbsa-ref: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 31/79] arm/versatilepb: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 32/79] arm/vexpress: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 33/79] arm/virt: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 34/79] arm/xilinx_zynq: drop RAM size fixup Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 35/79] arm/xilinx_zynq: use memdev for RAM Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 36/79] arm/xlnx-versal-virt: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 37/79] arm/xlnx-zcu102: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 38/79] s390x/s390-virtio-ccw: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 39/79] null-machine: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 40/79] cris/axis_dev88: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 41/79] hppa: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 42/79] x86/microvm: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 43/79] x86/pc: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 44/79] lm32/lm32_boards: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 45/79] lm32/milkymist: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 46/79] m68k/an5206: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 47/79] m68k/q800: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 48/79] m68k/mcf5208: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 49/79] m68k/next-cube: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 50/79] mips/boston: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 51/79] mips/mips_fulong2e: drop RAM size fixup Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 52/79] mips/mips_fulong2e: use memdev for RAM Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 53/79] mips/mips_jazz: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 54/79] mips/mips_jazz: add max ram size check Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 55/79] mips/mips_malta: use memdev for RAM Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 56/79] mips/mips_mipssim: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 57/79] mips/mips_r4k: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 58/79] ppc/e500: drop RAM size fixup Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 59/79] ppc/e500: use memdev for RAM Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 60/79] ppc/mac_newworld: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 61/79] ppc/mac_oldworld: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 62/79] ppc/pnv: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 63/79] ppc/ppc405_boards: add RAM size checks Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 64/79] ppc/ppc405_boards: use memdev for RAM Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 65/79] ppc/{ppc440_bamboo, sam460ex}: drop RAM size fixup Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 66/79] ppc/{ppc440_bamboo, sam460ex}: use memdev for RAM Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 67/79] ppc/spapr: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 68/79] ppc/virtex_ml507: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 69/79] sparc/leon3: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 70/79] sparc/sun4m: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 71/79] sparc/niagara: " Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 72/79] remove no longer used memory_region_allocate_system_memory() Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 73/79] exec: cleanup qemu_minrampagesize()/qemu_maxrampagesize() Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 74/79] exec: drop bogus mem_path from qemu_ram_alloc_from_fd() Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 75/79] make mem_path local variable Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 76/79] hostmem: introduce "prealloc-threads" property Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 77/79] hostmem: fix strict bind policy Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 78/79] tests/numa-test: make top level args dynamic and g_autofree(cli) cleanups Igor Mammedov
2020-02-19 16:09 ` [PATCH v6 79/79] tests:numa-test: use explicit memdev to specify node RAM Igor Mammedov
2020-02-19 16:58 ` [PATCH v6 00/79] refactor main RAM allocation to use hostmem backend no-reply
2020-02-24  8:45 ` Philippe Mathieu-Daudé
2020-02-24 11:33   ` Igor Mammedov
2020-02-24 11:38     ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200219160953.13771-25-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.