All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: sh-sci: prevent lockup on full TTY buffers
@ 2018-02-15 12:02 Ulrich Hecht
  2018-02-15 13:12 ` Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ulrich Hecht @ 2018-02-15 12:02 UTC (permalink / raw)
  To: linux-renesas-soc, linux-serial
  Cc: wsa, geert, yoshihiro.shimoda.uh, Ulrich Hecht

When the TTY buffers fill up to the configured maximum, a system lockup
occurs:

[  598.820128] INFO: rcu_preempt detected stalls on CPUs/tasks:
[  598.825796]  0-...!: (1 GPs behind) idle=5a6/2/0 softirq=1974/1974 fqs=1
[  598.832577]  (detected by 3, t=62517 jiffies, g=296, c=295, q=126)
[  598.838755] Task dump for CPU 0:
[  598.841977] swapper/0       R  running task        0     0      0 0x00000022
[  598.849023] Call trace:
[  598.851476]  __switch_to+0x98/0xb0
[  598.854870]            (null)

This can be prevented by doing a dummy read of the RX data register.

This issue affects both HSCIF and SCIF ports. Reported for R-Car H3 ES2.0;
reproduced and fixed on H3 ES1.1. Probably affects other R-Car platforms
as well.

Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
 drivers/tty/serial/sh-sci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index d9f399c..db2ebec 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -885,6 +885,8 @@ static void sci_receive_chars(struct uart_port *port)
 		/* Tell the rest of the system the news. New characters! */
 		tty_flip_buffer_push(tport);
 	} else {
+		/* TTY buffers full; read from RX reg to prevent lockup */
+		serial_port_in(port, SCxRDR);
 		serial_port_in(port, SCxSR); /* dummy read */
 		sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port));
 	}
-- 
2.7.4

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

* Re: [PATCH] serial: sh-sci: prevent lockup on full TTY buffers
  2018-02-15 12:02 [PATCH] serial: sh-sci: prevent lockup on full TTY buffers Ulrich Hecht
@ 2018-02-15 13:12 ` Wolfram Sang
  2018-02-16 14:27   ` Ulrich Hecht
  2018-02-16 18:44 ` Greg KH
  2018-02-19  8:21 ` Yoshihiro Shimoda
  2 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2018-02-15 13:12 UTC (permalink / raw)
  To: Ulrich Hecht; +Cc: linux-renesas-soc, linux-serial, geert, yoshihiro.shimoda.uh

[-- Attachment #1: Type: text/plain, Size: 215 bytes --]


> This can be prevented by doing a dummy read of the RX data register.

Just so I understand the issue correctly: We are reading the register to
throw the content away to prevent it being used in the TTY buffers?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] serial: sh-sci: prevent lockup on full TTY buffers
  2018-02-15 13:12 ` Wolfram Sang
@ 2018-02-16 14:27   ` Ulrich Hecht
  2018-02-19  8:16     ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Hecht @ 2018-02-16 14:27 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Linux-Renesas, linux-serial, Geert Uytterhoeven, shimoda

On Thu, Feb 15, 2018 at 2:12 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
>
>> This can be prevented by doing a dummy read of the RX data register.
>
> Just so I understand the issue correctly: We are reading the register to
> throw the content away to prevent it being used in the TTY buffers?

Not quite. The problem was that if the buffers are full,
sci_receive_chars() returned immediately without reading anything from
the data register, and that led to a lockup. I am not fully sure why
that is so (I arrived at the fix by examining how the different code
paths look from the serial controller's perspective), but dropping
data here fixes it. At this point buffers are full, so any data
received will have to be discarded anyway.

CU
Uli

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

* Re: [PATCH] serial: sh-sci: prevent lockup on full TTY buffers
  2018-02-15 12:02 [PATCH] serial: sh-sci: prevent lockup on full TTY buffers Ulrich Hecht
  2018-02-15 13:12 ` Wolfram Sang
@ 2018-02-16 18:44 ` Greg KH
  2018-02-19  8:20   ` Geert Uytterhoeven
  2018-02-19  8:21 ` Yoshihiro Shimoda
  2 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2018-02-16 18:44 UTC (permalink / raw)
  To: Ulrich Hecht
  Cc: linux-renesas-soc, linux-serial, wsa, geert, yoshihiro.shimoda.uh

On Thu, Feb 15, 2018 at 01:02:27PM +0100, Ulrich Hecht wrote:
> When the TTY buffers fill up to the configured maximum, a system lockup
> occurs:
> 
> [  598.820128] INFO: rcu_preempt detected stalls on CPUs/tasks:
> [  598.825796]  0-...!: (1 GPs behind) idle=5a6/2/0 softirq=1974/1974 fqs=1
> [  598.832577]  (detected by 3, t=62517 jiffies, g=296, c=295, q=126)
> [  598.838755] Task dump for CPU 0:
> [  598.841977] swapper/0       R  running task        0     0      0 0x00000022
> [  598.849023] Call trace:
> [  598.851476]  __switch_to+0x98/0xb0
> [  598.854870]            (null)
> 
> This can be prevented by doing a dummy read of the RX data register.
> 
> This issue affects both HSCIF and SCIF ports. Reported for R-Car H3 ES2.0;
> reproduced and fixed on H3 ES1.1. Probably affects other R-Car platforms
> as well.
> 
> Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>

Should this go to older kernel versions as well?
If so, how far back?

thanks,

greg k-h

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

* Re: [PATCH] serial: sh-sci: prevent lockup on full TTY buffers
  2018-02-16 14:27   ` Ulrich Hecht
@ 2018-02-19  8:16     ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2018-02-19  8:16 UTC (permalink / raw)
  To: Ulrich Hecht; +Cc: Wolfram Sang, Linux-Renesas, linux-serial, shimoda

Hi Uli,

On Fri, Feb 16, 2018 at 3:27 PM, Ulrich Hecht
<ulrich.hecht+renesas@gmail.com> wrote:
> On Thu, Feb 15, 2018 at 2:12 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
>>> This can be prevented by doing a dummy read of the RX data register.
>>
>> Just so I understand the issue correctly: We are reading the register to
>> throw the content away to prevent it being used in the TTY buffers?
>
> Not quite. The problem was that if the buffers are full,
> sci_receive_chars() returned immediately without reading anything from
> the data register, and that led to a lockup. I am not fully sure why
> that is so (I arrived at the fix by examining how the different code
> paths look from the serial controller's perspective), but dropping
> data here fixes it. At this point buffers are full, so any data
> received will have to be discarded anyway.

Do you get an interrupt storm, from the receive or overrun interrupt?

Anyway, the patch makes sense to me, so
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] serial: sh-sci: prevent lockup on full TTY buffers
  2018-02-16 18:44 ` Greg KH
@ 2018-02-19  8:20   ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2018-02-19  8:20 UTC (permalink / raw)
  To: Greg KH
  Cc: Ulrich Hecht, Linux-Renesas, linux-serial, Wolfram Sang,
	Yoshihiro Shimoda

Hi Greg,

On Fri, Feb 16, 2018 at 7:44 PM, Greg KH <greg@kroah.com> wrote:
> On Thu, Feb 15, 2018 at 01:02:27PM +0100, Ulrich Hecht wrote:
>> When the TTY buffers fill up to the configured maximum, a system lockup
>> occurs:
>>
>> [  598.820128] INFO: rcu_preempt detected stalls on CPUs/tasks:
>> [  598.825796]  0-...!: (1 GPs behind) idle=5a6/2/0 softirq=1974/1974 fqs=1
>> [  598.832577]  (detected by 3, t=62517 jiffies, g=296, c=295, q=126)
>> [  598.838755] Task dump for CPU 0:
>> [  598.841977] swapper/0       R  running task        0     0      0 0x00000022
>> [  598.849023] Call trace:
>> [  598.851476]  __switch_to+0x98/0xb0
>> [  598.854870]            (null)
>>
>> This can be prevented by doing a dummy read of the RX data register.
>>
>> This issue affects both HSCIF and SCIF ports. Reported for R-Car H3 ES2.0;
>> reproduced and fixed on H3 ES1.1. Probably affects other R-Car platforms
>> as well.
>>
>> Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
>> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
>
> Should this go to older kernel versions as well?
> If so, how far back?

This code path dates back to full-history-linux commit 2898a0e08c6ffb63
("[PATCH] SH Merge") in 2.6.2, back in 2004.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* RE: [PATCH] serial: sh-sci: prevent lockup on full TTY buffers
  2018-02-15 12:02 [PATCH] serial: sh-sci: prevent lockup on full TTY buffers Ulrich Hecht
  2018-02-15 13:12 ` Wolfram Sang
  2018-02-16 18:44 ` Greg KH
@ 2018-02-19  8:21 ` Yoshihiro Shimoda
  2 siblings, 0 replies; 7+ messages in thread
From: Yoshihiro Shimoda @ 2018-02-19  8:21 UTC (permalink / raw)
  To: Ulrich Hecht, linux-renesas-soc, linux-serial; +Cc: wsa, geert

Hi,

> From: Ulrich Hecht, Sent: Thursday, February 15, 2018 9:02 PM
> 
> When the TTY buffers fill up to the configured maximum, a system lockup
> occurs:
> 
> [  598.820128] INFO: rcu_preempt detected stalls on CPUs/tasks:
> [  598.825796]  0-...!: (1 GPs behind) idle=5a6/2/0 softirq=1974/1974 fqs=1
> [  598.832577]  (detected by 3, t=62517 jiffies, g=296, c=295, q=126)
> [  598.838755] Task dump for CPU 0:
> [  598.841977] swapper/0       R  running task        0     0      0 0x00000022
> [  598.849023] Call trace:
> [  598.851476]  __switch_to+0x98/0xb0
> [  598.854870]            (null)
> 
> This can be prevented by doing a dummy read of the RX data register.
> 
> This issue affects both HSCIF and SCIF ports. Reported for R-Car H3 ES2.0;
> reproduced and fixed on H3 ES1.1. Probably affects other R-Car platforms
> as well.
> 
> Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
> ---

Thank you for the patch. Our team tested this patch and the issue disappeared.
So,

Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>

Best regards,
Yoshihiro Shimoda

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

end of thread, other threads:[~2018-02-19  8:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 12:02 [PATCH] serial: sh-sci: prevent lockup on full TTY buffers Ulrich Hecht
2018-02-15 13:12 ` Wolfram Sang
2018-02-16 14:27   ` Ulrich Hecht
2018-02-19  8:16     ` Geert Uytterhoeven
2018-02-16 18:44 ` Greg KH
2018-02-19  8:20   ` Geert Uytterhoeven
2018-02-19  8:21 ` Yoshihiro Shimoda

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.