* [PATCH] tty/serial: atmel: fix RS485 half duplex with DMA
@ 2016-05-27 22:54 Alexandre Belloni
2016-06-02 10:41 ` Nicolas Ferre
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2016-05-27 22:54 UTC (permalink / raw)
To: Greg Kroah-Hartman, Nicolas Ferre
Cc: linux-serial, linux-arm-kernel, linux-kernel, Alexandre Belloni
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>
---
drivers/tty/serial/atmel_serial.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 954941dd8124..f9c798cba83f 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -482,19 +482,21 @@ static void atmel_start_tx(struct uart_port *port)
{
struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
- if (atmel_use_pdc_tx(port)) {
- if (atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN)
- /* The transmitter is already running. Yes, we
- really need this.*/
- return;
+ if (atmel_use_pdc_tx(port) && (atmel_uart_readl(port, ATMEL_PDC_PTSR)
+ & ATMEL_PDC_TXTEN))
+ /* The transmitter is already running. Yes, we
+ really need this.*/
+ return;
+ if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port))
if ((port->rs485.flags & SER_RS485_ENABLED) &&
!(port->rs485.flags & SER_RS485_RX_DURING_TX))
atmel_stop_rx(port);
+ if (atmel_use_pdc_tx(port))
/* re-enable PDC transmit */
atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN);
- }
+
/* Enable interrupts */
atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask);
}
--
2.8.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tty/serial: atmel: fix RS485 half duplex with DMA
2016-05-27 22:54 [PATCH] tty/serial: atmel: fix RS485 half duplex with DMA Alexandre Belloni
@ 2016-06-02 10:41 ` Nicolas Ferre
2016-06-13 9:51 ` Nicolas Ferre
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Ferre @ 2016-06-02 10:41 UTC (permalink / raw)
To: Alexandre Belloni, Greg Kroah-Hartman
Cc: linux-serial, linux-arm-kernel, linux-kernel
Le 28/05/2016 00:54, Alexandre Belloni a écrit :
> 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>
We can also add:
Cc: <stable@vger.kernel.org> # v4.3+
Thanks Alexandre!
> ---
> drivers/tty/serial/atmel_serial.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 954941dd8124..f9c798cba83f 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -482,19 +482,21 @@ static void atmel_start_tx(struct uart_port *port)
> {
> struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
>
> - if (atmel_use_pdc_tx(port)) {
> - if (atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN)
> - /* The transmitter is already running. Yes, we
> - really need this.*/
> - return;
> + if (atmel_use_pdc_tx(port) && (atmel_uart_readl(port, ATMEL_PDC_PTSR)
> + & ATMEL_PDC_TXTEN))
> + /* The transmitter is already running. Yes, we
> + really need this.*/
> + return;
>
> + if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port))
> if ((port->rs485.flags & SER_RS485_ENABLED) &&
> !(port->rs485.flags & SER_RS485_RX_DURING_TX))
> atmel_stop_rx(port);
>
> + if (atmel_use_pdc_tx(port))
> /* re-enable PDC transmit */
> atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN);
> - }
> +
> /* Enable interrupts */
> atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask);
> }
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tty/serial: atmel: fix RS485 half duplex with DMA
2016-06-02 10:41 ` Nicolas Ferre
@ 2016-06-13 9:51 ` Nicolas Ferre
0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Ferre @ 2016-06-13 9:51 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-serial
Cc: Alexandre Belloni, linux-arm-kernel, linux-kernel
Le 02/06/2016 12:41, Nicolas Ferre a écrit :
> Le 28/05/2016 00:54, Alexandre Belloni a écrit :
>> 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>
>
> We can also add:
> Cc: <stable@vger.kernel.org> # v4.3+
>
>
> Thanks Alexandre!
Greg,
It's not a regression but a good fix for this rs485 mode. So I suspect
it can still be queued for 4.7-rc... (aka: gentle ping).
Bye,
>> ---
>> drivers/tty/serial/atmel_serial.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>> index 954941dd8124..f9c798cba83f 100644
>> --- a/drivers/tty/serial/atmel_serial.c
>> +++ b/drivers/tty/serial/atmel_serial.c
>> @@ -482,19 +482,21 @@ static void atmel_start_tx(struct uart_port *port)
>> {
>> struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
>>
>> - if (atmel_use_pdc_tx(port)) {
>> - if (atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN)
>> - /* The transmitter is already running. Yes, we
>> - really need this.*/
>> - return;
>> + if (atmel_use_pdc_tx(port) && (atmel_uart_readl(port, ATMEL_PDC_PTSR)
>> + & ATMEL_PDC_TXTEN))
>> + /* The transmitter is already running. Yes, we
>> + really need this.*/
>> + return;
>>
>> + if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port))
>> if ((port->rs485.flags & SER_RS485_ENABLED) &&
>> !(port->rs485.flags & SER_RS485_RX_DURING_TX))
>> atmel_stop_rx(port);
>>
>> + if (atmel_use_pdc_tx(port))
>> /* re-enable PDC transmit */
>> atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN);
>> - }
>> +
>> /* Enable interrupts */
>> atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask);
>> }
>>
>
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-13 9:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-27 22:54 [PATCH] tty/serial: atmel: fix RS485 half duplex with DMA Alexandre Belloni
2016-06-02 10:41 ` Nicolas Ferre
2016-06-13 9:51 ` Nicolas Ferre
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).