From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Cc: "Dmitry Fleytman" <dmitry.fleytman@gmail.com>,
"Jason Wang" <jasowang@redhat.com>,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
"Greg Kurz" <groug@kaod.org>, "Gerd Hoffmann" <kraxel@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>
Subject: [PATCH v2 3/9] hw/audio/intel-hda: Use memory region alias to reduce .rodata by 4.34MB
Date: Thu, 5 Mar 2020 13:45:19 +0100 [thread overview]
Message-ID: <20200305124525.14555-4-philmd@redhat.com> (raw)
In-Reply-To: <20200305124525.14555-1-philmd@redhat.com>
The intel-hda model uses an array of register indexed by the
register address. This array also contains a pair of aliased
registers at offset 0x2000. This creates a huge hole in the
array, which ends up eating 4.6MiB of .rodata (size reported
on x86_64 host, building with --extra-cflags=-Os).
By using a memory region alias, we reduce this array to 132kB.
Before:
(qemu) info mtree
00000000febd4000-00000000febd7fff (prio 1, i/o): intel-hda
After:
(qemu) info mtree
00000000febd4000-00000000febd7fff (prio 1, i/o): intel-hda
00000000febd4000-00000000febd7fff (prio 1, i/o): intel-hda-container
00000000febd4000-00000000febd5fff (prio 0, i/o): intel-hda
00000000febd6000-00000000febd7fff (prio 0, i/o): alias intel-hda-alias @intel-hda 0000000000000000-0000000000001fff
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/audio/intel-hda.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 1bcc3e5cf8..e8d18b7c58 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -181,7 +181,9 @@ struct IntelHDAState {
IntelHDAStream st[8];
/* state */
+ MemoryRegion container;
MemoryRegion mmio;
+ MemoryRegion alias;
uint32_t rirb_count;
int64_t wall_base_ns;
@@ -670,12 +672,6 @@ static const struct IntelHDAReg regtab[] = {
.offset = offsetof(IntelHDAState, wall_clk),
.rhandler = intel_hda_get_wall_clk,
},
- [ ICH6_REG_WALLCLK + 0x2000 ] = {
- .name = "WALLCLK(alias)",
- .size = 4,
- .offset = offsetof(IntelHDAState, wall_clk),
- .rhandler = intel_hda_get_wall_clk,
- },
/* dma engine */
[ ICH6_REG_CORBLBASE ] = {
@@ -837,12 +833,6 @@ static const struct IntelHDAReg regtab[] = {
.size = 4, \
.offset = offsetof(IntelHDAState, st[_i].lpib), \
}, \
- [ ST_REG(_i, ICH6_REG_SD_LPIB) + 0x2000 ] = { \
- .stream = _i, \
- .name = _t stringify(_i) " LPIB(alias)", \
- .size = 4, \
- .offset = offsetof(IntelHDAState, st[_i].lpib), \
- }, \
[ ST_REG(_i, ICH6_REG_SD_CBL) ] = { \
.stream = _i, \
.name = _t stringify(_i) " CBL", \
@@ -1125,9 +1115,15 @@ static void intel_hda_realize(PCIDevice *pci, Error **errp)
error_free(err);
}
+ memory_region_init(&d->container, OBJECT(d),
+ "intel-hda-container", 0x4000);
memory_region_init_io(&d->mmio, OBJECT(d), &intel_hda_mmio_ops, d,
- "intel-hda", 0x4000);
- pci_register_bar(&d->pci, 0, 0, &d->mmio);
+ "intel-hda", 0x2000);
+ memory_region_add_subregion(&d->container, 0x0000, &d->mmio);
+ memory_region_init_alias(&d->alias, OBJECT(d), "intel-hda-alias",
+ &d->mmio, 0, 0x2000);
+ memory_region_add_subregion(&d->container, 0x2000, &d->alias);
+ pci_register_bar(&d->pci, 0, 0, &d->container);
hda_codec_bus_init(DEVICE(pci), &d->codecs, sizeof(d->codecs),
intel_hda_response, intel_hda_xfer);
--
2.21.1
next prev parent reply other threads:[~2020-03-05 12:49 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 12:45 [PATCH v2 0/9] hw, ui, virtfs-proxy-helper: Reduce QEMU .data/.rodata/.bss footprint Philippe Mathieu-Daudé
2020-03-05 12:45 ` [PATCH v2 1/9] hw/audio/fmopl: Fix a typo twice Philippe Mathieu-Daudé
2020-03-05 13:38 ` Stefano Garzarella
2020-03-09 11:36 ` Laurent Vivier
2020-03-05 12:45 ` [PATCH v2 2/9] hw/audio/fmopl: Move ENV_CURVE to .heap to save 32KiB of .bss Philippe Mathieu-Daudé
2020-03-05 13:44 ` Stefano Garzarella
2020-03-05 13:48 ` Stefano Garzarella
2020-03-05 13:50 ` Philippe Mathieu-Daudé
2020-03-05 13:59 ` Stefano Garzarella
2020-03-05 13:49 ` Philippe Mathieu-Daudé
2020-03-05 13:54 ` Daniel P. Berrangé
2020-03-05 12:45 ` Philippe Mathieu-Daudé [this message]
2020-03-05 12:45 ` [PATCH v2 4/9] hw/net/e1000: Add readops/writeops typedefs Philippe Mathieu-Daudé
2020-03-05 12:45 ` [PATCH v2 5/9] hw/net/e1000: Move macreg[] arrays to .rodata to save 1MiB of .data Philippe Mathieu-Daudé
2020-03-05 12:45 ` [PATCH v2 6/9] hw/usb/quirks: Use smaller types to reduce .rodata by 10KiB Philippe Mathieu-Daudé
2020-03-05 12:45 ` [PATCH v2 7/9] ui/curses: Make control_characters[] array const Philippe Mathieu-Daudé
2020-03-05 13:46 ` Stefano Garzarella
2020-03-05 12:45 ` [PATCH v2 8/9] ui/curses: Move arrays to .heap to save 74KiB of .bss Philippe Mathieu-Daudé
2020-03-05 12:45 ` [PATCH v2 9/9] virtfs-proxy-helper: Make the helper_opts[] array const Philippe Mathieu-Daudé
2020-03-05 13:15 ` [PATCH v2 0/9] hw, ui, virtfs-proxy-helper: Reduce QEMU .data/.rodata/.bss footprint no-reply
2020-03-05 13:25 ` no-reply
2020-03-05 13:42 ` Daniel P. Berrangé
2020-03-05 13:56 ` Philippe Mathieu-Daudé
2020-03-05 14:34 ` Eric Blake
2020-03-05 14:32 ` Eric Blake
2020-03-05 13:48 ` no-reply
2020-03-05 14:21 ` Eric Blake
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=20200305124525.14555-4-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=dmitry.fleytman@gmail.com \
--cc=groug@kaod.org \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=sgarzare@redhat.com \
/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).