From: Mark F. Brown Date: Thu, 1 Mar 2012 22:10:43 +0000 (-0800) Subject: serial: resolved race condition between spi transfers X-Git-Tag: 2.1b_release~1259 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=236aa01ab5999dfce713e64c0aa6cbcfb9631ac0;p=kernel%2Fkernel-mfld-blackbay.git serial: resolved race condition between spi transfers BZ: 25983 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. Change-Id: I42204edbad571d109840eaab2ffcc884e8890885 Signed-off-by: Mark F. Brown Reviewed-on: http://android.intel.com:8080/37363 Reviewed-by: Ng, Cheon-woei Tested-by: Ng, Cheon-woei Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c index ef3a7d5..8288712 100644 --- a/drivers/tty/serial/mrst_max3110.c +++ b/drivers/tty/serial/mrst_max3110.c @@ -57,6 +57,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; @@ -87,6 +88,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; @@ -101,6 +103,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; } @@ -817,6 +820,7 @@ static int __devinit 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;