diff mbox

[PATCH/RFC,v3,1/4] serial: sh-sci: Stop TX and RX on shutdown

Message ID 1440181546-7334-2-git-send-email-geert+renesas@glider.be (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Geert Uytterhoeven Aug. 21, 2015, 6:25 p.m. UTC
Make sure the transmitter and receiver are stopped when shutting down
the port, to avoid new RX DMA requests to arrive.

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

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v3:
  - No changes,

v2:
  - New.
---
 drivers/tty/serial/sh-sci.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Laurent Pinchart Aug. 21, 2015, 11:17 p.m. UTC | #1
Hi Geert,

Thank you for the patch.

On Friday 21 August 2015 20:25:43 Geert Uytterhoeven wrote:
> Make sure the transmitter and receiver are stopped when shutting down
> the port, to avoid new RX DMA requests to arrive.
> 
> Inspired by a patch in the BSP by Koji Matsuoka
> <koji.matsuoka.xm@renesas.com>.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v3:
>   - No changes,
> 
> v2:
>   - New.
> ---
>  drivers/tty/serial/sh-sci.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index d8b73e791a554823..0622cafaf1c71cab 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1820,12 +1820,16 @@ static void sci_shutdown(struct uart_port *port)
>  {
>  	struct sci_port *s = to_sci_port(port);
>  	unsigned long flags;
> +	u16 scscr;
> 
>  	dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
> 
>  	spin_lock_irqsave(&port->lock, flags);
>  	sci_stop_rx(port);
>  	sci_stop_tx(port);
> +	scscr = serial_port_in(port, SCSCR);
> +	scscr &= ~(SCSCR_TE | SCSCR_RE);
> +	serial_port_out(port, SCSCR, scscr);

Given that the register contains lots of interrupt enable bits, would it make 
sense to just write it to 0 to disable everything ? I don't think we need to 
keep any of the SCSCR bits across shutdown/startup.

>  	spin_unlock_irqrestore(&port->lock, flags);
> 
>  	sci_free_dma(port);
Geert Uytterhoeven Aug. 25, 2015, 1:01 p.m. UTC | #2
Hi Laurent, Matsuoka-san,

On Sat, Aug 22, 2015 at 1:17 AM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> On Friday 21 August 2015 20:25:43 Geert Uytterhoeven wrote:
>> Make sure the transmitter and receiver are stopped when shutting down
>> the port, to avoid new RX DMA requests to arrive.
>>
>> Inspired by a patch in the BSP by Koji Matsuoka
>> <koji.matsuoka.xm@renesas.com>.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

>> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
>> index d8b73e791a554823..0622cafaf1c71cab 100644
>> --- a/drivers/tty/serial/sh-sci.c
>> +++ b/drivers/tty/serial/sh-sci.c
>> @@ -1820,12 +1820,16 @@ static void sci_shutdown(struct uart_port *port)
>>  {
>>       struct sci_port *s = to_sci_port(port);
>>       unsigned long flags;
>> +     u16 scscr;
>>
>>       dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
>>
>>       spin_lock_irqsave(&port->lock, flags);
>>       sci_stop_rx(port);
>>       sci_stop_tx(port);
>> +     scscr = serial_port_in(port, SCSCR);
>> +     scscr &= ~(SCSCR_TE | SCSCR_RE);
>> +     serial_port_out(port, SCSCR, scscr);
>
> Given that the register contains lots of interrupt enable bits, would it make
> sense to just write it to 0 to disable everything ? I don't think we need to
> keep any of the SCSCR bits across shutdown/startup.

I don't  know.

Actually this patch causes a problem on e.g. armadillo and kzm9g, where
serial console output suddenly stops on halt/reboot:

| # halt
|
| Broadcast message from root@armadillo (ttySC1) (Tue Aug 25 14:52:35 2015):
| The system is going down for system halt NOW!
| INIT: Switching to runlevel: 0
| INIT: Sending process

After reverting, it continues again with:

| es the TERM signal
| [info] Using makefile-style concurrent boot in runlevel 0.
| [ ok ] Asking all remaining processes to terminate...done.
| [ ok ] All processes ended within 1 seconds...done.
| [ ok ] Stopping enhanced syslogd: rsyslogd.
| [ ok ] Stopping NFS common utilities: idmapd statd.
| rpcbind: rpcbind terminating on signal. Restart with "rpcbind -w"
| [ ok ] Stopping rpcbind daemon....
| [....] not deconfiguring network interfaces: network file systems
still mounted.[war (warning).
| [info] Saving the system clock.
| [info] Hardware Clock updated to Tue Aug 25 14:56:18 CEST 2015.
| [ ok ] Deactivating swap...done.
| [info] Will now halt.
| reboot: System halted

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
--
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 d8b73e791a554823..0622cafaf1c71cab 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1820,12 +1820,16 @@  static void sci_shutdown(struct uart_port *port)
 {
 	struct sci_port *s = to_sci_port(port);
 	unsigned long flags;
+	u16 scscr;
 
 	dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
 
 	spin_lock_irqsave(&port->lock, flags);
 	sci_stop_rx(port);
 	sci_stop_tx(port);
+	scscr = serial_port_in(port, SCSCR);
+	scscr &= ~(SCSCR_TE | SCSCR_RE);
+	serial_port_out(port, SCSCR, scscr);
 	spin_unlock_irqrestore(&port->lock, flags);
 
 	sci_free_dma(port);