diff mbox

[4/4] serial: sh-sci: Stop RX FIFO timer during port shutdown

Message ID 20180629142513.20743-8-geert+renesas@glider.be (mailing list archive)
State New, archived
Headers show

Commit Message

Geert Uytterhoeven June 29, 2018, 2:25 p.m. UTC
The RX FIFO timer may be armed when the port is shut down, hence the
timer function may still be called afterwards.

Fix this race condition by deleting the timer during port shutdown.

Fixes: 039403765e5da3c6 ("serial: sh-sci: SCIFA/B RX FIFO software timeout")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Tested with scifa0 on r8a7740/armadillo, after

    echo 2000 > /sys/devices/platform/e6c40000.serial/rx_fifo_timeout
---
 drivers/tty/serial/sh-sci.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Rob Landley July 1, 2018, 5:27 p.m. UTC | #1
On 06/29/2018 09:25 AM, Geert Uytterhoeven wrote:
> The RX FIFO timer may be armed when the port is shut down, hence the
> timer function may still be called afterwards.
> 
> Fix this race condition by deleting the timer during port shutdown.

Will any of this make the qemu-system-sh4 serial console work again?

Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Geert Uytterhoeven July 2, 2018, 9:50 a.m. UTC | #2
Hi Rob,

On Sun, Jul 1, 2018 at 7:27 PM Rob Landley <rob@landley.net> wrote:
> On 06/29/2018 09:25 AM, Geert Uytterhoeven wrote:
> > The RX FIFO timer may be armed when the port is shut down, hence the
> > timer function may still be called afterwards.
> >
> > Fix this race condition by deleting the timer during port shutdown.
>
> Will any of this make the qemu-system-sh4 serial console work again?

Probably not, as none of these patches touch the qemu source tree.

Gr{oetje,eeting}s,

                        Geert
Rob Landley July 2, 2018, 7:01 p.m. UTC | #3
On 07/02/2018 04:50 AM, Geert Uytterhoeven wrote:
> Hi Rob,
> 
> On Sun, Jul 1, 2018 at 7:27 PM Rob Landley <rob@landley.net> wrote:
>> On 06/29/2018 09:25 AM, Geert Uytterhoeven wrote:
>>> The RX FIFO timer may be armed when the port is shut down, hence the
>>> timer function may still be called afterwards.
>>>
>>> Fix this race condition by deleting the timer during port shutdown.
>>
>> Will any of this make the qemu-system-sh4 serial console work again?
> 
> Probably not, as none of these patches touch the qemu source tree.

So we remain well into the second year of each project pointing the finger at
the other on this, and nothing getting fixed. And the workaround remains "run a
kernel from before February 2017 if you want a working serial console under qemu.

Good to know,

Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Geert Uytterhoeven Aug. 3, 2018, 11:13 a.m. UTC | #4
On Mon, Jul 2, 2018 at 9:01 PM Rob Landley <rob@landley.net> wrote:
> On 07/02/2018 04:50 AM, Geert Uytterhoeven wrote:
> > On Sun, Jul 1, 2018 at 7:27 PM Rob Landley <rob@landley.net> wrote:
> >> On 06/29/2018 09:25 AM, Geert Uytterhoeven wrote:
> >>> The RX FIFO timer may be armed when the port is shut down, hence the
> >>> timer function may still be called afterwards.
> >>>
> >>> Fix this race condition by deleting the timer during port shutdown.
> >>
> >> Will any of this make the qemu-system-sh4 serial console work again?
> >
> > Probably not, as none of these patches touch the qemu source tree.
>
> So we remain well into the second year of each project pointing the finger at
> the other on this, and nothing getting fixed. And the workaround remains "run a
> kernel from before February 2017 if you want a working serial console under qemu.
>
> Good to know,

FTR, patch for qemu is "hw/char/sh_serial: Add timeout handling to unbreak
serial input"
(http://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg05579.html)

Gr{oetje,eeting}s,

                        Geert
diff mbox

Patch

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 58016386558c6789..cca3bbc62a6b1110 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2571,6 +2571,8 @@  static void sci_shutdown(struct uart_port *port)
 	}
 #endif
 
+	if (s->rx_trigger > 1 && s->rx_fifo_timeout > 0)
+		del_timer_sync(&s->rx_fifo_timer);
 	sci_free_irq(s);
 	sci_free_dma(port);
 }