summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFugang Duan <fugang.duan@nxp.com>2017-12-14 17:52:50 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:29:56 +0800
commit9700326fc1e4931930e6bf5eec7f4523e62af588 (patch)
treede9b6785518572b22e3c15aa32ba394078978efc
parent1daa4feaaf683b2935252e9f7eb7d481e55d7ff2 (diff)
MLK-17218 tty: serial: imx: add lock for register save/restore
The driver save/restore registers in system suspend/resume noirq stage to support no_console_suspend in power lost case. In noirq stage with no_console_suspend, .imx_console_write() _maybe_ called to print out log_buf message in .printk() or console_unlock() called by other drivers. It should add port.lock to protect the registers save/restore in noirq stage since .imx_console_write() also access them. Reported-by: Anson Huang <Anson.Huang@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
-rw-r--r--drivers/tty/serial/imx.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 27e14b3cce9a..e10068b785a3 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2314,9 +2314,12 @@ static int serial_imx_remove(struct platform_device *pdev)
static void serial_imx_restore_context(struct imx_port *sport)
{
+ unsigned long flags = 0;
+
if (!sport->context_saved)
return;
+ spin_lock_irqsave(&sport->port.lock, flags);
writel(sport->saved_reg[4], sport->port.membase + UFCR);
writel(sport->saved_reg[5], sport->port.membase + UESC);
writel(sport->saved_reg[6], sport->port.membase + UTIM);
@@ -2328,11 +2331,15 @@ static void serial_imx_restore_context(struct imx_port *sport)
writel(sport->saved_reg[2], sport->port.membase + UCR3);
writel(sport->saved_reg[3], sport->port.membase + UCR4);
sport->context_saved = false;
+ spin_unlock_irqrestore(&sport->port.lock, flags);
}
static void serial_imx_save_context(struct imx_port *sport)
{
+ unsigned long flags = 0;
+
/* Save necessary regs */
+ spin_lock_irqsave(&sport->port.lock, flags);
sport->saved_reg[0] = readl(sport->port.membase + UCR1);
sport->saved_reg[1] = readl(sport->port.membase + UCR2);
sport->saved_reg[2] = readl(sport->port.membase + UCR3);
@@ -2344,6 +2351,10 @@ static void serial_imx_save_context(struct imx_port *sport)
sport->saved_reg[8] = readl(sport->port.membase + UBMR);
sport->saved_reg[9] = readl(sport->port.membase + IMX21_UTS);
sport->context_saved = true;
+
+ if (uart_console(&sport->port) && sport->port.sysrq)
+ sport->saved_reg[0] |= UCR1_RRDYEN;
+ spin_unlock_irqrestore(&sport->port.lock, flags);
}
static void serial_imx_enable_wakeup(struct imx_port *sport, bool on)