Skip to content

Commit

Permalink
serial: mrst_max3110: Fix race condition between spi transfers
Browse files Browse the repository at this point in the history
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: Bin Gao <bin.gao@intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Bin Gao authored and Greg Kroah-Hartman committed Oct 16, 2013
1 parent 0923844 commit b6951b8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/tty/serial/mrst_max3110.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct uart_max3110 {
struct task_struct *main_thread;
struct task_struct *read_thread;
struct mutex thread_mutex;
struct mutex io_mutex;

u32 baud;
u16 cur_conf;
Expand Down Expand Up @@ -90,6 +91,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,
struct spi_transfer x;
int ret;

mutex_lock(&max->io_mutex);
spi_message_init(&message);
memset(&x, 0, sizeof x);
x.len = len;
Expand All @@ -104,6 +106,7 @@ static int max3110_write_then_read(struct uart_max3110 *max,

/* Do the i/o */
ret = spi_sync(spi, &message);
mutex_unlock(&max->io_mutex);
return ret;
}

Expand Down Expand Up @@ -805,6 +808,7 @@ static int serial_m3110_probe(struct spi_device *spi)
max->irq = (u16)spi->irq;

mutex_init(&max->thread_mutex);
mutex_init(&max->io_mutex);

max->word_7bits = 0;
max->parity = 0;
Expand Down

0 comments on commit b6951b8

Please sign in to comment.