diff mbox

[v2,2/4] serial: sh-sci: Stop transfers in sci_shutdown()

Message ID 1466780356-12623-3-git-send-email-geert+renesas@glider.be (mailing list archive)
State New, archived
Headers show

Commit Message

Geert Uytterhoeven June 24, 2016, 2:59 p.m. UTC
Make sure the transmitter and receiver are stopped when shutting down
the port, and related interrupts are disabled.

Without this:
  - New input data may be received into the RX FIFO, possibly
    triggering a new RX DMA completion,
  - Transfers will still be enabled on a subsequent startup of the UART,
    before the UART's FIFOs have been reset, causing reading of stale
    data.

Inspired by a patch in the BSP by Koji Matsuoka
<koji.matsuoka.xm@renesas.com>.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Do not clear clock source bits, since the serial console relies on
    them, as reported by Shimoda-san.

v1 was extracted from "[PATCH/RFC v3 0/4] serial: sh-sci: Add DT DMA
support".  The issues with the serial console seen before on
r8a7740/armadillo and sh73a0/kzm9g seem to be gone.  Changes after
resurrection:
  - Write zero to also disable related interrupts, as suggested by
    Laurent Pinchart,
  - Enhanced patch description.
---
 drivers/tty/serial/sh-sci.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Greg Kroah-Hartman June 25, 2016, 4:09 p.m. UTC | #1
On Fri, Jun 24, 2016 at 04:59:14PM +0200, Geert Uytterhoeven wrote:
> Make sure the transmitter and receiver are stopped when shutting down
> the port, and related interrupts are disabled.
> 
> Without this:
>   - New input data may be received into the RX FIFO, possibly
>     triggering a new RX DMA completion,
>   - Transfers will still be enabled on a subsequent startup of the UART,
>     before the UART's FIFOs have been reset, causing reading of stale
>     data.
> 
> Inspired by a patch in the BSP by Koji Matsuoka
> <koji.matsuoka.xm@renesas.com>.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
>   - Do not clear clock source bits, since the serial console relies on
>     them, as reported by Shimoda-san.
> 
> v1 was extracted from "[PATCH/RFC v3 0/4] serial: sh-sci: Add DT DMA
> support".  The issues with the serial console seen before on
> r8a7740/armadillo and sh73a0/kzm9g seem to be gone.  Changes after
> resurrection:
>   - Write zero to also disable related interrupts, as suggested by
>     Laurent Pinchart,
>   - Enhanced patch description.
> ---
>  drivers/tty/serial/sh-sci.c | 5 +++++
>  1 file changed, 5 insertions(+)

This patch does not apply to my tree :(
--
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
Greg Kroah-Hartman June 25, 2016, 4:10 p.m. UTC | #2
On Sat, Jun 25, 2016 at 09:09:39AM -0700, Greg Kroah-Hartman wrote:
> On Fri, Jun 24, 2016 at 04:59:14PM +0200, Geert Uytterhoeven wrote:
> > Make sure the transmitter and receiver are stopped when shutting down
> > the port, and related interrupts are disabled.
> > 
> > Without this:
> >   - New input data may be received into the RX FIFO, possibly
> >     triggering a new RX DMA completion,
> >   - Transfers will still be enabled on a subsequent startup of the UART,
> >     before the UART's FIFOs have been reset, causing reading of stale
> >     data.
> > 
> > Inspired by a patch in the BSP by Koji Matsuoka
> > <koji.matsuoka.xm@renesas.com>.
> > 
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > v2:
> >   - Do not clear clock source bits, since the serial console relies on
> >     them, as reported by Shimoda-san.
> > 
> > v1 was extracted from "[PATCH/RFC v3 0/4] serial: sh-sci: Add DT DMA
> > support".  The issues with the serial console seen before on
> > r8a7740/armadillo and sh73a0/kzm9g seem to be gone.  Changes after
> > resurrection:
> >   - Write zero to also disable related interrupts, as suggested by
> >     Laurent Pinchart,
> >   - Enhanced patch description.
> > ---
> >  drivers/tty/serial/sh-sci.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> 
> This patch does not apply to my tree :(

But I don't have access to my 2-factor token for about 24 hours, so my
tree will not be public until after then, sorry about that, I'll email
you when it gets synced up to kernel.org...

greg k-h
--
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
Greg Kroah-Hartman June 25, 2016, 5:01 p.m. UTC | #3
On Sat, Jun 25, 2016 at 09:10:51AM -0700, Greg Kroah-Hartman wrote:
> On Sat, Jun 25, 2016 at 09:09:39AM -0700, Greg Kroah-Hartman wrote:
> > On Fri, Jun 24, 2016 at 04:59:14PM +0200, Geert Uytterhoeven wrote:
> > > Make sure the transmitter and receiver are stopped when shutting down
> > > the port, and related interrupts are disabled.
> > > 
> > > Without this:
> > >   - New input data may be received into the RX FIFO, possibly
> > >     triggering a new RX DMA completion,
> > >   - Transfers will still be enabled on a subsequent startup of the UART,
> > >     before the UART's FIFOs have been reset, causing reading of stale
> > >     data.
> > > 
> > > Inspired by a patch in the BSP by Koji Matsuoka
> > > <koji.matsuoka.xm@renesas.com>.
> > > 
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > > v2:
> > >   - Do not clear clock source bits, since the serial console relies on
> > >     them, as reported by Shimoda-san.
> > > 
> > > v1 was extracted from "[PATCH/RFC v3 0/4] serial: sh-sci: Add DT DMA
> > > support".  The issues with the serial console seen before on
> > > r8a7740/armadillo and sh73a0/kzm9g seem to be gone.  Changes after
> > > resurrection:
> > >   - Write zero to also disable related interrupts, as suggested by
> > >     Laurent Pinchart,
> > >   - Enhanced patch description.
> > > ---
> > >  drivers/tty/serial/sh-sci.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > 
> > This patch does not apply to my tree :(
> 
> But I don't have access to my 2-factor token for about 24 hours, so my
> tree will not be public until after then, sorry about that, I'll email
> you when it gets synced up to kernel.org...

It's synced now, sorry for the noise.

greg k-h
--
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
diff mbox

Patch

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index d6ba90c572f7475c..eecace576c3b758f 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1890,12 +1890,17 @@  static void sci_shutdown(struct uart_port *port)
 {
 	struct sci_port *s = to_sci_port(port);
 	unsigned long flags;
+	u16 scr;
 
 	dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
 
 	spin_lock_irqsave(&port->lock, flags);
 	sci_stop_rx(port);
 	sci_stop_tx(port);
+	/* Stop RX and TX, disable related interrupts, keep clock source */
+	scr = serial_port_in(port, SCSCR);
+	serial_port_out(port, SCSCR, scr & (SCSCR_CKE1 | SCSCR_CKE0));
+
 	spin_unlock_irqrestore(&port->lock, flags);
 
 #ifdef CONFIG_SERIAL_SH_SCI_DMA