All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Richard Henderson <richard.henderson@linaro.org>,
	Alistair Francis <alistair@alistair23.me>,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	Laurent Vivier <laurent@vivier.eu>,
	qemu-arm@nongnu.org, Jan Kiszka <jan.kiszka@web.de>,
	qemu-ppc@nongnu.org, David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [RFC PATCH-for-6.1 03/10] hw/arm/musicpal: Map flash using memory_region_add_subregion_aliased()
Date: Fri, 26 Mar 2021 23:49:11 +0100	[thread overview]
Message-ID: <4feab40f-0133-8617-52c3-0af0adf419c6@amsat.org> (raw)
In-Reply-To: <20210326002728.1069834-4-f4bug@amsat.org>

On 3/26/21 1:27 AM, Philippe Mathieu-Daudé wrote:
> Instead of using a device specific feature for mapping the
> flash memory multiple times over a wider region, use the
> generic memory_region_add_subregion_aliased() helper.
> 
> There is no change in the memory layout.

- before:

  (qemu) info mtree
  00000000fe000000-00000000ffffffff (prio 0, i/o): pflash
    00000000fe000000-00000000fe7fffff (prio 0, romd): alias pflash-alias
@musicpal.flash 0000000000000000-00000000007fffff
    00000000fe800000-00000000feffffff (prio 0, romd): alias pflash-alias
@musicpal.flash 0000000000000000-00000000007fffff
    00000000ff000000-00000000ff7fffff (prio 0, romd): alias pflash-alias
@musicpal.flash 0000000000000000-00000000007fffff
    00000000ff800000-00000000ffffffff (prio 0, romd): alias pflash-alias
@musicpal.flash 0000000000000000-00000000007fffff

- after:

  00000000fe000000-00000000ffffffff (prio 0, i/o): masked musicpal.flash
[span of 8 MiB]
    00000000fe000000-00000000fe7fffff (prio 0, romd): alias
musicpal.flash [#0/4] @musicpal.flash 0000000000000000-00000000007fffff
    00000000fe800000-00000000feffffff (prio 0, romd): alias
musicpal.flash [#1/4] @musicpal.flash 0000000000000000-00000000007fffff
    00000000ff000000-00000000ff7fffff (prio 0, romd): alias
musicpal.flash [#2/4] @musicpal.flash 0000000000000000-00000000007fffff
    00000000ff800000-00000000ffffffff (prio 0, romd): alias
musicpal.flash [#3/4] @musicpal.flash 0000000000000000-00000000007fffff

Flatview is the same:

  (qemu) info mtree -f
  FlatView #0
   AS "memory", root: system
   AS "cpu-memory-0", root: system
   AS "emac-dma", root: system
   Root memory region: system
    00000000fe000000-00000000fe7fffff (prio 0, romd): musicpal.flash
    00000000fe800000-00000000feffffff (prio 0, romd): musicpal.flash
    00000000ff000000-00000000ff7fffff (prio 0, romd): musicpal.flash
    00000000ff800000-00000000ffffffff (prio 0, romd): musicpal.flash

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/arm/musicpal.c | 11 +++++++----
>  hw/arm/Kconfig    |  1 +
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
> index 8b58b66f263..7d1f2f3fb3f 100644
> --- a/hw/arm/musicpal.c
> +++ b/hw/arm/musicpal.c
> @@ -30,6 +30,7 @@
>  #include "hw/irq.h"
>  #include "hw/or-irq.h"
>  #include "hw/audio/wm8750.h"
> +#include "hw/misc/aliased_region.h"
>  #include "sysemu/block-backend.h"
>  #include "sysemu/runstate.h"
>  #include "sysemu/dma.h"
> @@ -1656,7 +1657,7 @@ static void musicpal_init(MachineState *machine)
>          qdev_prop_set_uint32(dev, "num-blocks", flash_size / sector_size);
>          qdev_prop_set_uint32(dev, "sector-length", sector_size);
>          qdev_prop_set_uint8(dev, "width", 2); /* 16-bit */
> -        qdev_prop_set_uint8(dev, "mappings", MP_FLASH_SIZE_MAX / flash_size);
> +        qdev_prop_set_uint8(dev, "mappings", 0);
>          qdev_prop_set_uint8(dev, "big-endian", 0);
>          qdev_prop_set_uint16(dev, "id0", 0x00bf);
>          qdev_prop_set_uint16(dev, "id1", 0x236d);
> @@ -1667,14 +1668,16 @@ static void musicpal_init(MachineState *machine)
>          qdev_prop_set_string(dev, "name", "musicpal.flash");
>          sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
>  
> -        sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
> -                        0x100000000ULL - MP_FLASH_SIZE_MAX);
> -
>          /*
>           * The original U-Boot accesses the flash at 0xFE000000 instead of
>           * 0xFF800000 (if there is 8 MB flash). So remap flash access if the
>           * image is smaller than 32 MB.
>           */
> +        memory_region_add_subregion_aliased(get_system_memory(),
> +                                0x100000000ULL - MP_FLASH_SIZE_MAX,
> +                                MP_FLASH_SIZE_MAX,
> +                                sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0),
> +                                flash_size);
>      }
>      sysbus_create_simple(TYPE_MV88W8618_FLASHCFG, MP_FLASHCFG_BASE, NULL);
>  
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 8c37cf00da7..aa8553b3cd3 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -101,6 +101,7 @@ config MUSICPAL
>      select MARVELL_88W8618
>      select PTIMER
>      select PFLASH_CFI02
> +    select ALIASED_REGION
>      select SERIAL
>      select WM8750
>  
> 


  reply	other threads:[~2021-03-26 22:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26  0:27 [RFC PATCH-for-6.1 00/10] hw/misc: Add memory_region_add_subregion_aliased() helper Philippe Mathieu-Daudé
2021-03-26  0:27 ` [RFC PATCH-for-6.1 01/10] hw/misc: Add device to help managing aliased memory regions Philippe Mathieu-Daudé
2021-03-26  0:27 ` [PATCH-for-6.1 02/10] hw/arm/musicpal: Open-code pflash_cfi02_register() call Philippe Mathieu-Daudé
2021-03-26  0:27 ` [RFC PATCH-for-6.1 03/10] hw/arm/musicpal: Map flash using memory_region_add_subregion_aliased() Philippe Mathieu-Daudé
2021-03-26 22:49   ` Philippe Mathieu-Daudé [this message]
2021-03-26  0:27 ` [PATCH-for-6.1 04/10] hw/arm/digic: Open-code pflash_cfi02_register() call Philippe Mathieu-Daudé
2021-03-26  0:27 ` [RFC PATCH-for-6.1 05/10] hw/arm/digic: Map flash using memory_region_add_subregion_aliased() Philippe Mathieu-Daudé
2021-03-26  0:27 ` [PATCH-for-6.1 06/10] hw/block/pflash_cfi02: Remove pflash_setup_mappings() Philippe Mathieu-Daudé
2021-03-29  4:11   ` David Gibson
2021-03-26  0:27 ` [PATCH-for-6.1 07/10] hw/block/pflash_cfi02: Simplify pflash_cfi02_register() prototype Philippe Mathieu-Daudé
2021-03-29  4:12   ` David Gibson
2021-03-26  0:27 ` [RFC PATCH-for-6.1 08/10] hw/misc/aliased_region: Simplify aliased I/O regions Philippe Mathieu-Daudé
2021-03-26  0:27 ` [PATCH-for-6.1 09/10] hw/m68k/q800: Add MacIO container Philippe Mathieu-Daudé
2021-03-26  0:27 ` [RFC PATCH-for-6.1 10/10] hw/m68k/q800: Map MacIO using memory_region_add_subregion_aliased() Philippe Mathieu-Daudé
2021-03-26 12:58 ` [RFC PATCH-for-6.1 00/10] hw/misc: Add memory_region_add_subregion_aliased() helper Richard Henderson
2021-03-27 21:45 ` Mark Cave-Ayland

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=4feab40f-0133-8617-52c3-0af0adf419c6@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alistair@alistair23.me \
    --cc=david@gibson.dropbear.id.au \
    --cc=jan.kiszka@web.de \
    --cc=laurent@vivier.eu \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.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.