From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Julien Grall" <julien.grall@citrix.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH 1/3] hw/dma.c: Fix conversion of ioport_register* to MemoryRegion
Date: Tue, 15 Jan 2013 19:47:55 +0100 [thread overview]
Message-ID: <1358275677-20590-2-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1358275677-20590-1-git-send-email-afaerber@suse.de>
From: Julien Grall <julien.grall@citrix.com>
The commit 582299336879504353e60c7937fbc70fea93f3da introduced a 1-shift for
some offset in DMA emulation.
Before the previous commit, which converted ioport_register_* to
MemoryRegion, the DMA controller registered 8 ioports with the following
formula:
base + ((8 + i) << d->shift) where 0 <= i < 8
When an IO occured within a Memory Region, DMA callback receives an
offset relative to the start address. Here the start address is:
base + (8 << d->shift).
The offset should be: (i << d->shift). After the shift is reverted, the
offsets are 0..7 not 1..8.
Fixes LP#1089996.
Reported-by: Andreas Gustafsson <gson@gson.org>
Signed-off-by: Julien Grall <julien.grall@citrix.com>
Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/dma.c | 22 +++++++++++-----------
1 Datei geändert, 11 Zeilen hinzugefügt(+), 11 Zeilen entfernt(-)
diff --git a/hw/dma.c b/hw/dma.c
index 0634baa..5bdf435 100644
--- a/hw/dma.c
+++ b/hw/dma.c
@@ -201,7 +201,7 @@ static void write_cont(void *opaque, hwaddr nport, uint64_t data,
iport = (nport >> d->dshift) & 0x0f;
switch (iport) {
- case 0x01: /* command */
+ case 0x00: /* command */
if ((data != 0) && (data & CMD_NOT_SUPPORTED)) {
dolog("command %"PRIx64" not supported\n", data);
return;
@@ -209,7 +209,7 @@ static void write_cont(void *opaque, hwaddr nport, uint64_t data,
d->command = data;
break;
- case 0x02:
+ case 0x01:
ichan = data & 3;
if (data & 4) {
d->status |= 1 << (ichan + 4);
@@ -221,7 +221,7 @@ static void write_cont(void *opaque, hwaddr nport, uint64_t data,
DMA_run();
break;
- case 0x03: /* single mask */
+ case 0x02: /* single mask */
if (data & 4)
d->mask |= 1 << (data & 3);
else
@@ -229,7 +229,7 @@ static void write_cont(void *opaque, hwaddr nport, uint64_t data,
DMA_run();
break;
- case 0x04: /* mode */
+ case 0x03: /* mode */
{
ichan = data & 3;
#ifdef DEBUG_DMA
@@ -248,23 +248,23 @@ static void write_cont(void *opaque, hwaddr nport, uint64_t data,
break;
}
- case 0x05: /* clear flip flop */
+ case 0x04: /* clear flip flop */
d->flip_flop = 0;
break;
- case 0x06: /* reset */
+ case 0x05: /* reset */
d->flip_flop = 0;
d->mask = ~0;
d->status = 0;
d->command = 0;
break;
- case 0x07: /* clear mask for all channels */
+ case 0x06: /* clear mask for all channels */
d->mask = 0;
DMA_run();
break;
- case 0x08: /* write mask for all channels */
+ case 0x07: /* write mask for all channels */
d->mask = data;
DMA_run();
break;
@@ -289,11 +289,11 @@ static uint64_t read_cont(void *opaque, hwaddr nport, unsigned size)
iport = (nport >> d->dshift) & 0x0f;
switch (iport) {
- case 0x08: /* status */
+ case 0x00: /* status */
val = d->status;
d->status &= 0xf0;
break;
- case 0x0f: /* mask */
+ case 0x01: /* mask */
val = d->mask;
break;
default:
@@ -468,7 +468,7 @@ void DMA_schedule(int nchan)
static void dma_reset(void *opaque)
{
struct dma_cont *d = opaque;
- write_cont(d, (0x06 << d->dshift), 0, 1);
+ write_cont(d, (0x05 << d->dshift), 0, 1);
}
static int dma_phony_handler (void *opaque, int nchan, int dma_pos, int dma_len)
--
1.7.10.4
next prev parent reply other threads:[~2013-01-15 18:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 18:47 [Qemu-devel] [PULL for-1.4 v2] Memory API ioport cleanups Andreas Färber
2013-01-15 18:47 ` Andreas Färber [this message]
2013-01-15 18:47 ` [Qemu-devel] [PATCH 2/3] xen_platform: Do not use old_portio-style callbacks Andreas Färber
2013-01-15 18:47 ` [Qemu-devel] [PATCH 3/3] acpi_piix4: " Andreas Färber
2013-01-15 23:02 ` [Qemu-devel] [PULL for-1.4 v2] Memory API ioport cleanups Anthony Liguori
2013-01-16 0:00 ` Andreas Färber
2013-01-16 0:35 ` Anthony Liguori
2013-01-16 11:12 ` Peter Maydell
2013-01-16 12:56 ` Stefan Hajnoczi
2013-01-16 1:18 ` Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2013-01-15 18:31 [Qemu-devel] [PULL for-1.4] " Andreas Färber
2013-01-15 18:31 ` [Qemu-devel] [PATCH 1/3] hw/dma.c: Fix conversion of ioport_register* to MemoryRegion Andreas Färber
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=1358275677-20590-2-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=julien.grall@citrix.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).