Commit 135e5d48 authored by Takatoshi Akiyama's avatar Takatoshi Akiyama Committed by Ben Hutchings

serial: sh-sci: Fix panic when serial console and DMA are enabled

commit 3c910176 upstream.

This patch fixes an issue that kernel panic happens when DMA is enabled
and we press enter key while the kernel booting on the serial console.

* An interrupt may occur after sci_request_irq().
* DMA transfer area is initialized by setup_timer() in sci_request_dma()
  and used in interrupt.

If an interrupt occurred between sci_request_irq() and setup_timer() in
sci_request_dma(), DMA transfer area has not been initialized yet.
So, this patch changes the order of sci_request_irq() and
sci_request_dma().

Fixes: 73a19e4c ("serial: sh-sci: Add DMA support.")
Signed-off-by: default avatarTakatoshi Akiyama <takatoshi.akiyama.kj@ps.hitachi-solutions.com>
[Shimoda changes the commit log]
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 4b879806
...@@ -1579,11 +1579,13 @@ static int sci_startup(struct uart_port *port) ...@@ -1579,11 +1579,13 @@ static int sci_startup(struct uart_port *port)
sci_port_enable(s); sci_port_enable(s);
sci_request_dma(port);
ret = sci_request_irq(s); ret = sci_request_irq(s);
if (unlikely(ret < 0)) if (unlikely(ret < 0)) {
sci_free_dma(port);
return ret; return ret;
}
sci_request_dma(port);
sci_start_tx(port); sci_start_tx(port);
sci_start_rx(port); sci_start_rx(port);
...@@ -1600,8 +1602,8 @@ static void sci_shutdown(struct uart_port *port) ...@@ -1600,8 +1602,8 @@ static void sci_shutdown(struct uart_port *port)
sci_stop_rx(port); sci_stop_rx(port);
sci_stop_tx(port); sci_stop_tx(port);
sci_free_dma(port);
sci_free_irq(s); sci_free_irq(s);
sci_free_dma(port);
sci_port_disable(s); sci_port_disable(s);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment