at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
Bryan Evenson
bevenson at melinkcorp.com
Fri Apr 7 07:22:14 PDT 2017
All,
> -----Original Message-----
> From: linux-arm-kernel [mailto:linux-arm-kernel-
> bounces at lists.infradead.org] On Behalf Of Bryan Evenson
> Sent: Tuesday, April 04, 2017 4:48 PM
> To: Sylvain Rochet <sylvain.rochet at finsecur.com>
> Cc: Nicolas Ferre <nicolas.ferre at atmel.com>; linux-arm-
> kernel at lists.infradead.org
> Subject: RE: at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on
> at91sam9x5
>
>
> Hi Sylvain,
>
> > -----Original Message-----
> > From: Sylvain Rochet [mailto:sylvain.rochet at finsecur.com]
> > Sent: Tuesday, April 04, 2017 4:33 PM
> > To: Bryan Evenson <bevenson at melinkcorp.com>
> > Cc: linux-arm-kernel at lists.infradead.org; Nicolas Ferre
> > <nicolas.ferre at atmel.com>
> > Subject: Re: at91: serial: Can't use DMA on 4.x kernels in RS-485 mode
> > on
> > at91sam9x5
> >
> > Hi Bryan,
> >
> > On Tue, Apr 04, 2017 at 08:28:34PM +0000, Bryan Evenson wrote:
> > >
> > > With the 3.10 kernel, I had to use the TX DMA only. For some reason
> > > receive wouldn't work for me with the DMA. Now with the latest on
> > > the
> > > linux-4.4-at91 branch I can't use the TX DMA. The data is
> > > transmitted correctly out the USART (verified on a receiving
> > > device), but then the return message is not received. I verified
> > > the same results when both RX&TX DMA was enabled and only when the
> > > TX DMA was enabled. If I use only the RX DMA, everything works fine
> > > if I have only one device on the RS-485 port. As soon as I daisy
> > > chain more than one device on an
> > > RS-485 port, then I start dropping messages. If I turn off both the
> > > RX and TX DMA, then all data transfers work just fine.
> > >
> > > I'd like to get both TX and RX DMA working for all three RS-485 ports.
> > > Anyone have any suggestions for what to look at to get DMA working
> > > while in RS-485 mode? I'm planning to start trying a git bisect,
> > > but given these are different branches I wasn't sure how well that
> > > was going to work.
I found a working version with my setup. Back at commit 1e1257860fd10487795b782f1dbb5b5f2c203474 (https://github.com/linux4sam/linux-at91/commit/1e1257860fd10487795b782f1dbb5b5f2c203474) I can use both RX and TX DMA on the RS-485 ports. As recent as commit b6f9cb564bcbfff46dc618bb7c246369194dfe11 (https://github.com/linux4sam/linux-at91/commit/b6f9cb564bcbfff46dc618bb7c246369194dfe11) neither the RX or TX DMA work for my RS-485 ports. I've been trying to bisect, but this has been slow going as I keep getting builds that don't boot (probably because I get a commit that is in the middle of a series). I'm assuming the change either has to do with the Atmel device tree, the Atmel DMA driver or the Atmel serial port driver. My current git bisect I started as follows:
git bisect start -- arch/arm/boot/dts/at91* drivers/tty/serial/atmel_serial.c drivers/dma/at_*
If there a section of source code that I should also focus on or if someone knows of a specific change I should test, I'd appreciate the suggestion.
Thanks,
Bryan
> >
> > Did you check that you didn't run out of available DMA channels on
> > each DMA controller ? AT91SAM9G25 unfortunately doesn't have much of
> them.
> >
>
> Here's what dmesg is telling me about the DMA channel access when I am
> enabling DMA on TX only.
>
> root at at91sam9x5ek:~# dmesg | grep -E '(DMA|dma)'
> [ 0.109375] DMA: preallocated 256 KiB pool for atomic coherent allocations
> [ 0.210937] at_hdmac ffffec00.dma-controller: Atmel AHB DMA Controller (
> cpy set slave sg-cpy ), 8 channels
> [ 0.218750] at_hdmac ffffee00.dma-controller: Atmel AHB DMA Controller (
> cpy set slave sg-cpy ), 8 channels
> [ 0.234375] at91_i2c f8010000.i2c: using dma0chan0 (tx) and dma0chan1 (rx)
> for DMA transfers
> [ 0.765625] atmel_nand 40000000.nand: Using dma0chan2 for DMA
> transfers.
> [ 0.914062] atmel_spi f0004000.spi: Using dma1chan0 (tx) and dma1chan1
> (rx) for DMA transfers
> [ 22.351562] atmel_usart f8020000.serial: using dma0chan3 for tx DMA
> transfers
> [ 22.406250] atmel_usart f8028000.serial: using dma1chan2 for tx DMA
> transfers
> [ 23.078125] atmel_usart f801c000.serial: using dma0chan4 for tx DMA
> transfers
>
> It looks like there should be enough DMA channels left (eight by my count)
> for me to also enable RX DMA on all three USARTs.
>
> Thanks,
> Bryan
>
> > Sylvain
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
More information about the linux-arm-kernel
mailing list