qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Joel Stanley" <joel@jms.id.au>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-block@nongnu.org, "Cédric Le Goater" <clg@kaod.org>
Subject: [PULL 04/16] aspeed/smc: Cache AspeedSMCClass
Date: Tue, 25 Oct 2022 17:20:30 +0200	[thread overview]
Message-ID: <20221025152042.278287-5-clg@kaod.org> (raw)
In-Reply-To: <20221025152042.278287-1-clg@kaod.org>

Store a reference on the AspeedSMC class under the flash object and
use it when accessing the flash contents. Avoiding the class cast
checkers in these hot paths improves performance by 10% when running
the aspeed avocado tests.

Message-Id: <20220923084803.498337-7-clg@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/hw/ssi/aspeed_smc.h | 2 ++
 hw/ssi/aspeed_smc.c         | 9 ++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
index 2d5f8f3d8f68..8e1dda556b91 100644
--- a/include/hw/ssi/aspeed_smc.h
+++ b/include/hw/ssi/aspeed_smc.h
@@ -30,6 +30,7 @@
 #include "qom/object.h"
 
 struct AspeedSMCState;
+struct AspeedSMCClass;
 
 #define TYPE_ASPEED_SMC_FLASH "aspeed.smc.flash"
 OBJECT_DECLARE_SIMPLE_TYPE(AspeedSMCFlash, ASPEED_SMC_FLASH)
@@ -37,6 +38,7 @@ struct AspeedSMCFlash {
     SysBusDevice parent_obj;
 
     struct AspeedSMCState *controller;
+    struct AspeedSMCClass *asc;
     uint8_t cs;
 
     MemoryRegion mmio;
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index faed7e0cbe17..22df4be528a7 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -388,7 +388,7 @@ static inline int aspeed_smc_flash_cmd(const AspeedSMCFlash *fl)
 static inline int aspeed_smc_flash_addr_width(const AspeedSMCFlash *fl)
 {
     const AspeedSMCState *s = fl->controller;
-    AspeedSMCClass *asc = ASPEED_SMC_GET_CLASS(s);
+    AspeedSMCClass *asc = fl->asc;
 
     if (asc->addr_width) {
         return asc->addr_width(s);
@@ -420,7 +420,7 @@ static uint32_t aspeed_smc_check_segment_addr(const AspeedSMCFlash *fl,
                                               uint32_t addr)
 {
     const AspeedSMCState *s = fl->controller;
-    AspeedSMCClass *asc = ASPEED_SMC_GET_CLASS(s);
+    AspeedSMCClass *asc = fl->asc;
     AspeedSegments seg;
 
     asc->reg_to_segment(s, s->regs[R_SEG_ADDR0 + fl->cs], &seg);
@@ -1234,7 +1234,6 @@ static const TypeInfo aspeed_smc_info = {
 static void aspeed_smc_flash_realize(DeviceState *dev, Error **errp)
 {
     AspeedSMCFlash *s = ASPEED_SMC_FLASH(dev);
-    AspeedSMCClass *asc;
     g_autofree char *name = g_strdup_printf(TYPE_ASPEED_SMC_FLASH ".%d", s->cs);
 
     if (!s->controller) {
@@ -1242,14 +1241,14 @@ static void aspeed_smc_flash_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    asc = ASPEED_SMC_GET_CLASS(s->controller);
+    s->asc = ASPEED_SMC_GET_CLASS(s->controller);
 
     /*
      * Use the default segment value to size the memory region. This
      * can be changed by FW at runtime.
      */
     memory_region_init_io(&s->mmio, OBJECT(s), &aspeed_smc_flash_ops,
-                          s, name, asc->segments[s->cs].size);
+                          s, name, s->asc->segments[s->cs].size);
     sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
 }
 
-- 
2.37.3



  parent reply	other threads:[~2022-10-25 15:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 15:20 [PULL 00/16] aspeed queue Cédric Le Goater
2022-10-25 15:20 ` [PULL 01/16] hw/i2c/aspeed: Fix old reg slave receive Cédric Le Goater
2022-10-25 15:20 ` [PULL 02/16] tests/avocado/machine_aspeed.py: Fix typos on buildroot Cédric Le Goater
2022-10-25 15:20 ` [PULL 03/16] ssi: cache SSIPeripheralClass to avoid GET_CLASS() Cédric Le Goater
2023-05-12  4:02   ` Philippe Mathieu-Daudé
2022-10-25 15:20 ` Cédric Le Goater [this message]
2023-05-12  4:00   ` [PULL 04/16] aspeed/smc: Cache AspeedSMCClass Philippe Mathieu-Daudé
2023-05-12  7:06     ` Cédric Le Goater
2022-10-25 15:20 ` [PULL 05/16] ast2600: Drop NEON from the CPU features Cédric Le Goater
2022-10-25 15:20 ` [PULL 06/16] hw/arm/aspeed: increase Bletchley memory size Cédric Le Goater
2022-10-25 15:20 ` [PULL 07/16] m25p80: Add basic support for the SFDP command Cédric Le Goater
2022-10-25 15:20 ` [PULL 08/16] m25p80: Add the n25q256a SFDP table Cédric Le Goater
2022-10-25 15:20 ` [PULL 09/16] m25p80: Add erase size for mx25l25635e Cédric Le Goater
2022-10-25 15:20 ` [PULL 10/16] m25p80: Add the mx25l25635e SFPD table Cédric Le Goater
2022-10-25 15:20 ` [PULL 11/16] m25p80: Add the mx25l25635f " Cédric Le Goater
2022-10-25 15:20 ` [PULL 12/16] m25p80: Add the mx66l1g45g SFDP table Cédric Le Goater
2022-10-25 15:20 ` [PULL 13/16] m25p80: Add the w25q256 SFPD table Cédric Le Goater
2022-10-25 15:20 ` [PULL 14/16] m25p80: Add the w25q512jv " Cédric Le Goater
2022-10-25 15:20 ` [PULL 15/16] m25p80: Add the w25q01jvq " Cédric Le Goater
2022-10-25 15:20 ` [PULL 16/16] arm/aspeed: Replace mx25l25635e chip model Cédric Le Goater
2022-10-26 18:54 ` [PULL 00/16] aspeed queue Stefan Hajnoczi

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=20221025152042.278287-5-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=alistair@alistair23.me \
    --cc=joel@jms.id.au \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.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 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).