From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH 1/6] dma: rcar-dma: add wait after stopping dma engine
Date: Thu, 15 Oct 2015 20:42:59 +0000 [thread overview]
Message-ID: <3509356.3FvnppCihM@avalon> (raw)
In-Reply-To: <1443559488-2416-2-git-send-email-hamzahfrq.sub@gmail.com>
Hello Hamza,
(With a question for Morimoto-san below)
On Thursday 15 October 2015 18:08:56 Hamza Farooq wrote:
> Hi Laurent,
>
> Thank you for the review. Please see my comments below. Also please let me
> know if this code needs to be fixed on somewhat urgent basis since I am a
> little occupied with few other tasks. I'd try to prioritize it then
I don't think this is urgent, so no worries.
> On Thu, Oct 15, 2015 at 5:58 PM, Laurent Pinchart wrote:
> > On Tuesday 29 September 2015 22:44:43 hamzahfrq.sub@gmail.com wrote:
> >> From: Muhammad Hamza Farooq <mfarooq@visteon.com>
> >>
> >> DMA engine does not stop instantaneously when transaction is going on
> >> (see datasheet). Wait has been added
> >>
> >> Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.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 7820d07..2b28291 100644
> >> --- a/drivers/dma/sh/rcar-dmac.c
> >> +++ b/drivers/dma/sh/rcar-dmac.c
> >> @@ -716,14 +716,38 @@ static int rcar_dmac_fill_hwdesc(struct
> >> rcar_dmac_chan *chan,
> >> /* ----------------------------------------------------------------------
> >> * Stop and reset
> >> */
> >>
> >> +#define NR_READS_TO_WAIT 5 /* number of times to check if DE = 0 */
> >> +static inline int rcar_dmac_wait_stop(struct rcar_dmac_chan *chan)
> >> +{
> >> + unsigned int i = 0;
> >> +
> >> + do {
> >> + u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
> >> +
> >> + if (!(chcr & RCAR_DMACHCR_DE))
> >> + return 0;
> >> + cpu_relax();
> >> + dev_dbg(chan->chan.device->dev, "DMA xfer couldn't be
> >> stopped");
> >>
> > Would it make sense to move the message out of the loop and use dev_err()
> > ? It seems like a pretty serious error.
>
> It happens quite often so dev_err might be too noisy. After couple
> attempts (1-3) it stops so I think it is better to not make it dev_err
That's why I mentioned moving it outside of the loop and only printing it when
the DMA channel doesn't stop.
> >> + } while (++i < NR_READS_TO_WAIT);
> >
> > How long does the DMA engine typically need to stop ? Is there a safe
> > upper bound ?
>
> I have tested it many times. The highest number of retries was 3 which
> occurred not very frequently. Normally it is 1-2
Morimoto-san, could you check with the hardware team if there's a worst case
guarantee regarding how long the channel could take to stop ?
> >> -static void rcar_dmac_chan_halt(struct rcar_dmac_chan *chan)
> >> + return -EBUSY;
> >> +}
> >> +
> >> +/* Called with chan lock held */
> >> +static int rcar_dmac_chan_halt(struct rcar_dmac_chan *chan)
> >> {
> >> - u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
> >> + u32 chcr;
> >> + int ret;
> >>
> >> + chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
> >> chcr &= ~(RCAR_DMACHCR_DSE | RCAR_DMACHCR_DSIE | RCAR_DMACHCR_IE |
> >> RCAR_DMACHCR_TE | RCAR_DMACHCR_DE);
> >> rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr);
> >> + ret = rcar_dmac_wait_stop(chan);
> >
> > As the rcar_dmac_wait_stop() function is used here only I'd inline the
> > code directly.
>
> It is used in DMA_PAUSE operation as well
Let's resolve the DMA pause issue and then decide :-)
> >> +
> >> + WARN_ON(ret < 0);
> >
> > If you use dev_err() instead of dev_dbg() above you could remove the
> > WARN_on.
>
> see comment about dev_err above
>
> >> +
> >> + return ret;
> >> }
> >>
> >> static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan)
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2015-10-15 20:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 20:44 [PATCH 1/6] dma: rcar-dma: add wait after stopping dma engine hamzahfrq.sub
2015-10-12 14:56 ` Vinod Koul
2015-10-15 15:58 ` Laurent Pinchart
2015-10-15 16:02 ` Hamza Farooq
2015-10-15 16:08 ` Hamza Farooq
2015-10-15 20:42 ` Laurent Pinchart [this message]
2015-10-19 20:54 ` Hamza Farooq
2015-10-19 21:06 ` Laurent Pinchart
2015-10-20 12:30 ` Hamza Farooq
2016-06-08 10:05 ` Kuninori Morimoto
2016-06-08 14:23 ` Laurent Pinchart
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=3509356.3FvnppCihM@avalon \
--to=laurent.pinchart@ideasonboard.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox