From: Peter Maydell <peter.maydell@linaro.org>
To: "Sergio Andrés Gómez Del Real" <sergio.g.delreal@gmail.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] hw/dma: Fix dead code in pl080.c
Date: Thu, 5 Jan 2017 11:47:22 +0000 [thread overview]
Message-ID: <CAFEAcA_JSkB5FiJTn_amM90vYdPVi=puaVVbfNScAf3p7nL9Cw@mail.gmail.com> (raw)
In-Reply-To: <20161227231156.22745-1-Sergio.G.DelReal@gmail.com>
On 27 December 2016 at 23:11, Sergio Andrés Gómez Del Real
<sergio.g.delreal@gmail.com> wrote:
> The patch fixes dead code in pl080_read() and pl080_write() as reported
> in bug #1637974. According to ARM's official Technical Reference Manual,
> offsets handled by the switch statement are 0x100, 0x104, 0x108, 0x10C
> and 0x110, so the solution suggested by the guy who reported the bug is
> right.
>
> Signed-off-by: Sergio Andrés Gómez Del Real <Sergio.G.DelReal@gmail.com>
> ---
> hw/dma/pl080.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/dma/pl080.c b/hw/dma/pl080.c
> index 7724c93..3b0c20b 100644
> --- a/hw/dma/pl080.c
> +++ b/hw/dma/pl080.c
> @@ -255,7 +255,7 @@ static uint64_t pl080_read(void *opaque, hwaddr offset,
> i = (offset & 0xe0) >> 5;
> if (i >= s->nchannels)
> goto bad_offset;
> - switch (offset >> 2) {
> + switch ((offset - 0x100) >> 2) {
> case 0: /* SrcAddr */
> return s->chan[i].src;
> case 1: /* DestAddr */
> @@ -316,7 +316,7 @@ static void pl080_write(void *opaque, hwaddr offset,
> i = (offset & 0xe0) >> 5;
> if (i >= s->nchannels)
> goto bad_offset;
> - switch (offset >> 2) {
> + switch ((offset - 0x100) >> 2) {
> case 0: /* SrcAddr */
> s->chan[i].src = value;
> break;
> --
> 2.10.2
Looking at the TRM, I don't think this fix is correct. The switches
are intended to handle all of the DMACC* DMA channel registers:
0x100 DMACC0SrcAddr
0x104 DMACC0DestAddr
0x108 DMACC0LLI
0x10C DMACC0Control
0x110 DMACC0Configuration
0x120 DMACC1SrcAddr
0x124 DMACC1DestAddr
etc
up to
0x1F0 DMACC7Configuration
and what the switch is trying to do is figure out which of
SrcAddr/DestAddr/LLI/Control/Configuration we're looking at
(it then uses the correctly calculated 'i' index to pick the
right index into the s->chan[] array for DMACC0 vs DMACC1 etc).
So the correct thing to switch on here is
(offset & 0x1f) >> 2.
thanks
-- PMM
next prev parent reply other threads:[~2017-01-05 11:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-27 23:11 [Qemu-devel] [PATCH] hw/dma: Fix dead code in pl080.c Sergio Andrés Gómez Del Real
2017-01-05 11:47 ` Peter Maydell [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-12-27 16:59 Sergio Andrés Gómez Del Real
2016-12-27 20:30 ` no-reply
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='CAFEAcA_JSkB5FiJTn_amM90vYdPVi=puaVVbfNScAf3p7nL9Cw@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sergio.g.delreal@gmail.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).