diff mbox

[v2,1/5] tty/serial/8250: fix RS485 half-duplex RX

Message ID 1458652329-10138-2-git-send-email-yegorslists@googlemail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yegor Yefremov March 22, 2016, 1:12 p.m. UTC
From: Yegor Yefremov <yegorslists@googlemail.com>

When in half-duplex mode RX will be disabled before TX, but not
enabled after deactivating transmitter. This patch enables
UART_IER_RLSI and UART_IER_RDI interrupts after TX is over.

Cc: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 drivers/tty/serial/8250/8250_port.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Matwey V. Kornilov March 22, 2016, 7:29 p.m. UTC | #1
Nice catch.
I would like to suggest to send this patch with proper "Fixes:" tag
and do it separately from the patch series.
The reason is that this patch fixes a bug which is not related to
MCTRL_GPIO itself.

2016-03-22 16:12 GMT+03:00  <yegorslists@googlemail.com>:
> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> When in half-duplex mode RX will be disabled before TX, but not
> enabled after deactivating transmitter. This patch enables
> UART_IER_RLSI and UART_IER_RDI interrupts after TX is over.
>
> Cc: Matwey V. Kornilov <matwey@sai.msu.ru>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>

Fixes: e490c9144cfa ("tty: Add software emulated RS485 support for 8250")

> ---
>  drivers/tty/serial/8250/8250_port.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index e213da0..00ad263 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -1403,9 +1403,18 @@ static void __do_stop_tx_rs485(struct uart_8250_port *p)
>         /*
>          * Empty the RX FIFO, we are not interested in anything
>          * received during the half-duplex transmission.
> +        * Enable previously disabled RX interrupts.
>          */
> -       if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX))
> +       if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
>                 serial8250_clear_fifos(p);
> +
> +               serial8250_rpm_get(p);
> +
> +               p->ier |= UART_IER_RLSI | UART_IER_RDI;
> +               serial_port_out(&p->port, UART_IER, p->ier);
> +
> +               serial8250_rpm_put(p);
> +       }
>  }
>
>  static void serial8250_em485_handle_stop_tx(unsigned long arg)
> --
> 2.1.4
>
Yegor Yefremov March 23, 2016, 8:58 a.m. UTC | #2
On Tue, Mar 22, 2016 at 8:29 PM, Matwey V. Kornilov <matwey@sai.msu.ru> wrote:
> Nice catch.
> I would like to suggest to send this patch with proper "Fixes:" tag
> and do it separately from the patch series.
> The reason is that this patch fixes a bug which is not related to
> MCTRL_GPIO itself.

Done.

Yegor

> 2016-03-22 16:12 GMT+03:00  <yegorslists@googlemail.com>:
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> When in half-duplex mode RX will be disabled before TX, but not
>> enabled after deactivating transmitter. This patch enables
>> UART_IER_RLSI and UART_IER_RDI interrupts after TX is over.
>>
>> Cc: Matwey V. Kornilov <matwey@sai.msu.ru>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>
> Fixes: e490c9144cfa ("tty: Add software emulated RS485 support for 8250")
>
>> ---
>>  drivers/tty/serial/8250/8250_port.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
>> index e213da0..00ad263 100644
>> --- a/drivers/tty/serial/8250/8250_port.c
>> +++ b/drivers/tty/serial/8250/8250_port.c
>> @@ -1403,9 +1403,18 @@ static void __do_stop_tx_rs485(struct uart_8250_port *p)
>>         /*
>>          * Empty the RX FIFO, we are not interested in anything
>>          * received during the half-duplex transmission.
>> +        * Enable previously disabled RX interrupts.
>>          */
>> -       if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX))
>> +       if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
>>                 serial8250_clear_fifos(p);
>> +
>> +               serial8250_rpm_get(p);
>> +
>> +               p->ier |= UART_IER_RLSI | UART_IER_RDI;
>> +               serial_port_out(&p->port, UART_IER, p->ier);
>> +
>> +               serial8250_rpm_put(p);
>> +       }
>>  }
>>
>>  static void serial8250_em485_handle_stop_tx(unsigned long arg)
>> --
>> 2.1.4
>>
>
>
>
> --
> With best regards,
> Matwey V. Kornilov.
> Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia
> 119991, Moscow, Universitetsky pr-k 13, +7 (495) 9392382
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matwey V. Kornilov March 28, 2016, 9:54 a.m. UTC | #3
2016-03-22 16:12 GMT+03:00  <yegorslists@googlemail.com>:
> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> When in half-duplex mode RX will be disabled before TX, but not
> enabled after deactivating transmitter. This patch enables
> UART_IER_RLSI and UART_IER_RDI interrupts after TX is over.
>
> Cc: Matwey V. Kornilov <matwey@sai.msu.ru>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>

Acked-by: Matwey V. Kornilov <matwey@sai.msu.ru>

> ---
>  drivers/tty/serial/8250/8250_port.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index e213da0..00ad263 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -1403,9 +1403,18 @@ static void __do_stop_tx_rs485(struct uart_8250_port *p)
>         /*
>          * Empty the RX FIFO, we are not interested in anything
>          * received during the half-duplex transmission.
> +        * Enable previously disabled RX interrupts.
>          */
> -       if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX))
> +       if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
>                 serial8250_clear_fifos(p);
> +
> +               serial8250_rpm_get(p);
> +
> +               p->ier |= UART_IER_RLSI | UART_IER_RDI;
> +               serial_port_out(&p->port, UART_IER, p->ier);
> +
> +               serial8250_rpm_put(p);
> +       }
>  }
>
>  static void serial8250_em485_handle_stop_tx(unsigned long arg)
> --
> 2.1.4
>
diff mbox

Patch

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index e213da0..00ad263 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1403,9 +1403,18 @@  static void __do_stop_tx_rs485(struct uart_8250_port *p)
 	/*
 	 * Empty the RX FIFO, we are not interested in anything
 	 * received during the half-duplex transmission.
+	 * Enable previously disabled RX interrupts.
 	 */
-	if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX))
+	if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
 		serial8250_clear_fifos(p);
+
+		serial8250_rpm_get(p);
+
+		p->ier |= UART_IER_RLSI | UART_IER_RDI;
+		serial_port_out(&p->port, UART_IER, p->ier);
+
+		serial8250_rpm_put(p);
+	}
 }
 
 static void serial8250_em485_handle_stop_tx(unsigned long arg)