Skip to contentSkip to conversation

serial: imx: protect Soft Reset of port with lock

PATCH New Jiada Wang 2 participants 4 messages Mar 13, 2015 – Apr 13, 2015

Subsystems (2)
lore
Share & tools
lore

Jiada Wang

author
#0 lore raw

PATCH 1/1 serial: imx: protect Soft Reset of port with lock

Previously Soft Reset (clear of SRST bit in UCR2 register) of UART in startup is not protected by lock, which may have race with console_write, as console_write may occur at anytime even when UART port is shutdown.

To avoid this race, protect Soft reset of UART port with spin_lock.

---
 drivers/tty/serial/imx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/tty/serial/imx.c +6 -6
index 0eb29b1..f81ccb1 100644
@@ -1165,6 +1165,12 @@ static int imx_startup(struct uart_port *port)
 
 	writel(temp & ~UCR4_DREN, sport->port.membase + UCR4);
 
+	/* Can we enable the DMA support? */
+	if (is_imx6q_uart(sport) && !uart_console(port) &&
+	    !sport->dma_is_inited)
+		imx_uart_dma_init(sport);
+
+	spin_lock_irqsave(&sport->port.lock, flags);
 	/* Reset fifo's and state machines */
 	i = 100;
 
@@ -1175,12 +1181,6 @@ static int imx_startup(struct uart_port *port)
 	while (!(readl(sport->port.membase + UCR2) & UCR2_SRST) && (--i > 0))
 		udelay(1);
 
-	/* Can we enable the DMA support? */
-	if (is_imx6q_uart(sport) && !uart_console(port) &&
-	    !sport->dma_is_inited)
-		imx_uart_dma_init(sport);
-
-	spin_lock_irqsave(&sport->port.lock, flags);
 	/*
 	 * Finally, clear and enable interrupts
 	 */
Signature · 1 line
1.9.3
maintainer
#1 lore raw

PATCH 1/1 serial: imx: protect Soft Reset of port with lock

Quoted 11 lines · Jiada Wang

Previously Soft Reset (clear of SRST bit in UCR2 register) of UART in startup is not protected by lock, which may have race with console_write, as console_write may occur at anytime even when UART port is shutdown.

To avoid this race, protect Soft reset of UART port with spin_lock.

---
 drivers/tty/serial/imx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Doesn't apply to my tree :(

author
#2 lore raw

PATCH 1/1 serial: imx: protect Soft Reset of port with lock

Hi Greg

Quoted 6 lines · Greg KH
Quoted 5 lines · Jiada Wang

Previously Soft Reset (clear of SRST bit in UCR2 register) of UART in startup is not protected by lock, which may have race with console_write, as console_write may occur at anytime even when UART port is shutdown.

Quoted 7 lines
Quoted 6 lines

To avoid this race, protect Soft reset of UART port with spin_lock.

---
  drivers/tty/serial/imx.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)

Doesn't apply to my tree :(

Can you tell me which tree are you using? so that I can submit another patch based same tree.

Thanks,
Jiada

maintainer
#3 lore raw

PATCH 1/1 serial: imx: protect Soft Reset of port with lock

Quoted 11 lines · jiwang

Hi Greg

Quoted 8 lines · Greg KH
Quoted 7 lines · Jiada Wang

Previously Soft Reset (clear of SRST bit in UCR2 register) of UART in startup is not protected by lock, which may have race with console_write, as console_write may occur at anytime even when UART port is shutdown.

To avoid this race, protect Soft reset of UART port with spin_lock.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
---
 drivers/tty/serial/imx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Doesn't apply to my tree :(

Can you tell me which tree are you using? so that I can submit another patch based same tree.

Always either work off of linux-next, or my tty tree, and the tty-next branch of it on git.kernel.org.

What tree were you working against, Linus's? If so, please read Documentation/development_process to get an understanding of how the kernel development process works.

thanks,

greg k-h