All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org,
	"Marcin Krzeminski" <marcin.krzeminski@nokia.com>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [Qemu-devel] [PATCH v2 06/11] aspeed/smc: adjust the size of the register region
Date: Mon,  9 Jan 2017 17:24:42 +0100	[thread overview]
Message-ID: <1483979087-32663-7-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1483979087-32663-1-git-send-email-clg@kaod.org>

The SPI controller of the AST2400 SoC has less registers. So we can
adjust the size of the memory region holding the registers depending
on the controller type. We can also remove the guest_error logging
which is useless as the range of the region is strict enough.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
---
 hw/ssi/aspeed_smc.c         | 25 ++++++++++---------------
 include/hw/ssi/aspeed_smc.h |  1 +
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 1ab5575dc848..7103d0c5b64a 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -130,6 +130,9 @@
 #define R_SPI_MISC_CTRL   (0x10 / 4)
 #define R_SPI_TIMINGS     (0x14 / 4)
 
+#define ASPEED_SMC_R_SPI_MAX (0x20 / 4)
+#define ASPEED_SMC_R_SMC_MAX (0x20 / 4)
+
 #define ASPEED_SOC_SMC_FLASH_BASE   0x10000000
 #define ASPEED_SOC_FMC_FLASH_BASE   0x20000000
 #define ASPEED_SOC_SPI_FLASH_BASE   0x30000000
@@ -185,6 +188,7 @@ static const AspeedSMCController controllers[] = {
         .flash_window_base = ASPEED_SOC_SMC_FLASH_BASE,
         .flash_window_size = 0x6000000,
         .has_dma           = false,
+        .nregs             = ASPEED_SMC_R_SMC_MAX,
     }, {
         .name              = "aspeed.smc.fmc",
         .r_conf            = R_CONF,
@@ -197,6 +201,7 @@ static const AspeedSMCController controllers[] = {
         .flash_window_base = ASPEED_SOC_FMC_FLASH_BASE,
         .flash_window_size = 0x10000000,
         .has_dma           = true,
+        .nregs             = ASPEED_SMC_R_MAX,
     }, {
         .name              = "aspeed.smc.spi",
         .r_conf            = R_SPI_CONF,
@@ -209,6 +214,7 @@ static const AspeedSMCController controllers[] = {
         .flash_window_base = ASPEED_SOC_SPI_FLASH_BASE,
         .flash_window_size = 0x10000000,
         .has_dma           = false,
+        .nregs             = ASPEED_SMC_R_SPI_MAX,
     }, {
         .name              = "aspeed.smc.ast2500-fmc",
         .r_conf            = R_CONF,
@@ -221,6 +227,7 @@ static const AspeedSMCController controllers[] = {
         .flash_window_base = ASPEED_SOC_FMC_FLASH_BASE,
         .flash_window_size = 0x10000000,
         .has_dma           = true,
+        .nregs             = ASPEED_SMC_R_MAX,
     }, {
         .name              = "aspeed.smc.ast2500-spi1",
         .r_conf            = R_CONF,
@@ -233,6 +240,7 @@ static const AspeedSMCController controllers[] = {
         .flash_window_base = ASPEED_SOC_SPI_FLASH_BASE,
         .flash_window_size = 0x8000000,
         .has_dma           = false,
+        .nregs             = ASPEED_SMC_R_MAX,
     }, {
         .name              = "aspeed.smc.ast2500-spi2",
         .r_conf            = R_CONF,
@@ -245,6 +253,7 @@ static const AspeedSMCController controllers[] = {
         .flash_window_base = ASPEED_SOC_SPI2_FLASH_BASE,
         .flash_window_size = 0x8000000,
         .has_dma           = false,
+        .nregs             = ASPEED_SMC_R_MAX,
     },
 };
 
@@ -522,13 +531,6 @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size)
 
     addr >>= 2;
 
-    if (addr >= ARRAY_SIZE(s->regs)) {
-        qemu_log_mask(LOG_GUEST_ERROR,
-                      "%s: Out-of-bounds read at 0x%" HWADDR_PRIx "\n",
-                      __func__, addr);
-        return 0;
-    }
-
     if (addr == s->r_conf ||
         addr == s->r_timings ||
         addr == s->r_ce_ctrl ||
@@ -551,13 +553,6 @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data,
 
     addr >>= 2;
 
-    if (addr >= ARRAY_SIZE(s->regs)) {
-        qemu_log_mask(LOG_GUEST_ERROR,
-                      "%s: Out-of-bounds write at 0x%" HWADDR_PRIx "\n",
-                      __func__, addr);
-        return;
-    }
-
     if (addr == s->r_conf ||
         addr == s->r_timings ||
         addr == s->r_ce_ctrl) {
@@ -625,7 +620,7 @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)
 
     /* The memory region for the controller registers */
     memory_region_init_io(&s->mmio, OBJECT(s), &aspeed_smc_ops, s,
-                          s->ctrl->name, ASPEED_SMC_R_MAX * 4);
+                          s->ctrl->name, s->ctrl->nregs * 4);
     sysbus_init_mmio(sbd, &s->mmio);
 
     /*
diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
index 861120b6e213..e811742728f8 100644
--- a/include/hw/ssi/aspeed_smc.h
+++ b/include/hw/ssi/aspeed_smc.h
@@ -45,6 +45,7 @@ typedef struct AspeedSMCController {
     hwaddr flash_window_base;
     uint32_t flash_window_size;
     bool has_dma;
+    uint32_t nregs;
 } AspeedSMCController;
 
 typedef struct AspeedSMCFlash {
-- 
2.7.4

  parent reply	other threads:[~2017-01-09 16:26 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 16:24 [Qemu-devel] [PATCH v2 00/11] Aspeed SMC controller fixes and improvements Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 01/11] aspeed/smc: remove call to reset in realize function Cédric Le Goater
2017-01-11 18:10   ` mar.krzeminski
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 02/11] aspeed/smc: remove call to aspeed_smc_update_cs() in reset function Cédric Le Goater
2017-01-16 17:23   ` mar.krzeminski
2017-01-17  8:05     ` Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 03/11] aspeed/smc: rework the prototype of the AspeedSMCFlash helper routines Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 04/11] aspeed/smc: autostrap CE0/1 configuration Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 05/11] aspeed/smc: unfold the AspeedSMCController array Cédric Le Goater
2017-01-09 16:24 ` Cédric Le Goater [this message]
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 07/11] aspeed/smc: handle SPI flash Command mode Cédric Le Goater
2017-01-19 19:26   ` Peter Maydell
2017-01-19 20:35     ` Cédric Le Goater
2017-01-20 10:13       ` Peter Maydell
2017-01-20 10:17         ` Cédric Le Goater
2017-01-20 11:22           ` Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 08/11] aspeed/smc: reset flash after each test Cédric Le Goater
2017-01-16 17:37   ` mar.krzeminski
2017-01-16 18:10     ` Cédric Le Goater
2017-01-16 18:19       ` mar.krzeminski
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 09/11] aspeed/smc: extend tests for Command mode Cédric Le Goater
2017-01-16 17:51   ` mar.krzeminski
2017-01-17  8:34     ` Cédric Le Goater
2017-01-17 17:34       ` mar.krzeminski
2017-01-18 14:56         ` Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 10/11] aspeed: use first FMC flash as a boot ROM Cédric Le Goater
2017-01-30 12:55   ` Peter Maydell
2017-01-30 13:38     ` Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 11/11] aspeed/smc: handle dummy bytes when doing fast reads in command mode Cédric Le Goater
2017-01-11 18:20   ` mar.krzeminski
2017-01-11 18:55     ` Cédric Le Goater
2017-01-14 18:56       ` mar.krzeminski
2017-01-16  8:18         ` Cédric Le Goater
2017-01-16 18:58           ` mar.krzeminski
2017-01-17  8:37             ` Cédric Le Goater
2017-01-17 17:30               ` mar.krzeminski
2017-01-16 17:00 ` [Qemu-devel] [PATCH v2 00/11] Aspeed SMC controller fixes and improvements Peter Maydell
2017-01-16 17:08   ` Cédric Le Goater

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=1483979087-32663-7-git-send-email-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=crosthwaite.peter@gmail.com \
    --cc=marcin.krzeminski@nokia.com \
    --cc=peter.maydell@linaro.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.