From: Peter Maydell <peter.maydell@linaro.org>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 08/12] hw/omap_gpmc: Fix region map/unmap when configuring prefetch engine
Date: Wed, 4 Jan 2012 13:56:22 +0000 [thread overview]
Message-ID: <1325685386-23315-9-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1325685386-23315-1-git-send-email-peter.maydell@linaro.org>
When configuring the prefetch engine (and also when resetting from
a state where the prefetch engine was enabled) be careful to adhere
to the "unmap/change config fields/map" ordering, to avoid trying
to delete the wrong MemoryRegions. This fixes an assertion failure
in some cases.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reported-by: Alexander Graf <agraf@suse.de>
Tested-by: Alexander Graf <agraf@suse.de>
---
hw/omap_gpmc.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/hw/omap_gpmc.c b/hw/omap_gpmc.c
index 414f9f5..2fc4137 100644
--- a/hw/omap_gpmc.c
+++ b/hw/omap_gpmc.c
@@ -443,6 +443,12 @@ void omap_gpmc_reset(struct omap_gpmc_s *s)
s->irqst = 0;
s->irqen = 0;
omap_gpmc_int_update(s);
+ for (i = 0; i < 8; i++) {
+ /* This has to happen before we change any of the config
+ * used to determine which memory regions are mapped or unmapped.
+ */
+ omap_gpmc_cs_unmap(s, i);
+ }
s->timeout = 0;
s->config = 0xa00;
s->prefetch.config1 = 0x00004000;
@@ -451,7 +457,6 @@ void omap_gpmc_reset(struct omap_gpmc_s *s)
s->prefetch.fifopointer = 0;
s->prefetch.count = 0;
for (i = 0; i < 8; i ++) {
- omap_gpmc_cs_unmap(s, i);
s->cs_file[i].config[1] = 0x101001;
s->cs_file[i].config[2] = 0x020201;
s->cs_file[i].config[3] = 0x10031003;
@@ -716,24 +721,31 @@ static void omap_gpmc_write(void *opaque, target_phys_addr_t addr,
case 0x1e0: /* GPMC_PREFETCH_CONFIG1 */
if (!s->prefetch.startengine) {
- uint32_t oldconfig1 = s->prefetch.config1;
+ uint32_t newconfig1 = value & 0x7f8f7fbf;
uint32_t changed;
- s->prefetch.config1 = value & 0x7f8f7fbf;
- changed = oldconfig1 ^ s->prefetch.config1;
+ changed = newconfig1 ^ s->prefetch.config1;
if (changed & (0x80 | 0x7000000)) {
/* Turning the engine on or off, or mapping it somewhere else.
* cs_map() and cs_unmap() check the prefetch config and
* overall CSVALID bits, so it is sufficient to unmap-and-map
- * both the old cs and the new one.
+ * both the old cs and the new one. Note that we adhere to
+ * the "unmap/change config/map" order (and not unmap twice
+ * if newcs == oldcs), otherwise we'll try to delete the wrong
+ * memory region.
*/
- int oldcs = prefetch_cs(oldconfig1);
- int newcs = prefetch_cs(s->prefetch.config1);
+ int oldcs = prefetch_cs(s->prefetch.config1);
+ int newcs = prefetch_cs(newconfig1);
omap_gpmc_cs_unmap(s, oldcs);
- omap_gpmc_cs_map(s, oldcs);
- if (newcs != oldcs) {
+ if (oldcs != newcs) {
omap_gpmc_cs_unmap(s, newcs);
+ }
+ s->prefetch.config1 = newconfig1;
+ omap_gpmc_cs_map(s, oldcs);
+ if (oldcs != newcs) {
omap_gpmc_cs_map(s, newcs);
}
+ } else {
+ s->prefetch.config1 = newconfig1;
}
}
break;
--
1.7.1
next prev parent reply other threads:[~2012-01-04 14:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-04 13:56 [Qemu-devel] [PULL 00/12] arm-devs queue Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 01/12] hw/pl181.c: Add save/load support Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 02/12] hw/pl110.c: Add post-load hook to invalidate display Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 03/12] hw/omap1.c: omap_mpuio_init() need not be public Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 04/12] hw/omap1.c: Separate PWL from omap_mpu_state Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 05/12] hw/omap1.c: Separate PWT " Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 06/12] hw/omap1.c: Separate dpll_ctl " Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 07/12] hw/omap1.c: Drop unused includes Peter Maydell
2012-01-04 13:56 ` Peter Maydell [this message]
2012-01-04 13:56 ` [Qemu-devel] [PATCH 09/12] arm: add missing scu registers Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 10/12] arm: Set frequencies for arm_timer Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 11/12] arm: add dummy gic security registers Peter Maydell
2012-01-04 13:56 ` [Qemu-devel] [PATCH 12/12] add L2x0/PL310 cache controller device Peter Maydell
2012-01-04 17:56 ` [Qemu-devel] [PULL 00/12] arm-devs queue Anthony Liguori
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=1325685386-23315-9-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=aliguori@us.ibm.com \
--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).