All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Andrew Jeffery <andrew@aj.id.au>
Subject: Re: [Qemu-devel] [PULL 01/14] ast2400: add a memory controller device model
Date: Tue, 6 Sep 2016 17:07:00 +0100	[thread overview]
Message-ID: <CAFEAcA81yRxf+iKiw+f8rmwuR1Zh+uMnJ6ttV8EGa7r+fSsd+w@mail.gmail.com> (raw)
In-Reply-To: <424cf1dd-3286-190f-7640-5c260c8827a3@kaod.org>

On 6 September 2016 at 16:52, Cédric Le Goater <clg@kaod.org> wrote:
> How's that ? See below. To apply on top of the ast2500 patchset.

Looks basically OK, but:

> From: Cédric Le Goater <clg@kaod.org>
> Subject: [PATCH] aspeed: add a ram_size property to the memory controller
> Date: Tue, 06 Sep 2016 17:42:54 +0200
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Configure the size of the RAM of the SOC using a property to propagate
> the value down to the memory controller from the board level.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/arm/aspeed.c               |    2 ++
>  hw/arm/aspeed_soc.c           |    2 ++
>  hw/misc/aspeed_sdmc.c         |   22 ++++++++++++----------
>  include/hw/misc/aspeed_sdmc.h |    1 +
>  4 files changed, 17 insertions(+), 10 deletions(-)
>
> Index: qemu-aspeed.git/hw/misc/aspeed_sdmc.c
> ===================================================================
> --- qemu-aspeed.git.orig/hw/misc/aspeed_sdmc.c
> +++ qemu-aspeed.git/hw/misc/aspeed_sdmc.c
> @@ -9,6 +9,7 @@
>
>  #include "qemu/osdep.h"
>  #include "qemu/log.h"
> +#include "qemu/error-report.h"
>  #include "hw/misc/aspeed_sdmc.h"
>  #include "hw/misc/aspeed_scu.h"
>  #include "hw/qdev-properties.h"
> @@ -139,9 +140,9 @@ static const MemoryRegionOps aspeed_sdmc
>      .valid.max_access_size = 4,
>  };
>
> -static int ast2400_rambits(void)
> +static int ast2400_rambits(AspeedSDMCState *s)
>  {
> -    switch (ram_size >> 20) {
> +    switch (s->ram_size >> 20) {
>      case 64:
>          return ASPEED_SDMC_DRAM_64MB;
>      case 128:
> @@ -151,8 +152,8 @@ static int ast2400_rambits(void)
>      case 512:
>          return ASPEED_SDMC_DRAM_512MB;
>      default:
> -        qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid RAM size: 0x%"
> -                      HWADDR_PRIx "\n", __func__, ram_size);
> +        error_report("warning: Invalid RAM size %dM. Using default 64M",
> +                     s->ram_size >> 20);

You should do this sanitizing when the property is set
on the device (ie at realize), not every time the device
is reset.

Or you could make it actually a realize error if you want to
force the user to use a valid ram size, though that's a bit
harsher than we usually are.

>          break;
>      }
>
> @@ -160,9 +161,9 @@ static int ast2400_rambits(void)
>      return ASPEED_SDMC_DRAM_64MB;
>  }
>
> -static int ast2500_rambits(void)
> +static int ast2500_rambits(AspeedSDMCState *s)
>  {
> -    switch (ram_size >> 20) {
> +    switch (s->ram_size >> 20) {
>      case 128:
>          return ASPEED_SDMC_AST2500_128MB;
>      case 256:
> @@ -172,8 +173,8 @@ static int ast2500_rambits(void)
>      case 1024:
>          return ASPEED_SDMC_AST2500_1024MB;
>      default:
> -        qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid RAM size: 0x%"
> -                      HWADDR_PRIx "\n", __func__, ram_size);
> +        error_report("warning: Invalid RAM size %dM. Using default 128M",
> +                     s->ram_size >> 20);
>          break;
>      }
>
> @@ -192,7 +193,7 @@ static void aspeed_sdmc_reset(DeviceStat
>      case AST2400_A0_SILICON_REV:
>          s->regs[R_CONF] |=
>              ASPEED_SDMC_VGA_COMPAT |
> -            ASPEED_SDMC_DRAM_SIZE(ast2400_rambits());
> +            ASPEED_SDMC_DRAM_SIZE(ast2400_rambits(s));
>          break;
>
>      case AST2500_A0_SILICON_REV:
> @@ -200,7 +201,7 @@ static void aspeed_sdmc_reset(DeviceStat
>          s->regs[R_CONF] |=
>              ASPEED_SDMC_HW_VERSION(1) |
>              ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB) |
> -            ASPEED_SDMC_DRAM_SIZE(ast2500_rambits());
> +            ASPEED_SDMC_DRAM_SIZE(ast2500_rambits(s));
>          break;
>
>      default:
> @@ -236,6 +237,7 @@ static const VMStateDescription vmstate_
>
>  static Property aspeed_sdmc_properties[] = {
>      DEFINE_PROP_UINT32("silicon-rev", AspeedSDMCState, silicon_rev, 0),
> +    DEFINE_PROP_UINT32("ram-size", AspeedSDMCState, ram_size, 0),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>
> Index: qemu-aspeed.git/include/hw/misc/aspeed_sdmc.h
> ===================================================================
> --- qemu-aspeed.git.orig/include/hw/misc/aspeed_sdmc.h
> +++ qemu-aspeed.git/include/hw/misc/aspeed_sdmc.h
> @@ -25,6 +25,7 @@ typedef struct AspeedSDMCState {
>
>      uint32_t regs[ASPEED_SDMC_NR_REGS];
>      uint32_t silicon_rev;
> +    uint32_t ram_size;
>
>  } AspeedSDMCState;
>
> Index: qemu-aspeed.git/hw/arm/aspeed.c
> ===================================================================
> --- qemu-aspeed.git.orig/hw/arm/aspeed.c
> +++ qemu-aspeed.git/hw/arm/aspeed.c
> @@ -121,6 +121,8 @@ static void aspeed_board_init(MachineSta
>                                     &error_abort);
>      object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1",
>                              &error_abort);
> +    object_property_set_int(OBJECT(&bmc->soc), ram_size, "ram-size",
> +                            &error_abort);

Having the property be 32 bit means that here you're silently
throwing away the top half of ram_size on a 64-bit host, and
there's nothing in the board model that's restricting the
user-provided ram size.

thanks
-- PMM

  reply	other threads:[~2016-09-06 16:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 13:07 [Qemu-devel] [PULL 00/14] target-arm queue Peter Maydell
2016-09-06 13:07 ` [Qemu-devel] [PULL 01/14] ast2400: add a memory controller device model Peter Maydell
2016-09-06 14:59   ` Peter Maydell
2016-09-06 15:52     ` Cédric Le Goater
2016-09-06 16:07       ` Peter Maydell [this message]
2016-09-06 16:21         ` Cédric Le Goater
2016-09-06 13:07 ` [Qemu-devel] [PULL 02/14] target-arm: Fix lpae bit in FSR on an alignment fault Peter Maydell
2016-09-06 13:07 ` [Qemu-devel] [PULL 03/14] ARM: ACPI: fix the AML ID format for CPU devices Peter Maydell
2016-09-06 13:07 ` [Qemu-devel] [PULL 04/14] ast2400: rename the Aspeed SoC files to aspeed_soc Peter Maydell
2016-09-06 13:07 ` [Qemu-devel] [PULL 05/14] ast2400: replace ast2400 with aspeed_soc Peter Maydell
2016-09-06 13:07 ` [Qemu-devel] [PULL 06/14] aspeed-soc: provide a framework to add new SoCs Peter Maydell
2016-09-06 18:51   ` Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 07/14] palmetto-bmc: rename the Aspeed board file to aspeed.c Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 08/14] palmetto-bmc: replace palmetto_bmc with aspeed Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 09/14] palmetto-bmc: add board specific configuration Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 10/14] hw/misc: use macros to define hw-strap1 register on the AST2400 Aspeed SoC Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 11/14] aspeed: add a ast2500 SoC and support to the SCU and SDMC controllers Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 12/14] arm: add support for an ast2500 evaluation board Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 13/14] palmetto-bmc: remove extra no_sdcard assignement Peter Maydell
2016-09-06 13:08 ` [Qemu-devel] [PULL 14/14] block: m25p80: Fix vmstate structure name Peter Maydell
2016-09-06 14:01 ` [Qemu-devel] [PULL 00/14] target-arm queue no-reply

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=CAFEAcA81yRxf+iKiw+f8rmwuR1Zh+uMnJ6ttV8EGa7r+fSsd+w@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --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.