Message ID | 1442232160-2615-2-git-send-email-hamzahfrq.sub@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Hi Hamza, On Mon, Sep 14, 2015 at 2:02 PM, <hamzahfrq.sub@gmail.com> wrote: > 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> Thanks for your patch! > diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c > index 7820d07..920f977 100644 > --- a/drivers/dma/sh/rcar-dmac.c > +++ b/drivers/dma/sh/rcar-dmac.c > @@ -716,14 +716,37 @@ static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, > /* ----------------------------------------------------------------------------- > * Stop and reset > */ > +#define NR_READS_TO_WAIT (5) /* number of reads to perform to check 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; > + dev_dbg(chan->chan.device->dev, "DMA transfer couldn't be stopped"); I would add a cpu_relax() to the loop. > + } > + while(++i < NR_READS_TO_WAIT); BTW, please run scripts/checkpatch.pl on your patches before submission. Thanks! 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 -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
SGkgR2VlcnQsDQoNClRoYW5rcyBmb3IgdGhlIGZlZWRiYWNrLg0KDQo+IEkgd291bGQgYWRkIGEg Y3B1X3JlbGF4KCkgdG8gdGhlIGxvb3AuDQpUaGlzIHJvdXRpbmUgaXMgYmVpbmcgY2FsbGVkIGZy b20gc29mdCBJUlEgY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bnZlcnNhdGlvbnMgd2l0aCB0ZWNobmljYWwgcGVvcGxlLCBJIGNhbGwg bXlzZWxmIGEgaGFja2VyLiBCdXQgd2hlbiBJJ20gdGFsa2luZyB0byBqb3VybmFsaXN0cyBJIGp1 c3Qgc2F5ICJwcm9ncmFtbWVyIiBvciBzb21ldGhpbmcgbGlrZSB0aGF0Lg0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAtLSBMaW51cyBUb3J2YWxkcw0K -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Hamza, On Tue, Sep 15, 2015 at 5:44 PM, Farooq, Muhammad (M.HAMZA.) <mfarooq@visteon.com> wrote: >> I would add a cpu_relax() to the loop. > This routine is being called from soft IRQ context (rx_timer_fn in case of sh-sci). Does it still make sense to add cpu_relax? Yes, it will add an explicit barrier. Possibly the implicit barrier in readw() in rcar_dmac_chan_read() is already good enough, but it's better to make this explicit. >> BTW, please run scripts/checkpatch.pl on your patches before submission. > I did run that and got no warning/error. Am I missing something? Strange. I get several warnings, e.g. for a missing space after the "if" in "if(!(chcr & RCAR_DMACHCR_DE))". 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 -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Geert, On Tue, Sep 15, 2015 at 6:03 PM, Geert Uytterhoeven <geert@linux-m68k.org> wrote: > On Tue, Sep 15, 2015 at 5:44 PM, Farooq, Muhammad (M.HAMZA.) > <mfarooq@visteon.com> wrote: >>> I would add a cpu_relax() to the loop. >> This routine is being called from soft IRQ context (rx_timer_fn in case of sh-sci). Does it still make sense to add cpu_relax? > > Yes, it will add an explicit barrier. > Possibly the implicit barrier in readw() in rcar_dmac_chan_read() is already > good enough, but it's better to make this explicit. > >>> BTW, please run scripts/checkpatch.pl on your patches before submission. >> I did run that and got no warning/error. Am I missing something? > > Strange. I get several warnings, e.g. for a missing space after the "if" in > "if(!(chcr & RCAR_DMACHCR_DE))". I used that with -f flag which somehow misses many warnings. I will fix these issues and send the patch series again Thanks for your input! Best, Hamza -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 7820d07..920f977 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -716,14 +716,37 @@ static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, /* ----------------------------------------------------------------------------- * Stop and reset */ +#define NR_READS_TO_WAIT (5) /* number of reads to perform to check 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; + dev_dbg(chan->chan.device->dev, "DMA transfer 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)