All of lore.kernel.org
 help / color / mirror / Atom feed
* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
@ 2017-04-04 20:28 Bryan Evenson
  2017-04-04 20:32 ` Sylvain Rochet
  0 siblings, 1 reply; 8+ messages in thread
From: Bryan Evenson @ 2017-04-04 20:28 UTC (permalink / raw)
  To: linux-arm-kernel

All,

I've been using the latest commit of the linux-3.10-at91 branch of Atmel's Linux fork at https://github.com/linux4sam/linux-at91 for my AT91SAM9G25.  I'm using three serial ports in RS-485 mode.  I'm working on upgrading to a more recent kernel and I'm having issues using DMA for these three serial ports.  I'm looking for some guidance as to what may be going wrong.

First, my board is very closely modeled after the AT91SAMG25-EK, so I'm able to use the at91sam9x5 device tree files with just a few modifications.  Here are my relevant device tree settings for the three USARTs in arch/arm/boot/dts/at91sam9x5ek.dtsi.

			usart0: serial at f801c000 {
				pinctrl-0 = <&pinctrl_usart0
					&pinctrl_usart0_rts
					&pinctrl_usart0_cts>;
					rs485-rts-delay = <15 1>;
					linux,rs485-enabled-at-boot-time;
					atmel,use-dma-rx;
					atmel,use-dma-tx;
				status = "okay";
			};

			usart1: serial at f8020000 {
				pinctrl-0 = <&pinctrl_usart1
					&pinctrl_usart1_rts
					&pinctrl_usart1_cts>;
					rs485-rts-delay = <15 1>;
					linux,rs485-enabled-at-boot-time;
					atmel,use-dma-rx;
					atmel,use-dma-tx;
				status = "okay";
			};

			usart3: serial at f8028000 {
				pinctrl-0 = <&pinctrl_usart3
					&pinctrl_usart3_rts
					&pinctrl_usart3_cts>;
					rs485-rts-delay = <15 1>;
					linux,rs485-enabled-at-boot-time;
					atmel,use-dma-rx;
					atmel,use-dma-tx;
				status = "okay";
			};

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.

Thanks,
Bryan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
  2017-04-04 20:28 at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5 Bryan Evenson
@ 2017-04-04 20:32 ` Sylvain Rochet
  2017-04-04 20:47   ` Bryan Evenson
  0 siblings, 1 reply; 8+ messages in thread
From: Sylvain Rochet @ 2017-04-04 20:32 UTC (permalink / raw)
  To: linux-arm-kernel

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.

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.

Sylvain

^ permalink raw reply	[flat|nested] 8+ messages in thread

* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
  2017-04-04 20:32 ` Sylvain Rochet
@ 2017-04-04 20:47   ` Bryan Evenson
  2017-04-07 14:22     ` Bryan Evenson
  0 siblings, 1 reply; 8+ messages in thread
From: Bryan Evenson @ 2017-04-04 20:47 UTC (permalink / raw)
  To: linux-arm-kernel

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@melinkcorp.com>
> Cc: linux-arm-kernel at lists.infradead.org; Nicolas Ferre
> <nicolas.ferre@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.
> 
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
  2017-04-04 20:47   ` Bryan Evenson
@ 2017-04-07 14:22     ` Bryan Evenson
  2017-04-11 18:32       ` Bryan Evenson
  0 siblings, 1 reply; 8+ messages in thread
From: Bryan Evenson @ 2017-04-07 14:22 UTC (permalink / raw)
  To: linux-arm-kernel

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@finsecur.com>
> Cc: Nicolas Ferre <nicolas.ferre@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@melinkcorp.com>
> > Cc: linux-arm-kernel at lists.infradead.org; Nicolas Ferre
> > <nicolas.ferre@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
  2017-04-07 14:22     ` Bryan Evenson
@ 2017-04-11 18:32       ` Bryan Evenson
  2017-04-11 18:59         ` Alexandre Belloni
  0 siblings, 1 reply; 8+ messages in thread
From: Bryan Evenson @ 2017-04-11 18:32 UTC (permalink / raw)
  To: linux-arm-kernel

All,

I found the commit that is causing problems for me.  More details below.

> -----Original Message-----
> From: Bryan Evenson
> Sent: Friday, April 07, 2017 10:22 AM
> To: Bryan Evenson <bevenson@melinkcorp.com>; Sylvain Rochet
> <sylvain.rochet@finsecur.com>
> Cc: Nicolas Ferre <nicolas.ferre@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
> 
> 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@finsecur.com>
> > Cc: Nicolas Ferre <nicolas.ferre@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@melinkcorp.com>
> > > Cc: linux-arm-kernel at lists.infradead.org; Nicolas Ferre
> > > <nicolas.ferre@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.

I narrowed my issues down to this commit: https://github.com/linux4sam/linux-at91/commit/0058f0871efe7b01c6f2b3046c68196ab73e96da 

	tty/serial: atmel: fix RS485 half duplex with DMA

	When using DMA, half duplex doesn't work properly because rx is not stopped
	before starting tx. Ensure we call atmel_stop_rx() in the DMA case.

	Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
	Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
	Cc: stable <stable@vger.kernel.org>
	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

If I revert this commit, I can use both TX and RX DMA on all three RS-485 ports (USART0, USART1 and USART3) with the current head of linux-4.4-at91 and linux-4.1-at91 on Atmel's fork.  I have not yet tried the mainline releases, but I see that atmel_start_tx() (the function modified by this commit) is identical in mainline so I'm assuming I'll have the same results.  In my case I am using my RS-485 ports in half-duplex mode, so the call to atmel_stop_rx() inside of atmel_start_tx() is the cause of my problems.

Anyone know why this would be a problem?  The commit makes sense to me and I don't see a good reason why it would break things.  I'm willing to test things out to see why this is causing a problem.

Thanks,
Bryan

> 
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
  2017-04-11 18:32       ` Bryan Evenson
@ 2017-04-11 18:59         ` Alexandre Belloni
  2017-04-11 20:13           ` Bryan Evenson
  0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Belloni @ 2017-04-11 18:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 11/04/2017 at 18:32:20 +0000, Bryan Evenson wrote:
> I narrowed my issues down to this commit: https://github.com/linux4sam/linux-at91/commit/0058f0871efe7b01c6f2b3046c68196ab73e96da 
> 
> 	tty/serial: atmel: fix RS485 half duplex with DMA
> 
> 	When using DMA, half duplex doesn't work properly because rx is not stopped
> 	before starting tx. Ensure we call atmel_stop_rx() in the DMA case.
> 
> 	Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> 	Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> 	Cc: stable <stable@vger.kernel.org>
> 	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> If I revert this commit, I can use both TX and RX DMA on all three RS-485 ports (USART0, USART1 and USART3) with the current head of linux-4.4-at91 and linux-4.1-at91 on Atmel's fork.  I have not yet tried the mainline releases, but I see that atmel_start_tx() (the function modified by this commit) is identical in mainline so I'm assuming I'll have the same results.  In my case I am using my RS-485 ports in half-duplex mode, so the call to atmel_stop_rx() inside of atmel_start_tx() is the cause of my problems.
> 
> Anyone know why this would be a problem?  The commit makes sense to me and I don't see a good reason why it would break things.  I'm willing to test things out to see why this is causing a problem.
> 

Do you have b389f173aaa1204d6dc1f299082a162eb0491545 in your tree ?


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
  2017-04-11 18:59         ` Alexandre Belloni
@ 2017-04-11 20:13           ` Bryan Evenson
  2017-04-11 20:25             ` Alexandre Belloni
  0 siblings, 1 reply; 8+ messages in thread
From: Bryan Evenson @ 2017-04-11 20:13 UTC (permalink / raw)
  To: linux-arm-kernel

Alexandre,

> -----Original Message-----
> From: Alexandre Belloni [mailto:alexandre.belloni at free-electrons.com]
> Sent: Tuesday, April 11, 2017 2:59 PM
> To: Bryan Evenson <bevenson@melinkcorp.com>
> Cc: Sylvain Rochet <sylvain.rochet@finsecur.com>; Nicolas Ferre
> <nicolas.ferre@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,
> 
> On 11/04/2017 at 18:32:20 +0000, Bryan Evenson wrote:
> > I narrowed my issues down to this commit:
> https://github.com/linux4sam/linux-
> at91/commit/0058f0871efe7b01c6f2b3046c68196ab73e96da
> >
> > 	tty/serial: atmel: fix RS485 half duplex with DMA
> >
> > 	When using DMA, half duplex doesn't work properly because rx is
> not stopped
> > 	before starting tx. Ensure we call atmel_stop_rx() in the DMA case.
> >
> > 	Signed-off-by: Alexandre Belloni <alexandre.belloni@free-
> electrons.com>
> > 	Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> > 	Cc: stable <stable@vger.kernel.org>
> > 	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >
> > If I revert this commit, I can use both TX and RX DMA on all three RS-485
> ports (USART0, USART1 and USART3) with the current head of linux-4.4-at91
> and linux-4.1-at91 on Atmel's fork.  I have not yet tried the mainline releases,
> but I see that atmel_start_tx() (the function modified by this commit) is
> identical in mainline so I'm assuming I'll have the same results.  In my case I
> am using my RS-485 ports in half-duplex mode, so the call to atmel_stop_rx()
> inside of atmel_start_tx() is the cause of my problems.
> >
> > Anyone know why this would be a problem?  The commit makes sense to
> me and I don't see a good reason why it would break things.  I'm willing to
> test things out to see why this is causing a problem.
> >
> 
> Do you have b389f173aaa1204d6dc1f299082a162eb0491545 in your tree ?
> 

No, I did not have that commit in my tree.  I cherry-picked from the linux-stable repository, tested and verified it fixed my DMA issues.

I checked the various branches on the linux-stable repository, and I see this commit in master and on 4.9, but I don't see it in any branches prior to that one.  Since this issue was introduced back in 4.1, I think this patch would be suitable for backporting to the 4.1 and 4.4 stable branches.  Is there something I can do to help make that happen?

Thanks,
Bryan

> 
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5
  2017-04-11 20:13           ` Bryan Evenson
@ 2017-04-11 20:25             ` Alexandre Belloni
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2017-04-11 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/04/2017 at 20:13:19 +0000, Bryan Evenson wrote:
> I checked the various branches on the linux-stable repository, and I see this commit in master and on 4.9, but I don't see it in any branches prior to that one.  Since this issue was introduced back in 4.1, I think this patch would be suitable for backporting to the 4.1 and 4.4 stable branches.  Is there something I can do to help make that happen?
> 

Indeed, the Fixes: tag doesn't have the usual format, that would explain
why.

I'll resend to stable

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-04-11 20:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 20:28 at91: serial: Can't use DMA on 4.x kernels in RS-485 mode on at91sam9x5 Bryan Evenson
2017-04-04 20:32 ` Sylvain Rochet
2017-04-04 20:47   ` Bryan Evenson
2017-04-07 14:22     ` Bryan Evenson
2017-04-11 18:32       ` Bryan Evenson
2017-04-11 18:59         ` Alexandre Belloni
2017-04-11 20:13           ` Bryan Evenson
2017-04-11 20:25             ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.