linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "REE erosca@DE.ADIT-JV.COM" <erosca@DE.ADIT-JV.COM>,
	Eugeniu Rosca <roscaeugeniu@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Simon Horman <horms+renesas@verge.net.au>,
	Chris Brandt <Chris.Brandt@renesas.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Ulrich Hecht <ulrich.hecht+renesas@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"George G . Davis" <george_davis@mentor.com>,
	Andy Lowe <andy_lowe@mentor.com>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
	<devicetree@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Magnus Damm <magnus.damm@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Michael Rodin <mrodin@de.adit-jv.com>
Subject: RE: [PATCH 2/6] Revert "arm64: dts: renesas: r8a7796: Enable DMA for SCIF2"
Date: Mon, 20 May 2019 09:52:46 +0000	[thread overview]
Message-ID: <OSBPR01MB31742E56261058846C5CBF44D8060@OSBPR01MB3174.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAMuHMdVR4idTqOiNWMi3GAS0D-V+SMsYSsukgEMYyz5zDcuPbw@mail.gmail.com>

Hi Geert-san,

Thank you for your reply!

> From: Geert Uytterhoeven, Sent: Monday, May 20, 2019 4:38 PM
> 
> Hi Shimoda-san,
> 
> Thanks for your analysis!
> 
> On Mon, May 20, 2019 at 4:18 AM Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > From: Eugeniu Rosca, Sent: Tuesday, May 7, 2019 4:43 AM
> > <snip>
> > > > > [0] v5.0-rc6 commit 97f26702bc95b5 ("arm64: dts: renesas: r8a7796: Enable DMA for SCIF2")
> > > > > [1] v4.14.106 commit 703db5d1b1759f ("arm64: dts: renesas: r8a7796: Enable DMA for SCIF2")
> > > > > [2] scif (DEBUG) and rcar-dmac logs:
> > > > >     https://gist.github.com/erosca/132cce76a619724a9e4fa61d1db88c66
> > <snip>
> > > Enabling DEBUG in drivers/dma/sh/rcar-dmac.c, I can notice that one of
> > > the symptoms is a NULL dst_addr revealed by:
> > >
> > > rcar-dmac e7300000.dma-controller: chan0: queue chunk (____ptrval____): 0@0xffff800639eb8090 -> 0x0000000000000000
> > >
> > > In working scenarios, dst_addr is never zero. Does it give any hints?
> >
> > Thank you for the report! It's very helpful to me.
> > I think we should fix the sh-sci driver at least.
> >
> > According to the [2] log above,
> >
> > [    4.379716] sh-sci e6e88000.serial: sci_dma_tx_work_fn: ffff800639b55000: 0...0, cookie 126
> >
> > This "0...0" means the s->tx_dma_len on the sci_dma_tx_work_fn will be zero. And,
> 
> How can this happen? schedule_work(&s->work_tx) is called only if
> !uart_circ_empty(), and while holding the port lock? So the circular
> buffer must be made empty in between the call to schedule_work() and the
> work function sci_dma_tx_work_fn() being called.
> 
> I think this can happen if uart_flush_buffer() is called at the right
> moment?

I think so. According to the log [2], the xmit->head and tail is set to zero.

278 [    4.331234] sh-sci e6e88000.serial: sci_dma_tx_work_fn: ffff800639b55000: 9...52, cookie 124 
279 [    4.334885] sh-sci e6e88000.serial: sci_dma_tx_complete(0) 
280 [    4.339992] sh-sci e6e88000.serial: sci_dma_tx_work_fn: ffff800639b55000: 52...100, cookie 125 
281 [    4.343340] sh-sci e6e88000.serial: sci_dma_tx_complete(0) 
282 [    4.379716] sh-sci e6e88000.serial: sci_dma_tx_work_fn: ffff800639b55000: 0...0, cookie 126 

> > > rcar-dmac e7300000.dma-controller: chan0: queue chunk (____ptrval____): 0@0xffff800639eb8090 -> 0x0000000000000000
> >
> > This means the chunk->dst_addr is not set to the "dst_addr" for SCIF because the len on rcar_dmac_chan_prep_sg is zero.
> > So, I'm thinking:
> >  - we have to fix the sh_sci driver to avoid "tx_dma_len = 0" transferring.
> 
> That sounds like just a simple check for !s->tx_dma_len in
> sci_dma_tx_work_fn(), to return early, _and_ reset s->cookie_tx to
> -EINVAL.
> 
> However, uart_flush_buffer() may still be called in between the check
> and the calls to dmaengine_prep_slave_single() /
> dma_sync_single_for_device(), clearing s->tx_dma_len again.
> Unless something has changed recently, these two calls cannot be moved
> inside the spinlock-protected section?

I also think these two calls (and dmaengine_submit() and dma_async_issue_pending())
should be moved inside the spinlock-protected section like sci_dma_rx_complete().

Also, sci_flush_buffer() should have the spinlock-protected section and
check the xmit and dma state somehow.

> Using a cached value of s->tx_dma_len for the dmaengine calls might
> work, though.
> 
> > and
> >
> >  - also we have to fix the rcar-dmac driver to avoid this issue because the DMA Engine API
> >    guide doesn't prevent the len = 0.
> 
> I guess returning an error makes most sense?
> Else we have to fix it deeper into the driver, where handling becomes
> more complex.

I see. I think so. (We should avoid more complex.)

Best regards,
Yoshihiro Shimoda


  reply	other threads:[~2019-05-20  9:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-04  0:42 [PATCH 0/6] Zap SCIF2 DMA configuration in R-Car Gen3 DTS Eugeniu Rosca
2019-05-04  0:42 ` [PATCH 1/6] serial: sh-sci: Reveal ptrval in dev_dbg Eugeniu Rosca
2019-05-06 13:47   ` Simon Horman
2019-05-06 15:24     ` Eugeniu Rosca
2019-05-06 16:46       ` Geert Uytterhoeven
2019-05-06 17:12         ` Eugeniu Rosca
2019-05-04  0:42 ` [PATCH 2/6] Revert "arm64: dts: renesas: r8a7796: Enable DMA for SCIF2" Eugeniu Rosca
2019-05-06 10:02   ` Geert Uytterhoeven
2019-05-06 19:42     ` Eugeniu Rosca
     [not found]       ` <1557413011-1662-1-git-send-email-george_davis@mentor.com>
2019-05-10 17:10         ` [PATCH] serial: sh-sci: disable DMA for uart_console Eugeniu Rosca
2019-05-10 18:38           ` George G. Davis
2019-05-13 10:28             ` Eugeniu Rosca
2019-05-13 11:13         ` Geert Uytterhoeven
2019-05-13 11:42           ` Simon Horman
2019-05-13 13:51         ` Wolfram Sang
2019-05-13 15:43           ` George G. Davis
2019-05-20  2:18       ` [PATCH 2/6] Revert "arm64: dts: renesas: r8a7796: Enable DMA for SCIF2" Yoshihiro Shimoda
2019-05-20  7:37         ` Geert Uytterhoeven
2019-05-20  9:52           ` Yoshihiro Shimoda [this message]
2019-05-04  0:42 ` [PATCH 3/6] arm64: dts: renesas: r8a7795: zap dma configuration in scif2 Eugeniu Rosca
2019-05-04  0:42 ` [PATCH 4/6] Revert "arm64: dts: renesas: r8a77965: Enable DMA for SCIF2" Eugeniu Rosca
2019-05-04  0:42 ` [PATCH 5/6] Revert "arm64: dts: renesas: r8a77990: " Eugeniu Rosca
2019-05-04  0:42 ` [PATCH 6/6] Revert "arm64: dts: renesas: r8a77995: add " Eugeniu Rosca

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=OSBPR01MB31742E56261058846C5CBF44D8060@OSBPR01MB3174.jpnprd01.prod.outlook.com \
    --to=yoshihiro.shimoda.uh@renesas.com \
    --cc=Chris.Brandt@renesas.com \
    --cc=andy_lowe@mentor.com \
    --cc=devicetree@vger.kernel.org \
    --cc=erosca@DE.ADIT-JV.COM \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=george_davis@mentor.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms+renesas@verge.net.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mrodin@de.adit-jv.com \
    --cc=robh+dt@kernel.org \
    --cc=roscaeugeniu@gmail.com \
    --cc=ulrich.hecht+renesas@gmail.com \
    --cc=wsa+renesas@sang-engineering.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).