All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: linux-sh@vger.kernel.org
Subject: Re: Issues with rcar-dmac and sh-sci
Date: Mon, 17 Aug 2015 14:03:52 +0000	[thread overview]
Message-ID: <CAMuHMdUQ+za1cZqzP1MyAKYt6M3BO_Wfn83bwUAdgBh7Hm1AJQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1507162026200.821@ayla.of.borg>

Hi Laurent,

On Sat, Aug 15, 2015 at 1:42 AM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> From 131968befd5de3400631b879b1574beea27b8239 Mon Sep 17 00:00:00 2001
> From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Date: Sat, 15 Aug 2015 01:28:28 +0300
> Subject: [PATCH] dmaengine: rcar-dmac: Fix residue reporting for pending
>  descriptors
>
> Cookies corresponding to pending transfers have a residue value equal to
> the full size of the corresponding descriptor. The driver miscomputes
> that and uses the size of the active descriptor instead. Fix it.

Thanks!

> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/dma/sh/rcar-dmac.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 7820d07e7bee..a98596a1f12f 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1143,19 +1143,43 @@ static unsigned int rcar_dmac_chan_get_residue(struct
> rcar_dmac_chan *chan,
>         struct rcar_dmac_desc *desc = chan->desc.running;
>         struct rcar_dmac_xfer_chunk *running = NULL;
>         struct rcar_dmac_xfer_chunk *chunk;
> +       enum dma_status status;
>         unsigned int residue = 0;
>         unsigned int dptr = 0;
>
>         if (!desc)
>                 return 0;
>
> +
> +       /*
> +        * If the cookie corresponds to a descriptor that has been completed
> +        * there is no residue. The same check has already been performed by the
> +        * caller but without holding the channel lock, so the descriptor could
> +        * now be complete.
> +        */
> +       status = dma_cookie_status(&chan->chan, cookie, NULL);
> +       if (status = DMA_COMPLETE)
> +               return 0;
> +
>         /*
>          * If the cookie doesn't correspond to the currently running transfer
>          * then the descriptor hasn't been processed yet, and the residue is
>          * equal to the full descriptor size.
>          */
> -       if (cookie != desc->async_tx.cookie)
> -               return desc->size;
> +       if (cookie != desc->async_tx.cookie) {
> +               list_for_each_entry(desc, &chan->desc.pending, node) {
> +                       if (cookie = desc->async_tx.cookie)
> +                               return desc->size;
> +               }

The descriptor may be either on the pending or active list, so I had to add

+               list_for_each_entry(desc, &chan->desc.active, node) {
+                       if (cookie = desc->async_tx.cookie)
+                               return desc->size;
+               }

After that it seems to work fine. Will do more testing...

> +
> +               /*
> +                * No descriptor found for the cookie, there's thus no residue.
> +                * This shouldn't happen if the calling driver passes a correct
> +                * cookie value.
> +                */
> +               WARN(1, "No descriptor for cookie!");
> +               return 0;
> +       }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  parent reply	other threads:[~2015-08-17 14:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 18:36 Issues with rcar-dmac and sh-sci Geert Uytterhoeven
2015-08-14 23:42 ` Laurent Pinchart
2015-08-15  9:40 ` Lars-Peter Clausen
2015-08-15 10:02 ` Geert Uytterhoeven
2015-08-17 14:03 ` Geert Uytterhoeven [this message]
2015-08-18  6:35 ` Laurent Pinchart
2015-09-14 12:39 ` Hamza Farooq

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=CAMuHMdUQ+za1cZqzP1MyAKYt6M3BO_Wfn83bwUAdgBh7Hm1AJQ@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=linux-sh@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.