From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Stephen Checkoway" <stephen.checkoway@oberlin.edu>,
qemu-block@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Max Reitz" <mreitz@redhat.com>,
"David Edmondson" <david.edmondson@oracle.com>,
qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"David Gibson" <david@gibson.dropbear.id.au>
Subject: [PATCH v2 6/7] hw/block/pflash_cfi02: Remove pflash_setup_mappings()
Date: Mon, 19 Apr 2021 11:43:28 +0200 [thread overview]
Message-ID: <20210419094329.1402767-7-f4bug@amsat.org> (raw)
In-Reply-To: <20210419094329.1402767-1-f4bug@amsat.org>
All boards calling pflash_cfi02_register() use nb_mappings=1,
which does not do any mapping:
$ git grep -wl pflash_cfi02_register hw/
hw/arm/xilinx_zynq.c
hw/block/pflash_cfi02.c
hw/lm32/lm32_boards.c
hw/ppc/ppc405_boards.c
hw/sh4/r2d.c
We can remove this now unneeded code.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/block/pflash_cfi02.c | 35 ++---------------------------------
1 file changed, 2 insertions(+), 33 deletions(-)
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 02c514fb6e0..6f4b3e3c3fe 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -75,7 +75,6 @@ struct PFlashCFI02 {
uint32_t nb_blocs[PFLASH_MAX_ERASE_REGIONS];
uint32_t sector_len[PFLASH_MAX_ERASE_REGIONS];
uint32_t chip_len;
- uint8_t mappings;
uint8_t width;
uint8_t be;
int wcycle; /* if 0, the flash is read normally */
@@ -92,13 +91,6 @@ struct PFlashCFI02 {
uint16_t unlock_addr1;
uint8_t cfi_table[0x4d];
QEMUTimer timer;
- /*
- * The device replicates the flash memory across its memory space. Emulate
- * that by having a container (.mem) filled with an array of aliases
- * (.mem_mappings) pointing to the flash memory (.orig_mem).
- */
- MemoryRegion mem;
- MemoryRegion *mem_mappings; /* array; one per mapping */
MemoryRegion orig_mem;
bool rom_mode;
int read_counter; /* used for lazy switch-back to rom mode */
@@ -158,23 +150,6 @@ static inline void toggle_dq2(PFlashCFI02 *pfl)
pfl->status ^= 0x04;
}
-/*
- * Set up replicated mappings of the same region.
- */
-static void pflash_setup_mappings(PFlashCFI02 *pfl)
-{
- unsigned i;
- hwaddr size = memory_region_size(&pfl->orig_mem);
-
- memory_region_init(&pfl->mem, OBJECT(pfl), "pflash", pfl->mappings * size);
- pfl->mem_mappings = g_new(MemoryRegion, pfl->mappings);
- for (i = 0; i < pfl->mappings; ++i) {
- memory_region_init_alias(&pfl->mem_mappings[i], OBJECT(pfl),
- "pflash-alias", &pfl->orig_mem, 0, size);
- memory_region_add_subregion(&pfl->mem, i * size, &pfl->mem_mappings[i]);
- }
-}
-
static void pflash_reset_state_machine(PFlashCFI02 *pfl)
{
trace_pflash_reset(pfl->name);
@@ -917,12 +892,7 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
pfl->sector_erase_map = bitmap_new(pfl->total_sectors);
pfl->rom_mode = true;
- if (pfl->mappings > 1) {
- pflash_setup_mappings(pfl);
- sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
- } else {
- sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->orig_mem);
- }
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->orig_mem);
timer_init_ns(&pfl->timer, QEMU_CLOCK_VIRTUAL, pflash_timer, pfl);
pfl->status = 0;
@@ -950,7 +920,6 @@ static Property pflash_cfi02_properties[] = {
DEFINE_PROP_UINT32("num-blocks3", PFlashCFI02, nb_blocs[3], 0),
DEFINE_PROP_UINT32("sector-length3", PFlashCFI02, sector_len[3], 0),
DEFINE_PROP_UINT8("width", PFlashCFI02, width, 0),
- DEFINE_PROP_UINT8("mappings", PFlashCFI02, mappings, 0),
DEFINE_PROP_UINT8("big-endian", PFlashCFI02, be, 0),
DEFINE_PROP_UINT16("id0", PFlashCFI02, ident0, 0),
DEFINE_PROP_UINT16("id1", PFlashCFI02, ident1, 0),
@@ -1008,6 +977,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base,
{
DeviceState *dev = qdev_new(TYPE_PFLASH_CFI02);
+ assert(nb_mappings <= 1);
if (blk) {
qdev_prop_set_drive(dev, "drive", blk);
}
@@ -1015,7 +985,6 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base,
qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
qdev_prop_set_uint32(dev, "sector-length", sector_len);
qdev_prop_set_uint8(dev, "width", width);
- qdev_prop_set_uint8(dev, "mappings", nb_mappings);
qdev_prop_set_uint8(dev, "big-endian", !!be);
qdev_prop_set_uint16(dev, "id0", id0);
qdev_prop_set_uint16(dev, "id1", id1);
--
2.26.3
next prev parent reply other threads:[~2021-04-19 9:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-19 9:43 [PATCH v2 0/7] hw/misc: Add memory_region_add_subregion_aliased() helper [pflash part] Philippe Mathieu-Daudé
2021-04-19 9:43 ` [RFC PATCH v2 1/7] hw/misc: Add device to help managing aliased memory regions Philippe Mathieu-Daudé
2021-04-22 1:33 ` Richard Henderson
2021-07-06 21:24 ` Philippe Mathieu-Daudé
2021-04-19 9:43 ` [PATCH v2 2/7] hw/arm/musicpal: Open-code pflash_cfi02_register() call Philippe Mathieu-Daudé
2021-04-22 1:37 ` Richard Henderson
2021-04-19 9:43 ` [PATCH v2 3/7] hw/arm/musicpal: Map flash using memory_region_add_subregion_aliased() Philippe Mathieu-Daudé
2021-04-22 1:41 ` Richard Henderson
2021-04-19 9:43 ` [PATCH v2 4/7] hw/arm/digic: Open-code pflash_cfi02_register() call Philippe Mathieu-Daudé
2021-04-22 1:42 ` Richard Henderson
2021-04-19 9:43 ` [PATCH v2 5/7] hw/arm/digic: Map flash using memory_region_add_subregion_aliased() Philippe Mathieu-Daudé
2021-04-22 1:43 ` Richard Henderson
2021-04-19 9:43 ` Philippe Mathieu-Daudé [this message]
2021-04-22 1:47 ` [PATCH v2 6/7] hw/block/pflash_cfi02: Remove pflash_setup_mappings() Richard Henderson
2021-04-19 9:43 ` [PATCH v2 7/7] hw/block/pflash_cfi02: Simplify pflash_cfi02_register() prototype Philippe Mathieu-Daudé
2021-04-22 1:48 ` Richard Henderson
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=20210419094329.1402767-7-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=david.edmondson@oracle.com \
--cc=david@gibson.dropbear.id.au \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stephen.checkoway@oberlin.edu \
/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).