Commit b6951b8a authored by Bin Gao's avatar Bin Gao Committed by Greg Kroah-Hartman

serial: mrst_max3110: Fix race condition between spi transfers

There is a race between termios configuration and xmit that can cause the
intel_mid_ssp_spi driver to stall.

Serializing spi transactions fixes the problem.
Signed-off-by: default avatarBin Gao <bin.gao@intel.com>
Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 09238443
...@@ -61,6 +61,7 @@ struct uart_max3110 { ...@@ -61,6 +61,7 @@ struct uart_max3110 {
struct task_struct *main_thread; struct task_struct *main_thread;
struct task_struct *read_thread; struct task_struct *read_thread;
struct mutex thread_mutex; struct mutex thread_mutex;
struct mutex io_mutex;
u32 baud; u32 baud;
u16 cur_conf; u16 cur_conf;
...@@ -90,6 +91,7 @@ static int max3110_write_then_read(struct uart_max3110 *max, ...@@ -90,6 +91,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,
struct spi_transfer x; struct spi_transfer x;
int ret; int ret;
mutex_lock(&max->io_mutex);
spi_message_init(&message); spi_message_init(&message);
memset(&x, 0, sizeof x); memset(&x, 0, sizeof x);
x.len = len; x.len = len;
...@@ -104,6 +106,7 @@ static int max3110_write_then_read(struct uart_max3110 *max, ...@@ -104,6 +106,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,
/* Do the i/o */ /* Do the i/o */
ret = spi_sync(spi, &message); ret = spi_sync(spi, &message);
mutex_unlock(&max->io_mutex);
return ret; return ret;
} }
...@@ -805,6 +808,7 @@ static int serial_m3110_probe(struct spi_device *spi) ...@@ -805,6 +808,7 @@ static int serial_m3110_probe(struct spi_device *spi)
max->irq = (u16)spi->irq; max->irq = (u16)spi->irq;
mutex_init(&max->thread_mutex); mutex_init(&max->thread_mutex);
mutex_init(&max->io_mutex);
max->word_7bits = 0; max->word_7bits = 0;
max->parity = 0; max->parity = 0;
......
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