From: David Gibson <david@gibson.dropbear.id.au>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH REPOST v3 65/80] ppc/{ppc440_bamboo, sam460ex}: use memdev for RAM
Date: Mon, 27 Jan 2020 14:40:08 +1100 [thread overview]
Message-ID: <20200127034008.GD1818@umbus.fritz.box> (raw)
In-Reply-To: <1579779525-20065-66-git-send-email-imammedo@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 7193 bytes --]
On Thu, Jan 23, 2020 at 12:38:30PM +0100, Igor Mammedov wrote:
> 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.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> v3:
> * drop ram_size from comment above ppc4xx_sdram_banks
> (BALATON Zoltan <balaton@eik.bme.hu>)
> * move memory alias initialization into the same loop
> where RAM is split on banks.
> (BALATON Zoltan <balaton@eik.bme.hu>)
> v3.1
> * rebase on top of previous patch due to changed context
>
> CC: balaton@eik.bme.hu
> CC: david@gibson.dropbear.id.au
> CC: qemu-ppc@nongnu.org
> ---
> include/hw/ppc/ppc4xx.h | 2 +-
> hw/ppc/ppc440_bamboo.c | 3 ++-
> hw/ppc/ppc4xx_devs.c | 25 +++++++++----------------
> hw/ppc/sam460ex.c | 3 ++-
> 4 files changed, 14 insertions(+), 19 deletions(-)
>
> diff --git a/include/hw/ppc/ppc4xx.h b/include/hw/ppc/ppc4xx.h
> index b8c8f32..cc19c8d 100644
> --- a/include/hw/ppc/ppc4xx.h
> +++ b/include/hw/ppc/ppc4xx.h
> @@ -42,7 +42,7 @@ enum {
> qemu_irq *ppcuic_init (CPUPPCState *env, qemu_irq *irqs,
> uint32_t dcr_base, int has_ssr, int has_vr);
>
> -void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks,
> +void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks,
> MemoryRegion ram_memories[],
> hwaddr ram_bases[], hwaddr ram_sizes[],
> const ram_addr_t sdram_bank_sizes[]);
> diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
> index 29a9642..1d4a11d 100644
> --- a/hw/ppc/ppc440_bamboo.c
> +++ b/hw/ppc/ppc440_bamboo.c
> @@ -202,7 +202,7 @@ static void bamboo_init(MachineState *machine)
> /* SDRAM controller */
> memset(ram_bases, 0, sizeof(ram_bases));
> memset(ram_sizes, 0, sizeof(ram_sizes));
> - ppc4xx_sdram_banks(machine->ram_size, PPC440EP_SDRAM_NR_BANKS, ram_memories,
> + ppc4xx_sdram_banks(machine->ram, PPC440EP_SDRAM_NR_BANKS, ram_memories,
> ram_bases, ram_sizes, ppc440ep_sdram_bank_sizes);
> /* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */
> ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_memories,
> @@ -289,6 +289,7 @@ static void bamboo_machine_init(MachineClass *mc)
> mc->desc = "bamboo";
> mc->init = bamboo_init;
> mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("440epb");
> + mc->default_ram_id = "ppc4xx.sdram";
> }
>
> DEFINE_MACHINE("bamboo", bamboo_machine_init)
> diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
> index d89008a..0e2f81c 100644
> --- a/hw/ppc/ppc4xx_devs.c
> +++ b/hw/ppc/ppc4xx_devs.c
> @@ -666,7 +666,7 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,
> sdram_map_bcr(sdram);
> }
>
> -/* Fill in consecutive SDRAM banks with 'ram_size' bytes of memory.
> +/* Split RAM between SDRAM banks.
> *
> * sdram_bank_sizes[] must be in descending order, that is sizes[i] > sizes[i+1]
> * and must be 0-terminated.
> @@ -674,16 +674,14 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,
> * The 4xx SDRAM controller supports a small number of banks, and each bank
> * must be one of a small set of sizes. The number of banks and the supported
> * sizes varies by SoC. */
> -void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks,
> +void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks,
> MemoryRegion ram_memories[],
> hwaddr ram_bases[], hwaddr ram_sizes[],
> const ram_addr_t sdram_bank_sizes[])
> {
> - MemoryRegion *ram = g_malloc0(sizeof(*ram));
> - ram_addr_t size_left = ram_size;
> + ram_addr_t size_left = memory_region_size(ram);
> ram_addr_t base = 0;
> ram_addr_t bank_size;
> - int last_bank = 0;
> int i;
> int j;
>
> @@ -691,11 +689,15 @@ void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks,
> for (j = 0; sdram_bank_sizes[j] != 0; j++) {
> bank_size = sdram_bank_sizes[j];
> if (bank_size <= size_left) {
> + char name[32];
> +
> ram_bases[i] = base;
> ram_sizes[i] = bank_size;
> base += bank_size;
> size_left -= bank_size;
> - last_bank = i;
> + snprintf(name, sizeof(name), "ppc4xx.sdram%d", i);
> + memory_region_init_alias(&ram_memories[i], NULL, name, ram,
> + ram_bases[i], ram_sizes[i]);
> break;
> }
> }
> @@ -706,7 +708,7 @@ void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks,
> }
>
> if (size_left) {
> - ram_addr_t used_size = ram_size - size_left;
> + ram_addr_t used_size = memory_region_size(ram) - size_left;
> GString *s = g_string_new(NULL);
>
> for (i = 0; sdram_bank_sizes[i]; i++) {
> @@ -722,15 +724,6 @@ void ppc4xx_sdram_banks(ram_addr_t ram_size, int nr_banks,
> g_string_free(s, true);
> exit(EXIT_FAILURE);
> }
> -
> - memory_region_allocate_system_memory(ram, NULL, "ppc4xx.sdram", ram_size);
> -
> - for (i = 0; i <= last_bank; i++) {
> - char name[32];
> - snprintf(name, sizeof(name), "ppc4xx.sdram%d", i);
> - memory_region_init_alias(&ram_memories[i], NULL, name, ram,
> - ram_bases[i], ram_sizes[i]);
> - }
> }
>
> /*****************************************************************************/
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index 949acba..b48aea5 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -324,7 +324,7 @@ static void sam460ex_init(MachineState *machine)
> /* SDRAM controller */
> /* put all RAM on first bank because board has one slot
> * and firmware only checks that */
> - ppc4xx_sdram_banks(machine->ram_size, 1, ram_memories, ram_bases, ram_sizes,
> + ppc4xx_sdram_banks(machine->ram, 1, ram_memories, ram_bases, ram_sizes,
> ppc460ex_sdram_bank_sizes);
>
> /* FIXME: does 460EX have ECC interrupts? */
> @@ -483,6 +483,7 @@ static void sam460ex_machine_init(MachineClass *mc)
> mc->init = sam460ex_init;
> mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("460exb");
> mc->default_ram_size = 512 * MiB;
> + mc->default_ram_id = "ppc4xx.sdram";
> }
>
> DEFINE_MACHINE("sam460ex", sam460ex_machine_init)
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-01-27 3:41 UTC|newest]
Thread overview: 134+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-23 11:37 [PATCH REPOST v3 00/80] refactor main RAM allocation to use hostmem backend Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 01/80] numa: remove deprecated -mem-path fallback to anonymous RAM Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 02/80] machine: introduce memory-backend property Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 03/80] machine: alias -mem-path and -mem-prealloc into memory-foo backend Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 04/80] machine: introduce convenience MachineState::ram Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 05/80] initialize MachineState::ram in NUMA case Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 06/80] alpha:dp264: use memdev for RAM Igor Mammedov
2020-01-23 15:07 ` BALATON Zoltan
2020-01-24 8:13 ` Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 07/80] arm/aspeed: actually check RAM size Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 08/80] arm/aspeed: use memdev for RAM Igor Mammedov
2020-01-23 12:08 ` Joel Stanley
2020-01-23 11:37 ` [PATCH REPOST v3 09/80] arm/collie: " Igor Mammedov
2020-01-23 12:27 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 10/80] arm/cubieboard: " Igor Mammedov
2020-01-23 12:30 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 11/80] arm/digic_boards: " Igor Mammedov
2020-01-23 12:32 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 12/80] arm/highbank: " Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 13/80] arm/imx25_pdk: drop RAM size fixup Igor Mammedov
2020-01-23 12:39 ` Andrew Jones
2020-01-23 14:32 ` Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 14/80] arm/imx25_pdk: use memdev for RAM Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 15/80] arm/integratorcp: " Igor Mammedov
2020-01-23 12:40 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 16/80] arm/kzm: drop RAM size fixup Igor Mammedov
2020-01-23 22:23 ` Chubb, Peter (Data61, Kensington NSW)
2020-01-24 8:10 ` Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 17/80] arm/kzm: use memdev for RAM Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 18/80] arm/mcimx6ul-evk: " Igor Mammedov
2020-01-23 12:50 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 19/80] arm/mcimx7d-sabre: " Igor Mammedov
2020-01-23 12:51 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 20/80] arm/mps2-tz: " Igor Mammedov
2020-01-23 12:59 ` Andrew Jones
2020-01-23 13:39 ` Igor Mammedov
2020-01-23 14:37 ` Andrew Jones
2020-01-23 14:37 ` [PATCH v4 " Igor Mammedov
2020-01-23 14:47 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 21/80] arm/mps2: " Igor Mammedov
2020-01-23 13:00 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 22/80] arm/musicpal: " Igor Mammedov
2020-01-23 13:07 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 23/80] arm/nseries: " Igor Mammedov
2020-01-23 13:09 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 24/80] arm/omap_sx1: " Igor Mammedov
2020-01-23 13:12 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 25/80] arm/palm: " Igor Mammedov
2020-01-23 13:13 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 26/80] arm/raspi: " Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 27/80] arm/sabrelite: " Igor Mammedov
2020-01-23 13:15 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 28/80] arm/sbsa-ref: " Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 29/80] arm/versatilepb: " Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 30/80] arm/vexpress: " Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 31/80] arm/virt: " Igor Mammedov
2020-01-23 13:17 ` Andrew Jones
2020-01-23 11:37 ` [PATCH REPOST v3 32/80] arm/xilinx_zynq: drop RAM size fixup Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 33/80] arm/xilinx_zynq: use memdev for RAM Igor Mammedov
2020-01-23 11:37 ` [PATCH REPOST v3 34/80] arm/xlnx-versal-virt: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 35/80] arm/xlnx-zcu102: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 36/80] s390x/s390-virtio-ccw: " Igor Mammedov
2020-01-23 18:05 ` Cornelia Huck
2020-01-23 11:38 ` [PATCH REPOST v3 37/80] null-machine: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 38/80] cris/axis_dev88: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 39/80] hw/hppa/machine: Correctly check the firmware is in PDC range Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 40/80] hw/hppa/machine: Restrict the total memory size to 3GB Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 41/80] hw/hppa/machine: Map the PDC memory region with higher priority Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 42/80] hppa: use memdev for RAM Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 43/80] x86/microvm: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 44/80] x86/pc: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 45/80] lm32/lm32_boards: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 46/80] lm32/milkymist: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 47/80] m68k/an5206: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 48/80] m68k/mcf5208: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 49/80] m68k/next-cube: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 50/80] mips/boston-cube: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 51/80] mips/mips_fulong2e: drop RAM size fixup Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 52/80] mips/mips_fulong2e: use memdev for RAM Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 53/80] mips/mips_jazz: " Igor Mammedov
2020-01-24 17:15 ` Aleksandar Markovic
2020-01-23 11:38 ` [PATCH REPOST v3 54/80] mips/mips_malta: " Igor Mammedov
2020-01-24 17:16 ` Aleksandar Markovic
2020-01-23 11:38 ` [PATCH REPOST v3 55/80] mips/mips_mipssim: " Igor Mammedov
2020-01-24 17:17 ` Aleksandar Markovic
2020-01-23 11:38 ` [PATCH REPOST v3 56/80] mips/mips_r4k: " Igor Mammedov
2020-01-24 17:15 ` Aleksandar Markovic
2020-01-23 11:38 ` [PATCH REPOST v3 57/80] ppc/e500: drop RAM size fixup Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 58/80] ppc/e500: use memdev for RAM Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 59/80] ppc/mac_newworld: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 60/80] ppc/mac_oldworld: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 61/80] ppc/pnv: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 62/80] ppc/ppc405_boards: add RAM size checks Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 63/80] ppc/ppc405_boards: use memdev for RAM Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 64/80] ppc/{ppc440_bamboo, sam460ex}: drop RAM size fixup Igor Mammedov
2020-01-23 16:22 ` BALATON Zoltan
2020-01-27 3:39 ` [PATCH REPOST v3 64/80] ppc/{ppc440_bamboo,sam460ex}: " David Gibson
2020-01-23 11:38 ` [PATCH REPOST v3 65/80] ppc/{ppc440_bamboo, sam460ex}: use memdev for RAM Igor Mammedov
2020-01-23 16:23 ` BALATON Zoltan
2020-01-27 3:40 ` David Gibson [this message]
2020-01-23 11:38 ` [PATCH REPOST v3 66/80] ppc/prep: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 67/80] ppc/spapr: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 68/80] ppc/virtex_ml507: remove unused arguments Igor Mammedov
2020-01-24 9:40 ` David Gibson
2020-01-23 11:38 ` [PATCH REPOST v3 69/80] ppc/virtex_ml507: use memdev for RAM Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 70/80] sparc/leon3: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 71/80] sparc/sun4m: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 72/80] sparc/niagara: " Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 73/80] remove no longer used memory_region_allocate_system_memory() Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 74/80] exec: cleanup qemu_minrampagesize()/qemu_maxrampagesize() Igor Mammedov
2020-01-24 10:25 ` Igor Mammedov
2020-01-27 3:31 ` David Gibson
2020-01-27 8:06 ` [PATCH v3.1 " Igor Mammedov
2020-01-27 8:18 ` David Gibson
2020-01-23 11:38 ` [PATCH REPOST v3 75/80] exec: drop bogus mem_path from qemu_ram_alloc_from_fd() Igor Mammedov
2020-01-24 9:35 ` Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 76/80] make mem_path local variable Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 77/80] hostmem: introduce "prealloc-threads" property Igor Mammedov
2020-01-24 9:50 ` Igor Mammedov
2020-01-23 11:38 ` [PATCH REPOST v3 78/80] hostmem: fix strict bind policy Igor Mammedov
2020-01-24 19:17 ` Halil Pasic
2020-01-27 7:39 ` Igor Mammedov
2020-01-27 14:41 ` Halil Pasic
2020-01-28 12:07 ` Igor Mammedov
2020-01-28 12:37 ` Halil Pasic
2020-01-23 11:38 ` [PATCH REPOST v3 79/80] tests:numa-test: make top level args dynamic and g_autofree(cli) cleanups Igor Mammedov
2020-01-23 16:25 ` BALATON Zoltan
2020-01-23 16:33 ` Thomas Huth
2020-01-23 11:38 ` [PATCH REPOST v3 80/80] tests:numa-test: use explicit memdev to specify node RAM Igor Mammedov
2020-01-23 16:52 ` Thomas Huth
2020-01-23 13:04 ` [PATCH REPOST v3 00/80] refactor main RAM allocation to use hostmem backend no-reply
2020-01-23 14:45 ` Laurent Vivier
2020-01-23 16:14 ` [PATCH v4 81/80] m68k/q800: use memdev for RAM Igor Mammedov
2020-01-23 19:31 ` Laurent Vivier
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=20200127034008.GD1818@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 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).