dma: rcar-dma: add wait after stopping dma engine
Subsystems (3)
PATCH RESEND 1/6 dma: rcar-dma: add wait after stopping dma engine
From: Muhammad Hamza Farooq <[email protected]>
DMA engine does not stop instantaneously when transaction is going on (see datasheet). Wait has been added
--- drivers/dma/sh/rcar-dmac.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/dma/sh/rcar-dmac.c +27 -3
@@ -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" ); + }while (++i <NR_READS_TO_WAIT ); -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_DMACHCR_TE |RCAR_DMACHCR_DE );rcar_dmac_chan_write (chan,RCAR_DMACHCR , chcr); + ret =rcar_dmac_wait_stop (chan); + +WARN_ON (ret <0 ); + +return ret; }static void rcar_dmac_chan_reinit (struct rcar_dmac_chan *chan)
Signature · 1 line
1.9.1
Hello.
Quoted 15 lines · On 9/20/2015 10:10 PM, [email protected] wrote:
From: Muhammad Hamza Farooq <[email protected]>
DMA engine does not stop instantaneously when transaction is going on (see datasheet). Wait has been added
Signed-off-by Muhammad Hamza Farooq <[email protected]>--- drivers/dma/sh/rcar-dmac.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)drivers/dma/sh/rcar-dmac.c +0
-0
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 719
Quoted 4 lines
drivers/dma/sh/rcar-dmac.c +1
-0@@ -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 */
Parens not needed. (I'm seeing this patchset for the first time.)
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 731
Quoted 12 lines
drivers/dma/sh/rcar-dmac.c +12
-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" ); + }while (++i <NR_READS_TO_WAIT );
Hm, this can be a *for* loop, no?
[...]
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 744
Quoted 11 lines
drivers/dma/sh/rcar-dmac.c +6
-2+/* 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_DMACHCR_TE |RCAR_DMACHCR_DE );
Please don't change the existing indentation, it doesn't seem like you're
changing anything else here.
[...]
MBR, Sergei
Hi,
Quoted 3 lines
Quoted 1 line
+#define
NR_READS_TO_WAIT(5) /* number of times to check if DE = 0 */Parens not needed. (I'm seeing this patchset for the first time.)
They prevent funny things from happening so I use them all the time. First time when I sent the patch-set, I had missed linux-sh mailing list.
Here's the link from dmaengine mailing list in case you're interested
http://www.spinics.net/lists/dmaengine/msg06103.html
Quoted 6 lines
Quoted 6 lines
drivers/dma/sh/rcar-dmac.c +6
-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);
Quoted 8 lines
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 731
Quoted 6 lines
drivers/dma/sh/rcar-dmac.c +6
-0+ +if (!(chcr &RCAR_DMACHCR_DE )) +return 0 ; +cpu_relax (); +dev_dbg (chan->chan.device->dev,"DMA xfer couldn't be stopped" ); + }while (++i <NR_READS_TO_WAIT );Hm, this can be a *for* loop, no?
Could you explain why would you prefer a for loop here? do..while makes sure even if NR_READS_TO_WAIT is set to 0, the stop action takes place
Quoted 1 line
Please don't change the existing indentation, it doesn't seem like you're changing anything else here
ok. How should I send the updates patch though, through replying to this email or a new thread?
Thanks!
Hamza
Quoted 68 lines · Sergei Shtylyov
Hello.
Quoted 15 lines · On 9/20/2015 10:10 PM, [email protected] wrote:
From: Muhammad Hamza Farooq <[email protected]>
DMA engine does not stop instantaneously when transaction is going on (see datasheet). Wait has been added
Signed-off-by Muhammad Hamza Farooq <[email protected]>--- drivers/dma/sh/rcar-dmac.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)drivers/dma/sh/rcar-dmac.c +0
-0drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct · line 720
Quoted 6 lines
drivers/dma/sh/rcar-dmac.c +1
-1@@ -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 */ Parens not needed. (I'm seeing this patchset for the first time.)
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 731
Quoted 13 lines
drivers/dma/sh/rcar-dmac.c +12
-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"); + }while (++i <NR_READS_TO_WAIT );Hm, this can be a *for* loop, no?
[...]
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 744
Quoted 12 lines
drivers/dma/sh/rcar-dmac.c +6
-2+/* 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_DMACHCR_TE |RCAR_DMACHCR_DE );Please don't change the existing indentation, it doesn't seem like you're
changing anything else here.[...]
MBR, Sergei
Quoted 2 lines · Hamza Farooq
ok. How should I send the updates patch though, through replying to this email or a new thread?
V2 patch series addressing all comments, sent using git send email would be preferred
Signature · 1 line
~Vinod
Hello.
Quoted 5 lines · Hamza Farooq
Quoted 3 lines
Quoted 1 line
+#define
NR_READS_TO_WAIT(5) /* number of times to check if DE = 0 */Parens not needed. (I'm seeing this patchset for the first time.)
They prevent funny things from happening so I use them all the time.
No, they don't in this case.
Quoted 4 lines
First time when I sent the patch-set, I had missed linux-sh mailing list.
Here's the link from dmaengine mailing list in case you're interested
http://www.spinics.net/lists/dmaengine/msg06103.html
Thanks for the link.
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/dma/sh/rcar-dmac.c +6
-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);Quoted 8 lines
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 731
Quoted 6 lines
drivers/dma/sh/rcar-dmac.c +6
-0+ +if (!(chcr &RCAR_DMACHCR_DE )) +return 0 ; +cpu_relax (); +dev_dbg (chan->chan.device->dev,"DMA xfer couldn't be stopped" ); + }while (++i <NR_READS_TO_WAIT );Hm, this can be a *for* loop, no?
Quoted 3 lines
Could you explain why would you prefer a for loop here? do..while makes sure even if
NR_READS_TO_WAITis set to 0, the stop action takes place
Hm, this doesn't make sense to me. If # of reads is 0, we shouldn't read, no?
Quoted 4 lines
Quoted 1 line
Please don't change the existing indentation, it doesn't seem like you're changing anything else here
ok. How should I send the updates patch though, through replying to this email or a new thread?
New thread I think.
Quoted 2 lines
Thanks!
Hamza
MBR, Sergei
Hello,
From: Sergei Shtylyov [mailto:[email protected]]
Quoted 15 lines
Quoted 14 lines
Quoted 14 lines
drivers/dma/sh/rcar-dmac.c static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, · line 731
Quoted 12 lines
drivers/dma/sh/rcar-dmac.c +12
-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" ); + }while (++i <NR_READS_TO_WAIT );Hm, this can be a *for* loop, no?
Quoted 5 lines
Quoted 3 lines
Could you explain why would you prefer a for loop here? do..while makes sure even if
NR_READS_TO_WAITis set to 0, the stop action takes placeHm, this doesn't make sense to me. If # of reads is 0, we shouldn't read, no?
The datasheet states that we have to wait after a write. I have used do..while to impose this check
Best,
Hamza
Quoted 65 lines · Sergei Shtylyov
Hello.
Quoted 7 lines · Hamza Farooq
Quoted 4 lines
Quoted 1 line
+#define
NR_READS_TO_WAIT(5) /* number of times to check if DE = 0 */Parens not needed. (I'm seeing this patchset for the first time.)
They prevent funny things from happening so I use them all the time.
No, they don't in this case.
Quoted 4 lines
First time when I sent the patch-set, I had missed linux-sh mailing list.
Here's the link from dmaengine mailing list in case you're interested
http://www.spinics.net/lists/dmaengine/msg06103.htmlThanks for the link.
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
drivers/dma/sh/rcar-dmac.c +8
-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))Quoted 8 lines
Quoted 5 lines
drivers/dma/sh/rcar-dmac.c +3
-0+return 0 ; +cpu_relax (); + dev_dbg(chan->chan.device->dev, "DMA xfer couldn't bestopped");
+ } while (++i <NR_READS_TO_WAIT);Hm, this can be a *for* loop, no?
Quoted 3 lines
Could you explain why would you prefer a for loop here? do..while makes sure even if
NR_READS_TO_WAITis set to 0, the stop action takes placeHm, this doesn't make sense to me. If # of reads is 0, we shouldn't read,
no?Quoted 6 lines
Quoted 2 lines
Please don't change the existing indentation, it doesn't seem like
you're changing anything else hereok. How should I send the updates patch though, through replying to this email or a new thread?
New thread I think.
Quoted 2 lines
Thanks!
HamzaMBR, Sergei