From 1502b7f36eb148278cf0e8ff4fc0de5895d14402 Mon Sep 17 00:00:00 2001 From: Chandana Kishori Chiluveru Date: Mon, 12 Jul 2021 10:22:21 +0530 Subject: [PATCH] serial: msm-geni-serial: Update is_clock_off to atomic variable Update is_clock_off and wakeup_enabled variable to atomic to avoid race conditions while accessing it. Change-Id: I7e792b5938befeeede60f15353be328d20c25758 Signed-off-by: Anvesh Salveru Signed-off-by: Chandana Kishori Chiluveru --- drivers/tty/serial/msm_geni_serial.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/msm_geni_serial.c b/drivers/tty/serial/msm_geni_serial.c index 21dbdc0075f1..04d6bdd1084c 100644 --- a/drivers/tty/serial/msm_geni_serial.c +++ b/drivers/tty/serial/msm_geni_serial.c @@ -232,7 +232,7 @@ struct msm_geni_serial_port { struct completion s_cmd_timeout; spinlock_t rx_lock; bool pm_auto_suspend_disable; - bool is_clock_off; + atomic_t is_clock_off; enum uart_error_code uart_error; }; @@ -1268,7 +1268,7 @@ static void msm_geni_serial_start_tx(struct uart_port *uport) static unsigned int ios_log_limit; /* when start_tx is called with UART clocks OFF return. */ - if (uart_console(uport) && msm_port->is_clock_off) { + if (uart_console(uport) && (uport->suspended || atomic_read(&msm_port->is_clock_off))) { IPC_LOG_MSG(msm_port->console_log, "%s. Console in suspend state\n", __func__); return; @@ -2166,7 +2166,7 @@ static void msm_geni_serial_handle_isr(struct uart_port *uport, bool s_cmd_done = false; bool m_cmd_done = false; - if (uart_console(uport) && msm_port->is_clock_off) { + if (uart_console(uport) && atomic_read(&msm_port->is_clock_off)) { IPC_LOG_MSG(msm_port->console_log, "%s. Console in suspend state\n", __func__); goto exit_geni_serial_isr; @@ -2991,11 +2991,11 @@ static void msm_geni_serial_cons_pm(struct uart_port *uport, if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF) { se_geni_resources_on(&msm_port->serial_rsc); - msm_port->is_clock_off = false; + atomic_set(&msm_port->is_clock_off, 0); } else if (new_state == UART_PM_STATE_OFF && old_state == UART_PM_STATE_ON) { + atomic_set(&msm_port->is_clock_off, 1); se_geni_resources_off(&msm_port->serial_rsc); - msm_port->is_clock_off = true; } } @@ -3620,6 +3620,7 @@ static int msm_geni_serial_sys_suspend(struct device *dev) struct uart_port *uport = &port->uport; if (uart_console(uport) || port->pm_auto_suspend_disable) { + IPC_LOG_MSG(port->console_log, "%s start\n", __func__); uart_suspend_port((struct uart_driver *)uport->private_data, uport); IPC_LOG_MSG(port->console_log, "%s\n", __func__); @@ -3652,6 +3653,7 @@ static int msm_geni_serial_sys_resume(struct device *dev) if ((uart_console(uport) && console_suspend_enabled && uport->suspended) || port->pm_auto_suspend_disable) { + IPC_LOG_MSG(port->console_log, "%s start\n", __func__); uart_resume_port((struct uart_driver *)uport->private_data, uport); IPC_LOG_MSG(port->console_log, "%s\n", __func__);